What is it?
Twin wheeled skateboard that works like a Segway. Electric skateboard exist already with motors on the rear wheels. The plan here however is to build something like a Segway but in the form of a skateboard. It knows which way is "up" via a combination of gyroscope and an accelerometer sensors, using what is known as a complementary (not complimentary) filter which reads and combines data from both 100 times per second.
What's new on this Instructable?
July 26th 2011: Step 49 now describes a better way to power the Arduino using a very efficient voltage regulator
July 26th 2011: Step 50 describes alternative build with pneumatic tyres.
Jan 2012: As well as old sketches attached to pages 43 - 47 which work in Arduino V22, I have rewritten each sketch and attached it to work with latest Arduino environment V1.0. also with some bugs fixed regarding accelerometer orientation
How does it stay level?
It controls the wheel motors so the wheels always stay under your centre of balance, like balancing a broomstick on your fingertip. This in engineering terms is called a "PID" control system and is used for all sorts of things. For example think of the 300+ feet high Apollo rockets used in the moon landings..........
Q: How come they didn't they just fall over when they took off? They took off incredibly slowly for the first few seconds, tailfins would have no effect, much slower than the Shuttle launches. Watch this video and see what I mean.......................
It takes a full 10 seconds just to get to 100m and clear the launch tower: http://www.youtube.com/watch?v=F0Yd-GxJ_QM
A: They had engines mounted on gimbals (swivelling joints) hydraulically controlled by a PID control system (lots of analog electronics too). Hence the mystery phrase "we've hit gimbal lock" which keeps cropping up during the film, Apollo 13.
Background:
In 2008 I saw a YouTube video by Ben Smithers of his one-wheeled self balancing skateboard whizzing around a car park in Norwich UK. http://www.robosys.co.uk/ Video: http://www.youtube.com/watch?v=HGbbag9dklU
It turns out he was a Lotus cars controls system engineer - which makes sense.
Also see Trevor Blackwell's site: http://www.tlb.org/eunicycle.html
Meanwhile I wanted to teach myself microcontroller programming and, totally underestimating the task, thought this would be a great fun way to do this. I built several machines some with one wheel and some with two. Advantage of two wheelers is that they turn more easily and can turn and balance even when stationary - which is fun.
Why an Instructable?
Having learned lessons the hard way I thought it would be worth redesigning the project around an Arduino microcontroller, then seeing how low-cost and easy-build I could possibly make it. Clearly something like this is not for the complete Arduino beginner, nor is it that "easy" however this is about as easy as a self-balancing machine is realistically ever going to get.
Skills:
Projects like this lend themselves to being built as a team. Some examples below were built as college projects. There are
i) some electronics (not making circuit boards, just wiring and soldering) to master,
ii) some mechanical fabrication; this version is designed to require no welding, just nuts bolts and some woodwork. Wheel/sprockets/axles/bearings come as a unit (electric scooter rear wheel assemblies).
iii) some programming; the programs (Arduino sketches) you need, including those to help debugging, are attached to the last few pages of this instructable.
How much does it cost?
There are a number of self-balancing robots out there. I realised when costing them up that the cost of a self balancing robot would only be a little lower than that of a ride on machine, therefore I went for the ride-on machine! Robot motor/gearbox combinations are pretty expensive.
For me the cost was about $300 equivalent PLUS whatever batteries you choose to use. I recommend starting with lead-acid batteries then make improvements later once you have a working machine. Lithium batteries etc are expensive!
Why do it?
i) For the challenge of doing something original. Most things have been invented, indeed self-balancing machines have been invented. Segway skateboards have been invented in principle BUT there is huge room for improvement.
ii) Making something that is practical and intuitive to ride is quite a challenge in terms of both electronics/software and fabrication/packaging. Cannot all be done on a computer. Eventually you have to actually build something then incrementally improve it. Despite the myth of "Eureka" moments, the truth is that this is how most innovations come about, by slow incremental development and hard work. Edison did not invent the lightbulb. He developed the first practical lightbulb.
iii) To educate yourself. You will learn a huge amount.
iv) These things are really good fun to ride! I have taken this to 2 UK Maker Faires now and both times people are wanting to have a go. The last time the BBC cameramen who also had an exhibit politely waited until the end of the show, then they too asked to try it out.
This instructable:
There are a large number of pages in this. This is deliberate, if you are serious about building one then you need every single step documented with no gaps.
Additional information:
I have documented all my machines both good and bad on another website here:
http://sites.google.com/site/onewheeledselfbalancing/
I have a page of links to dozens of other self-balancing projects from around the world here:
http://sites.google.com/site/onewheeledselfbalancing/Home/links-to-other-self-balancing-projects
Can I do this as a beginnner?
The fabrication in this has been deliberately kept really simple.
The soldering between sensors and arduino board needs to be good quality!
If you are new to Arduino I would recommend buying an Arduino starter kit. These usually come with a number of ancillary sensors etc and a set of about 12 tutorials. Work through them all (about 2 days of work) and read a beginners book to Arduino. You will then be ready to have a go at something like this.
Has anyone else built one of these?
Oh yes! Ages currently range from 12yrs to 81yrs.
This Instructable is over a year old now, so yes indeed, people have. Here are a few I know of:
1) Skateboard: http://www.youtube.com/watch?v=kSW7YXLCjqk
2) Skateboard: http://www.youtube.com/watch?v=u-uUidBZEnM
3) The Velociryder: http://www.youtube.com/watch?v=xvfUIxusPZw&feature=player_embedded
4) Great board video - Buffalo State College senior project: http://www.youtube.com/watch?v=FEaTxahyQxc
5) Another board based on this Instructable: http://www.youtube.com/watch?v=vhbH_AmIKZA&feature=related
6) A board based on old FIRST robotics parts + code from this instructable (FIRST robotics was started by Dean Kamen who also invented the Segway, to encourage youth to get interested in engineering): http://www.youtube.com/watch?v=Vh9LpNQ_S0k&feature=related
7) Carbon fiber racing car seat with 2 wheels also based on this instructable - the SciChair:
http://www.youtube.com/watch?v=HtivH7INpZ4
http://www.youtube.com/watch?v=1hG24CTgBL4&feature=related
8) Carey's self-balancing platform, good video: http://www.youtube.com/watch?v=ngMJcxeB7og
9) Really cool video (on clifftop path by the sea): Skate auto-balancé
Took 3 years. Used similar parts list except for accelerometers which are from a Wii-Nunchuck. 350W motors. Batteries: two 3Ah LiPo and one 5Ah LiPo. http://www.youtube.com/watch?v=MsYoNA3s7O0
10) The KSLURP board from Malaysia: http://www.youtube.com/watch?v=x3O2NkjJOlg
NOTE:
You build these at your own risk. If tilted they WILL accelerate to correct the tilt. If you are not on the board, this means it can fly across a room. This is why you have to have some form of emergency hand switch that cuts the power if you let go of it. If it develops a fault it does not have multiple redundant systems like a real segway, most likely you will fall off! The code is not guaranteed against any bugs.
If you don't believe me here is a video of Clint Rutkas developing his machine, also featuring some holes it punched in the walls of his apartment! http://vimeo.com/2013773
Have fun. Treat it as an adventure. Once you get it to balance there are many ways to improve it.
John
Remove these ads by
Signing UpStep 1Parts
| « Previous Step | Download PDFView All Steps | Next Step » |



















































































