PACERBOT Part 17 – 20: The Last Encoder
How I transformed an IR sensor into an encoder, that enables the calculation of speed and distance.
After giving it some thought, I have decided not to use the custom 3D printed encoder I have started building. Commercial parts should be more reliable, and when it comes to speed control over a long period of time, I value reliability.
The new encoder works by the same principle of the old custom one; a slotted wheel( which is connected to the drive shaft) spins inside the IR sensor, which registers the number of times a slot has been seen in one second. This piece of data is the number rounds per second the driveshaft undergoes. By multiplying this information by the gear ratio of the differential and the circumference of the tires, the linear speed of the robot can be calculated.
The velocity is controlled by a PID loop. The PID ensures that the speed will be consistent by moderating the signal fed to the ESC, calculating the new signal values by comparing the current speed with the desired one. This method of control is able to overcome unexpected disruptions, such as winds or slopes.