Why build a DIY Segway?
The main reason that I wanted to build a DIY Segway was simply because I wanted to see if it was possible. I also liked the idea of building something that strongly interacts with humans. I will now describe how I built it.
The motors, wheels, chain, gears and batteries came from electric scooters like the one to the right. You need hardware from two since the electric scooters only have one motor and gear setup. The motors are some cheap china unbranded ones. They are rated as 300W 24Volt, 2750 rpm
The gearing is made in one step from the small gear on the motor to the bigger gear head on the wheel. The ratio is approx 6:1, a higher ratio would be preferred to get a better torque and a lower top speed. Now the motors have to work pretty hard and currents above 30A(in total from both motors) have been registered since the fuse burned.
The fasting of the gear on the 12” wheel was based on a freewheel mechanism therefore I had to open up the freewheel and remove all the grease and then use epoxy to make it possible to drive it in both directions. In the picture below you can see the freewheel after it has been filled with epoxy as well as a tool made to be able to open it up.
There is one fixed axle on which both wheels rotate, this axle is attached with three aluminum blocks which fixates the axle with 5mm set screws.
Steering, to be able to turn left and right by just tilting the handlebar a rigid joint was needed, the design was made in SolidWorks and then produced in a CNC mill. The transfer from the CAD drawing to the machine instructions (g-code) was made with CAMBAM. The same method was used to produce the box for the electronics and the assembly for the emergency brake.
The handlebar is a normal bicycle handlebar, the pipe on which it is connected is a 25mm hollow steel pipe. To keep the pipe centered and to give some force feedback two springs are attached with steel wires. On the handlebar there is also an emergency button which is connected to a standard car relay which directly cuts the power to the motors. Two 12V 12Ah lead batteries are used in series since the motors run at 24V
All PCBs are custom made, the main board (top left in image above) takes care of the computation, gathers data from sensor such as gyro(ADXRS614), accelerometer(ADXL203) and a trim potentiometer which is modified and positioned in the steering joint to detect in which direction you want to turn. The main processor is an AVR AtMega168. The communication to my laptop is made over Bluetooth using a RN-41 from Roving Networks (the same is used in Sparkfuns BlueSMiRF Gold).
The two H-bridges (right-hand side in the image) which convert the control signals from the main board to the power to the motors are designed by friend named Benjamin Vedder. Each H-bridge also have an AtMega168, the communication between the boards is done via UART, originally I2C was used but due to the high currents produced by the motors too much noise was generated and was influencing the I2C communication. All the electronics run on a separate battery (a LiPo 7.4v 900mAh).
To have easy access for charging the batteries, programming the main board and changing parameters to the control loop a small box with several connectors, a switch to turn on and off the power to the electronics and trim potentiometer is positioned on the top side.
The software in the microcontroller mainly consists of a filter for the gyro and accelerometer and a PD control loop. The idea from the beginning was to have the DIY Segway as a platform for testing different types of control methods. However since the power of the motors and the mass of the system was quite big it turned out that it is not such a great test platform (at least if you don’t like getting lots of bruises and destroying the interior of the place you are testing it at).
A better option would be to have a smaller balancing setup which fits on a table and with a mass of less than 1kg for this purpose.
Regarding the filtering of the gyro and accelerometer I tested both a Kalman filter and a Complemenatry filter. It turned out that the performance was very similar of the two filters but the Complementary filter required less computation and is therefore currently used.
On the computer I made an application written in Java where I can see all the sensor values and control signals, battery status etc. It’s a great way of debugging the system.
I didn’t keep a strict log over my purchases so this is mainly an estimate, however I have tried to overestimated all costs to not give a too optimistic result. The biggest cost was the motors wheels and batteries. I managed to reduce this cost pretty well by buying a second hand scooter which was malfunctioning due to an electrical error, the parts I scavenged from it makes up one setup of wheel motor and gears. Since I needed parts from two scooters I also bought a separate setup as spare parts so these were completely new. Regarding the electronics I bought several items via eBay which can give great prices.
2 motors, 2 wheels and 2 lead batteries 150€
Steel pipe 5€
Aluminum blocks 10€
Aluminum base plate 10€
12mm Steel axle 5€
Emergency brake 3€
2 Springs 8€
3 x AtMega168
Capacitors & resistors
Double layer PCB