November 07, 2017

Self-balancing robot version 2

Every project must include something new.

I wasn't happy with version 1.

Here's version 2, completely different:


It stays up for over half an hour on smooth floors! It also doesn't roam around as much as version 1.

View from the top.

The big differences between version 2 and version 1 are:

  • rigid frame and motor mounts instead of Lego pieces
  • hobby DC motors instead servo motors
  • two battery holders to power the motors separately from everything else
  • L293D motor controller

The L293D is an ancient motor controller from many decades ago. It isn't energy efficient, runs hot and can only provide 600mA of sustained current per channel. However, that is more than sufficient because I don't need to run the motors at full power at all. Besides, L293D has separate power and motor pins, builtin clamping diodes to protect the chip from motor back emf and over-temperature protection.

The various data sheets (STmicroelectronics , Texas Instruments) have all the application information needed to use the chip. Even better, check out this guide.

First, I prototyped the circuit on the breadboard on the donor chassis:

Then I squeezed the DIP socket, capacitors, a switch and connectors on a tiny perfboard I happened to have. The two connectors on the right are for the two motors and the two connectors on the left are for motor and logic power. The three wires on each side together control a motor.

The back doesn't look so nice. And I really do not recommend using such a small perfboard.

The micro:bit works with 2V to 3.6V and I am powering it with 2.7V. The L293D needs at least 2.3V for high input and the micro:bit drives high outputs very close to its 2.7V supply voltage. That works. However, the L293D needs at least 4.5V for the logic power supply pin according to the data sheet. I should really use a 5V step-up regulator. But it seems to work with 2.7V and that will do for now. This is just a toy after all.

The code is mostly the same as version 1. Instead of using the servo apis to control the servo motor, each DC motor is controlled by applying PWM signals to the motor enable pin (grey line) and setting the correct output to two other lines (yellow and green).

Finally, the PID controller's parameters need to be retuned by hand.

Yeah, I was going to post the code.

But first, I have to talk about the 9-axis MPU-9255 gyroscope, accelerometer and compass that is used in both versions of the robot. Coming up.

No comments:

Post a Comment

Note: Only a member of this blog may post a comment.