DIYSegwayHeader.jpg
 

 

"Tipper" the $45 Self-Balancing Segway Scooter

 

 

A new Segway was $6,000. This self-balancing electric scooter: $45 in parts. The motors and tires were salvaged from a broken electric wheelchair, the metal was scrap, the battery surplus from a garage sale, all the circuits including the motor controller and processing board from scratch.

The system has three primary components: a controller circuit and its sensors (gyroscope and accelerometers), a dual H-bridge motor controller, and the mechanical assembly including the drive motors and energy storage. An inverted pendulum software control system was modeled and optimized in Matlab, and then written in C to run on the target hardware. Final system calibration was performed in the lab (with a helmet).

segway.JPG
DSC_0098.JPG
 

Control System

The Tipper is controlled by a microcontroller that runs through a control loop several hundred times per second. The loop reads sensor data and commands two H-Bridge motor controllers. The objective is to always keep the handlebars close to upright. When this invariant is held true, if one leans forward the Tipper accelerates forward to compensate and keep the handlebars upright. If one leans backward, the Tipper turns the motors in reverse to compensate in the opposite direction. If the rider wants to go forward, just lean forward.

In order to do this, the controller needs to know the current tilt of the device, which is not a trivial task. The system uses accelerometer and gyroscope data to estimate the physical state of the system by applying a low pass filter on the accelerometer reading, a high pass filter on the gyroscope reading, and combining the two into a single tilt estimate. The accelerometer provides an accurate measurement of the component of gravity over the long term, but suffers from short term errors due to acceleration of the plant, and the gyroscope provides an accurate measurement of the rate of tilt, but integration drift tarnishes the estimate over a long period of time. Over time, small errors accumulate making the estimated position increasingly incorrect. When filtered, weighted and combined, they give a fairly accurate estimate of the Tipper's tilt state.

With the current system state (the tilt) now known, and the desired state a constant (upright the Tipper at all times), the controller can now command the motor speed controllers. The speed controllers are variable, which means the controller must choose a desired velocity for the motors and send that request to the speed controllers. A PID (proportional, integral, derivative) control loop was used to pick the correct motor velocity in order to close the difference between the desired and current system state. Since the inverted pendulum is an inherently unstable system, the entire device was mathematically modeled in Matlab/Simulink in order to fine tune the control parameters prior to testing on the device.

Power Electronics

The Tipper uses a custom dual H-bridge motor controller to regulate voltage to the two drive motors. Since voltage sets speed on a DC motor, these are effectively speed controllers. The H-bridge uses MOSFETs to switch current on and off the motors at a fast rate. By controlling the time (duty cycle) that the motors receive power in each switching cycle, the average voltage, and therefore speed, is set. 

 

Mechanical platform utilizes two wheelchair motors and pneumatic tires.

Mechanical platform utilizes two wheelchair motors and pneumatic tires.

Board layout for the integrated system controller and H-bridge board.

Board layout for the integrated system controller and H-bridge board.

Mechanical Assembly

The Tipper was built on an aluminum base. Bolted to this base are two gearhead motors salvaged from an old electric wheelchair. To reinforce the base and motor structure, a thinner aluminum top plate is mounted above the gearheads. On top of the top plate sits a rechargeable lead-acid battery that powers the entire system. The handlebars are made of steel piping. At the top a T-elbow is screwed on. A slit in the top plate gives the handlebars fore/aft stability and the ability to pivot left and right for turning command input from the rider. A bolt coupled to a potentiometer at the very bottom secures the handlebars to the Tipper and senses turn indications.

Steel pipe handlebars rise above the waterjet top plate. A slit in the top plate allows the operator to move the handlebars left and right. A potentiometer reads this pivot and differentially powers the motors so that the Tipper steers in the desired direction.