This is just a quick post to show how one might about setting up indicators (turn signals) with a CAN Keypad or other input method.
Typically with indicators, it is required that an indicator that is currently turned is automatically cancelled when the other indicator is turned on and vice versa.
This can be a little tricky with the PDM, one might think that all you need to do is add a condition in the indicator output function, so that the indicator does not turn on when the other is active. This does not work, as both indicators will continually be turning off as the other tries to turn on - think two people trying to go through a door at the same time.
The best solution right now is to utilize the PDM counters as follows -
Set up two counters as shown, one is responsible for the left indicator, the other for the right.
Note, for counter 1, it will increment when the keypad button 1 (left ind) button is pressed and reset when keypad button 2 (right ind) is pressed.
For counter 2, the opposite is true, it will increment when keypad button 2 (right ind) button is pressed and reset when keypad button 1 (left ind) is pressed.
Both counters will reach the end value at 2. This means that if you press the button once, the counter goes to 1. If you press the button again, the counter goes to 2 and then loops back to 0.
We can now simply use these counters in the output function for each indicator.
The output function for the left indicator is as follows. The counter value is AND'd with Timer 1, which is a simple 400ms On, 400ms Off timer to make the indicators flash.
Output 2 is similar, except it uses counter 2 instead.
If you wanted Hazard light functionality, you would simply add another OR condition to the output function so that the indicator also comes on with your hazard button.
One thing to note, the keypad buttons have been set up as momentary. For the keypad buttons to light up, you will need to attach them to the output state as is shown below.