My Sensors.ino code has been changed for the Mag calibration step to look like this:
Code: Select all
if (tCal != 0) {
if ((t - tCal) < 30000000) { // 30s: you have 30s to turn the multi in all directions
LEDPIN_TOGGLE;
for(axis=0;axis<3;axis++) {
if (magADC[axis] < magZeroTempMin[axis]) {
magZeroTempMin[axis] = magADC[axis];
alarmArray[7] = 1; // Beep Buzzer
}
if (magADC[axis] > magZeroTempMax[axis]) {
magZeroTempMax[axis] = magADC[axis];
alarmArray[7] = 1; // Beep Buzzer
}
}
}
The "alarmArray[7] = 1; // Beep Buzzer" line on each MAX and MIN check block will beep the buzzer, if the new value detected is higher than the MAX or lower than the MIN value currently detected.
The calibration process I use is to activate the MAG calibration (you get 30 seconds to calibrate) and then hold the platform flat (horizontal) and rotate on the spot (turn around 360 degrees). I turn around twice, first time round there are lots of beeps, second time round hardly any (as the max and mins have been found on the first turn).
Secondly I hold the platform with the nose pointing skywards and again rotate on the spot, first turn around lots of beeps, second time around hardly any... then to be sure I point the platform all around me randomly to see if I can get any more beeps out of it...
For info this is the kind of calibration procedure carried out on a DJI Phantom when it needs to be calibrated.
This could also be used to check the motor effect on the mag... calibrate first by turning around in each orientation then, before the calibration finishes, power up the motors... if you get beeping, then the mag has been effected by the motors!
Not sure how to add this modification to a branch of the code, so hoping someone on here will pick this up and think about implementing it!
Cheers,
Terry.