You need to UP your sample rate or use interrupts (on change) to prevent aliasing.
If you MUST display the current values on an LCD, I believe you'll need to use interrupts as others have said.
I'm currently working with an encoder with 50 slots, rotating at 1rps (200 positions per second in grey code) and need to sample at <1mS to ensure no errors. This is because there are no absolute guarantees that each of the 4 phases (codes) are equal in length, due to quality control issues with soldering and placement of the LEDs and Photodiodes. Thus, although technically you expect 200 codes per second in this scenario, "normal" oversampling rules dictate 2x that sampling rate, and the error factor that I'm encountering with component placement suggests 5x instead. If you cut your sampling time back, or miss one of these, it can result in an incorrect count.
Thus you're pretty much bound to use interrupts: either on change, or on timer to sample (change is more efficient for obvious reasons).
-------------Picster-----------------------




Bookmarks