Pololu Balboa 32U4 User manual

Pololu Balboa 32U4 Balancing
Robot User’s Guide
Pololu Balboa 32U4 Balancing Robot User’s Guide © 2001–2019 Pololu Corporation
https://www.pololu.com/docs/0J70/all Page 1 of 97

1. Overview . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 3
1.1. Included components . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 4
1.2. What you will need . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 8
1.3. Supported operating systems . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 12
2. Contacting Pololu . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 13
3. Balboa 32U4 in detail . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 14
3.1. Microcontroller . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 14
3.2. User interface . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 14
3.3. Motors . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 17
3.4. Quadrature encoders . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 17
3.5. Inertial sensors . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 19
3.6. Power . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 21
3.7. xpansion headers . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 24
3.8. Raspberry Pi interface and level shifters . . . . . . . . . . . . . . . . . . . . . . . . . 27
3.9. Pin assignments . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 31
3.10. Adding electronics . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 34
3.11. AVR timers . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 36
3.12. Bumper cage . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 37
3.13. Stability Conversion Kit . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 41
3.14. Schematics and dimensions . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 43
4. Assembling the Balboa 32U4 kit . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 45
5. Programming the Balboa 32U4 . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 67
5.1. Installing Windows drivers . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 67
5.2. Programming using the Arduino ID . . . . . . . . . . . . . . . . . . . . . . . . . . . 69
5.3. Programming using avr-gcc and AVRDUD . . . . . . . . . . . . . . . . . . . . . . . 74
6. Balboa 32U4 Arduino library . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 77
7. How to make a Balboa balance . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 78
7.1. Sensor measurements . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 78
7.2. An example balancing algorithm . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 80
8. The Balboa 32U4 USB interface . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 87
9. The A-Star 32U4 Bootloader . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 89
10. Reviving an unresponsive Balboa 32U4 . . . . . . . . . . . . . . . . . . . . . . . . . . . . 92
10.1. Reviving using the Arduino ID . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 92
10.2. Reviving using AVRDUD . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 94
11. Related resources . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 96
Pololu Balboa 32U4 Balancing Robot User’s Guide © 2001–2019 Pololu Corporation
Page 2 of 97

