I am interested in using one of the solid state magnetometer devices for north detection. What kind of accuracy can I achieve with these devices. I am looking for +/- 2 degrees. Can this be achieved?
Any advice would be appreciated!
Vic
magnetometer accuracy
Moderators: adafruit_support_bill, adafruit
Please be positive and constructive with your questions and comments.
- adafruit_support_bill
- Posts: 88093
- Joined: Sat Feb 07, 2009 10:11 am
Re: magnetometer accuracy
Properly calibrated and tilt-compensated, the LSM303 is capable of at least that accuracy. http://www.adafruit.com/products/1120#Technical_Details
You also need to consider potential interference from nearby magnetic fields, large ferrous structures or deposits and the magnetic declination of the locale where it will be used. What is the application?
You also need to consider potential interference from nearby magnetic fields, large ferrous structures or deposits and the magnetic declination of the locale where it will be used. What is the application?
-
- Posts: 7
- Joined: Sun May 12, 2013 2:34 pm
Re: magnetometer accuracy
I have an LSM303DLHC breakout Acc/Mag board and I have downloaded all the appropriate libraries, and all the example files are working well, I can read the g value on the Z-axis and the micro Tesla values on x,y,z.
However, the problem seems to be the calibration. I have run the Heading example and can read the compass heading in degrees. However, when compared to a real compass, North is off by about 25 deg and when I rotate the sensor 90 deg, the serial monitor is showing about 180 deg!
The good news is that it always gets back to 0 deg at the same place. I have tried the calibration process from the user guide and have placed the values for the Min and Max back into the .cpp file. However, this appears to make very little difference to the heading value. These are my calibration values:
Accel Min -10.43 -11.14 -12.53
Accel Max 9.96 10.63 11.73
Mag Min -49.36 -60.82 -43.67
Mag Max 51.18 54.08 54.08
I have tried moving the device to a difference place on the table well away from all electrical devices and metal. Still the same result.
I know that the magnetic declination is only about 1 deg here in the UK, so that is not it.
Any ideas or advice from anyone who has set this up would be welcomed.
However, the problem seems to be the calibration. I have run the Heading example and can read the compass heading in degrees. However, when compared to a real compass, North is off by about 25 deg and when I rotate the sensor 90 deg, the serial monitor is showing about 180 deg!
The good news is that it always gets back to 0 deg at the same place. I have tried the calibration process from the user guide and have placed the values for the Min and Max back into the .cpp file. However, this appears to make very little difference to the heading value. These are my calibration values:
Accel Min -10.43 -11.14 -12.53
Accel Max 9.96 10.63 11.73
Mag Min -49.36 -60.82 -43.67
Mag Max 51.18 54.08 54.08
I have tried moving the device to a difference place on the table well away from all electrical devices and metal. Still the same result.
I know that the magnetic declination is only about 1 deg here in the UK, so that is not it.
Any ideas or advice from anyone who has set this up would be welcomed.
- adafruit_support_bill
- Posts: 88093
- Joined: Sat Feb 07, 2009 10:11 am
Re: magnetometer accuracy
That's interesting. Your min & max readings for the magnetometer look OK. Compared with the real compass, at what orientation do the min and max values occur?
-
- Posts: 7
- Joined: Sun May 12, 2013 2:34 pm
Re: magnetometer accuracy
0 deg = 0 deg
90 deg = 299 deg
180 deg = 251 deg
270 deg = 195 deg
360 deg = 0 deg
Hope this helps!
90 deg = 299 deg
180 deg = 251 deg
270 deg = 195 deg
360 deg = 0 deg
Hope this helps!
- adafruit_support_bill
- Posts: 88093
- Joined: Sat Feb 07, 2009 10:11 am
Re: magnetometer accuracy
Hmmm. Looks almost-but-not-quite backwards. Can you post a photo of your complete setup?
-
- Posts: 7
- Joined: Sun May 12, 2013 2:34 pm
Re: magnetometer accuracy
Sorry for the delay, here is the image of the setup.
- adafruit_support_bill
- Posts: 88093
- Joined: Sat Feb 07, 2009 10:11 am
Re: magnetometer accuracy
Looks like a pretty straightforward setup. I don't see anything that would explain the strange output you are seeing. If you contact [email protected] with a link to this thread we can send you a replacement sensor.
-
- Posts: 7
- Joined: Sun May 12, 2013 2:34 pm
Re: magnetometer accuracy
Thanks Bill,
I have sent an email as suggested.
Stephen.
I have sent an email as suggested.
Stephen.
-
- Posts: 7
- Joined: Sun May 12, 2013 2:34 pm
Re: magnetometer accuracy
Hi Bill,
I received the new sensor and have just tested it.
The results are pretty much the same as before; a 90 deg rotation can produce between 45 and 200 deg!
I noticed a small error in your calibration sketch, where you reference the Mag values. I think that you have the z referenced under y by mistake. This does affect the calibration values.
Also, it is not very well indicated how/where you use these values. I assume it is in the cpp file. This could be explained better.
FYI - I tested the Arduino sensor using the Pololu code, and the sensor reads perfectly, it is also tilt compensated (a big plus).
Cheers,
Stephen.
I received the new sensor and have just tested it.
The results are pretty much the same as before; a 90 deg rotation can produce between 45 and 200 deg!
I noticed a small error in your calibration sketch, where you reference the Mag values. I think that you have the z referenced under y by mistake. This does affect the calibration values.
Also, it is not very well indicated how/where you use these values. I assume it is in the cpp file. This could be explained better.
FYI - I tested the Arduino sensor using the Pololu code, and the sensor reads perfectly, it is also tilt compensated (a big plus).
Cheers,
Stephen.
-
- Posts: 306
- Joined: Wed Jun 12, 2013 5:01 pm
Re: magnetometer accuracy
The results look to be a code error. Check that you didn't miss a minus sign on the Mag x or y value before doing Atan.
I've been working with the LSM303 on an R-Pi. With the LSM303 level I get good results but still haven't gotten the Tilt compensation working correctly. A pretty good App Note on the theory, math and code is:
http://www.freescale.com/files/sensors/ ... AN4248.pdf
I've been working with the LSM303 on an R-Pi. With the LSM303 level I get good results but still haven't gotten the Tilt compensation working correctly. A pretty good App Note on the theory, math and code is:
http://www.freescale.com/files/sensors/ ... AN4248.pdf
-
- Posts: 7
- Joined: Sun May 12, 2013 2:34 pm
Re: magnetometer accuracy
Thanks Waltr,
A useful guide. Check out the pololu LSM303 code, I got excellent results from this.
Regards,
Stephen.
A useful guide. Check out the pololu LSM303 code, I got excellent results from this.
Regards,
Stephen.
-
- Posts: 306
- Joined: Wed Jun 12, 2013 5:01 pm
Re: magnetometer accuracy
Ok, did you work out what is wrong?
I did figure out why my code did not work for tilt compensation, I had the Roll and Pitch angles reversed when passing them into the tilt function. It now works perfectly.
I did figure out why my code did not work for tilt compensation, I had the Roll and Pitch angles reversed when passing them into the tilt function. It now works perfectly.
- bhatadb
- Posts: 17
- Joined: Thu May 01, 2014 3:46 pm
Re: magnetometer accuracy
Hello Waltr,
I am currently trying to use the tilt compensation for the LSM303, but am not having any luck. It seems that the heading changes with the pitching motion.
If possible, can you please share your code, or atleast point me in the right direction. I am using the unified Adafruit library, and tried using their AHRS example, but even that isn't giving the correct tilt compensation. I seem to get errors > 10 degrees.
Any help will be greatly appreciated,
Thanks,
Abhi
I am currently trying to use the tilt compensation for the LSM303, but am not having any luck. It seems that the heading changes with the pitching motion.
If possible, can you please share your code, or atleast point me in the right direction. I am using the unified Adafruit library, and tried using their AHRS example, but even that isn't giving the correct tilt compensation. I seem to get errors > 10 degrees.
Any help will be greatly appreciated,
Thanks,
Abhi
Please be positive and constructive with your questions and comments.