Converting an encoder count into a speed
In Chapter 6, Measuring Movement with Encoders on Raspberry Pi Pico, we used PIO to retrieve a count from the motor encoding sensors. We ended that chapter by measuring for movement and counting encoder transitions over some time.
In this section, we will relate wheel geometry to the encoder. Then, we will use that to convert encoder counts into a speed or a distance.
Loose bolts and nuts
Vibration can sometimes cause nuts to drop out – a tiny dab of nail varnish across the nut and thread can reduce this.
Robot wheel geometry
Calculating the distance traveled by a wheel requires its circumference. Let’s start by measuring the diameter of the wheel, as shown:
Figure 11.1 – Measuring wheels with calipers
The preceding diagram shows how you can measure wheel diameter with digital calipers. The diameter can be used in our code directly. In robot.py
, add your measurement rounded to the...