AeroCore 2 Duovero LMS303D Calibration for Magnetic Sensor

Previous Topic Next Topic
 
classic Classic list List threaded Threaded
6 messages Options
Reply | Threaded
Open this post in threaded view
|

AeroCore 2 Duovero LMS303D Calibration for Magnetic Sensor

glen@jetsoftdev.com
Hi All,

I have been studying the data sheets of the LMS303D for the AeroCore 2 Duovero. It say there is a factory calibration done which should make the compass accurate down to 2 degrees. 

However, when I run the numbers based up the application notes, I have get a 60 degree or 2/3 differential. Has anyone done a calibration of this sensor with regards to the compass for soft iron, hard iron, and scale for the just the electronics on the raw Duovero+Aerocore 2 expansion board?

Glen

-- 
Glen Wernersbach
Innovator and CEO
MotionLABs LLC.
"Making the Next Thing Happen Now!"™
513-240-9929


------------------------------------------------------------------------------

_______________________________________________
gumstix-users mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/gumstix-users
Reply | Threaded
Open this post in threaded view
|

Re: AeroCore 2 Duovero LMS303D Calibration for Magnetic Sensor

Andrew C. Smith
Hi Glen,

As part of the calibration procedure on the PX4 software there is a calibration step that requires motion about all axis.  I don't know remember what model they're using for estimation but my results were a lot better than 60 degrees.  I'd say my results are consistent (don't know about accuracy) to a degree or two.


Andrew
Reply | Threaded
Open this post in threaded view
|

Re: AeroCore 2 Duovero LMS303D Calibration for Magnetic Sensor

glen@jetsoftdev.com
The LMS 303D  compass should not require this calibration to be directionally accurate down to 2 degrees.

From the app notes:
"All ST MEMS accelerometers are factory calibrated, allowing the user to avoid any further
calibration for most of the applications now present in the market. However, to reach a
heading accuracy of below 2°, an easy calibration procedure is hereafter described."

it appears my problem was that I really need to use the 3axis heading calculations in the same app notes. This seems to be down in the 2 degree range even thought you have the noise from the accelerometer to deal with.

The 2 axis heading was off by 60 degrees. You probably could work very hard to get the board gravity flat and maybe correct this. Not really a useful calculation.
Reply | Threaded
Open this post in threaded view
|

Re: AeroCore 2 Duovero LMS303D Calibration for Magnetic Sensor

glen@jetsoftdev.com
I spoke too soon.
 
I now have one board that gives a 3axis heading due north and 360 degrees.

I then put the same exact software on another board. it is giving weird heading readings. I just don't get it. The factory settings should not this far off of due north and should not shift like 30-60 degrees .from board to board.


Reply | Threaded
Open this post in threaded view
|

Re: AeroCore 2 Duovero LMS303D Calibration for Magnetic Sensor

glen@jetsoftdev.com
In reply to this post by Andrew C. Smith
Hi All,

Well. I think I have taken adventures the magnetometer on the Aero 2 Core about as far as I can take them. 

The date sheet says the LMS303D should be factory calibrated to 2 degree of magnetic north and fairly accurate.  Out of the box it is way off this and can be way off by 100 of degrees board to board and not very accurate for rotation.

Doing the "commander calibrate mag” seems to get the boards with +-10 degree of each other and +-10 degrees of their proper heading when doing this calibrating by hand. I suspect with a machine calibrate you probably could get this better.  

I build a rig with two boards mounted at a 90 degree angle running the same software to see if the would be report 90 degrees differences and maintain there different when being rotated around by 90 degrees steps. One out of the box was somewhat close to accurate before calibration. The other board  was way off.  I could try a third board.

These tests were done indoors. I checked to see if there was any interference from various sources there was not. Maybe better results outside but the compass on my phone work just find in doors and reports 90 degree change when rotated 90 degrees. 

Here is the code I was using to get degrees to the console:

——
//raw. is just a variable name.  
//_raw is un calibrated
//_ga has scaling and offset applied to it.
double CompassHeadingRaw = 180 * atan2(raw.magnetometer_raw[1],raw.magnetometer_raw[0])/M_PI;
if (CompassHeadingRaw < 0) 
CompassHeadingRaw = (360 + CompassHeadingRaw);
double CompassHeading2Axis = 180 * atan2(raw.magnetometer_ga[1],raw.magnetometer_ga[0])/M_PI;
if (CompassHeading2Axis < 0) 
CompassHeading2Axis = (360 + CompassHeading2Axis);
double pitch = asin((double) -raw.accelerometer_m_s2[0]/CONSTANTS_ONE_G);
double roll = asin( ( (double) raw.accelerometer_m_s2[1]/CONSTANTS_ONE_G)/cos( pitch));

double xh = (double) raw.magnetometer_ga[0] * cos(pitch) + (double) (raw.magnetometer_ga[2]) * sin(pitch);
double yh = (double) raw.magnetometer_ga[0] * sin(roll) * sin(pitch) + (double) raw.magnetometer_ga[1] * cos(roll) - (double) raw.magnetometer_ga[2] * sin(roll) * cos(pitch);
//double zh = (double) -raw.magnetometer_ga[0] * cos(roll) * sin(pitch) + (double) raw.magnetometer_ga[1] * sin(roll) + (double) raw.magnetometer_ga[2] * cos(roll) * cos(pitch);
double CompassHeading3Axis = 180 * atan2(yh, xh)/M_PI;
if (yh < 0)
CompassHeading3Axis = (360 + CompassHeading3Axis);
printf("[px4_simple_app] Accelerometer:\t%8.4f\t%8.4f\t%8.4f\t%8.4f\t%8.4f\t%8.4f\t%8.4f\n",
      (double)raw.accelerometer_m_s2[0],
      (double)raw.accelerometer_m_s2[1],
      (double)raw.accelerometer_m_s2[2],
  pitch,
      roll,
      yh,
      xh
      );
      
      
printf("[px4_simple_app] Compass:\t%8.4f\t%8.4f\t%8.4f\t%8.4f\t%8.4f\t%8.4f\n",
      (double)raw.magnetometer_ga[0],
      (double)raw.magnetometer_ga[1],
      (double)raw.magnetometer_ga[2],
      CompassHeadingRaw,
      CompassHeading2Axis,
      CompassHeading3Axis);
      
// see appendix A in app note AN3192 
———

I am open to be doing something wrong but I fail to see how you could use this device in real life for navigation even with sensor fusion.  I am hoping some has a different experience with the Aero 2 Core magnetometer chip and can give me some insight to where I went wrong.

Please respond,

Glen

P.S. I hope the Gyro and Accelerometer give better results. 
-- 





On 9/26/16, 8:57 AM, "Andrew C. Smith" <[hidden email]> wrote:

Hi Glen,

As part of the calibration procedure on the PX4 software there is a
calibration step that requires motion about all axis.  I don't know remember
what model they're using for estimation but my results were a lot better
than 60 degrees.  I'd say my results are consistent (don't know about
accuracy) to a degree or two.


Andrew



--
Sent from the Gumstix mailing list archive at Nabble.com.

------------------------------------------------------------------------------
_______________________________________________
gumstix-users mailing list


------------------------------------------------------------------------------

_______________________________________________
gumstix-users mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/gumstix-users
Reply | Threaded
Open this post in threaded view
|

Re: AeroCore 2 Duovero LMS303D Calibration for Magnetic Sensor

glen@jetsoftdev.com
In reply to this post by Andrew C. Smith
One thing I did notice on the data sheet. The factory calibration is done at 2.5v and this is specifically noted! The aerocore supplies voltage at 3.3v. Maybe this is why there is no factory calibration?