Balboa encoder, showing the magnetic disc and
sensors (with one motor removed).
Each drive motor on the Balboa 32U4 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
. 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 the wheels, calculate the
total gear ratio of the gearmotors and the Balboa
chassis’s gearboxes combined by multiplying their individual gear ratios, then multiply the result by 12.
For example, if
[https://www.pololu.com/product/3073]
(which have gear ratios more
accurately specified as 51.45:1) are used along with the plastic gears that give an additional 2.88:1
reduction, the encoders provide 51.45 × 2.88 × 12 ≈
1778 CPR
.
Quadrature encoder transitions are often detected by monitoring both encoder channels directly.
However, since transitions on the Balboa’s encoders can occur at high frequencies (several thousand
per second) when its motors are running, it is necessary to use the AVR’s pin change interrupts or
external interrupts to read the encoders. To reduce the required number of interrupt pins, the Balboa
32U4 control board XORs together both channels of each encoder and connects the resulting signal
to an interrupt pin, while channel B of each encoder is connected to a non-interrupt pin:
•
Digital pin 7
, or PE6, reads the
right encoder XORed signal
using external interrupt INT6.
•
Digital pin 8
, or PB4, reads the
left encoder XORed signal
using pin change interrupt
PCINT4.
•
Digital pin 23
(analog pin 5), or PF0, reads the
right encoder channel B
.
• Pin
PE2
reads the
left encoder channel B
.
Pololu Balboa 32U4 Balancing Robot User’s Guide
© 2001–2019 Pololu Corporation
3. Balboa 32U4 in detail
Page 18 of 97