3 Simple Ways to
Share What You Make

With Instructables you can share what you make with the world — and tap into an ever-growing community of creative experts.

PhotosPhotos

Share one or more photos of a project, recipe, or whatever you've made, quickly and easily.

Step by StepStep-By-Step

Share your step-by-step photos with text instructions of what you made so others can do it too!

VideoVideo

Share your how-to video. You'll need your embed code from a video site such as YouTube.

Easy build self balancing electric skateboard

Easy build self balancing electric skateboard

What is it?
Twin wheeled skateboard that works like a Segway.  Electric skateboard exist already - motors on rear wheels. The plan here was 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 a complementary (not complimentary) filter which reads and combines data from both 100 times per second. Steering by a simple rocker switch in hand controller (or a rewired Wii-Nunchuck as in photo if you are more ambitious).

What's new on this Instructable?
Feb 2012:
i)
Sparkfun are discontinuing the 5DOF IMU, so in response to requests I have rewritten a code example (attached to page 46) to work with a newer(ish) 6DOF "Razor" IMU also from Sparkfun. This has analog voltage outputs and should not be confused with their 6DOF digital version. I have not had time to upgrade the other attached program examples yet. This one compiles OK, though I have not tested it. Many stores still have this in stock but Sparkfun also discontinuing the "Razor" too.
ii) Have updated all examples of the 5dof IMU code from original Instructable.
iii) Working on code to use the new Sparkfun 6dof DIGITAL IMU. FIRST VERSION ATTACHED 8th March 2012 TO PAGE 53. Only tested as sensor/arduino but prints out believable angles etc, have posted it for those who want to experiment with it.


APRIL 2012: Clone of the original Sparkfun 5dof Analog IMU discovered on eBay: This Instructable originally used an analog 5 degree of freedom gyro/accel combination now discontinued by Sparkfun. However this has appeared on eBay and looks exactly the same, at a good price too:     http://www.ebay.com/itm/190478609162?ssPageName=STRK:null:IT&_trksid=p3984.m1542.l2649
April 14th: Sparkfun have just released an updated version of their 5dof analog output IMU. IMU Analog Combo Board - 5 Degrees of Freedom IDG500/ADXL335   Part number SEN-11072   so, everything is OK again.

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 just fall over when they took off? They took off incredibly slowly for the first few seconds, tailfins would have no effect, far slower than Shuttle launches.                Watch this video
It takes a full 10 seconds just to get to 100m and clear the launch tower:
http://www.youtube.com/watch?v=TmHABUfjYPI&feature=relmfu
A: They had engines mounted on gimbals (swivelling joints) hydraulically controlled by a PID control system (lots of analog electronics involved 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 (P43 - 47).
There are; IMU tester, motor tester, balances-nothing-else, rocker switch steered and potentiometer steered code examples.

How much does it cost?
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 a 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. Last time the BBC cameramen who also had an exhibit politely waited until the end of 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 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 come with some ancillary sensors etc and a set of about 12 tutorials. Work through them all (about 2 days work) and read a beginners book to Arduino. You will then be ready.

Can I build a SegwayTM clone?
Yes. Australian SciTech group have built a very low cost machine using a version of the Arduino code from this Instructable:
http://www.instructables.com/id/Self-Balancing-Scooter-Ver-20/
Here also is the Thatch No-Way Segway using my code almost unaltered: http://www.youtube.com/watch?v=R4ax3N0UW38

Has anyone else built one of these?
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 - the SciChair: http://www.youtube.com/watch?feature=player_embedded&v=HtivH7INpZ4
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é http://www.youtube.com/watch?
10) The KSLURP board from Malaysia: http://www.youtube.com/watch?v=x3O2NkjJOlg
11) The MIT Seboard, video clip: http://www.youtube.com/watch?v=zZQb-w_wyhM
12) The SITWAY sit-on machine by the 81year old gentleman above, with video: http://www.instructables.com/id/SITWAY/

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 or into your head. This is why you have to have an 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 a similar 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 adsRemove these ads by Signing Up
 

Step 1Parts

Parts
Here are the parts laid out on floor
« Previous StepDownload PDFView All StepsNext Step »
418 comments
1-40 of 418next »
May 23, 2012. 9:32 AMgrunff says:
Hi XenonJohn,

I built a robot using this setup a while back, but never managed to get it to work satisfactorily. I've now picked the project back up to see if I can get it working.

The problem I'm having is caused by the Level drifting very quickly, so the board never finds its level. It tries to level, but by the time it gets there, the Level variable is way off horizontal, so it can't balance.

Any idea what can cause this drift? It happens over a few seconds, and within 30 seconds or so instead of being 0 deg it's 400 deg.
May 25, 2012. 8:33 AMgrunff says:
Thanks for your help John, I appreciate it.

I'd actually got past this point, but I'm still having trouble getting it to balance. It starts off well, then oscillates wildly out of control. I suspect the values in your sketch are not working well on this small frame (~500g).

I'm experimenting with overallgain, and also with the scaling variables in the balance_torque calculation (4.5 and 0.5), but I still haven't managed to make it balance.

