Waterproof a rotary encoder

Go To Last Post
2 posts / 0 new
Author
Message
#1
  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

I've got a small Sharp mechanical rotary encoder with 24 detent positions (11) and I want to know how I can make it waterproof.

CW = 11 10 00 01 11
CCW = 11 01 00 10 11

What I do now is this.

rotEnc:
debounce to steady values
If 11 clear flag
If 00 set flag else clear flag
If 01 && flag set -> INC
If 10 && flag set -> DEC
ret

But when a user should turn exidently 11 10 00 10 11, so when the encoder drops halfway back into the detent position were it came from it must not INC or DEC, now it does now and then.

I've another type encoder which does not have three switch positions, this one has so I think it can be made waterproof.

:roll:

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

To make this work, you have to make a small state machine with four states. Your flag has only two states.

Try constructing the state table with the four state columns and the four possible input combination rows from the encoder. Some of the state transitions change the encoder counter value.

ekh