Step 43IMU testing sketch
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 Step | Download PDFView All Steps | Next Step » |



























































































(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
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
I have uploaded slightly tweaked version of the IMU tester. It will now show accsum in serial view window (it was commented out).
Best wishes
John
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
When you download the Arduino programming environment, softwareserial is a library that should come with it, built in.
It is a bit of code that allows you to send serial commands using any of the digital pins on the arduino.
It is standard with all versions of Arduino beyond V6 so should not cause you any problem.
More:
http://arduino.cc/hu/Tutorial/SoftwareSerial
Best wishes
John