May 18, 2017
| By: Christine Young
Blogger, Maxim Integrated
Justin Jordan, a member of the technical staff in Maxim's Embedded Security Business Unit, has always enjoyed tinkering with robotics. While in school, he was on an underwater robot team and has also built line-following robots. Over the years, he has admired self-balancing robots that others have created, especially since these involve control system theory, an area of interest. So when the opportunity arose for Jordan to write some example code for the Bosch Sensortec BMI160 inertial measurement unit (IMU) on Maxim’s MAX32630FTHR board, he jumped at the chance to build his own self-balancing robot.
One of the first things that Jordan did was configure the on-board IMU, which estimates a pitch angle from vertical to help the robot stay straight. Basically, when the robot drifts away from the vertical point, the control loop directs the DC motors to keep the base of the robot under its center of gravity. The IMU samples data from the accelerometer/gyroscope, running this data through a complementary filter to produce an estimated feedback signal (providing the estimated pitch of the robot at a given time) for the control loop. Jordan noted that the complementary filter, which fuses accelerometer and gyroscope data into a single feedback signal, provides an easier-to-use option than the traditional Kalman filters that can also be used for this purpose.
The MAX32630FTHR board can be used to build a variety of applications, such as fitness monitors, portable medical devices, sensor hubs and, yes, self-balancing robots.
The MAX32630FTHR board is designed to help engineers quickly implement battery-optimized solutions with the MAX32630 ARM® Cortex®-M4F microcontroller. Since this microcontroller features a floating-point unit, Jordan didn't have to perform any approximations to generate the pitch estimates. The floating-point calculations are performed quickly, since they’re done in hardware instead of software. The board also features 512K of SRAM, which was used for data logging while the control loop was running. For example, Jordan used a sample rate of 1.25ms (800Hz) and recorded 14400 samples of the accelerometer horizontal and vertical axis, the gyroscope x-axis, and the pulse-width modulation (PWM + DC) sent to each motor. All of this used only 45% of the available RAM, and consisted of 18 seconds of data. Since the board provides a micro SD card connector, Jordan was able to write the saved data to an SD card as a CSV file and then remove the card for data analysis on a PC.
Jordan notes that he could have used various other microcontrollers as the underlying technology for his robot. But the MAX32630FTHR board, he says, is a "nice buy" with all that it includes. The 0.9-inch x 2.0-inch board comes with an array of resources, including a MAX14690 power management IC, a dual-mode Bluetooth module, and a 6-axis accelerometer/gyroscope. The board is suited for fast proofs-of-concept and early software development of applications like fitness monitors, portable medical devices, sensor hubs, sports watches, wearable medical patches and, of course, robots.
For schematics, a diagram of the control loop, and data plots for Jordan's self-balancing robot, see his project published on Hackster.io.