MinIMU-9 v2 Gyro, Accelerometer, and Compass (L3GD20 and LSM303DLHC Carrier)
The Pololu MinIMU-9 v2 is an inertial measurement unit (IMU) that packs an L3GD20 3-axis gyro and an LSM303DLHC 3-axis accelerometer and 3-axis magnetometer onto a tiny 0.8″ × 0.5″ board. An I²C interface accesses nine independent rotation, acceleration, and magnetic measurements that can be used to calculate the sensor’s absolute orientation. The module includes a voltage regulator and a level-shifting circuit that allows operation from 2.5 to 5.5 V.
|Description||Specs (8)||Pictures (7)||Resources (13)||FAQs (1)||On the blog (4)|
- Why are some of my magnetometer readings -4096?
When the magnetometer reads -4096, it means the sensor reading is overflowing at the current gain setting.
From section 9.2.4 of the LSM303DLH datasheet (599k pdf):
In the event the ADC reading overflows or underflows for the given channel, or if there is a math overflow during the bias measurement, this data register will contain the value -4096 in 2’s complement form. This register value clears after the next valid measurement is made.
Although this is not mentioned in the LSM303DLM or LSM303DLHC datasheets, it seems to apply for those sensors as well.
To avoid overflowing, try reducing the gain by setting the three gain-setting bits in CRB_REG_M. If you are using our Arduino library, insert this code into the setup method after
compass.enableDefault();to get the lowest gain (largest sensor input field range) possible:
// see the description of the CRB_REG_M register in the datasheet for other values compass.writeMagReg(LSM303_CRB_REG_M, 0b11100000);
Alternatively, you can use the
setMagGain()function to do the same thing:
// see LSM303.h for other values compass.setMagGain(LSM303::magGain_81);