Rotary Encoder Object?
David Betz
Posts: 14,516
in Propeller 1
Does anyone know of a Spin object that handles a rotary encoder? I tried the one in OBEX but it doesn't seem to track very well. I'm not sure it is handling contact bounce.
Comments
Jim
Jim
John Abshier
ENS1J-B28-L00256L-ND try this on digikey
I've used that exact encoder several times. It's really hard to get the output to change by one. As ErNa suggests, just take this into account in your program.
I don't know which quadrature encoder object you used but there's an object written by Kye (how usually does great stuff) which doesn't always count encoder transitions correctly.
It should be a simple matter of waiting until A goes low and checking B. Turned CW if B is still high when A goes low, or CCW if B is already low when A goes low. Then debounce until A and B are steady high.
between two neighbouring states which is fine (this can happen with optical shaft encoders at
low speeds for instance). You should be ignoring small changes (ie have a little hysteresis)
when interpreting the count value in higher level code, as the switch may be teetering on the
edge of making contact and oscillate anyway.
This is essentially the X4 encoding scheme that I recently implemented in order to use a cheap (in terms of quality and price) encoder as a tuner knob for an FM radio. Since I also monitored the switch, my pseudo-code looks like:
WAITPNE EN0ABSW, EN0ABSW
IF EN0SW = 0 THEN {seek next valid channel}
ELSE
WAITPEQ 0, EN0A
IF EN0B = 1 THEN {INC channel}
ELSE {DEC channnel}
ENDIF
ENDIF
WAITPEQ EN0ABSW, EN0ABSW