LSM9DS1 and balancing math

JwolfJwolf Posts: 9
edited December 6 in Robotics Vote Up0Vote Down
Hello,
I have the LSM9 working with raw outputs... but im having trouble with the math.
How do I link the gyro + accel to create a stable orientation output?
I just want to get this to work so it can be used for any type of project, whether it be an rc aircraft, drone, balancing, or general heading output.

I'm using the Elev8 source from Jesse Burt.
Accel outputs at rest output +16,400 to -16,400, increased output due to g-forces... I 'think' its reading at 400hz
gyro is about 2x that when rotated quickly.
I guess I need a formula to deal with 3 different accelero axi's correlated with each other, minus g-forces, checked against 3 different gyro axi's, at the sampled rate.

I've been studying for a while now on basic concept... (((rate of change) - noise) / units)) = amount of correction needed to stay level in specified units

Cannot figure out how to make the LSM9 output usable.... please help!

Comments

  • 2 Comments sorted by Date Added Votes
  • Hello Jwolf,

    There are two main filters you can use to fuse gyroscope and accelerometer measurements - the extended Kalman filter and the complementary filter. The complementary filter is far simpler to implement but does not account for system dynamics so it will not work well for fast moving vehicles such as fixed wing aircraft. For balancing applications, the complementary filter works fine. It can be implemented in code by:
    accelAngle = atan2(ax,az);
     theta = 0.98*(theta+gy*Ts)+.02*accelAngle;
    

    where accelAngle is the angle computed from the accelerometer, ax is the acceleration value in g's in the x direction, az is the acceleration value in g's in the z direction, theta is the pitch angle you are estimating, gy is the gyroscope output about the y axis, and Ts is the loop sample time. You may have to map your sensor outputs according to a north, east, down coordinate system where north is in the x direction and points out of the front of your vehicle, east is in the y direction and points out the right wing of your vehicle, and down is in the z direction and points out of the bottom of your vehicle towards earth. This way, if you are estimating theta (pitch), the gy measurement is about the the y axis. Once you are able to estimate theta, you can easily implement an estimation of phi (roll).

    See my thread here: http://forums.parallax.com/discussion/169330/is-there-a-faster-way-to-read-sensor-data#latest
    if you are interested in implementing the extended Kalman filter. Oh and make sure you are using the LMM main RAM memory model. Your code will run about 5 times faster than if you use the CMM RAM memory model. It took me a while to figure this out. If you have any questions, just ask and I'll try to help.

    Thanks,
    David



  • good info, thanks very much!
    Will get back to ya when I have time to absorb that into the ol'melon :smile:
Sign In or Register to comment.