Pololu Romi 32U4 Manual de usuario

Pololu Romi 32U4 Control
Board User’s Guide
Pololu Romi 32U4 Control Board User’s Guide © 2001–2019 Pololu Corporation
https://www.pololu.com/docs/0J69/all Page 1 of 55

1. Overview . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 3
1.1. Included components . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 3
1.2. What you will need . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 4
1.3. Supported operating systems . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 5
2. Contacting Pololu . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 6
3. Romi 32U4 Control Board . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 7
3.1. Microcontroller . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 7
3.2. User interface . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 7
3.3. Motor drivers and encoders . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 9
3.4. Inertial sensors . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 11
3.5. Power . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 12
3.6. Expansion areas . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 16
3.7. Raspberry Pi interface and level shifters . . . . . . . . . . . . . . . . . . . . . . . . . 19
3.8. Pin assignments . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 22
3.9. Adding electronics . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 26
3.9.1. Controlling a servo . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 29
3.10. AVR timers . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 29
3.11. Schematics and dimensions . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 30
4. Assembling the Romi 32U4 Control Board . . . . . . . . . . . . . . . . . . . . . . . . . . . . 32
5. Programming the Romi 32U4 Control Board . . . . . . . . . . . . . . . . . . . . . . . . . . . 34
5.1. Installing Windows drivers . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 34
5.2. Programming using the Arduino IDE . . . . . . . . . . . . . . . . . . . . . . . . . . . 36
5.3. Programming using avr-gcc and AVRDUDE . . . . . . . . . . . . . . . . . . . . . . . 41
6. Romi 32U4 Arduino library . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 44
7. The Romi 32U4 USB interface . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 45
8. The A-Star 32U4 Bootloader . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 47
9. Reviving an unresponsive Romi 32U4 . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 50
9.1. Reviving using the Arduino IDE . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 50
9.2. Reviving using AVRDUDE . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 52
10. Related resources . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 54
Pololu Romi 32U4 Control Board User’s Guide © 2001–2019 Pololu Corporation
Page 2 of 55

