Rotary encoder wiring

Hi, I did have plans to use an 8-position rotary switch on my steering wheel to control multiple functions. Seemed like a good idea at the time, but i now realise that it just won’t work the way i thought it would. I was going to use a keypad button to change function, but when i do that, it will just jump straight to the position the switch is at. For example, if the switch is at position 1 for page 1, and i want to change traction level from 6 to 7, if i change the allocated function to traction, the level will jump straight to 1. (Hope that makes sense) I think what i need is a rotary encoder. I have had a look into doing this but without it setup in front of me to work on the logic my head is spinning a bit. I think i would be best to try figuring this out on my own, so i learn. I just would like some confirmation that it can be done, so i don’t waste my time. I think i would need 5V, Gnd, 2x digital inputs for the encoder plus 1x digital for the pushbutton. Could anyone tell me if this is correct?

How many spare analog inputs do you have?

I currently have 1, but i could free up 3. I’m at harness development stage.

I have a project that uses a rotary encoder, via a blink marine keypad, it’s encoder data via CANbus but is very function heavy and uses up most of the ADU memory.

You could just have 3 separate analog inputs each with their own rotary switch to simplify things.

Don’t seem to have much memory left. I was set to use a Bosch LWS for steering logging and Team Plus for tyre data.

I did search this, and your previous posts came up.

We used a grahill power track which transmits an encoder counter value and direction bit.

I can send you the project but it might not be of any use if you’re trying to directly wire an encoder to the digital inputs.

Looking to have functionality in the steering wheel.

Ok, first hurdle, i think i need to take the previous value of a table, before the encoder is moved, and subtract the new value of the table, after the encoder is moved. A value of -1 or 3, means the encoder has moved clockwise and a value of -3 or 1 means the encoder has moved anticlockwise.
encoder setup.adu (6 KB)

Where I’m at so far. For those following along at home.
encoder setup.adu (7.3 KB)
Long way off yet.

Small correction, moved the number element that calculates direction above the number element that sets the encoder value. My understanding is this should subtract the new value from the old value.
encoder setup.adu (7.3 KB)

I went out and purchased a rotary encoder to do some tests. Turns out i didn’t understand the operation correctly.


going by this diagram, i assumed that each click of the shaft would be as follows;
terminal A 0110011
terminal B 1100110 and so could be given the numbers;
01230123 and so on.
But it turns out each click or detent is 4, so goes from 00 to 11, or in the table 0 to 2 to 0.
Like this

Confusing. Those images came from 2 datasheets available for the same part.

The general description of how to read the incremental encoder:

  1. Check for a rising or falling edge on signal A.
  2. Check the voltage level of the signal B while the signal A is changing.
  3. (Rising edge + low level) or (Falling edge + high level) = clockwise step
  4. (Rising edge + high level) or (Falling edge + low level) = counterclockwise step

I didn’t think about how to implement that in the project tree yet.
If you have trouble implementing that, we can try to find a solution.

The implementation is actually pretty simple.

It’s essentially what I wrote, with a virtual switch to get a cycling state number.

encoder.adu (6.3 KB)

1 Like

Hopefully i"ll figure it out. Thanks for the info and reply

I’m just going to go ahead and pretend that you didn’t just make me look stupid lol.
Thankyou very much. LOL