on 2021-10-22 02:45 AM
The description of MotionMC library for the magnetic sensor calibration gives the opportunity to get a more detailed overview on the magnetic sensor.
A magnetic sensor is usually intended to measure Earth magnetic field to get the absolute position/direction of the sensor in space. However, near the surroundings of a magnetometer, it can cause distortion of Earth magnetic field. Based on the distortion character, we can categorize it as two types: hard iron and soft iron effect. Hard iron distortion arises from permanent magnets, magnetized iron or steel located nearby the magnetometer. This distortion remains constant and in fixed location related to the magnetometer for all heading orientations. Hard iron effect adds a constant magnitude field component along each magnetometer axis. Soft iron distortion arises from the interaction of the Earth magnetic field and the material which surrounds the magnetometer sensor distorting the Earth magnetic field. The distortion magnitude and direction depend on the incident angle of the Earth magnetic field on the material. Hence, it varies with the magnetometer orientation.
As we will see in more detail in the next post, the library acquires data from the magnetometer and calculates the hard iron (HI) and soft iron (SI) coefficients. The calibration coefficients are then used to compensate raw data from the magnetometer and reduce hard iron and soft iron effects.
The MotionMC library acquires data from the magnetometer and features the hard iron compensation, theoretically unlimited (within sensor range) and a wide scale factor compensation range from 0.65 to 1.35 in every direction.
The two central functions for the MotionMC manage the magnetometer parameters calibration and are the following ones:
>> void MotionMC_Update (MMC_Input_t *data_in)
>> void MotionMC_GetCalParams (MMC_Output_t *data_out)
where the input data *data_in is a structure composed from:
and the output data *data_out is also a structured of:
See below the typical flowchart of the MotionMC calibration procedure :fast_down_button: