So I am making a combination lock that uses a Rotary Incremental Encoder for the device. I have 90% of the code done but some things aren’t working like I expect. I have been beating my head against a wall for a few weeks now so decided time to open it up to the collective mind.
First here is a list of components:
- Arduino Nano Clone
- TRDA-20R1N100VD Encoder from Automation Direct (using 3 wires, A+ B+ and Z+
- Sparkfun Rotary Switch Potentiometer (for the combination pots)
Second a list of what is not working as expected:
- The encoder is counting and resetting when it passes 0 but if you spin fast it doesn’t always keep up. I am using interrupts and are really quick but don’t know about accuracy.
- I am still having trouble getting the true position out of the wheel when going in reverse. After it passes 0 it goes into negative numbers but if I am looking for position 2 I need it the same going in reverse or forward. ABS and reversing numbers does not seem to work. I have 100 counts on this encoder, when they work as expected.
- Compare and Overshoot seem to be glitching (technical term for not always doing what I expect) For some reason if I just move the encoder without landing on the actual numbers at some point it just solves the lock. And that’s with the Reverse direction not working either.
And lastly the code itself. A large amount so not opposed to assistance on cleaning it up but right now more worried about getting it working first.
(Had to attach the code since it is too large for the forum)
Ships_Wheel_Combo_Lock_cleanup.ino (8.77 KB)