1. Overview
The Romi 32U4 Control Board is designed to be assembled with a Romi chassis
[https://www.pololu.com/category/202/romi-chassis-and-accessories] to create a capable integrated robot
platform that can easily be programmed and customized.
Like our A-Star 32U4 programmable controllers [https://www.pololu.com/category/149/a-star-
programmable-controllers], the Romi 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 and is designed to connect to a Romi Encoder Pair
Kit [https://www.pololu.com/product/3542] (available separately) to allow closed-loop motor control. 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. A 3-axis accelerometer and gyro enable a
Romi 32U4 robot to make inertial measurements, estimate its orientation, and detect external forces.
Three on-board pushbuttons offer a convenient interface for user input, while indicator LEDs, a buzzer,
and a connector for an optional LCD allow the robot to provide feedback.
The Romi 32U4 Control Board 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 Romi 32U4
Control Board for low-level tasks, like running motors, reading encoders, and interfacing with other
analog or timing-sensitive devices.
The I/O lines of both the ATmega32U4 and the Raspberry Pi are broken out to 0.1″-spaced through-
holes along the front and rear of the control board, and the board’s power rails are similarly accessible,
enabling sensors and other peripherals to easily be connected.
A software add-on is available that makes it easy to program a Romi 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. Included components
Pololu Romi 32U4 Control Board User’s Guide © 2001–2019 Pololu Corporation
1. Overview Page 3 of 55

The following components are
included with the Romi 32U4
Control Board:
• two low profile female headers for motors and encoders
•buzzer [https://www.pololu.com/product/1484]
•2×7 female header [https://www.pololu.com/product/1027] and male header
[https://www.pololu.com/product/966] for LCD
• battery terminals
• four 3/16″ #2-56 screws and nuts
• four M2.5 standoffs [https://www.pololu.com/product/1952] (11 mm length), screws
[https://www.pololu.com/product/1968], and nuts [https://www.pololu.com/product/1967] for mounting
Raspberry Pi
An LCD and Raspberry Pi are not included with the Romi 32U4 Control Board.
1.2. What you will need
These additional items are also needed for using and assembling the Romi 32U4 Control Board:
Required accessories
• a Romi Chassis Kit [https://www.pololu.com/category/203/romi-chassis-kits] (this includes motors,
wheels, one ball caster, and battery contacts)
• a Romi Encoder Pair Kit [https://www.pololu.com/product/3542]
• six AA batteries [https://www.pololu.com/product/1003]. The Romi chassis and control board
Pololu Romi 32U4 Control Board User’s Guide © 2001–2019 Pololu Corporation
1. Overview Page 4 of 55

work with both alkaline and NiMH batteries, though we recommend rechargeable NiMH cells.
Assembly tools
• 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
•USB A to Micro-B cable [https://www.pololu.com/product/2072] to connect the board to your
computer for programming and debugging
Optional tools
• small 2 mm slotted screwdriver for adjusting the LCD contrast
•small pair of pliers [https://www.pololu.com/product/150]
•wire cutter and stripper [https://www.pololu.com/product/1923], for adding wires for peripherals
• tape or small clamps (for holding parts together when soldering)
Optional accessories
You might also consider getting these for your Romi 32U4 Robot:
• an 8×2 character LCD [https://www.pololu.com/product/356]
• 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])
•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 rechargeable batteries; since the Romi 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 Romi 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 Romi 32U4 Control Board User’s Guide © 2001–2019 Pololu Corporation
1. Overview Page 5 of 55

2. Contacting Pololu
We would be delighted to hear from you about any of your projects and about your experience with
the Romi 32U4 Control Board. 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 Romi 32U4 Control Board User’s Guide © 2001–2019 Pololu Corporation
2. Contacting Pololu Page 6 of 55

3. Romi 32U4 Control Board
3.1. Microcontroller
Like our A-Star 32U4 programmable controllers [https://www.pololu.com/category/149/a-star-
programmable-controllers], the Romi 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.5 for more details.
The control board’s ATmega32U4 comes preloaded with the Arduino-compatible A-Star 32U4 USB
bootloader [https://www.pololu.com/docs/0 66/7], which allows it to be easily programmed using the
Arduino IDE. or more information about programming the Romi 32U4 Control Board, 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
LEDs
The Romi 32U4 Control Board has five indicator LEDs.
Pololu Romi 32U4 Control Board User’s Guide © 2001–2019 Pololu Corporation
3. Romi 32U4 Control Board Page 7 of 55

• A yellow user LED is connected to Arduino digital pin 13, or PC7. You can drive this pin high
in a user program to turn this LED on. The A-Star 32U4 Bootloader [https://www.pololu.com/
docs/0 61/9] fades this LED on and off while it is waiting for a sketch to be loaded.
• A green user LED 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 LED when it is transmitting data via the USB connection.
• A red user LED 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 LED when it is receiving data via the USB connection.
The Romi32U4 library contains functions that make it easier to control the three user LEDs (see
Section 6). All three user LED control lines are also LCD data lines, so you will see them flicker when
you update the LCD. The green and red user LEDs also share I/O lines with pushbuttons (see below).
• A blue power LED next to the power switch indicates when the controller is receiving power
from the Romi’s batteries (the power switching circuit must be turned on).
• A green power LED on the bottom edge of the board near the USB connector indicates when
the USB bus voltage (VBUS) is present.
Pushbuttons
The Romi 32U4 Control Board has five pushbuttons: a power button in the rear left corner, a reset
button on the front right edge and three user pushbuttons located along the rear 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 LEDs, 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 Romi 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 Romi32U4 library take care of configuring the pins, reading and
debouncing the buttons, and restoring the pins to their original states.
LCD
The Romi 32U4 Control Board has a set of through-holes in the center where a 2×7 header can be
soldered to connect an 8×2 character LCD [https://www.pololu.com/product/356] (or any other LCD with
the common HD44780 parallel interface [https://www.pololu.com/file/0 71/DMC50448N-AAE-AD.pdf] (109k
Pololu Romi 32U4 Control Board User’s Guide © 2001–2019 Pololu Corporation
3. Romi 32U4 Control Board Page 8 of 55

pdf)). You can adjust the LCD contrast with the potentiometer on the top right of the LCD connector.
We recommend using a 2 mm slotted screwdriver to adjust the contrast.
The Romi32U4 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 LED 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 an LCD header soldered to the board should not interfere with
mounting a Raspberry Pi.
Buzzer
The buzzer [https://www.pololu.com/product/1484] included with the Romi 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 Romi32U4 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.
3.3. Motor drivers and encoders
Motor drivers
The Romi 32U4 Control Board has two Texas Instruments DRV8838 motor drivers that are used
to power the Romi chassis’s two mini plastic gearmotors [https://www.pololu.com/product/1520]. our
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.
or more information about the drivers, see the DRV8838 datasheet [https://www.pololu.com/file/0 806/
drv8838.pdf] (1MB pdf). We also sell a carrier board [https://www.pololu.com/product/2990] for this driver.
The Romi32U4 library provides functions that allow you to easily control the motors (see Section 6).
Pololu Romi 32U4 Control Board User’s Guide © 2001–2019 Pololu Corporation
3. Romi 32U4 Control Board Page 9 of 55

The motor driver connections are brought out to two pairs of headers that are intended to interface with
the Romi Encoder Pair Kit [https://www.pololu.com/product/3542]. A pair of low-profile female headers is
included with the Romi 32U4 Control Board and can be soldered into either the outer or inner row of
through-holes on each side. (Note that these headers must be soldered into the positions that match
the male header installed on the encoder board.)
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.5) or using the encoders and other
sensors to monitor the movement of the robot.
Quadrature encoders
The Romi 32U4 Control Board is configured to connect the quadrature encoder outputs from the Romi
Encoder Pair Kit to the ATmega32U4 microcontroller. The encoders can be used to track the rotational
speed and direction of the robot’s drive wheels. They provide a resolution of 12 counts per revolution
of the motor shaft when counting both edges of both channels, which corresponds to approximately
1440 counts per revolution of the Romi’s wheels. or more information about the specifications of the
Romi encoders, please see the Romi Encoder Pair Kit product page [https://www.pololu.com/product/
3542].
Quadrature encoder transitions are often detected by monitoring both encoder channels directly.
However, since transitions on the Romi’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 Romi
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 P 0, reads the right encoder channel B.
• Pin PE2 reads the left encoder channel B.
Pololu Romi 32U4 Control Board User’s Guide © 2001–2019 Pololu Corporation
3. Romi 32U4 Control Board Page 10 of 55
Otros manuales para Romi 32U4
1
Tabla de contenidos
Otros manuales de Controladores de Pololu

Pololu
Pololu Orangutan X2 Manual de usuario

Pololu
Pololu Mini Maestro Series Manual de usuario

Pololu
Pololu DMC01 Manual de usuario

Pololu
Pololu G2 Manual de usuario

Pololu
Pololu DRV8825 Manual de usuario

Pololu
Pololu Jrk G2 21v3 Manual de usuario

Pololu
Pololu A-Star 32U4 Series Manual de usuario

Pololu
Pololu Qik 2s12v10 Manual de usuario

Pololu
Pololu Orangutan SVP-324 Manual de usuario

















