Step 46Full balancing code
NOTE: It works with Arduino V22. They have now released a newer version (V1.0) with a new softserial library with slightly different softserial commands so it might not work with very latest version of Arduino.
NOTE 3: As Sparkfun are discontinuing the 5DOF IMU, I have rewritten the code here to work with a 6DOF "Razor" IMU also from Sparkfun, in response to requests. 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 but this one compiles, though I have not tested it.
The overallgain is set in the code (to 0.5) so you don't need the potentiometer connected to make this work.
There is a value currently set to 338 in the code that needs adjusting by trial and error until your board balances perfectly level when the tipstart has kicked in. This is clearly indicated in the code.
HOW TO DO THIS:
Open this sketch.
As when we tweaked the IMU tester: alter the value of 338 in this line of code (if you need to) in for the value you wrote down for accsum when running IMU tester and holding your board level: x_accdeg = (float)((accsum - 338) * 0.862);
Recompile the balance code with this new value in and you are now ready to try it out.
On next page I have similar code but modified so you can experiment with using a 10K potentiometer for steering and another to fine tune the balance point.
| « Previous Step | Download PDFView All Steps | Next Step » |



























































































and is there link for right 6dof IMU, I found one but its also retired.
or should this work http://www.ebay.com/itm/190478609162?ssPageName=STRK:null:IT&_trksid=p3984.m1542.l2649?
This is why I attached a version of the code for a 6DOF "Razor" analog IMU which is being discontinued but some stores still have a few in stock (be prepared to buy from anywhere in the world).
I am currently working on code for the 6DOF DIGITAL IMU from sparkfun as soon this will be the only one you can buy.
Best wishes
John
Or if no luck with that I just wait your 6dof digital version code...
br
Pumo
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