Easy build self balancing electric skateboard

 by XenonJohn
Featured

Step 19: Electronics

IMU and wiring.jpg
NOTE added Feb 2012:
See my comment on intro page regarding use of a 6dof "Razor" IMU from Sparkfun instead as this 5dof one is becoming difficult to obtain any more.



Original text:
There is a 5 degree of freedom inertial measurement unit (IMU) from Sparkfun.
This is cheapest one they do that will do the job - a situation that is always changing by the way.

It has a 3 axis accelerometer. We will only use one of these.
It has 2 solid state gyroscopes. One is used with the accelerometer (using a "combination" filter) to make the thing balance.

The other is used to allow machine to resist sudden changes in direction (one wheel hitting a pebble for example) so it does not spin you off. This is easier and more reliable possibly than using wheel speed encoders which is the other way to do this.

I like ribbon cable as it is neat. I also use blu-tack when doing this sort of soldering as it holds wire in exactly the right spot as well as holding the little circuit board still.

I tin the wire ends then solder them to the holes.




NOTE: Someone has already found a cheaper (different) IMU here:
www.gadgetgangster.com/find-a-project/56.html
You would have to work it out for yourself and modify code perhaps but it also looks ideal for a project like this. It is amazing how these things have come down in price. The one-axis gyro in my monowheel was about £100 ($150) on its own.
 
Remove these adsRemove these ads by Signing Up
eyhseow says: Jan 15, 2013. 12:40 AM
Dear Sir
Do you have any spare anlalog IMU-5DOF or 6DOF that I can purchase from you? Please advise.
eyhseow says: Jan 15, 2013. 12:32 AM
Dear Sir
Do you have the software code for the whole project using the digital 6DOF, and the full schematics diagram for the whole project. If not the connections between the digital 6 DOF and the Arduino. I will greatly appreciate for your help.
Pizzapie500 says: Aug 7, 2012. 7:24 PM
Hi! I'm new to electronics and stuff, so this may be an "easy to figure out" question. Anyhow, how come in the picture, the gyro has nine wires coming out of it, but in the arduino connection diagram, the gyro is only connected to six ports? Is it connected to something else than the arduino?
nimith says: Jun 14, 2012. 10:22 AM
Hi John,

I just purchased the New replacement of IMU -5DOF from SparkFun and this one already have building Reg for 3v . Can I use the same code that you have ?

I believed the same of your configuration.

Thank
XenonJohn (author) in reply to nimithJun 21, 2012. 8:42 AM
I think it has its own built in voltage regulator.

I would check the data sheet but presumably you can run it from the arduino 5v line without blowing it up.

Check the datasheet first as the old one would definitely not work any more if you connected it to 5v supply. It would blow the gyro leaving you just with accel values!

John
nimith in reply to XenonJohnJun 21, 2012. 10:00 AM
I believed it said on the Sparkfun website

http://www.sparkfun.com/products/11072

Features:

Full Scale Gyro Range: 500°/s
Full Accelerometer Range: +/-3g
On-Board Voltage Regulation
Input Voltage: 3-16V
Analog Output
Breadboard Friendly


But I already connect with 5V from Arduino and got the Acc.

Nimth
miguipda says: Aug 6, 2011. 10:16 AM
Hi John,

thanks to share your arduino segway like project. Because I also think to make a segway like but my knowledge is limited in electronic. I am sure I can do it with an arduino and I enjoy to read your project.

Just two thinks I need to ask you and may be that will upgrade your project :

1) At 1:19 on this video we can see that a segway use five gyros : http://www.youtube.com/watch?v=OVCzB1AZPA0
may be for front to back + left to right + one wheel up or down the other.
What do you think about this ? I mean if your "segway" like have one wheel a little a bit up the other does it continue to run anyway ? If well what the need of five gyros on the real segway ?

2) to answer to your question concerning the fact to reduce the cost of your segway like I just discovered this gyro reduction. In place of paying it 100$ you can build it to 8$ (as he said) : http://underfinished.blogspot.com/
May be can you give us your project with this use.

3) Do you think that overclocking the arduino can help for the answer time or unneeded ?

4) Can the one chip arduino be cheaper and or more useful (consumption with some LiPo battery in place of weight battery) ?

Sincerely thanks for your informations and have a nice day.

Miguipda ;-)
http://www.geocities.jp/arduino_diecimila/obaka/project-2/index_en.html
XenonJohn (author) in reply to miguipdaAug 7, 2011. 9:39 AM
1) Why dont I use 5 gyros?
A real segway will probably work with some of the gyros failed. It is designed with redundancy in mind (2 motor windings for each motor for example) for safety where the users are not at all interested in how it works.
2) I use 1 gyro with 1 accel to balance. This is the minimum. If they fail you fall off.
3) Also there are starnge situations that can occur such as tuening while on a slope or with one wheel on a slippery surface while truning while on a slope, and so on. The 5 gyros help with the "calculations" for such situations I suspect.
4) Why overclock the arduino? My software at present only works for about 1/3 of the time, the rest is a delay, and that gives you 100 program loops per second which is ample for the balance algorithm
5) One chip arduino? Not sure what you mean, maybe the tiny versions of the arduino's you can get. They will save you space for sure if space is tight I suppose. Perhaps will use a little less power if powering them from a small battery perhaps. Marginal gain therefore.
6) $8 "gyro" is not a gyro. It has a wheel with a weight on it that "will always be closest to the ground" which is then connacted to a sort of optical position sensor. Well no actually, if you braked hard, the weight would swing forwards. It would give you a "I am tilting" reading when in fact you were not. My gyro in 2008 cost be about $200. Now sparkfun do a board with 2 gyros and 3 accels all for about $50 so to be honest I am not complaining about price of gyros any more. You can even use a WiiMotionPLus module which has gyros inside to save money, but you need to understand all the code required to decode the data from these.
Therefis already plenty to go wrong in these machines, don't make life even harder for yourself just to save a couple of dollars.