Any further insights would be much appreciated.
May 27, 2012. 2:00 PMgrunff says:
Thanks very much for that John. I will spend this evening trying to tune it :-)
May 18, 2012. 5:45 AMtranct says:
Hi John,
I am a beginner. As I see on Ebay lots of Sabertooth >But they are not the same with yours -
Please, could you show me where to buy this one
Many thanks
TRANCT
May 23, 2012. 3:18 AMtranct says:
Where can I find a complete list of all objets to buy ?
Thanks
TRANCT
May 23, 2012. 3:11 AMtranct says:
Merci John
May 4, 2012. 9:28 PManiles jr says:
In this code dose it have to highest the motors can go is 50%?


dreniles

thank you
May 12, 2012. 4:11 AManiles jr says:
thank you how long do you thing it will take me to get it to balence
May 17, 2012. 1:16 AManiles jr says:
i appercatie all your help john i cant thank you enough i did the motor test and the IMU test and it worked perfect. but when i let go of the kill bottom it stops hard when it post to go to the next % this is how it went 10.00 20.00 30.00 40.00 50.00 40.00( let go of the kill switch) and then finish with the 40.00 then is stops hard when you let go of the kill switch is it post to stop keep balancing?




Thank you very much
May 8, 2012. 3:28 PManiles jr says:
For the main code can i limit it to 50%. and when im useing the POT to steer do i turn the POT to the middle and then turn left to right?
May 10, 2012. 12:09 AManiles jr says:
and how do i wire the pot's
May 10, 2012. 12:16 AManiles jr says:
two questions how do i wire the POT for steering and i want to limt my motors to go 50% is there a way i could put a buzzer for when it gose above 50%?

thank you
May 12, 2012. 4:15 AManiles jr says:
thank you
May 4, 2012. 4:47 PMpumo says:
with motor testing did I something wrong?
without pressing deadmanswitch motors turns byself..
it logs level 10 without turning motors.
and when pressing button then motors wont even turn.
I did add 12k pulldown resistor also

ou are NOT Pressing Dead Man Button so all power has been cut
level 0.00
You are NOT Pressing Dead Man Button so all power has been cut
level 10.00
You are NOT Pressing Dead Man Button so all power has been cut
level 20.00
level 30.00
You are NOT Pressing Dead Man Button so all power has been cut
level 40.00
You are NOT Pressing Dead Man Button so all power has been cut
level 50.00
level 40.00
You are NOT Pressing Dead Man Button so all power has been cut
level 30.00
You are NOT Pressing Dead Man Button so all power has been cut
level 20.00
You are NOT Pressing Dead Man Button so all power has been cut
level 10.00
You are NOT Pressing Dead Man Button so all power has been cut
level 0.00
You are NOT Pressing Dead Man Button so all power has been cut
level 10.00
You are NOT Pressing Dead Man Button so all power has been cut
May 4, 2012. 6:49 PMpumo says:
I got wrong schematic (from Self Balancing Scooter Ver 2.0)
I did change for your connection deadman switch to pin 9 and thru 1,8kohm resistor to +5V now it works, kindof..
it spins motors by own and stops after all levels but if I push button down it runs thru all levels once from 0...50...0
not sure should it be like this, but I think it works :)
May 1, 2012. 12:40 PMcjustini says:
John,

First, thanks for contributing such a great project and providing so much help. Everything is pretty clear, i am buying parts and will get started in the next few weeks with my kids. My only doubt is around the batteries. You suggest somewhere using other than Lead-acid. I don't mind spending a little more if I can get better weight:power ratio, for example. Where can I learn about battery types, chargers, optimum charger procedures etc.?

Thanks, will send you pictures once done, and hope to "grow" with many ideas from this design.

Best.
May 3, 2012. 4:20 AMDelpap says:
Could you send the code please, my email address is: d.prajitno@gmail.com
Thanks
Apr 29, 2012. 8:54 AManiles jr says:
i know this seems like a dum question but if i put two arduino boreds toghter would it go fast like will it give faster resuslts.


thank you
Apr 22, 2012. 7:54 PMld'sa says:
Hi Xenon,

i am working on a self balancing bot
even i checked out this website

but i need help with the variables to take in order for my code to perform calculations
because it is a digital IMU (6dof) i am facing a lot of problems as i am a beginner. If you could help me out i am will to share my details with you so other guys can also use it for their projects

thanks
Apr 25, 2012. 4:44 AMld'sa says:
I have only a week left to submit my project and also i am from India so it would not be possible to order another one from sparkfun.
If you could please provide me your assistance.
Thank You.
Apr 26, 2012. 7:14 AMld'sa says:
yes i tried getting the code from page 53 but i couldn't get a link to download. could you help me on that?

And my project guide is helping us out so he would be able to fix the bugs as he has used IMU for some sort of robotic arms...
Apr 26, 2012. 7:21 PMld'sa says:
have one more doubt..

in your motor calculations the tilt angles and gyro rates passed are in degrees and degrees/sec respectively? or are they the raw values?
Apr 26, 2012. 7:06 PMld'sa says:
i will surely give you the resources to my project if it works even 50%

thank you
1-40 of 418next »

Pro

Get More Out of Instructables

Already have an Account?

close

All Steps Viewing
View all steps of an Instructable on the same page when you're a Pro Member.

Upgrade to Pro today!
127
Followers
10
Author:XenonJohn