Controlling Motion with Encoders on Raspberry Pi Pico
So far in this book, we’ve added sensors to our robot that can track counts as its wheels turn. We’ve also looked at a PID algorithm to close the robot control loop. We can combine these concepts to control our motors and wheels more precisely.
This combination will let us maintain a known speed on each motor and correct their relative speeds for a straight line. Encoders with some geometry will let us drive the robot a predetermined distance.
In this chapter, we will cover the following main topics:
- Converting an encoder count into a speed
- Using PID to maintain speed and a straight line
- Driving a known distance