1. Overview
The Balboa 32U4 is a highly integrated balancing robot that is both programmable and customizable.
Like our A-Star 32U4 programmable controllers [https://www.pololu.com/category/149/a-star-
programmable-controllers], the Balboa 32U4 control board is built around a USB-enabled Atmel
ATmega32U4 AVR microcontroller, and it ships preloaded with an Arduino-compatible bootloader. The
control board features two H-bridge motor drivers, as well as quadrature encoders and a complete
inertial measurement unit (accelerometer, gyro, and magnetometer) that allows it to determine its
orientation – essential for balancing. It also includes a powerful 5 V switching step-down regulator that
can supply up to 2 A continuously, along with a versatile power switching and distribution circuit. Three
on-board pushbuttons offer a convenient interface for user input, while indicator L Ds, a buzzer, and
a connector for an optional LCD allow the robot to provide feedback.
The Balboa 32U4 can be used either as a standalone control solution or as a base for a more powerful
Raspberry Pi controller. Its on-board connector and mounting holes allow a compatible Raspberry
Pi (Model B+ or newer, including Pi 3 Model B [https://www.pololu.com/product/2759] and Model A+
[https://www.pololu.com/product/2760]) to plug directly into the control board. Integrated level shifters make
it easy to set up I²C communication and interface other signals between the two controllers, and
the control board automatically supplies 5 V power to an attached Raspberry Pi. In this setup, the
Raspberry Pi can handle the high-level robot control while relying on the Balboa 32U4 control board
for low-level tasks, like running motors, reading encoders, and interfacing with other analog or timing-
sensitive devices.
Pololu Balboa 32U4 Balancing Robot User’s Guide © 2001–2019 Pololu Corporation
1. Overview Page 3 of 97

Balboa 32U4 Balancing Robot with
80×10mm wheels and a Raspberry Pi 1
Model A+. Balboa 32U4 Balancing Robot with
80×10mm wheels and a Raspberry Pi 3
Model B.
Many of the ATmega32U4 I/O lines are broken out to 0.1″-spaced through-holes along the edges of
the board, and the board’s power rails are also accessible, enabling sensors and other peripherals to
easily be connected.
A software add-on is available that makes it easy to program a Balboa 32U4 robot from the Arduino
environment, and we have Arduino libraries and example sketches to help get you started. A USB A
to Micro-B cable [https://www.pololu.com/product/2072] (not included) is required for programming.
1.1. ncluded components
Pololu Balboa 32U4 Balancing Robot User’s Guide © 2001–2019 Pololu Corporation
1. Overview Page 4 of 97

The Balboa 32U4 is available
as a kit [https://www.pololu.com/
product/3575] that requires
assembly and soldering. The
kit includes the following
components:
• Balboa core chassis
◦ battery box and cover
◦ two motor retention clips/
gearbox housings
◦ two gearbox covers
◦ six 683 ball bearings
◦ two 3 mm D-shafts
◦ ten plastic pinion gears (small
– two each with 17, 19, 21, 23,
and 25 teeth)
◦ ten plastic output gears (large
– two each with 41, 43, 45, 47,
and 49 teeth)
◦ battery terminals
•Balboa 32U4 control board
[https://www.pololu.com/product/3576] and
related parts:
◦buzzer [https://www.pololu.com/
product/1484]
Pololu Balboa 32U4 Balancing Robot User’s Guide © 2001–2019 Pololu Corporation
1. Overview Page 5 of 97

◦ jumper wires (for soldering motors to the main board)
◦ two magnetic encoder discs [https://www.pololu.com/product/2599] (12 CPR)
◦ four 3/16″ #2-56 screws and nuts
•bumper cage kit [https://www.pololu.com/product/3574], which includes:
◦ four bumper skids
◦ four bumper cage cross bars
◦ two bumper skid spacers
◦ twelve 12 mm M3 screws and nuts
Pololu Balboa 32U4 Balancing Robot User’s Guide © 2001–2019 Pololu Corporation
1. Overview Page 6 of 97

Pololu Balboa 32U4 Balancing Robot User’s Guide © 2001–2019 Pololu Corporation
1. Overview Page 7 of 97

The robot and chassis kit might include extra parts like jumper wires, screws, and nuts,
so do not be concerned if you have some leftover hardware after assembling your
Balboa.
1.2. What you will need
You will need a number of additional components and tools to complete your Balboa robot, the most
important of which are motors and wheels. Since the Balboa 32U4 robot kit works with a variety of
motors and wheels, motors and wheels are not included; this means you can choose your own to
personalize your robot.
Motor selection
Pololu Balboa 32U4 Balancing Robot User’s Guide © 2001–2019 Pololu Corporation
1. Overview Page 8 of 97

A look inside the external
gearbox on the Balboa 32U4
Balancing Robot.
The Balboa uses two micro metal gearmotors to drive external
2-gear gearboxes that further increase the gear ratio and support
the weight of the robot with ball bearings rather than the motor
shafts themselves. The Balboa kit gives you five reduction options
to choose from when assembling your robot (ranging from 1.64:1
to 2.88:1), and you can further customize the gear ratio based on
which micro metal gearmotor you choose for your robot. The
integrated quadrature encoders require gearmotors with
extended motor shafts, and we specifically recommend the 30:1
HPCB [https://www.pololu.com/product/3072],50:1 HPCB
[https://www.pololu.com/product/3073], or 75:1 HPCB
[https://www.pololu.com/product/3074] versions. Note that torque is
approximately proportional to the gear ratio and speed is
inversely proportional, so as the gear ratio gets bigger, the torque
increases while the speed decreases.
Micro metal gearmotor HPCB with
extended motor shaft.
The kit includes magnetic encoder discs, and the encoder sensors are built into the Balboa 32U4
control board, so you do not need to order encoders with your motors.
Wheel selection
We recommend using the Balboa with 80×10mm Pololu wheels, which are available in five colors
—black [https://www.pololu.com/product/1430],red [https://www.pololu.com/product/1431],yellow
[https://www.pololu.com/product/1432],blue [https://www.pololu.com/product/1433], and white
[https://www.pololu.com/product/1434] — but our larger 90×10mm wheels [https://www.pololu.com/product/
1435] and smaller 70×8mm wheels [https://www.pololu.com/product/1425] are also options if you know
what you are doing (note that the 70×8mm wheels only offer a few millimeters of clearance when the
robot is balancing).
Pololu Balboa 32U4 Balancing Robot User’s Guide © 2001–2019 Pololu Corporation
1. Overview Page 9 of 97

Balboa 32U4 Balancing Robot with battery cover
removed.
Pololu wheel 80×10mm pair – red.
These additional items are also needed for using and assembling the Balboa 32U4 robot kit:
Other things you will need
• six AA batteries [https://www.pololu.com/
product/1003]. The Balboa works with
both alkaline and NiMH batteries,
though we recommend rechargeable
NiMH cells.
•USB A to Micro-B cable
[https://www.pololu.com/product/2072] to
connect the board to your computer for
programming and debugging
• soldering iron and solder (we
recommend one with adjustable
temperature control like the Hakko
FX-888D Digital Soldering Station
[https://www.pololu.com/product/2779])
• small Phillips screwdriver
•wire cutter [https://www.pololu.com/
product/159] for trimming leads
Optional tools
•small pair of pliers [https://www.pololu.com/product/150]
•wire stripper [https://www.pololu.com/product/1923], for adding wires for peripherals
Pololu Balboa 32U4 Balancing Robot User’s Guide © 2001–2019 Pololu Corporation
1. Overview Page 10 of 97

Center-aligned mounting option for the
5-Channel reflectance sensor array for Balboa.
• tape or small clamps (for holding parts together when soldering)
• small 2 mm slotted screwdriver for adjusting the LCD contrast
Optional accessories
You might also consider getting these for your Balboa:
• an 8×2 character LCD [https://www.pololu.com/product/356] and low-profile 2×7 male header
[https://www.pololu.com/product/2663] so you can connect it to the female LCD header on the
Balboa
• a compatible Raspberry Pi (Model B+ or newer, including Pi 3 Model B [https://www.pololu.com/
product/2759] and Model A+ [https://www.pololu.com/product/2760]) and a 2×20 female header
[https://www.pololu.com/product/1037],standoffs [https://www.pololu.com/product/2713],screws
[https://www.pololu.com/product/1968], and nuts [https://www.pololu.com/product/1967] for mounting it
◦ The Balboa is intended to be used with our standoffs with 4 mm
threads [https://www.pololu.com/product/2713]. Our standoffs with longer
(6 mm) threads will interfere with the chassis.
•5-Channel Reflectance Sensor Array
[https://www.pololu.com/product/3577] for
identifying changes in reflectance on
the ground directly underneath the
Balboa (like detecting or following a
black line on a white background)
• other sensors [https://www.pololu.com/
category/7/sensors], such as optical
[https://www.pololu.com/category/79/sharp-
distance-sensors] or sonar range
finders [https://www.pololu.com/category/
78/sonar-range-finders]
•connectors and jumper wires
[https://www.pololu.com/category/19/
connectors], for connecting additional
sensors and components
• battery charger, if you are using
Pololu Balboa 32U4 Balancing Robot User’s Guide © 2001–2019 Pololu Corporation
1. Overview Page 11 of 97

rechargeable batteries; since the Balboa just uses ordinary AA batteries, we recommend
basic AA chargers (into which you stick the individual cells) available at most general
electronics stores, though we carry a much fancier iMAX-B6AC V2 balance charger/
discharger [https://www.pololu.com/product/2588] that can be also used for this
1.3. Supported operating systems
The Balboa 32U4 control board can be programmed using any operating system that supports the
Arduino environment. This includes Microsoft Windows 10, 8.1, 8, 7, Vista, XP (with Service Pack 3),
Linux, and macOS.
Pololu Balboa 32U4 Balancing Robot User’s Guide © 2001–2019 Pololu Corporation
1. Overview Page 12 of 97

2. Contacting Pololu
We would be delighted to hear from you about any of your projects and about your experience with
the Balboa 32U4. You can contact us [https://www.pololu.com/contact] directly or post on our forum
[http://forum.pololu.com/]. Tell us what we did well, what we could improve, what you would like to see in
the future, or anything else you would like to say!
Pololu Balboa 32U4 Balancing Robot User’s Guide © 2001–2019 Pololu Corporation
2. Contacting Pololu Page 13 of 97

3. Balboa 32U4 in detail
3.1. Microcontroller
Like our A-Star 32U4 programmable controllers [https://www.pololu.com/category/149/a-star-
programmable-controllers], the Balboa 32U4 control board features an integrated, USB-enabled
ATmega32U4 AVR microcontroller from Atmel, clocked by a precision 16 MHz crystal oscillator. This
is the same microcontroller and clock frequency used in the Arduino Leonardo [https://www.pololu.com/
product/2192] and Micro [https://www.pololu.com/product/2188].
The control board includes a USB Micro-B connector that can be used to connect to a computer’s
USB port via a USB A to Micro-B cable [https://www.pololu.com/product/2072] (not included). The USB
connection can be used to transmit and receive data from the computer and program the board
over USB. The USB connection can also provide power for the microcontroller and most of the other
hardware on the board (but not motor power); see Section 3.6 for more details.
The control board’s ATmega32U4 comes preloaded with the Arduino-compatible A-Star 32U4 USB
bootloader [https://www.pololu.com/docs/0J66/7], which allows it to be easily programmed using the
Arduino ID . For more information about programming the Balboa 32U4, see Section 5.
The board also has a 6-pin ISP header that allows it to be programmed with an external programmer,
such as our USB AVR programmer [https://www.pololu.com/product/3172]. Pin 1 of the header is indicated
with a small white dot and has an octagonal shape.
3.2. User interface
Pololu Balboa 32U4 Balancing Robot User’s Guide © 2001–2019 Pololu Corporation
3. Balboa 32U4 in detail Page 14 of 97

LEDs
The Balboa 32U4 control board has five indicator L Ds, three of which are user-controllable:
• A yellow user L D is connected to Arduino digital pin 13, or PC7. You can drive this pin high
in a user program to turn this L D on. The A-Star 32U4 Bootloader [https://www.pololu.com/
docs/0J61/9] fades this L D on and off while it is waiting for a sketch to be loaded.
• A green user L D is connected to Arduino pin 30, or PD5, and lights when the pin is driven
low. While the board is running the A-Star 32U4 Bootloader or a program compiled in the
Arduino environment, it will flash this L D when it is transmitting data via the USB connection.
• A red user L D is connected to Arduino pin 17, or PB0, and lights when the pin is driven low.
While the board is running the A-Star 32U4 Bootloader or a program compiled in the Arduino
environment, it will flash this L D when it is receiving data via the USB connection.
These three user L Ds are all located near the bottom of the board, and the Balboa32U4 library
contains functions that make it easier to control them (see Section 6). All three user L D control lines
are also LCD data lines, so you will see them flicker when you update the LCD. The green and red
user L Ds also share I/O lines with pushbuttons (see below).
The remaining two L Ds are power indicators, and they are located in the top left corner of the board
near the USB connector:
• A blue power L D indicates when the controller is receiving power from the Balboa’s
batteries (the power switching circuit must be turned on).
• A green power L D indicates when the USB bus voltage (VBUS) is present.
Pushbuttons
The Balboa 32U4 control board has five pushbuttons: a power button in the bottom left corner, a
reset button in the top right corner, and three user pushbuttons located along the bottom edge. The
user pushbuttons, labeled A, B, and C, are on Arduino pin 14 (PB3), pin 30 (PD5), and pin 17 (PB0),
respectively. Pressing one of these buttons pulls the associated I/O pin to ground through a resistor.
The three buttons’ I/O lines are also used for other purposes: pin 14 is MISO on the SPI interface, pin
30 and pin 17 control the green and red user L Ds, and all three pins are LCD data lines. Although
these uses require the pins to be driven by the AVR (or SPI slave devices in the case of MISO),
resistors in the button circuits ensure that the Balboa 32U4 control board will not be damaged even
if the corresponding buttons are pressed at the same time, nor will SPI or LCD communications be
disrupted. The functions in the Balboa32U4 library take care of configuring the pins, reading and
Pololu Balboa 32U4 Balancing Robot User’s Guide © 2001–2019 Pololu Corporation
3. Balboa 32U4 in detail Page 15 of 97

Balboa 32U4 Balancing Robot with 80×10mm
wheels and LCD.
debouncing the buttons, and restoring the pins to their original states.
Buzzer
The buzzer [https://www.pololu.com/product/1484] included with the Balboa 32U4 control board can be
soldered into the designated through-holes and used to generate simple sounds and music. By
default, it is connected to digital pin 6 (which also serves as OC4D, a hardware PWM output from
the AVR’s 10-bit Timer4). If you alternate between driving the buzzer pin high and low at a given
frequency, the buzzer will produce sound at that frequency. You can play notes and music with the
buzzer using functions in the Balboa32U4 library. If you want to use pin 6 for an alternate purpose, you
can disconnect the buzzer circuit by cutting the surface-mount jumper next to the buzzer.
LCD header
The Balboa 32U4 control board has a 2×7
header where you can connect an 8×2 character
LCD [https://www.pololu.com/product/356] with a low-
profile male header [https://www.pololu.com/
product/2663] (or any other LCD with the common
HD44780 parallel interface
[https://www.pololu.com/file/0J71/DMC50448N-AAE-
AD.pdf] (109k pdf)). You can adjust the LCD
contrast with the potentiometer directly above the
LCD connector. We recommend using a 2 mm
slotted screwdriver to adjust the contrast.
The Balboa32U4 library provides functions to
display data on a connected LCD. It is designed
to gracefully handle alternate use of the LCD
data lines by only changing pin states when
needed for an LCD command, after which it will
restore them to their previous states. This allows the LCD data lines to be used for other functions
(such as pushbutton inputs and L D drivers).
Note that the control board is not designed to allow both an LCD and a Raspberry Pi to plug into it at
the same time. However, having a Raspberry Pi header (not included) soldered to the board should not
interfere with mounting an LCD, and the on-board LCD connector should not interfere with mounting
a Raspberry Pi.
Pololu Balboa 32U4 Balancing Robot User’s Guide © 2001–2019 Pololu Corporation
3. Balboa 32U4 in detail Page 16 of 97

3.3. Motors
Motor drivers
Two on-board Texas Instruments DRV8838 motor drivers power the Balboa’s two micro metal
gearmotors. Four Arduino pins are used to control the drivers:
•Digital pin 15, or PB1, controls the right motor direction (LOW drives the motor forward,
HIGH drives it in reverse).
•Digital pin 16, or PB2, controls the left motor direction.
•Digital pin 9, or PB5, controls the right motor speed with PWM (pulse width modulation)
generated by the ATmega32U4’s Timer1.
•Digital pin 10, or PB6, controls the left motor speed with PWM.
Note that “forward” refers to the rotation direction that would cause a balancing Balboa to move in the
direction its battery cover is facing.
For more information about the drivers, see the DRV8838 datasheet [https://www.pololu.com/file/0J806/
drv8838.pdf] (1MB pdf). We also sell a carrier board [https://www.pololu.com/product/2990] for this driver.
The Balboa32U4 library provides functions that allow you to easily control the motors, and it can
optionally take care of flipping a direction signal for you if you accidentally soldered in a motor
backwards (see Section 6).
As your batteries run out, the voltage supplied to the motor drivers (VSW) will decrease,
which will make the motors slower. It is possible to account for this in your code
by monitoring the battery voltage (see Section 3.6) or using the encoders and other
sensors to monitor the movement of the robot.
3.4. Quadrature encoders
Pololu Balboa 32U4 Balancing Robot User’s Guide © 2001–2019 Pololu Corporation
3. Balboa 32U4 in detail Page 17 of 97

Balboa encoder, showing the magnetic disc and
sensors (with one motor removed).
ach 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 magnetic encoder kits for
micro metal gearmotors [https://www.pololu.com/
product/3081]. 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 50:1 motors [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 P 6, 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

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 Section 6).
3.5. nertial sensors
Pololu Balboa 32U4 Balancing Robot User’s Guide © 2001–2019 Pololu Corporation
3. Balboa 32U4 in detail Page 19 of 97

The Balboa 32U4’s IMU and compass chips.
Balboa 32U4 includes on-board inertial
sensors that allow it to determine its own
orientation by implementing an inertial
measurement unit (IMU); this is key to
Balboa’s balancing ability. The first chip,
an ST LSM6DS33 [https://www.pololu.com/
product/2736], combines a 3-axis
accelerometer and 3-axis gyro into a
single package. The second chip is an ST
L S3MDL [https://www.pololu.com/product/
2737] 3-axis magnetometer.
Both sensor chips are connected to the
board’s I²C bus by default. Level shifters built into the control board allow the ATmega32U4, operating
at 5 V, to communicate with the 3.3 V sensors. If a Raspberry Pi is plugged into the control board, its
I²C pins are connected to the 3.3 V side of the bus as well. (See Section 3.8 for more information
about the Raspberry Pi interface.)
The Balboa32U4 library (see Section 6) includes example programs that demonstrate how to use
the sensors, including a balancing demo. In addition, the sensor ICs on Balboa 32U4 are the
same as those on our Min MU-9 v5 [https://www.pololu.com/product/2738], so software written for the
MinIMU-9 (such as our Arduino AHRS example [https://github.com/pololu/minimu-9-ahrs-arduino]) can
also be adapted to work on Balboa.
Please note that the LIS3MDL magnetometer can be affected by magnetic fields from the Balboa
itself. These include magnets in the motors and encoders, electrical currents through the board, and
hard iron distortions from metal (probably mostly from the batteries). The magnetometer is positioned
as far away from the motors as possible to avoid interference from them, but we have found that
hard iron distortions still influence the readings significantly, making it difficult to accurately determine
the Balboa’s absolute heading based on the raw magnetometer data. This post on the Pololu
forum [https://forum.pololu.com/t/correcting-the-balboa-magnetometer/14315] details a technique for correcting
for hard iron distortions, making it possible to use of the magnetometer as a compass for navigation in
environments that are not dominated by magnetic interference.
For more information on the sensors and how to use them, see the LSM6DS33 datasheet
[https://www.pololu.com/file/0J1087/LSM6DS33.pdf] (1MB pdf) and L S3MDL datasheet
[https://www.pololu.com/file/0J1089/L S3MDL.pdf] (2MB pdf).
Pololu Balboa 32U4 Balancing Robot User’s Guide © 2001–2019 Pololu Corporation
3. Balboa 32U4 in detail Page 20 of 97
Table of contents
Other Pololu Robotics manuals