Support » Pololu Zumo 2040 User’s Guide » 6. The Zumo 2040 in detail »
6.4. Quadrature encoders
Each drive motor on the Zumo 2040 has a corresponding quadrature encoder system consisting of a magnetic disc attached to the extended motor shaft and a pair of Hall effect sensors mounted on the main board. Other than the sensor orientation, these encoders work similarly to our magnetic encoder kits for Micro Metal Gearmotors. They can be used to track the rotational speed and direction of the robot’s wheels.
The encoders provide a resolution of 12 counts per revolution of the motor shaft when counting both edges of both channels. To compute the counts per revolution of a wheel, multiply the motor’s gear ratio by 12. For example, if 75:1 motors (which have gear ratios more accurately specified as 75.81:1) are used, the encoders provide 75.81 × 12 ≈ 909.7 CPR. The exact gear ratios of our Micro Metal Gearmotors are specified on their product pages.
Four GPIO pins are used to read the encoders:
- GP8 reads the right encoder channel A.
- GP9 reads the right encoder channel B.
- GP12 reads the left encoder channel A.
- GP13 reads the left encoder channel B.
For both encoders, channel B leads channel A when the motor is rotating in the forward direction; that is, B rises before A rises and B falls before A falls.
The Zumo 2040 Robot Libraries and Example Code provide appropriate functions for reading the encoders and keeping track of their counts.