kriswiner / MPU6050

Basic MPU6050 Arduino sketch of sensor function
720 stars 190 forks source link

Accel Bias #16

Open PierreGogendeau opened 7 years ago

PierreGogendeau commented 7 years ago

Hi,

I was looking at your file "MPU9250_MS5637_AHRS_t3" and there is something that I don't understand. at the line 373 when you used this function :

accelgyrocalMPU9250(gyroBias, accelBias); // Calibrate gyro and accelerometers, load biases in bias registers

Here you store in the internal registers of the MPU9250 biais from the Gyro and Accel. Then line 478 in the main loop you substract it again :

// Now we'll calculate the accleration value into actual g's ax = (float)MPU9250Data[0]*aRes - accelBias[0]; // get actual g value, this depends on scale being set ay = (float)MPU9250Data[1]*aRes - accelBias[1]; az = (float)MPU9250Data[2]*aRes - accelBias[2];

I thought that when you store the offset value in the MPU9250, it do it by itself to substract the offset. Maybe there is something that I miss understood ?

Thanks in advance for your help

Cheers

Pierre Gogendeau

kriswiner commented 7 years ago

I don't like the way the MPU9250 handles the accel bias when written to the register so I donlt usually write the value there, rather I subtract it manually in the main code.

On Wed, Jun 28, 2017 at 10:50 PM, PierreGogendeau notifications@github.com wrote:

Hi,

I was looking at your file "MPU9250_MS5637_AHRS_t3" and there is something that I don't understand. at the line 373 when you used this function :

accelgyrocalMPU9250(gyroBias, accelBias); // Calibrate gyro and accelerometers, load biases in bias registers

Here you store in the internal registers of the MPU9250 biais from the Gyro and Accel. Then line 478 in the main loop you substract it again :

// Now we'll calculate the accleration value into actual g's ax = (float)MPU9250Data[0]aRes - accelBias[0]; // get actual g value, this depends on scale being set ay = (float)MPU9250Data[1]aRes - accelBias[1]; az = (float)MPU9250Data[2]*aRes - accelBias[2];

I thought that when you store the offset value in the MPU9250, it do it by itself to substract the offset. Maybe there is something that I miss understood ?

Thanks in advance for your help

Cheers

Pierre Gogendeau

— You are receiving this because you are subscribed to this thread. Reply to this email directly, view it on GitHub https://github.com/kriswiner/MPU6050/issues/16, or mute the thread https://github.com/notifications/unsubscribe-auth/AGY1qhjcu2yu1oGe9UInK-HZnHXcz4GVks5sIzsbgaJpZM4OI2gI .

PierreGogendeau commented 7 years ago

Ok thank you for your very very fast answer. Have a good day.

lindig commented 5 years ago

I believe the bias is corrected by the chip and again in the main loop - and this is wrong. Not doing it in the main loop I can observe that the values are much closer to zero when the chip is not moving. So I suspect a bug here.

kriswiner commented 5 years ago

The only way the "chip" can correct offset bias is if the user writes the offset into the bias registers. So yes, double correcting the biases would produce incorrect results...

On Tue, Feb 5, 2019 at 1:34 PM Christian Lindig notifications@github.com wrote:

I believe the bias is corrected by the chip and again in the main loop - and this is wrong. Not doing it in the main loop I can observe that the values are much closer to zero when the chip is not moving. So I suspect a bug here.

— You are receiving this because you commented. Reply to this email directly, view it on GitHub https://github.com/kriswiner/MPU6050/issues/16#issuecomment-460812739, or mute the thread https://github.com/notifications/unsubscribe-auth/AGY1qpKCDEK6sVAOgGJwVlGYPZj6Ke5eks5vKfjygaJpZM4OI2gI .

lindig commented 5 years ago

In MPU6050BasicExample.ino mpu.calibrateMPU6050() is called, which does write the data to the chip, and it subtracts the bias explicitly in the main loop.

kriswiner commented 5 years ago

Then, of course, this is wrong. These sketches are examples, nbot perfect black boxes. Buyer beware...

On Tue, Feb 5, 2019 at 1:39 PM Christian Lindig notifications@github.com wrote:

In MPU6050BasicExample.ino mpu.calibrateMPU6050() is called, which does write the data to the chip, and it subtracts the bias explicitly in the main loop.

— You are receiving this because you commented. Reply to this email directly, view it on GitHub https://github.com/kriswiner/MPU6050/issues/16#issuecomment-460814133, or mute the thread https://github.com/notifications/unsubscribe-auth/AGY1qjw3jnm6437qygDMMwsS7dIFkG4mks5vKfn8gaJpZM4OI2gI .