MPU-6050-9250-I2C-CompFilter icon indicating copy to clipboard operation
MPU-6050-9250-I2C-CompFilter copied to clipboard

bias applied incorrectly in magCalSlider and magCalVisualizer

Open WillemD61 opened this issue 2 years ago • 3 comments

In the main program magnetometer calibration routine the RAW magnetometer values are captured and the bias and scale factors are calculated. The instructions say that the RAW values should be stored in data.txt and the bias and scale factor should then be defined in the two visualization programs. These will then display raw and corrected graphs.

In the main program : bias = RAWbias * scaleFactor * factorycalibration and scale=avgrange/axis-range (where RAWbias=(maxRAW+minRAW)/2)

In the visualization programs however you are applying the bias to the RAW magnetometer values (retrieved from data.txt) So you are subtracting a bias that is alread corrected with scalefactor and factorycalibration values from a RAW magnetometer value. I think you should either subtract a raw bias from raw values or corrected bias from corrected values.

Also note that the scalefactor is calculated from RAW values but applied on corrected values. Since these are close to 1 anyway the impact is small.

That is why currently the magCalSlider each time requires further manual adjustment.

(notes :

  1. in the explanation of calibration by Kris Winer and the example routine he provides, you can see the variables mag_bias[ ] and dest1[ ] for the raw and corrected values respectively.
  2. also note that you bias correction in the main program (in the processvalues function) is correct. The error only exists in the visualization programs magCalSlider and magCalVisualizer

WillemD61 avatar Mar 02 '22 15:03 WillemD61