lewisxhe / SensorLib

Commonly used I2C , SPI device multi-platform libraries
MIT License
70 stars 15 forks source link

Question: QMI8658 example gets 1/2 of true acceleration value when gyro is disabled #2

Closed lyusupov closed 3 weeks ago

lyusupov commented 1 year ago

Sketch: QMI8658_GetDataExample

Normal use case: when both gyro and accel are enabled - the getAccelerometer() function gives correct acceleration value

Issue: when gyro is disabled like that:

#if 0
    qmi.configGyroscope(
        /*
        * GYR_RANGE_16DPS

< --- skipped --->

    // In 6DOF mode (accelerometer and gyroscope are both enabled),
    // the output data rate is derived from the nature frequency of gyroscope
    qmi.enableGyroscope();
#endif

The workaround is to enable the gyro all the time like the SoftRF did ... But could we avoid that and get correct acceleration value regardless if the gyro is on or off ?

lewisxhe commented 1 year ago

Give me some time, I'm currently on vacation

LazaroFilm commented 1 year ago

This may be related to the fact that the Accelerometer's ODR has different values when used alone than with the gyro on. see from documentation.

Screenshot 2023-07-11 at 8 41 35 PM

lewisxhe commented 3 weeks ago

@lyusupov

Linar .

I tested QMI today and found no change in acceleration value when turning on and off the gyroscope.

Tested turning on acceleration alone image

Turning on acceleration and gyroscope image

From the manual, we know that the output frequency of turning on acceleration alone comes from the internal oscillator. When turning on acceleration and gyroscope at the same time, the output frequency of both is changed to the output frequency of the gyroscope. My personal understanding is that only the output frequency is changed, and the data value will not be changed.

lewisxhe commented 3 weeks ago

No, I tested it differently than you did. I configured the gyroscope and then disabled it. After testing, this may be related to the gyroscope's self-test.

lewisxhe commented 3 weeks ago

After removing the self-test, enabling acceleration alone now works fine, the self-test usage was wrong before.

lyusupov commented 3 weeks ago

Thank you, Lewis!

I am unable to verify the sketch right now... If you are sure that the issue is no longer a factor after your fix - please, feel yourself free to close this ticket.

lewisxhe commented 3 weeks ago

OK. I'll close it first. Feel free to open it if you have any questions.