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

Step 43IMU testing sketch

IMU testing sketch
IMU testing sketch mentioned on previous page is attached hereas a text file.

Paste it into an empty new Arduino sketch window and it will then work.

NOTE:
Updated Feb 25th 2012
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.




MAKE SURE ARDUINO POWERED BY A BATTERY NOT JUST THE USB LEAD, ELSE ACCEL READINGS CHANGE.

Open serial view window.

Accel readings will be about right and zero when board more or less level. Gyro will read about zero except for when you are actively tipping the board one way or the other.

However when you tilt the board so accel values go +ve, the gyro values should TRANSIENTLY go more +ve also.

They will go transiently -ve as accel angle goes -ve when you are tilting it the other way.

If this happens then you have your accel and gyro mounted correctly!

NOTE: Read text at start of the sketch. At some stage when running this sketch, hold you board straight and level, then write down the value "accsum" displayed on the screen. If it substantially different from my default value of 338, you will need to change the value of 338 in subsequent code to a new value.

IF YOU NEED TO DO THIS:

Open this sketch again and change the value of 338 in the line of code: x_accdeg = (float)((accsum - 338) * 0.862);
Insert the value you obtained for accsum when you were holding board level earlier instead of the 338 (it should be about 338).

This procedure will make sure your board balances more or less level and compensates for any slight offset from vertical your IMU mounting might have.

THEN
Recompile, load and run this IMU tester sketch again.
Now,
1) tipstart should engage when board is very nearly level.
2) The accel should read zero, angle should be displayed as zero and both should go -ve or +ve as you tilt board one way or the other from the level point.

« Previous StepDownload PDFView All StepsNext Step »
3 comments
Apr 13, 2012. 11:53 AMpumo says:
I dont understand, is there something wrong with my connections or what.
(I have this ebay clone board)
when starting serial monitor there isnt any accsum number, or any even readings nearby 338

TILT-START ENGAGED
3,9\n
balancegyroDegrees:-6.84 accelDegrees:7.88 overallAngleofTilt:-1.263,10\n
balancegyroDegrees:-8.92 accelDegrees:5.17 overallAngleofTilt:-3.173,10\n
balancegyroDegrees:-58.72 accelDegrees:13.55 overallAngleofTilt:-14.824,9\n
balancegyroDegrees:-9.22 accelDegrees:12.48 overallAngleofTilt:-15.913,9\n
balancegyroDegrees:-9.38 accelDegrees:12.07 overallAngleofTilt:-16.614,9\n

Apr 13, 2012. 12:12 PMpumo says:
and upside down two holes nearest to ground readings are
TILT-START ENGAGED
3,9\n
balancegyroDegrees:-5.53 accelDegrees:-2.42 overallAngleofTilt:4.173,8\n
balancegyroDegrees:5.46 accelDegrees:-3.45 overallAngleofTilt:2.433,9\n
balancegyroDegrees:3.69 accelDegrees:-7.02 overallAngleofTilt:2.123,9\n
balancegyroDegrees:12.53 accelDegrees:-1.72 overallAngleofTilt:1.163,9\n
balancegyroDegrees:22.67 accelDegrees:0.82 overallAngleofTilt:2.714,8\n
Apr 8, 2012. 6:34 PME1024d says:
I saw every programs star with #include
but I didn't find "SoftwareSerial.h".
where can I find it.And If I should put it in sketch libery or somewhere else?
Thanks

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