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 ads by
Signing UpStep 1Parts
| « Previous Step | Download PDFView All Steps | Next Step » |



























































































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.
This is a classic issue. The gyro is doing the short term balancing but it drifts so after 30 sec or so it still balances but at an odd angle. The accel is supposed to gradually correct this. What you describe is the accel acting against the gyro rather than with it (i.e. back to front).
Solutions, turn IMU over (current upper side downwards) or alter code:
Take this line:
x_accdeg = (float)((accsum - (338 + balancetrim))* (-0.862));
Change the sign before the 0.862. If +ve now change it to a minus sign or vice versa.
Alternative is to take this line in code:
angle = (float) ((1-aa) * (angle + gyroangledt)) - (aa * x_accdeg);
and again, change the sign so now reads opposite of what it was before:
angle = (float) ((1-aa) * (angle + gyroangledt)) + (aa * x_accdeg);
It makes the accel interact with the gyro readings in opposite way to whatever it is doing currently.
Hope this helps
John
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.
Set all constants to zero
1) increase prportional gain constant (currently 4.5) until it more or less balances but starts to oscillate wildly. Then set the value to about 1/2 to 2/3 this value.
2) Increase derivative gain constant (0.5 at present) so that when you tilt it one way it rapidly corrects in a damped sort of way, i.e as it get back closer to balance point the force of the correction drops off so it rapidly corrects without overshooting or oscillating.
3) The I gain is more what tends to keep it in one place. Keep increasing it until you get oscillation then back off a bit. If too high and you push it off balance machine will roll along, regain balance, then roll back the other way as the I gain was too high. I gain in this sketch is actually the cur-speed multiplier value So that is the line of code you need to play with.
I am not an expert, whole theses are written on this, but this is one relatively simple explanation i found on the web.
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
http://www.robotshop.com/dimension-engineering-sabertooth-2x25-6.html
http://www.solarbotics.com/product/50120/
http://www.lynxmotion.com/p-623-sabertooth-2x25-regenerative-dual-channel-motor-controller.aspx
http://robotbits.co.uk/motor-drivers/sabertooth-2x-25amp-motor-driver/prod_62.html
John
Thanks
TRANCT
Do it in stages.
Get mechanicals right: wooden board, brackets, motors, chains, Razor wheel sets.
Then start on electronics:
IMU
Arduino
Battery to power Arduino initially
Switches/buttons
Also need sabertooth motor controller and 2 x 12V batteries.
I would not try this as complete beginner. I would make some Arduino projects first so you are fairly familiar with how it all works.
dreniles
thank you
I have done all these things with my own projects. However, purpose of this instructable was to keep thiings fairly simple, more complexity means more things to go wrong.
You have to get it balancing first, then you add in clever features afterwards.
John
If you follow instructable sometimes people get the IMU back to front and things like that. Should be pretty quick so long as no faulty components or dry solder joints, misaligned drive chains and so on.
The IMU tester and motor tester software examples are there to help spot some of these basic problems before you get to the first self-balance test.
Thank you very much
In main code for balancing machine, it can go up to 100%.
thank you
As you move the pot the middle connection is connected to the wiper of the pot that moves over the carbon track inside it. This middle connection is connected to the analog input pin of the arduino for that pot.
When knob is in centre position, 2.5V will be read at the analog input pin, i.e. a
value of about 512 on the scale of 0 - 1023. If you do not know what this means buy a starter book of Arduino projects as they all describe how to control a motor or brightness of an LED using a potentiomer.
John
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
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 :)
Make sure wheels are going in same direction, if not one of your motor wires are back to front.
John
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.
Lots of batty summaries and discussions on electric bike forums. Some ebike shop websites have battery discussions.
I would not waste 200 - 300 dollars on a battery like this though until you have your machine balancing on a couple of much cheaper lead acids.
I have also used 2 x 12v nickel metal hydride packs designed for large radio controlled racing cars in the past as well. These are not so far behind lithium these days but cheaper and the chargers are cheaper. Have to make sure they can give thie peak current your motors require.
Lots of online stores for RC car parts and battery packs to choose from. Also combat robot sites have battery packs in all shapes and sizes.
Hope this helps
John
Thanks
Jon
thank you
If you want one to run the self balancing and for example one to read a wii nunchuck you can do that. To begin with though you just want it to balance, add all the clever controls later in the V2 rebuild.
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
It looks as if sparkfun have released a new updated version of the 5dof one I originally used.
Would be worth getting one of those. There is also a clone on ebay of the original one still available, see some of discussions below for links.
Best wishes
John
If you could please provide me your assistance.
Thank You.
However unless you are pretty good at programming, i.e. not a beginner, I cannot see how you would be able to work on this and get all the bugs out of the code within 1 week. Sorry but true.
I am happy to help people and have done several times, but I do have a day job so it is just whenever I have some free time. If it is a college project with a deadline, contact me well before the deadline!
Best wishes
John
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...
Example (unfinished) of code to read the 6dof DIGITAL imu seemed to have disappeared from my instructable. I have just put it back as an attachment to Page 53.
Hope this helps. If your supervisor gets it to work please do let me see the improved code as others would benefit from it.
Best wishes
John
in your motor calculations the tilt angles and gyro rates passed are in degrees and degrees/sec respectively? or are they the raw values?
later on in the examples (not the only part finished 6dof digital example) I then convert to smaller values to get the scaling correct for the motor driver part of the software.
If it seems odd it is because the code has evolved by trial and error.
All the examples need a complete rewrite but on the other hand they do work as they are, which is always useful!
Best wishes
John
thank you