6.4. Quadrature encoders

Each drive motor on the 3pi+ 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 control 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 30:1 motors (which have gear ratios more accurately specified as 29.86:1) are used, the encoders provide 29.86 × 12 ≈ 358.3 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 on the Turtle Edition and Standard Edition, 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.

Since the motor directions on the Hyper Edition are reversed (see Section 6.3), the behavior described above corresponds to backward rotation instead on that version.

The 3pi+ 2040 Robot Libraries and Example Code provide appropriate functions for reading the encoders and keeping track of their counts.

Related Products

3pi+ 2040 Robot - Standard Edition (30:1 MP Motors), Assembled
3pi+ 2040 Robot - Turtle Edition (75:1 LP Motors), Assembled
3pi+ 2040 Robot - Hyper Edition (15:1 HPCB Motors), Assembled
3pi+ 2040 Robot Kit with 30:1 MP Motors (Standard Edition Kit)
3pi+ 2040 Robot Kit with 75:1 LP Motors (Turtle Edition Kit)
3pi+ 2040 Robot Kit with 15:1 HPCB Motors (Hyper Edition Kit)
3pi+ 2040 Control Board
Log In
Pololu Robotics & Electronics
Shopping cart
(702) 262-6648
Same-day shipping, worldwide
Menu
Shop Blog Forum Support
My account Comments or questions? About Pololu Contact Ordering information Distributors