Best wishes

John
kriogenic says: Apr 8, 2011. 9:26 PM
Hey there, I am going to experiment but I was wondering if you knew if this IMU unit would be applicable.

http://www.sparkfun.com/products/9250

I have no idea really but think it will be fine without the capabilty of resisting sudden turns?
kriogenic in reply to kriogenicApr 20, 2011. 6:13 AM
Hey there,

I got a few things for this project underway now,

I got my motors, motor controller, IMU and arduino.

Using your examples I got the accel and gyro to give me usable figures....

Using the motor example I got my motors to run fine.

Using your balancing only code and a few tweaks I have gotten the IMU to spin the motor depending on its orinetation. however the motor controller seems to cut out after the motor reaches 100%, i am not sure why this is. I can post a video for you if it would make it easier.

Thanks,
Kriogenic.
XenonJohn (author) in reply to kriogenicJun 1, 2011. 1:49 PM
June 1, 2011:
This turned out to be a bug in the code. The "Integral" value of the PID accumulates indefinitely if you hold it tilted on a bench rig for a long time for example. Eventually it flips back around to 1 again!

I now have put a limits check on it so it cannot do this any more.

John
XenonJohn (author) in reply to kriogenicApr 23, 2011. 2:53 PM
When both motors running at 100% then current draw on batteries may be pretty high.

Not sure what batteries you are using but if the current draw exceeds what batteries can give, voltage across them will drop. If it goes too low the sabertooth will shut down. I am not sure at what voltage this happens but might be worth measuring voltage across batteries and seeing how low it goes when you are running both motors at 100%.

In the motor testing sketch they only go to 50% each then decrease again.

John
aniles jr in reply to XenonJohnJul 3, 2011. 5:29 PM
what if you put it up to 80% because i want mines to go fast

thanks

adrian
XenonJohn (author) in reply to kriogenicApr 9, 2011. 1:41 PM
This should work OK

Minimum needed to balance is one accel and one gyro

karandex says: May 28, 2010. 11:24 AM
I am from india and i dont have access to 5 axis can i use 3 axis accelerometer and single gyro ? I have access to this shop please suggest parts
rhydolabz.com 
XenonJohn (author) in reply to karandexMay 29, 2010. 9:59 AM
If I were buying from this supplier I would use:
MMA7260Q Accelerometer Module (1.5/2/4/6G ) as it has an analog voltage output.
LISY300AL Single Axis Gyro (300 degree/sec) as it has, again, an analog voltage output.
I put a link to my page describing how you scale the output from these devices in my previous reply.
This should get you going. You are going to need to do some experimentation and modify the code somewhat, I cannot give any guarantees everything will work first time. However I see no reason why these sensors shouldn’t work OK. I am happy to give advice but not going to rewrite the code for every single accel / gyro combination on the market – just don’t have the time. Best of luck.
 
John
XenonJohn (author) in reply to karandexMay 29, 2010. 9:50 AM
The minimum you need to get something to balance is a one axis accel and a one axis gyro like my original monowheel board has.
I put some notes on reading and scaling these here on my original website:
sites.google.com/site/onewheeledselfbalancing/Home/software-with-all-explanatory-notes-removed

The nunchuk / wiimote+ combination looks pretty complex to me. I put a link to it on page 1 of this instructable - good luck if this the way you really want go. I am no expert on that combination.
Montspy in reply to XenonJohnJun 4, 2010. 8:05 AM
I rewrote your code to use it with the WM+ and Nunchuk code from the Arduino forum (complementary filter). I'm waiting for parts to be delivered but I can send you the code if you want. Actually it's quite sure it won't work beacause I can't test the whole thing
karandex in reply to MontspyJun 4, 2010. 11:13 AM
Thanks but i desided to use IMU as i found a vender in my country. My thinking is that if there is project make it as the instruction say and then improve or customize on it and not to start from scratch
karandex in reply to XenonJohnMay 29, 2010. 9:10 PM
 thank you but i got a vendor in india with 5dof tenet technologies
is this code robust that if i keep the electronics same it will work with any low CG configuration ? I was thinking to build a prototype with DC motors, what rpm or voltage should i use ?
Also one more thing , can i make segway with it ?

Thank you for your valuable time.
mrityunjay in reply to karandexAug 5, 2010. 11:07 AM
hey i m from india too can u plz help wer u got 5dof ?
XenonJohn (author) in reply to karandexJun 1, 2010. 8:53 AM
To be honest more or less all of this has been discussed in this Q and A section.

Here is a page I made with links to every single amateur built self balancing skateboard / segway and other oddities I can find on the net. Plenty of people have built segway style vehicles along these lines (i.e. 2 x cheap 24V scooter motors from China).
Link:
sites.google.com/site/onewheeledselfbalancing/Home/links-to-other-self-balancing-projects

So my answer is a) probably with some adjustments to code, b) 2 x 24V cheap scooter motors 250W or above, but on level ground may be OK with lower power motors c) Yes.

Best wishes

John



Pro

Get More Out of Instructables

Already have an Account?

close

PDF Downloads
As a Pro member, you will gain access to download any Instructable in the PDF format. You also have the ability to customize your PDF download.

Upgrade to Pro today!