stanleyhuangyc / Freematics

Official source code repository for Freematics
https://freematics.com
433 stars 351 forks source link

MEMS Stuck around value #48

Open laurentvm opened 6 years ago

laurentvm commented 6 years ago

Hi Stanley,

We have remarked that sometimes, the gyroscope get stuck around a value and oscillate around that value. Therefore, code implementation based on gyroscope to detect and end of trip does not work because the accerleration levels appear to be high which is not true. Here is an output where you can see that Az is stuck around 10.

Ax Ay Az
2.98 -2.95 -10.35
3.3 -5.08 -10.13
2.46 -5.07 -9.81
0.44 -4.91 -9.39
2.26 -3.03 -10.57
3.22 -3.15 -10.27
2.17 -3.91 -10.31
6.42 -3.9 -10.35
2.53 -1.82 -10.96
2.78 -2.97 -10.68

Another good output on same device:

Ax Ay Az
0.22 0.26 0.18
0.03 0.02 0.28
0.18 0.19 0.17
0.1 0.11 0.22
0.14 0.14 0.12
0.14 0.22 0.25
0.13 0.13 0.14
0.11 0.18 0.14

We do this to compute the calibration bias

#if MEMS_MODE
    Serial.print("ACC BIAS...");
    accBias[0] = 0;
    accBias[1] = 0;
    accBias[2] = 0;
    int n;
    for (n = 0; n < 100; n++)
    {
        float acc[3] = {0};
        mems.read(acc);
        accBias[0] += acc[0];
        accBias[1] += acc[1];
        accBias[2] += acc[2];
        delay(10); // TODO do we have new values in 10 millis????
    }
    accBias[0] /= n;
    accBias[1] /= n;
    accBias[2] /= n;
    Serial.print(accBias[0]);
    Serial.print('/');
    Serial.print(accBias[1]);
    Serial.print('/');
    Serial.println(accBias[2]);
#endif

I found also this page http://www.sureshjoshi.com/embedded/invensense-imus-what-to-know/ which refers to dmp_set_accel_bias function which I have not found in your code.

Any idea?