GanzBot IV
It had been a long time since GanzBot PBR, and I thought it would be fun to build another balancing robot. This guy is from the 2018/2019 time frame.
I haven’t done much outside of making him balance though. His “brain” is still on a breadboard while I decide what I really want in it before I lay out a custom PCB.
Though for his motor driver I did already design a custom PCB which communicates with the main MCU and offloads motor control for both motors.
Custom Dev Tool
For development ease, I also created the C# Wireless Dashboard, which allows me to plot data from him real-time and change parameters and gains over Bluetooth. No tethers and real-time plots are great for balancing robots.
Overview
Since his predecessor was built, all the typical components have pretty much become commodities now. It’s a lot easier to put a balancing robot together, and 3D printers make the structural part straightforward and fun. I couldn’t resist.
What he’s made of:
- Main processor is a Teensy 3.2 (ARM Cortex M4, 72 MHz) performing the gyro/accelerometer sensor fusion and balancing control loops
- complementary filter for sensor fusion
- 250 Hz controller loop rate
- calculations in floating point – no more fixed point arithmetic like I had to do for GanzBot PBR !
- Custom Motor Controller PCB generates step & direction signals for two stepper motors
- HC-05 Bluetooth module for wireless connection to custom C# Wireless Dashboard
- Pololu AltIMU-10 v4 Inertial Measurement Unit with L3GD20H 3-axis angular rate sensor (gyro) and LSM303D accelerometer/magnetometer (magnetometer is not used).
- gyro set to +/-245 deg/sec range
- accelerometer set to +/-2 g range
- PLA 3D printed structure, with heat-set brass threaded inserts. Love them.
- 8 cell, NiCd, 9.6V, 2.4 AHr battery pack (i.e. 23WHr, or 0.028% of a Tesla Model 3)
- handful of blinky lights. LEDs for status info (ready to balance, balancing, error, etc.)
- 98 mm scooter wheels (Amazon)
- NEMA17, bipolar, 1.7A, 42mm x 38mm, 200steps/rev stepper motors (Pololu #2267)
- aluminum shaft adapters (Pololu #2673)
Custom Motor Board
This board is a custom PCB I designed for driving two stepper motors. In addition to the low-level stepper drive boards, it has it’s own smarts using an ATmega32U4 MCU (A-Star 32U4 Micro board). This enables it to offload the Teensy from having to generate the step and direction pulses. Depending on the microstepping mode chosen, creating the step pulses can be high frequency and consume considerable CPU cycles.
Custom Motor Board main features:
- ATmega32U4 MCU (A-Star 32U4 Micro board)
- communicates with main brain (Teensy 3.2) over UART, at 115.2Kbaud
- receives speed commands for each motor
- receives motor current limit command
- provides fault status when requested
- two MP6500 Pololu stepper drivers, with digital (not potentiometer) current control
- software selectable stepper current limit, via 32U4 PWM outputs
- +/-5 amp battery current sensing (Allegro hall effect sensor on Pololu carrier)
- battery voltage sensing
- charger input, diode protection, and charger-present voltage sensing
- 5V, 2.5A step-down switching voltage regulator (Pololu 2850)
- 4 layer, 1 oz. Cu, 118 mm x 75 mm, HASL. JLCPCB.com $67 for 10 boards
Why the 32U4 MCU for the motor drive board?
I specifically chose the Pololu A-Star 32U4 board for the custom motor PCB since it has the AVR ATmega32U4 MCU. This may seem like nothing special, but it has a major feature that is nonobvious. It is similar to the boards with the AVR ATmega328P (such as the Arduino Uno, Nano, or Pro Mini), but there is a key difference in the timer system. The ATmega32U4 MCU has an additional 16 bit timer. That allowed me to dedicate two 16 bit timers (Timers 1 and 3) to generate step pulses for their corresponding motors. Combined with tight Interrupt Service Routines, this provides for high frequency, low jitter, independent step pulse generation.
Next Steps
Maybe at some point I’ll decide what I want for additional sensors and processing, and layout a board to carry the Teensy 3.2, IMU, and the HC05 Bluetooth and whatever else.
Another option is to kick it up a notch and use an NVIDIA Jetson or Raspberry Pi. I’ll probably have to jack up the battery size though to get a respectable run time. We’ll see.