Go Down

Topic: Guide to gyro and accelerometer with Arduino including Kalman filtering (Read 313 times) previous topic - next topic


Hi Lauszus,

I've been learning a lot from your code, thanks very much for putting it on here.

I have a board with single axis gyro with 3 axis accelerometer, analogue outputs.

I'm looking to find the Roll angle, so the single gyro board will need to be orientated up on its end so that the Roll axis goes through the middle of the gyro. The accelerometers with then be: X=up/down, Y=left/right, Z=forward/backward.

In this configuration which combination of the X,Y and Z accelerometers should I be using in the code?

I am guessing that it's the X and Y as the Z axis accelerometer is not effected by roll when the board is mounted on it's end

Your code uses X and Z and Y and Z in the arctan function, so I should use X and Y, correct?


It depends on your gyro - some have to be orientated up others don't.
Regarding which axis you should use on your accelerometer: I can't say for sure. It depends on how it's orientated. Either it's X and Z or Y and Z.
Try to modify this code: https://github.com/TKJElectronics/Example-Sketch-for-IMU-including-Kalman-filter/blob/master/IMU6DOF/LPR530AL_%20LY530ALH_%20ADXL335/LPR530AL_%20LY530ALH_%20ADXL335.ino, so it's uses the correct sensitivity values for your setup.
Then afterwards you can easily see which angles should be fused together.
You might also need to invert some of the readings, as I have done here: https://github.com/TKJElectronics/Example-Sketch-for-IMU-including-Kalman-filter/blob/master/IMU6DOF/LPR530AL_%20LY530ALH_%20ADXL335/LPR530AL_%20LY530ALH_%20ADXL335.ino#L51


Hi Lauszus,

I have your code running ok with the single gyro and x,y,z accelerometers.

I'll dump the intermediate angle calculation values out and see if I can figure which pair I need to combine with the gyro.




Hi Lauszus,

All sorted out now. I had everything coded correctly but missed the initial offset from zero for the down axis accelerometer due to gravity.

It works very well and rejects linear movements really well.

Just need to feed the angle into my motor controller now.

Thanks for everything!

Go Up