The XORed signal and the channel B signal can be used to reconstruct the channel A signal by simply
XORing them again:
(A XOR B) XOR B = A
. 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
waveforms in the diagram above would be produced by forward rotation.) Note that “forward” refers to
the rotation direction that would cause a balancing Balboa to move in the direction its battery cover is
facing.
The Balboa32U4 library provides appropriate interrupt service routines and functions for reading the
encoders and keeping track of their counts (see
3.5. Inertial sensors
Pololu Balboa 32U4 Balancing Robot User’s Guide
© 2001–2019 Pololu Corporation
3. Balboa 32U4 in detail
Page 19 of 97