Help with HMC5843

I have an HMC5843 hooked up to my arduino mega and I'm having some trouble getting the data correct.

Basically I found this document that helped explain what to do with the values from the hmc library.

http://www51.honeywell.com/aero/common/documents/myaerospacecatalog-documents/Defense_Brochures-documents/Magnetic__Literature_Application_notes-documents/AN203_Compass_Heading_Using_Magnetometers.pdf

I took the values and put them through the equations provided and the microcontroller is spitting out some strange data.

I have to post the code later but (its very simple) and the output but for now words will have to suffice.

Basically the micro controller spits out correct headings in degrees but only between say -45 to 45 degrees the rest of the angles come out as fixed values like 270.00, 180.00, 360.00 ect.. No matter how far I turn the sensor the values stay the same fixed number until I turn it back within that -45 to 45 degree range then they get to be precise. Also if I watch the raw data it does not change either until I'm within that range.

This is strange.....is the sensor suppose to do this??? Or is it those equations that are wrong.

Post any links of info on how to take the raw data and turn it into a compass heading that would help too.

There is some demo code for the HMC5883 here: http://garden.seeedstudio.com/index.php?title=Twig_-_3-axis_Compass_v0.9b

the MHC5883 is the replacement for the HMC5843 and there may be some differences required in the sketch code but you could try to use that calculation to produce the x and y values and convert to angle.

I hope that helps

the MHC5883 is the replacement for the HMC5843

That's not entirely true. The HMC5883L is the modern replacement for the HMC5843. The IC used on the Seeedstudio board is an older HMC5883. There are several hardware differences between the 5883 and 5883L. It seems Seeedstudio is the only place actually selling the older HMC5883 instead the 5883L version.

The HMC5583 is a replacement for the HMC5843 (I didn't say it was identical). I believe the The OPs question was regarding software and I hope the demo code linked will be of some help with his problem.

I've seen a similar behavior with bad soldered wires to the magnetometer.. when rotating the board I was getting garbage just because it wasn't communicating properly.. just something you may wanna check.