sparkfun / Qwiic_9DoF_IMU_ICM20948_Py

Python module for the SparkFun 9DoF IMU Breakout - ICM-20948 (Qwiic)
MIT License
31 stars 13 forks source link

Units of measurement is not documented #2

Closed cst0 closed 4 years ago

cst0 commented 4 years ago

Hello,

I'm unable to find documentation indicating what units values are reported in. I tried finding the values by making some measurements, and although I'm definitely getting values, they don't line up with anything I can make sense of: for example, I'm expecting acceleration due to gravity to be either ~9.8m/s^2 or ~32.2ft/s^2, but I'm actually getting ~1600. I understand I may need to do some calibrating, but without knowing what units are being used, I'm not sure where to go with that. I believe that documenting what units are being used, and potentially what steps can be taken to calibrate the device in custom code, would resolve this issue.

lewispg228 commented 4 years ago

Hi @thieraufc , Thanks for reaching out. All of the data reported by the ICM20948 are signed 16-bit values (−32,768 to 32,767). The full scale range determines what those values convert into units.

The full scale range settings for the accelerometer and gyro are setup in the .begin() function here:

https://github.com/sparkfun/Qwiic_9DoF_IMU_ICM20948_Py/blob/master/qwiic_icm20948.py#L1049

    # set full scale range for both accel and gryo (separate functions)
    self.setFullScaleRangeAccel(gpm2)
    self.setFullScaleRangeGyro(dps250)

And these correspond to:

gpm2 = 2Gs (note, gpm stands for "Gravity Forces Plus or Minus") dps250 = 250 degrees per second

For the accelerometer, you should be able to divide your incoming 16-bit int value by 16.384 and you will get milliGs. That is what our current Arduino Library does.

For the gryo, you should be able to divide by 131, to get degrees per second. Again, this is what our Arduino Library does.

As for the magnetometer, it does not have a full scale range selection, so you'll need to convert your input from 0-32767 to 0-4900uT. Multiplying your incoming value by 0.15 would get you close. This is what our Arduino Library does.

Sorry we don't currently have the capacity to fully port this scaling functionality from our Arduino Library into this Python module, but I hope this helps for now and good luck! -Pete

cst0 commented 4 years ago

Thank you, that's very helpful-- I should be able to do what I need with that info and reference code.

You mention not having the capacity to port this functionality: is that a manpower/time resources issue? Seeing as I'll be needing to write that functionality for myself anyway, I'm happy to take a shot at writing it and making a PR.

I'll mark this as resolved.

lewispg228 commented 4 years ago

You're welcome @thieraufc , We would greatly appreciate a PR on this functionality. I'd be happy to review it when it comes through. Thanks again and good luck!