MinIMU-9 v3 Magnometer Axis Trouble

Hey everyone. I am relatively new to some of these concepts so just keep that in mind. I bought the MinIMU-9 v3 last week along with the Teensy 2.0 pjrc.com/store/teensy.html.

I connected the two as follows.
Teensy 2.0 → MinIMU-9
SCL PD0 → SCL
SDA PD1 → SDA
Vcc → Vin
GND → GND

I attached pictures of my setup.






I am using the following libraries:
L3G: github.com/pololu/l3g-arduino
LSM303: github.com/pololu/lsm303-arduino

I am running the simple script, “Serial”, from the examples in the LSM303 library. Here is the code:

#include <Wire.h>
#include <LSM303.h>

LSM303 compass;

char report[80];

void setup()
{
  Serial.begin(9600);
  Wire.begin();
  compass.init();
  compass.enableDefault();
}

void loop()
{
  compass.read();

  snprintf(report, sizeof(report), "A: %6d %6d %6d    M: %6d %6d %6d",
    compass.a.x, compass.a.y, compass.a.z,
    compass.m.x, compass.m.y, compass.m.z);
  Serial.println(report);

  delay(100);
}

Here is a sample of the outputs.
A: -12436 77 11178 M: 14913 530 -32768
A: -12392 47 11171 M: 14889 538 -32768
A: -12406 57 11179 M: 14889 538 -32768
A: -12398 100 11170 M: 14905 554 -32768
A: -12415 91 11108 M: 14910 540 -32768
A: -12428 50 11129 M: 14910 540 -32768
A: -12430 54 11103 M: 14902 535 -32768
A: -12445 70 11161 M: 14897 572 -32768
A: -12423 70 11164 M: 14897 572 -32768
A: -12392 68 11211 M: 14899 534 -32768
A: -12363 19 11166 M: 14911 546 -32768
A: -12380 61 11146 M: 14911 546 -32768
A: -12421 59 11181 M: 14901 552 -32768
A: -12375 70 11156 M: 14909 526 -32768
A: -12399 75 11144 M: 14909 526 -32768
A: -12442 78 11137 M: 14896 538 -32768
A: -12460 88 11146 M: 14910 537 -32768

All of the values do what I expect as I move the chip, except for the z-axis of the magnetometer. The z-axis of the magnetometer is always -32768. I assume it is an overflow but I have been unsuccessful in troubleshooting the issue.

Thanks in advance.

Hello.

Yes, it looks like you are getting an overflow with the MinIMU-9. Can you try reducing the sensitivity of the magnetometer to see if that changes anything? You can add this line:

compass.writeReg(LSM303::CTRL6, 0x40);

under enableDefault, which should set the sensitivity to +/- 8 gauss.

-Jon

Thanks for the reply! Using this code I still get the z-axis overflow.

#include <Wire.h>
#include <LSM303.h>

LSM303 compass;

char report[80];

void setup()
{
  Serial.begin(9600);
  Wire.begin();
  compass.init();
  compass.enableDefault();
  compass.writeReg(LSM303::CTRL6, 0x40); 
}

void loop()
{
  compass.read();

  snprintf(report, sizeof(report), "A: %6d %6d %6d    M: %6d %6d %6d",
    compass.a.x, compass.a.y, compass.a.z,
    compass.m.x, compass.m.y, compass.m.z);
  Serial.println(report);

  delay(100);
}

You might try further reducing the sensitivity to its lowest setting (±12 gauss):

compass.writeReg(LSM303::CTRL6, 0x60);

As a last ditch effort, can you try desoldering your MinIMU from the Teensy and then try to read the data with the MinIMU at least a couple inches away from the Teensy? (You could use a breadboard or common 3" or 6" jumper wires.) I suspect there might be some electromagnetic field generated by the components on the Teensy that is interfering with your magnetometer reading.

If you are still getting an overflow after trying that out, I suspect your magnetometer might be broken. If you email us and reference this thread, I might be able to help you out with a replacement.

-Jon