Implementing Optical Encoders

So far, I have enabled the platform to move forward, in reverse, and to turn at an angle using optical encoders. The encoders measure the rotation of the wheels by triggering an interrupt 10 times per revolution. This allows me to calculate the distance that the platform travels and its speed when moving or turning. However, there’s a problem. Based on the measurements taken, the encoder produces much more interrupts than it should resulting in inaccurate calculations. This problem is typically due to contact ┬ábouncing which is when a switch or sensor bounces between values several times before settling.

There are two solutions for this problem that were discovered by previous undergraduate students who worked with these encoders. One was a software solutions that incorporated delays in the Arduino code to record an interrupt after the signal from the encoder has settled. I’ve implemented this solution and obtained readings from 1000 interrupts to about 46 interrupts. ┬áThis is significantly more accurate than initially but still not very accurate. I’ve determined that at maximum speed, the platform’s wheels rotate for 2.3 to 2.5 revolutions every 2 seconds. Thus, the encoders should produce about 23 to 25 interrupts.

The next solution is a hardware solution. It incorporates NAND gates into the circuit in order to minimize the amount of bouncing in the encoders. I’ve also implemented this solution along with the software solution and obtained readings of 26 to 28 interrupts. This is very close to the desired readings but not yet sufficient to increase the precision of the platform. More work needs to be done in order to accurately measure the distance the platform travels which is key for implementing PID algorithms.