Hi SW-developers,
I'm working my way through the code of MultiWii and MultiWii-Conf at the moment and I'm not able to find out how compass calibration is done within the software.
Is it done on the AVR alone, or is the GUI required to measure and calculate the necessary values from telemetry data? Where is the code that calculates it?
I found the flags to initiate compass calibration but the actual process was nowhere to be found...
I'm using the Crius All in one pro V1 as a basis.
Thanks in advance for pointing me to the right spot!
Best regards,
Timo
How is the magnetometer calibration done in software?
Re: How is the magnetometer calibration done in software?
The GUI is required to initiate the calibration process.
( Can be done with sticks when disarmed - Throttle hi & Yaw Right & Pitch back)
When you click "Calibrate" (or use the sticks) the software requires you to rotate your copter (sensor) through all possible angles so that the sensor can read the maximum / minimum magnetic fields in all planes of rotation.
From this the "span" or "range" is stored and used as a reference to calculate the "heading", given the influences of the specifics of your particular installation and location.
This is why the Mag sensor should be kept away from magnetic influences such as ESC wiring and other metallic / magnetic influences.
Note: A properly calibrated Mag sensor is imperative for good POS Hold and GPS Navigation.
Once calibrated, the "Heading" (in the GUI) should, when the copter is tilted, remain constant.
H.
Edit: Also be sure to enter your specific locations' Magnetic Declination in Config.h #define MAG_DECLINATION xx.xx
Use this online tool: http://magnetic-declination.com
The deviation is given in degrees,minutes (minutes are 0 to 60) but MultiWii requires decimal minutes so to get decimal minutes, divide minutes by 60.
Eg: -27degrees 30minutes = -27.5 degrees
Declination is each locations variation from true magnetic North, dependant on where you are on the earth.
If you are in the Southern Hemisphere, (south of the Equator, declination is NEGATIVE, so put a "-" in front of the declination value in Config.h
( Can be done with sticks when disarmed - Throttle hi & Yaw Right & Pitch back)
When you click "Calibrate" (or use the sticks) the software requires you to rotate your copter (sensor) through all possible angles so that the sensor can read the maximum / minimum magnetic fields in all planes of rotation.
From this the "span" or "range" is stored and used as a reference to calculate the "heading", given the influences of the specifics of your particular installation and location.
This is why the Mag sensor should be kept away from magnetic influences such as ESC wiring and other metallic / magnetic influences.
Note: A properly calibrated Mag sensor is imperative for good POS Hold and GPS Navigation.
Once calibrated, the "Heading" (in the GUI) should, when the copter is tilted, remain constant.
H.
Edit: Also be sure to enter your specific locations' Magnetic Declination in Config.h #define MAG_DECLINATION xx.xx
Use this online tool: http://magnetic-declination.com
The deviation is given in degrees,minutes (minutes are 0 to 60) but MultiWii requires decimal minutes so to get decimal minutes, divide minutes by 60.
Eg: -27degrees 30minutes = -27.5 degrees
Declination is each locations variation from true magnetic North, dependant on where you are on the earth.
If you are in the Southern Hemisphere, (south of the Equator, declination is NEGATIVE, so put a "-" in front of the declination value in Config.h
Re: How is the magnetometer calibration done in software?
Hey Howard,
thanks a lot for describing the process and what happens while calibrating the compass. But unfortunately, that was not the information I was searching for. It was still helpful, though!
I was asking for the .h and .c file and line number where the 30second calibration process actually takes place.
I checked Protocol.cpp, line 559:
As well as Sensors.cpp, line 1114:
But I couldn't find the actual 30 second min/max checking...
Any hints?
thanks a lot for describing the process and what happens while calibrating the compass. But unfortunately, that was not the information I was searching for. It was still helpful, though!
I was asking for the .h and .c file and line number where the 30second calibration process actually takes place.
I checked Protocol.cpp, line 559:
Code: Select all
case MSP_MAG_CALIBRATION:
if(!f.ARMED) f.CALIBRATE_MAG = 1;
headSerialReply(0);
break;
As well as Sensors.cpp, line 1114:
Code: Select all
if (f.CALIBRATE_MAG) {
tCal = t;
for(axis=0;axis<3;axis++) {
global_conf.magZero[axis] = 0;
magZeroTempMin[axis] = imu.magADC[axis];
magZeroTempMax[axis] = imu.magADC[axis];
}
f.CALIBRATE_MAG = 0;
}
But I couldn't find the actual 30 second min/max checking...
Any hints?
Re: How is the magnetometer calibration done in software?
Sorry... I just found it. Its 10 lines below... Thanks a lot!