View Full Version : Problem with HMC5883L magnetometer

11-30-2012, 08:20 PM

I have been debugging the FreeIMU on teensy 3.0 for weeks now. Everything else works fine, barometer, accelerometer, gyroscopes. There is a strange problem with the HMC5883L magnetometers...

It works fine on the arduino with the Arduino libraries(I use a separate arduino shell for the ATmegas).
It does not work with the Teensy libraries(whether on the Arduino board or Teensy with relevant code changed for each eg definitions)

I am using the Wire library on both shells for the same program, (HMC58X3_raw.ino) http://bazaar.launchpad.net/~fabio-varesano/freeimu/trunk/files/head:/libraries/HMC58X3/

To simplify matters, I am only using the IMU with the ArduinoDuemilanove in both shells(Arduino standard, and Teensy Modified).
Here's the strange bit. When I "initialise" the IMU with the standard arduino shell and then upload the sketch from the teensy shell, everything works fine.(Serial displays good values, responsive magnetometer)
But as soon as I unplug and plug back in, the values returned by the HMC5883L become constant and seem to be a maximum. This has nothing to do with missing pull-up resistors, I have made sure they are all pulling up to 3.3V(internal pull-up resistors in arduino turned off). However if I use the reset button instead of unplugging, the results are still fine. Alas, I cannot possibly "initialize" the teensy from the standard shell, so I need a fix for this weird issue.

Anyone have any ideas? Why does the ATmega328 "started up" with code from teensy shell differ from one "started up" with the standard shell?
I think it might be an I2C sync problem, or Wire library problem. However, the teensy wire library works perfectly fine with all the other sensors..just this one..