The two motors (left and right) should say:
- Both forward (acceleration ramp%)
- Both backward (with ramp acceleration%)
- Turn right (starboard engine spins up)
- Turn left (turn left engine plane)
- Do you reverse right or left (respectively, the engines run against each other).
I use two 180w 12V motors
Sabertooth
Arduino 2009
yojstik assembled on Arduino as links.
I suppose you are super busy but I'd be very grateful if I persuades a tip on the Arduino programming and electrical connections.
PS: I build the vehicle has two front wheels and rear swivel type robots.
Sorry so much for English .... I'm Italian!
Hello and see you soon!
Thanks!
For people who are interested in making a remote controlled two wheeler, check this out:
http://www.youtube.com/watch?v=Yjsp1-DrsHI&feature=plcp&context=C3c668efUDOEgsToPDskIjtX14x24OF2K3_r7mJgcn
I have just recently tackled this project to use daily taking me to and from class. However i was wondering if this system is stable enough for daily use or just time to time to show off to your friends.. I will be using 2x 300W motors instead of 250.
You can fallow my project at www.aggiespaceprogram.com
Gig'em
Good luck with the project. All depends on how smooth the paths are at your college. If very rough use the E300 wheels with pneumatic tyres (note they seem to come with 2 different sprocket diameters depending on the website you look at).
It is stable enough otherwise. Check out video No.9 on the front page of this instructable. His has 300 or 350 Watt motors and lithium batteries.
Make sure your deck is thick enough wood/metal so it doesn't bend under your weight and slacken off the drive chains.....this adds unintentional instability!
John
with the balance test I seem to have problems, I lean it forward count to 5 then activate the deadman switch and slowly bring it level and just as it gets level the tiltstart kicks in but it doesn't selfbalance at level the motors stop if I tilt it slightly forward the motors move forward if I tilt it back the motors reverse and the more I tilt it the faster it will go, of course let the deadman switch go everything stops.
What am I missing out on? I,m not a programmer nor have I an oscilloscope.
Any help would be much appreciated.
Jan 15th 2012
I have attached new sketches in addition to the old ones to pages 43 to 47. Old ones ran in Arduino 22. Latest version of Arduino environment is V1.0 and it has a different sofwareserial library and commands.
New sketches same as old ones but
a) Run in latest Arduino V1.0 and
b) Have the bug fixed regarding orientation of the accelerometer (I think).
John
x_accdeg = (float)((accsum - (340 + balancetrim)) * (-0.862)); //approx 1.16 steps per degree so divide by 1.16 i.e. multiply by 0.862. We actually use -0.862 as accel is wrong way around relative to gyro.
It should work.
angle = (float) ((1-aa) * (angle + gyroangledt)) + (aa * x_accdeg);
with this:
angle = (float) ((1-aa) * (angle + gyroangledt)) - (aa * x_accdeg);
Cheers
Sorry about this bug.
If your board powers up when roughly level (i.e. tipstart becomes active) then tries to balance but with a balance angle that gradually drifts (i.e. it leans more and more to one side while still balancing OK) it means the accel is not correcting for the inherent drift in the gyro and is acting in wrong direction.
Remember, the gyro corrects small instantanous wobbles of the board while the accel slowly, over a long period, gently corrects the drift in the gyro zero point. This is why, with the above accel fault, it self balances OK for a few seconds but at a gradually changing angle.
This is why changing this:
angle = (float) ((1-aa) * (angle + gyroangledt)) + (aa * x_accdeg);
to this:
angle = (float) ((1-aa) * (angle + gyroangledt)) - (aa * x_accdeg);
usually fixes the problem.
I will do a comprehensive code revision soon as I am still working on similar machines and still learning all the time. The code here evolved by months of trial and error and really needs a full rewrite!
Arduino sketches exist to "read" data from arduino nunchucks. I have even done an instructable on that. If anyone has the time to merge it with the self balancing code, and get it all to work, please go ahead. I am just short of time to work on these things right now.
John
I know its been awhile since the last comment but I was just wondering if I can use a motor with built in motor controller? thanks
Motor with a built in controller could be used if arduino can talk to the controller OK.
Remember it has to be able to go from forward to reverse with no delays or problems. Also need high torque ideally.
However the motor web page you gave me the link to shows brushless servo motors with integrated encoders (position encoders). These tell an external brushless motor controller how to turn the motor.
I could not see one there with a built in motor controller.
I have stuck to brushed motors with robot H-bridge controllers for now as brushless controllers seem more complex to get control of with an Arduino board.
If anyone knows how to reliably control an affordable hubless motor controller with an Arduino I would like to know as then I will get a 1000Watt Chinese e-bike wheel with brushless pancake hub motor and build a self-balancing unicycle!
John
http://www.teknic.com/products/servo_motor.php
The code unlike earliest versions now has a timekeeper routine added.
This works out how long one cycle of the program loop has taken in milliseconds, then adds a variable delay so that the overall loop time is 10 milliseconds. This means program will loop round at 100 times per second so long as it is not so unwieldy that just doing all the calculations takes more than 10 ms.
Therefore the code that sends a pulse out to an oscilloscope is there just so you can double check how fast the program is cycling. Not actually required for the setup process so long as code all working properly.
Check out the scooter the boy is riding!
http://movies.yahoo.com/feature/lorax.html?showVideo=1#theatrical
Wish I could ride mine in real life as well as he does in this cartoon!
here is a link to my board running : http://www.youtube.com/watch?v=s9WJ29vczaU
the problem im experiencing is the shuddering in the entire board when changing from forward to reverse or reverse to forward , im pretty stuck im thinking its a program fault , maybe when changing directions i need to add a delay or a way to ramp power up, any guidance would be much appreciated
I get this if the chain is a little too slack in my drive system plus the overall gain is too high.
In the wheelchair mechanisms you have, there is a little backlash in the gears. You get rattles around the balance point when stationary, as motors flip from forward to reverese and back, these are transmitted into the gyro/accel unit causing more trouble.
When rolling along you do not have the problem as motor controller is not reversing direction, just providing variable forward power.
3 possible solutions:
Let us imagine you calculate a torque value to send to each motor and then you multiply that by a value called "overallgain"
Options:
a) Reduce your overallgain.
b) Let us imagine the range of torque values that can be sent to each motor is
-100 to +100 (zero being stationary), then when the value is between say -4 to +4, then within this range reduce the overallgain to half what it is otherwise.
c) Make the overallgain value increase proportionally to the desired torque value in each direction (so it is low around the mid i.e. stationary balance point).
Actually might be better to make the overallgain a low fixed value, than ADD to that a small additional value proportional to the torque (which has a maximum possible value about the same as the baseline fixed value it is added to).
I think these would help. Need to do some experiments but b or c might be the things to try out.
Best wishes
John
I used this code for my try.
I got the tilt started point.. But the skate can't balance properly.It's look like week and the deck slowly drop.
The skateboard just go away slowly (the skateboard can't stay)..But when I push the deck, the motor still work to get the balanced.
So, what part of the code that can I adjust?
Thank you...
John
Send me a message with a working email and I will correspond directly with you.
Make a video of it, put it on youtube for friends only, send me the link. I can tell a lot by just looking at how it behaves.
Best wishes
John
BTW, Thanks to all for all the support so far. It's funny that the more DIY stuff I do the more I feel the support comes from so many others. I a very big way, none of us do anything entirely on their own :)
Exception in thread "AWT-EventQueue-0" java.lang.ArrayIndexOutOfBoundsException: 0
at processing.app.Sketch.setCurrentCode(Sketch.java:1106)
at processing.app.Sketch.load(Sketch.java:218)
at processing.app.Sketch.(Sketch.java:140)...
Any Advice? Thanks
So anyway... I was thinking about what motors to use. I want to use one of these motors, but im unsure which one, and if the sabertooth will be enough to handle it.
http://www.ampflow.com/ampflow_motors.htm
Ive also found this battery which can handle the juice.
http://teamassociated.com/reedy/parts/details/626/
thanks :D
-Jaysen
However the main draw on a motor controller is when the motor is held stationary by mechanical obstruction, too steep a hill, and so on.
The Sabertooth does have overload protection that shuts it down allowing it to live to fight another day, which is good.
Also there is now a more powerful Sabertooth I believe that will take higher currents if this is what you want.
http://www.dimensionengineering.com/Sabertooth2x60.htm
thank you
When the board is running it will have its own power supply so recommend using that when using the IMU tester, especially as can use the IMU tester code to find the perfect balance point of your board to enter into the code of the full balancing software.
Firstly could I use this( http://diydrones.com/profiles/blogs/arduimu-now-available ), because I have a couple floating around the place.
And secondly could you make it as an assist for a pedal (with brakes) bike like this ( http://www.n55.dk/MANUALS/SPACEFRAMEVEHICLES/spaceframevehicles.html ) (with the back wheel taken of)?
Not sure if it could act as an assist to a pedal recumbent bike.
Could however probably use pedal power (cautiously) in combination with a self balancing system so long as pedal derived top speed did not exceed ability of electric motors to accelerate further if starting to tilt forwards.
im building a segway and instead of putting left-right on a SWICTH iwant to lean the handel over to the left to turn left and the father father i push it to the left or right the tighter the turns. would this mean i would have to put the gyro some were in the steering bar? and how much would i have to change in the code?
thanks