47 #define F_USING_MAG 0x0002 // normally should be defined in build.h 53 #define MAGBUFFSIZEX 14 54 #define MAGBUFFSIZEY (2 * MAGBUFFSIZEX)
55 #define MINMEASUREMENTS4CAL 110
56 #define MINMEASUREMENTS7CAL 220
57 #define MINMEASUREMENTS10CAL 330
58 #define MAXMEASUREMENTS 360
59 #define CAL_INTERVAL_SECS 300
60 #define MINBFITUT 10.0F
61 #define MAXBFITUT 90.0F
62 #define FITERRORAGINGSECS 86400.0F
63 #define MESHDELTACOUNTS 50
64 #define DEFAULTB 50.0F
134 #else // if F_USING_MAG 145 #endif // if F_USING_MAG 146 #endif // #ifndef MAGNETIC_H int8_t iMagBufferReadOnly
flag to denote that the magnetic measurement buffer is temporarily read only
int32_t iValidMagCal
solver used: 0 (no calibration) or 4, 7, 10 element
int8_t iNewCalibrationAvailable
flag denoting that a new calibration has been computed
float fYTY
Y^T.Y for 4 element calibration = (iB^2)^2.
#define MAGBUFFSIZEX
x dimension in magnetometer buffer (12x24 equals 288 elements)
void fUpdateMagCalibration7Slice(struct MagCalibration *pthisMagCal, struct MagBuffer *pthisMagBuffer, struct MagSensor *pthisMag)
void fUpdateMagCalibration7(struct MagCalibration *pthisMagCal, struct MagBuffer *pthisMagBuffer, struct MagSensor *pthisMag)
int8_t iCalInProgress
flag denoting that a calibration is in progress
int8_t i10ElementSolverTried
flag to denote at least one attempt made with 4 element calibration
void fUpdateMagCalibration4Slice(struct MagCalibration *pthisMagCal, struct MagBuffer *pthisMagBuffer, struct MagSensor *pthisMag)
void fInitializeMagCalibration(struct MagCalibration *pthisMagCal, struct MagBuffer *pthisMagBuffer)
void fUpdateMagCalibration4(struct MagCalibration *pthisMagCal, struct MagBuffer *pthisMagBuffer, struct MagSensor *pthisMag)
The MagSensor structure stores raw and processed measurements for a 3-axis magnetic sensor...
void fUpdateMagCalibration10Slice(struct MagCalibration *pthisMagCal, struct MagBuffer *pthisMagBuffer, struct MagSensor *pthisMag)
float ftrFitErrorpc
trial value of fit error %
int8_t i7ElementSolverTried
flag to denote at least one attempt made with 4 element calibration
float fFitErrorpc
current fit error %
int16_t iBs[3][MAGBUFFSIZEX][MAGBUFFSIZEY]
uncalibrated magnetometer readings
int16_t tanarray[MAGBUFFSIZEX - 1]
array of tangents of (100 * angle)
float fB
current geomagnetic field magnitude (uT)
int16_t iMagBufferCount
number of magnetometer readings
Magnetic Calibration Structure.
int32_t itimeslice
counter for tine slicing magnetic calibration calculations
int8_t i4ElementSolverTried
flag to denote at least one attempt made with 4 element calibration
void fInvertMagCal(struct MagSensor *pthisMag, struct MagCalibration *pthisMagCal)
void fRunMagCalibration(struct MagCalibration *pthisMagCal, struct MagBuffer *pthisMagBuffer, struct MagSensor *pthisMag, int32_t loopcounter)
float fBSq
square of fB (uT^2)
float ftrB
trial value of geomagnetic field magnitude in uT
#define MAGBUFFSIZEY
y dimension in magnetometer buffer (12x24 equals 288 elements)
int8_t iInitiateMagCal
flag to start a new magnetic calibration
int32_t index[MAGBUFFSIZEX][MAGBUFFSIZEY]
array of time indices
void fUpdateMagCalibration10(struct MagCalibration *pthisMagCal, struct MagBuffer *pthisMagBuffer, struct MagSensor *pthisMag)
void iUpdateMagBuffer(struct MagBuffer *pthisMagBuffer, struct MagSensor *pthisMag, int32_t loopcounter)