I have bought this compass to use as a setup reference for a rotating motor project. (ton of details)
short story is that I want to align the motor direction true north. then do a rotation with the motor(no compass), then after the rotation, do another calibration, repeat, repeat and so on. I have added the calibration sketch from the tutorial and got it to compile and everything, I need to do the physical rotation part since I skipped it ( over read it ) and then see if it calibrates it better.
So to the question. Once I calibrate this compass, How often should it be calibrated? before every use? once a month etc.
Also, should I loop the calibration function so it will continuously calibrate while I physically rotate it or what is the best way to do it? ( cause it runs through the script in about 50ms)
LSM 303 Compass Calibration
Moderators: adafruit_support_bill, adafruit
Please be positive and constructive with your questions and comments.
- adafruit_support_bill
- Posts: 88086
- Joined: Sat Feb 07, 2009 10:11 am
Re: LSM 303 Compass Calibration
At the silicon die level, these devices are pretty stable. The primary reason for calibration is to compensate for any positioning offset incurred during packaging the chip, soldering it to the board and/or mounting the board to your project. If your installation is subject to strong vibrations that might cause mountings to drift, then you might want to calibrate periodically, or after some number of hours of operation. But for most purposes, you should be able to calibrate once on installation.
-
- Posts: 14
- Joined: Fri Feb 07, 2014 3:27 pm
Re: LSM 303 Compass Calibration
when I run the calibration sketch, should I loop it constantly until I can get it spun on all axes ?
- adafruit_support_bill
- Posts: 88086
- Joined: Sat Feb 07, 2009 10:11 am
Re: LSM 303 Compass Calibration
That depends. If you will only be rotating it in one axis in actual use, you only need to find the min and max points for rotation on that axis. If it will be free to move on more than one axis (e.g. an arial drone), you will need to keep measuring until you register the min and max on all axis.
-
- Posts: 14
- Joined: Fri Feb 07, 2014 3:27 pm
Re: LSM 303 Compass Calibration
Ok that makes sense. Mainly I'll be using this to find true north on a leveled platform. So how many rotations would you need to run it to call it safe? 3?
- adafruit_support_bill
- Posts: 88086
- Joined: Sat Feb 07, 2009 10:11 am
Re: LSM 303 Compass Calibration
If it is mounted to a platform, you could do it with as little as one (slow) rotation.
-
- Posts: 306
- Joined: Wed Jun 12, 2013 5:01 pm
Re: LSM 303 Compass Calibration
What the calibration is doing is finding the Min and Max values of each axis. This will then calculate the OFFSET ERROR of each axis so that the trig used to calculate the angle is correct. With a slow rotation the sampling will get the min and max values.
To get a TRUE heading you will need to look up the local magnetic deviation for where you live and add this to the magnetometer angle calculation (magnetic North).
To get a TRUE heading you will need to look up the local magnetic deviation for where you live and add this to the magnetometer angle calculation (magnetic North).
-
- Posts: 14
- Joined: Fri Feb 07, 2014 3:27 pm
Re: LSM 303 Compass Calibration
Yeah I knew that it would be true north but I think magnetic north will be fine for this project. Later I might get more precise with the true north. Thanks for all of your help, Jonathan
-
- Posts: 14
- Joined: Fri Feb 07, 2014 3:27 pm
Re: LSM 303 Compass Calibration
Since I have been unable to work on my project, left it at school and school was cancelled due to snow, I've been looking into correcting the true north magnetic factors. so I've found source from NOAA which im sure are pretty accurate dealing with the degree of change. Where in the calibration code would I add in this factor. I'm using the calibration sketch from the tutorials. I'm guessing that I would just have to say something like
magmaxval_x = magmaxval_x + offsetvalue;
or something similar to that in both x and y ?
Thanks in advance for the help, Jonathan
magmaxval_x = magmaxval_x + offsetvalue;
or something similar to that in both x and y ?
Thanks in advance for the help, Jonathan
- adafruit_support_bill
- Posts: 88086
- Joined: Sat Feb 07, 2009 10:11 am
Re: LSM 303 Compass Calibration
Usually the magnetic declination is given in degrees. You would simply add that value to your calculated heading.
Note that magnetic declination is not a static value - The Earth's magnetic field is always changing and the magnetic poles are slowly moving. For a short-term project, you can get away with hard-coding it. But in a few years it will most likely have shifted a bit.
Note that magnetic declination is not a static value - The Earth's magnetic field is always changing and the magnetic poles are slowly moving. For a short-term project, you can get away with hard-coding it. But in a few years it will most likely have shifted a bit.
-
- Posts: 14
- Joined: Fri Feb 07, 2014 3:27 pm
Re: LSM 303 Compass Calibration
Yes I am aware of the slow changes. It'll just have to be something that will be kept up with and constantly changed. But it doesn't have to go in the calibration sketch, but it's just added to the heading direction correct? Cause if that is the cause then technically we don't have to hard code it as we could just set it up and off set it by a number of degrees that matches the current magnetic field
- adafruit_support_bill
- Posts: 88086
- Joined: Sat Feb 07, 2009 10:11 am
Re: LSM 303 Compass Calibration
Yes. Same as you would with a regular compass.but it's just added to the heading direction correct?
- spork99
- Posts: 48
- Joined: Mon Jul 25, 2011 3:27 pm
Re: LSM 303 Compass Calibration
You can get updated magnetic declination for your exact position from NOAA on the web. Also many airports also publish the precise declination daily. Keep in mind that in some places, like BANNED, the declination can be as much as 20 degrees from true North. Depending on where you are, things like iron ore or lodestone deposits can affect a compass too.
I'd also be concerned about EM interference from your project affecting your compass. I know a guy who failed a nighttime land navigation trial because he held his light next to his compass when taking a bearing and the light pulled the compass needle about 20 degrees off.
I'd also be concerned about EM interference from your project affecting your compass. I know a guy who failed a nighttime land navigation trial because he held his light next to his compass when taking a bearing and the light pulled the compass needle about 20 degrees off.
Please be positive and constructive with your questions and comments.