DIY Segway
Project Background
I've actually been interested in Segways for quite some time. I recently stumbled across this drawing I made when I was younger. I would estimate that I was 10-12 years old. This old drawing will soon be a reality though in a slightly different form. Note the drawing on the right features a large bar graph for battery percentage, a speedometer, some sort of controls (turn signals maybe?) on the left grip, two buttons to detect feet, and a fancy single-spoke wheel design. The cheap SLA batteries won't hold a candle to the Lithium setup in the sketch, foot sensors are being replaced with software safety features, and I'm using inexpensive appliance dolly wheels instead of the ones I sketched. The basic device will be similar however, and that's exciting. |
Latest news:
Last night was the big reveal (sort of). I rode up and down the hall and the chains aren't slipping anymore since I finally finished up the metal work. I gave about a dozen test rides, and most everyone loved it. Now I am starting to see how fast it can go. I am not sure what the top speed is, but I have gone as fast as 8-9 mph so I might eventually even exceed my 12mph goal. Battery life seems to be good so far. I have driven it a lot and it has just started to drop to about 24V. I haven't charged these batteries yet so I'm really hoping my cheap charger does the job. I'm taking it to my computer classes tomorrow to demonstrate and give test rides :D
4/12/15
Thursday of this week I have an appointment with an engineering major friend who is going to complete the metalwork with me in the machine shop on campus. That will be the last major hurdle of the platform part of this project. Then I just need to cut the chain to length (which I've practiced doing) and assemble it. I'm seriously excited about this!
2/24/15
The project is coming along nicely. Just this morning the last parts to complete the functional platform came in. All I need is the metal work and enough time to finish the wiring to have it moving under its own power. Soon I'll see it balance itself under power for the first time :D
2/17/15
Last night was the big reveal (sort of). I rode up and down the hall and the chains aren't slipping anymore since I finally finished up the metal work. I gave about a dozen test rides, and most everyone loved it. Now I am starting to see how fast it can go. I am not sure what the top speed is, but I have gone as fast as 8-9 mph so I might eventually even exceed my 12mph goal. Battery life seems to be good so far. I have driven it a lot and it has just started to drop to about 24V. I haven't charged these batteries yet so I'm really hoping my cheap charger does the job. I'm taking it to my computer classes tomorrow to demonstrate and give test rides :D
4/12/15
Thursday of this week I have an appointment with an engineering major friend who is going to complete the metalwork with me in the machine shop on campus. That will be the last major hurdle of the platform part of this project. Then I just need to cut the chain to length (which I've practiced doing) and assemble it. I'm seriously excited about this!
2/24/15
The project is coming along nicely. Just this morning the last parts to complete the functional platform came in. All I need is the metal work and enough time to finish the wiring to have it moving under its own power. Soon I'll see it balance itself under power for the first time :D
2/17/15
pLANNING STAGES
I have tried to plan this thing thoroughly and think things through before throwing money at it, mainly because it's good practice and also because I'm a Freshman at Bob Jones University, therefore the budget for this project is tight. Of course I started with YouTube videos of successful builds. I have poured over build logs, pictures, and demo videos for hours determining what I want to incorporate into my own design.
I'm not recycling much of anything with this build, but I'm trying to find the ideal parts to purchase that are the best available value. The motors, for example, were chosen because they offered one of the best watts-to-cost ratios I could find within my budget. I'm not an expert with programming or mathematics, but part of the purpose of this robot is to encourage other hobbyists to take on the challenge. As you will see in the code comments, I was able to find the code to take care of the filtering of values using a mathematical process called linear quadratic estimation. I have a general idea of the theory behind this, but I don't know a thing about the math. Open-source projects completed by others will allow me to implement this value scrubbing technique to get perfectly smooth readings from the motion processor. The bottom line is that I am doing this project to learn as much as possible, and to have a functional personal transport vehicle when I finish. |
Components
COPMUTER (MCU)
Of course all the magic of a Segway-like device is the balancing act performed by the computer. Like many of the other projects on this site (and dozens not yet on this site) I decided to go with the Arduino. Arduino is ubiquitous enough that you can get help from a huge community, find libraries for nearly anything, and attach anything to it. I have about 2.5 years of experience with Arduino and I love the fact that it is open-source. I also chose to use it because it is what I have on hand and it's what I'm familiar with. VERDICT: ARDUINO UNO R3 COST: $25 BUY: AMAZON INFORMATION: ARDUINO.CC MOTION SENSOR (MPU)
The Arduino doesn't do too much by itself, so to do any motion sensing I had to find a gyro-accelerometer. I still regret that the one I decided to buy is closed-source, but this thing is so powerful, simple to use, and inexpensive that I had to go with the Invensense MPU6050. The chip has a built-in DMP (Digital Motion Processor) that does all the heavy-lifting automatically, and it has 6DOF (Degrees of Freedom) gyro, an accelerometer, and a random thermometer. The chip is well-documented and widely-used in Segway projects I've seen. That's probably my main draw to this chip: a lot of people use it in Segway project. (Photo from Invensense.com) VERDICT: INVENSENSE MPU6050 COST: $5 BUY: (breakout boards discussed next) INFORMATION: INVENSENSE.COM MPU BREAKOUT BOARD
My chosen motion sensor chip is SMD only, but fortunately there are several breakout boards on the market. The Arduino website actually lists them here and explains & links them. I actually didn't give this too much attention when I found that I could buy the GY-521 breakout with the MPU6050 chip for about $6 on Amazon.com. After using the board, I can tell you that it uses just 3 pins (2 analog and one digital) in addition to 5V and GND. That's really pretty good for a sensor like this, and it leaves the rest of the Arduino to do other fun things. Oh, and did I mention that the computer board that does motion sensing is $6? Crazy! Beware though, the board doesn't spend a lot of time in quality control. Mine came with the green LED soldered on upside down (which I fixed myself), but it still doesn't light. It doesn't seem to affect the function. If you buy one, hook it up and test it when you get it. There isn't official documentation, so I linked a helpful writeup below. VERDICT: GY-521 BREAKOUT COST: $6 BUY: AMAZON INFORMATION: ARDUINO.CC MOTOR CONTROLLER
Sadly, motors large enough to move a human being can't exactly be controlled directly by the Arduino. This is the single most expensive part of my Segway project but I think it's well worth the investment. I chose the Dimension Engineering Sabertooth 2x25V2 motor driver. This board is really classy. Not only are the tolerances comfortably higher than what your average Segway needs, but controlling the motors is ridiculously easy. The board accepts serial input. Better yet, Dimension Engineering provides an Arduino library. That's right, there's an Arduino library for the motor controller. The product page for this device has about 17 resources ranging from PC software to datasheets. There are pictorial quick start guides and everything else to make this absolutely refreshing to use. The cost is annoying, but there isn't really anything I could find from China or anywhere else that offered so much convenience and quality. The board also features healthy-sized heat-sinks, and large screw terminals for the high-current wiring. The controller is dual-channel which means that it will just take one board to control both Segway motors. The pin cost for the Arduino is low again, requiring just one digital pin (TX-1) and GND. The Arduino can actually be powered from the Sabertooth by connecting the 5V terminal to the 5V pin on the Arduino. That lets your Arduino be powered by the main battery bank of your robot therefore deleting a cable and separate battery bank for the low-voltage stuff. This board also has over-current protection and a bunch of other "insurance" measures to make sure you don't fry anything. (Photo from Amazon.com) VERDICT: DIMENSION ENGINEERING SABERTOOTH 2X25 (v2) COST: $125 BUY: AMAZON INFORMATION: DIMENSION ENGINEERING BATTERIES
The sketch at the top of the page specifies lithium-ion batteries, but my budget specifies otherwise. I've only seen a couple Segway projects use the more expensive lithium options, and the alternative is simpler to implement and much less expensive. I'm using SLA (Sealed Lead Acid) batteries much like you'd find in emergency lights, battery backup power strips, and small electric scooters. I'll need a 24V system, so I ordered a pair of large 12V batteries that will be wired in series to provide 24V. They are each 7Ah batteries, and several other Segway projects are using 12Ah batteries, but I couldn't beat the value I got on this set. If I find the battery life to be inconveniently short, I can always upgrade at a later date. (Photo from Amazon.com) VERDICT: 2X 12v 7AH SLA BATTERIES COST: $28 (FOR BOTH) BUY: AMAZON INFORMATION: WIKIPEDIA MOTORS
Of course you're not going anywhere without motors. Due to the need to steer the vehicle, two motors are needed. Some people do 250W motors, some do 300W, 350W, and a few go for 500W motors. I found that I could get the best value on a couple of 280W motors. I'm not too large of a person, and since I'm not planning to win any races on it I think they will do just fine. They are from a Razor E300 electric scooter. It's the same thing you'll see in Walmart. I just went to eBay and found E300 replacement motors. I found a US seller that was selling them for a decent price, and ordered two. These have an 11-tooth sprocket built on the drive shaft already, sturdy mounting brackets, and long enough wires to make hook-up simple. If you're shopping around, be sure and watch shipping costs because these are pretty heavy. These are rated at just over 15A, but the Sabertooth motor controller I bought will handle up to 25A on each channel. They operate at 24V so the 12V batteries will be wired in series as I mentioned before. (Photo from eBay.com listing) VERDICT: 2X 280W BRUSHED MOTORS COST: $73 (BOTH MOTORS + SHIPPING) BUY: EBAY INFORMATION: ELECTRICSCOOTERSONLINE.COM WHEELS
Tires and wheels presented a challenge. I wound up with appliance dolly wheels, rated for 330lbs. each. They have a 13" diameter, 4" width, and 5/8" bore. They are a semi-knobby design that should provide good traction outdoors but still be nice and smooth indoors. They have good double ball-bearing hubs that are smooth and greased. The 5 bolts around the hub are very important to my design as those will actually drive the wheels in the final product. I bought some 5/16"x4" hex bolts that are threaded all the way up the shank. I'm using 5 on each wheel to replace the original short bolts from the split hubs. I'll discuss that in more detail later. I found these on sale at the local Tractor Supply Co. for just $10 each. Other retailers sell very similar ones for about $14. VERDICT: 2X 13"X4" PNEUMATIC HAND TRUCK WHEELS COST: $20 (FOR BOTH) BUY: TRACTOR SUPPLY CO. INFORMATION: TRACTORSUPPLY.COM |
SPROCKETS
I found the sprockets on eBay, but unfortunately they were the last two available so I don't have a link. They are 78 teeth which gives me about a 7.1:1 drive ratio. Theoretical top speed is around 15 Mph, but I'm shooting for 12 Mph. Starting off it might be around 3 Mph. The main considerations in buying these sprockets were that the motors included 11-tooth #25 sprockets, so I wanted the wheel sprockets to be #25. I wanted about a 7:1 drive ratio, so somewhere in the 77 tooth area was the goal. I also needed something with 5 spokes or at least have material all the way around. VERDICT: NO-BRAND 78 TOOTH 25H SPROCKETS (5 SPOKE) COST: $25.20 (FOR BOTH) BUY: eBay.com |
Non major parts links:
(Prices estimated within a few dollars) Battery charger - $11 not tested yet... Chain - $12 Battery Meter - $10 Axle - $8 Relay - $5 Master Links - $4 Project Box - $7 Wire Connector - $4 Machine Screws (long) - $1 Machine Screws (short) - $1 Nuts - $1 Short Standoffs - $2 Long Standoffs - $2 Fan Guards - $3 (I'm not using these yet. I will if the Sabertooth is heating up the box too much which it is likely to do.) |
Non-Linked minor parts list:
Pipe holder Nuts and bolts (for wheel) Pipe Clips Electrical Crimp Connects Fuse Holder Fuses (30A) Plywood Washers, nuts, bolts, etc. to mount components to platform |
Design
I'm not exactly doing anything new here. It's not an invention, it's not original, but it is still a great project. I'm taking design cues form a couple dozen DIY Segway builds floating around on the internet already. All you need to do is search YouTube to find some of these builds. There are some that are very inexpensive and recycle old parts, there are some that are crazy expensive (one over $4k???) and there are some that are just ugly. I'm not recycling anything that I know of (yet), but what I'm going for in this build is simplicity, function, and cost effectiveness. I am doing it myself, but I'm pulling in resources and advice from people who are better at certain aspects of the design and function.
DESIGN GOALS:
1. Fit through house-sized doors. (32", 81.3cm) -- Works! I can easily navigate doors.
2. Don't be too tall (7.25", 18.4cm to top of platform) -- Done! I don't need to duck for doors (some still might)
3. Don't be too short (ground clearance for components underneath) -- Still enough clearance for light off-roading.
4. Don't be too heavy - between 30 and 40 lbs (13-18kg) -- It's kinda heavy, but I think it still might be under 40. (exact measurement soon).
DESIGN GOALS:
1. Fit through house-sized doors. (32", 81.3cm) -- Works! I can easily navigate doors.
2. Don't be too tall (7.25", 18.4cm to top of platform) -- Done! I don't need to duck for doors (some still might)
3. Don't be too short (ground clearance for components underneath) -- Still enough clearance for light off-roading.
4. Don't be too heavy - between 30 and 40 lbs (13-18kg) -- It's kinda heavy, but I think it still might be under 40. (exact measurement soon).
Code
The use of the MPU6050 and Sabertooth motor controller really cuts down on the code end of things. I wrote most of what I needed to get started within a few hours. Once I got a basic circuit up and running, it took about 3-4 hours to debug. As you can see in the video at the top of the page, the code is functioning properly, though the values will need to be tweaked. I'd like to use potentiometers for the final adjustments so that the parameters can be adjusted on-the-fly, but I may stick with hard-coding just so there is less hardware to incorporate into the fairly compact platform. I'm still considering the possibility of having an RF receiver inside to take commands from a remote control. That way I can still have some control even if I'm not riding it. I might include things like low/med/high settings, remote kill switch, lighting controls, and other goodies.
CHANGE LOG 1/20/15 This release adds some new variables to help the user more easily adjust the sensitivity of the steering and forward/reverse controls. It also features code for an on/off switch (low voltage) which simply determines whether or not the Arduino will send readings or zeros to the controller. Since zeros are effectively "stop everything" to the Sabertooth, it is effectively an on/off switch for the Segway. Regardless of the switch position the whole circuit will operate at full voltage running the Sabertooth, Arduino and motion processor. This is meant to be used as a ready switch and not as a kill switch. Some parameters were changed to allow greater speed. Those are now easily adjusted by the const int statements at the top of the code. 2/24/15 Now that the segway is mostly assembled and operating at 24V, I was able to smooth out the mathematics that control the motors to get a smoother, more linear output. The code reverses the direction of the motors (I hooked my motors to the motor controller backwards of what the code expected) and modifies the "fallen" mode so that the kiy will need to be switched off and on again to reset (this is just the ready switch; the main power can stay on). One of my motors was rolling backward at about .8V when I was sending the zero "stop" command to it (the other did not move, however) so I changed the idle/off command to -1 and it works just fine. Dimension Engineering suggests that I can add a pull-down resistor across S1 and GND on the motor controller. Since the code change fixed it I have not implemented that solution. The top of the code now sports a sensitivity adjustment for easy debugging. |
File last updated: 2/24/15
|