October 28, 2017

Self-balancing robot version 1


I got my hand on a few micro:bits and a Kitronic :MOVE mini buggy. They were meant for my kids. But I had always wanted to build a remote controlled self-balancing robot. What's the easiest way to get something working? Repurpose parts from the buggy, add Lego and some code!

Here's version 1. It is fragile and wobbly. With a simple PID controller written in Javascript using makecode/PXT, it self-balances on carpet for over 20 minutes but doesn't do so well on hard floors.


I use a second micro:bit to instruct the robot to turn using the micro:bit's radio service. Turn too much and it falls over!


The bot:


Stripped of the Lego frame:


As you can see, it isn't exactly as "kid-friendly" as just adding Legos.

I had to add a digital gyroscope (MPU-9255), an edge connector and solder some connectors to get access to the I2C pins. See parts list below.

The hardware turns out to be too flimsy. The motors do not stay in position. The wheels have limited friction on hard floors. Tuning the PID parameters was hard and time consuming with so many sources of errors.

On the software side, I had to read the MPU-9255 specification and write code to talk to it using I2C. There is no existing makecode module for that 9-axis gyroscope/accelerometer/compass chip. The version of Javascript in makecode does not support floating point or trigonometric functions. Certainly, this can be made more "kid-friendly".

In the end, I was just amazed that it somewhat self-balanced on carpet for more than 20 minutes. It is not anywhere near Segway stable, which is not surprising given the rather primitive control algorithm.

Parts:
The servo:lite board isn't necessary. It holds 3xAAA batteries to generate regulated 3.3V volts for both the micro:bit and the servos. The micro:bit can actually run off 2xAAA batteries directly and the servos can be powered unregulated with up to 6V (4xAA batteries).

Version 3 is the updated version 1 without the servo:lite board and Legos.

Links to all the micro:bit robot posts:


No comments:

Post a Comment