From the MITERS lab at MIT, via Instructables, comes the Segstick, the poor man’s version of Dean Kamen’s Segway PT. Like the Segway, the Segstick is a self balancing robot that uses a combination of accelerometers and gyroscopes to sense and adjust it’s tilt. Unlike the Segway, the Segstick is made from things like a broom stick and cordless drill motors.

The cordless drill motor is a clever choice since it incorporates a high torque motor, 2 speed gearbox, and chuck all in one easy to get package. This project uses one with a 1/2″ chuck so it can latch onto the 1/2″ shaft that the wheel goes on. The project also uses a 6 degree of freedom inertial sensor from SparkFun, an Arduino, and H bridge motor drivers from Pololu.

I was looking forward to reading the Instructable page that discusses the control algorithm. Control theory interested me both before and after (but unfortunately not during) the one controls class I took as an undergraduate. I blame the professor for not being more engaging. That’s an easy way to place blame since most engineering professors aren’t very engaging.

The Segstick uses a Proportional Derivative controller (PD), a subset of the full PID (proportional integral differential) controller. In a PD controller the proportional term applies a correction that is proportional to how far away the system is from the desired location. In this example the P term is like a spring, applying a force that is proportional to how far the stick is from vertical. The differential term is proportional to the derivative of the position, or to it’s velocity. In the Segstick the D term applies a correction based on the velocity of the stick rather than the position. If the stick moves quickly the D term applies more resistance than if it moves slowly. The P term is comparable to a spring in a mechanical system, and the D term is comparable to friction, or a shock absorber or dashpot.

It’s easy to imagine that the amount of P and D needed depend on the physical parameters of the system, like the force applied to the stick, the weight on the SegStick, the torque of the drive motors. If the coefficients of these terms are not right then the control system will fail: The position won’t be maintained, or will oscillate. The coefficients are chosen from a mathematical model that represents the problem, which is what I was looking forward to reading about. For the SegStick the author just picked values and tuned until it worked. In the real world that would require exhaustive testing to make sure no combination of real world inputs can cause your control loop to become unstable, which is why models are used instead.

There is a good discussion of the complementary filter that is used to combine the readings from both the accelerometer and the gyroscope (in the inertial measurement unit) in the calculation that determines the angle of the stick. The accelerometer is useful for longer term angle measurement while the gyroscope provides quick response to changes.

The end result works as you can see in the video on the last step. It may not be rigorous, but it’s pretty good for a couple days work. The last step also has links to other self balancing robots, some of which seem to have better discussions of how the control algorithms are set up.

Steve Ravet

Design News Gadgeteer