Main Site Documentation

HMC6343 compass


#1

Hopefully someone else has seen this issue and can give some advice.

I got the HMC6343 tilt compensated compass from Sparkfun.com and wired it into my breadboard connecting it to my fez domino. It appears to work but i am seeing some weird data. i am using the compass driver file provided by GregO on this forum post:
http://www.tinyclr.com/forum/2/456/#/2/

but i am not getting very logical data. here is this code for what i am doing (simplified):


Compass c = new Compass();

while (true)
{
	c.ReadBearings();
	Debug.Print(c.realHeading.ToString());
}

while this does give me values, those values dont change by 90 degrees when i rotate the compass 90 degrees. generally the output ranges from 10 degrees - 90 degrees (not the 0-360 i was expecting). could it just need to be calibrated or something? is using a compass inside give that much interference? im at a loss here


#2

You might check the Netduino forums. Greg had come up with a pretty easy solution that I’m sure you could port to GHI’s firmware.


#3

One thing i’ve noticed is the 6343 is a little sensitive to local magnetic fields. I’d recommend connecting some jumpers to it and moving it away from local electronics - 6-12" should be enough. Also - make sure it’s stable when it starts up (for the first couple seconds).

You can avoid the weird readings doing the above, or doing a “hard iron” calibration but I’d recommend not doing that (it’s annoying) until you’re ready to put it into your final project.


#4

Do you still like the 6343 over the 9DoF IMU?


#5

Tilt compensation on the 6343 is handled by a 3 axis acceleration sensor. Which can be done with the Razor. Since it includes a 3 axis compass and a 3 axis acceleration sensor. So i guess for the extra expense you are buying someone doing the math for you and not getting a 3 axis gyro?


#6

I guess what I am more asking is how much more accurate the 6343 is over the 9DoF


#7

GregO: you think the FEZ under the compass (look at my wiring diagram) is what is causing this issue? i have the breadboard shield right on top of the domino but i didnt think that the domino would be giving off a significant field. i will move it and test, update you later.

All: i cant give an accuracy estimation yet since my compass is giving garbage. i spent too much (i love electronic toys) on both for this single goal of finding magnetic orientation but the truth is the 9DOF IMU is $25 cheaper than the HMC6343 and provides a lot more possibly useful data. Ill let you know when they are both actually working.


#8

Cool will be good to hear your findings.


#9

Yeah, you do NOT want to have stuff around the compass, it will just interfere with the data coming back. Even plexiglas bothers my 9DoF.


#10

ok, well i tested it with the compass not right on top of the FEZ and got the same result. my readings look like this:


64.3000031
64.3000031
64.3000031
64.3000031
64.3000031
64.3000031
64.3000031

but never get above 90 or below about 20 (no matter what direction its turned). am i using the compass class right? c.realHeading sould give a float between 0 and 360 right?


#11

Compass datasheet (page 7) sais it can be mounted flat or with 90 degree to the surface. Like accelerometers on some IMU boards.
Maybe you can try tilt your compass and then look at readings?
If this would help you can send appropriete command to compass to make it read data at flat position.


#12

wow, no replies? can anyone tell me if c.realHeading is what i am supposed to be reading for the compass angle?


#13

I would guess you and greg would be the only ones with it at the moment. By looking at the code yeah sure that what you should be looking at but i wouldn’t really know unless i have the device in front of my face and could step through the code looking at the results along the way.


#14

update: after looking more carefully at the datasheet:
http://www.magneticsensors.com/datasheets/HMC6343.pdf

i have seen that it says:
[italic]The circuit is sensitive to power supply noise, and adding a 1.0 microfarad ceramic capacitor is recommended on the positive supply to help reduce noise.[/italic]

i also have the leads wired directly to the SDA and SLC without the pulldown resistors that are listed on the datasheet. i made assumptions about how to wire this to the domino. i have ordered the specified parts (im a wiring noob and dont have those on hand). i am hoping that this will straighten out my numbers.

i did do a screen capture of the compass properties while running


#15

I’m getting a HMC6352 tommorrow

Its the same but without tilt… We make slew limiters using compasses and we dont usually have to calibrate them, We do advise our customers to be at least 150mm away from ANYTHING metalic (aluminium and stainless are usually ok) .

But one thing I do know you need at least 2.2k pullup resistors not pulldown youre lucky o get any reading without them.


#16

Yeah the main different between the 2 talked about. is the 6343 has a built in algorithm to tilt compensate. The 6352 does not but with the third axis you you can write the algorithm your self.


#17

IanR: sorry, pullup not pulldown (again im a wiring noob). i did get the 10k resistors and a 1.0uF capacitor from radio shack (who has almost nothing but phones now), i will update you guys when i get it wired in. if it works i will also add a pic of how i wired it into the fez (i wish there were more wiring digrams on tinyclr)

GregO: can you give us an image of how you wired yours in?


#18

If you have 10k resistors you better run it at 100khz as they are atad too large the recomended resistance for 5V rail is 4.7k (this is how I run mine) but at 3.3v you should drop it down to 2.7k.

if you run the device (presuming it can) at 400khz with 10k pullups the signal will be considerably degraded.

With 4.7k you get the best of both worlds… low power and speed.


#19

To be honest I’d have to go back and rewire it all - it’s been a while since I was playing with that compass and I don’t remember exactly how I got it done! :slight_smile:

@ Chris - I’m still undecided but part of me leans a bit back towards the 9DOF because I can reprogram it and get raw data from 3 different kinds of sensors.


#20

IanR: hmmm, now i am more confused since the datasheet says 10k, but the refresh rate is 5Hz and i am a wiring noob so i dont get how you are calculating the resistors against the refresh rate. would you still recommend the 4.7k for a 5hz refresh rate or will the 10k work?

GregO: i have the 9DOF as well (only tested through USB so far) but i am worried about moving the calculation of the heading (plus the tilt compensation calculation) to the FEZ. i like knowing that the heavy lifting is done by the HMC6343 and not taking up processor cycles. is there some reason that they wouldnt just include the capacitor and 10k resistors directly on the HMC6343?

i will have time to test this after work tonight (i wish my job was making robots instead of hospial tracking software), ill update you when i get it tested