UWCubeSat / DubSat1

Main repository for all flight software (including all subsystems, core libraries, and hardware abstraction layers) for the DubSat-1 3U Cubesat.
22 stars 10 forks source link

IMU byte endianness does not match datasheet #221

Open djdupre opened 6 years ago

djdupre commented 6 years ago

The IMU was sending terrible data (-140 deg/s on the X axis) until I flipped the byte order in 6b49b6d96c59c9420dff5e7dab85c8260e58f0a7. I tilted the flatsat on each axis and the readings are much more reasonable.

The weird part is that the datasheet says the default is "LSB @ the lower address" (little-endian), but the working code now uses the MSB at the lower address:

idata.rawGyroX = (int16_t)(i2cBuff[1] | ((uint16_t)i2cBuff[0] << 8));
djdupre commented 6 years ago

I configured the endianess using CTRL3_C and found that although the default is little-endian, the IMU is somehow being configured as big-endian after a couple of reboots. I set CTRL3_C manually in 85ec0fd798b82b05166463b62d36a6e92ad8c4c8 and flipped the parsing code back to little-endian.

For some reason the IMU now only works when the analyzer is plugged in, even after undoing the changes and rebooting. Maybe I messed up some persistent configuration --- it would be worth trying this on another IMU.