Rotary Encoder Help
ADZ_916
Posts: 30
After posting in the general forum it seams to me this may have been the correct area to ask for assistance for my issue, original post is here:
http://forums.parallax.com/showthread.php/145613-Rotary-Encoder-Help
http://forums.parallax.com/showthread.php/145613-Rotary-Encoder-Help
Comments
Close, with an encoder, you need to consider not just valid states, but also how the states get from one to another.
eg Imagine your encoder is break-before-make, or you get one or more polls of 000, (or indeed, any 'illegal' combination ) - try that with a pencil thru your CASE statements, and see what the outcome is.
If you do have these resistors, which way? pulling up to the supply voltage, or pulling down to ground?
what value are these resistors?
with 3 inputs it's just a matter of patience as things will always settle out even with switch bounce.
Like if you're at the A state, and then the dial is turned to B, well eventually the B input is just going to be asserted, no matter how much B bounces or is delayed from the transition of A.
That is true for the pins, but not quite so true for a (poorly written) state-engine following those pins.
Thanks again!
-ADZ
This is the correct answer and you should always do this for cases like this.
When dealing with digital circuitry you have to drive in both directions. an input should either be at the level of the supply voltage (+5V, +3.3V, etc), or at ground level (0V). Never left floating. For hobbyist applications on microcontrollers, we just generally leave unused inputs floating, but in professional practice this is bad. It tends to waste power and amplify noise and send more noise into the adjacent circuits with all the almost-random toggling from 1 to 0 and back.
I know industrial equipment (PLC I/O) acts differently, where you can connect one side of a mechanical switch to the voltage source, and the other side to the input. Works perfectly where if the switch is closed, the input is read as a 1 because CURRENT is flowing, otherwise 0 because no significant current is flowing. But not with digital circuitry. Digital circuitry uses VOLTAGE to determine the 1 or 0.
ABC_Encoder.spin
I will continue to update as this project moves along.
Thanks Again!
-ADZ