Shop OBEX P1 Docs P2 Docs Learn Events
IMU based on lsm9ds1 9DOF Mems chip and Madgwick quaternion filtering — Parallax Forums

IMU based on lsm9ds1 9DOF Mems chip and Madgwick quaternion filtering

I think I finally have this working!

It is mostly in the the fastspin's C, although the i2c is done by @JonnyMac's Spin2 driver.

The trick to getting yaw working was to calibrate the magnetic sensor. This is a bit of a pain.
Accelerometer and Gyro can be calibrated by just holding the device steady.
But, the magnetometer has to be calibrated by feeding the data while moving the sensor every which way to an external program.
Here, I'm using Magneto 1.2 program to do this. Adafruit shows a nicer looking way, but I wasn't able to make that work.

This code is using the quasi-standard Madgwick filter to process the input data into a filtered yaw, pitch, and roll output.

Here's the code:

Comments

  • Nice Ray! Are you using Parallax https://www.parallax.com/product/28065

    Do you have a link to Magneto 1.2 ? I get very old links with a Google search.

  • RaymanRayman Posts: 13,898
    My board has IMU onboard... But, that Parallax version looks like it would work.

    Here's my instructions for using magneto from the code:
    //Note:  You must do a magnetic calibration to get accurate yaw readings !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
    //Steps:
    //1.  Edit platform.h so that uSD pins are set correctly for your board
    //2.  Uncomment the call to CreateMagCalFile() in main()
    //3.  Insert uSD card into board
    //4.  Run this program, it will now create at text file with magnatic calibrations
    //5.  Download Magneto 1.2 from here:  https://sites.google.com/site/sailboatinstruments1/home
    //6.  Run this program on PC and give it the text file from uSD
    //7.  Click "Calibrate" and copy the b and A-1 floating point numbers from the dialog
    //8.  Paste these numbers in the section of loop() that starts with the comment "//Apply calibrations from Magneto to data"
    
  • Hi Ray

    Have you tried the BNO055?
    Its can do the fusion for you, (apparently)

    Dave
  • RaymanRayman Posts: 13,898
    That chip does look interesting...
    About the same price.
    Modules with it are twice as expensive for some reason looks like...
  • Probably won't matter for any P2 application, but the BMX055 (which I'm guessing the BNO055 uses the same sensors as) has much higher power consumption than the LSM9DS1. Discovered that in a recent project running off CR2032s.
Sign In or Register to comment.