HM55B Parallax Compass

Hello all

I just got the compass and i'm trying to get it work with my arduinoBT.
I run the scetch on the playground ( Arduino Playground - HM55B ) and the compass seems to work fine, but when I try to face North (near 0 degrees) it doesnt work as expected.

The scetch is supposed to provide the degrees from 0 - 180 and -180 - 0. Total of 360 degrees.

I took a measurement from the compass. 120 degrees. When i rotated it by 180 degrees the next value was -120 degrees (60 degrees gap?)

i chanced the scetch like another guy did in the forum

if (angle < 0){
angle = 360 + angle;
  }

to get the degrees from 0 - 360.

When my compass is at 30 degrees and i rotate it a little bit to the North the next value it shows is 0 and the compass goes crazy. (0 - 30 random values). Same happens when the compass is at 330 degrees and I rotate it closer to North, just a little bit. Next values shown on the serial monitor are 0 - 330 degrees. There seems to be a 60 degrees gap in my measurements.

Does anyone have a clue why this is happening? Do electronic devices affect the compass when they are near it? I've also tested the compass in the balcony with the same results.

bump :-[

The compass will be affected by metal objects or magnetic fields caused by currents flowing in conductors, though to what degree (no pun intended) it is difficult to say.
Try to isolate the sensor from all other influences.
Can you maybe post your sketch?

I doubt that isolating the compass from any magnetic influences will work for me, as the project im working on is an autonomous robot, which includes batteries, wires, motors, which all probably affect the compass performance.

the sketch is in the playground: Arduino Playground - HM55B

from what i read in the compass documantation theres some kind of calibration need to be done for the compass in order to work correctly.

This calibration is done by running 2 programs that come with the compass. The problem is that the programs are writen in the language for the parallax microcontrollers, so i guess i'll have to convert them to c++ for the arduino :frowning:

I'll first need to understand how exactly this calibration is done. I'll come back for further help and questions.

doubt that isolating the compass from any magnetic influences will work for me,

Well without it the compass will not work for you either.

That's what it measures magnetic field. You go an distort the Earth's field with lumps of metal or generate new fields with motors it will measure that instead.

Alright, i tried my compass away from the vehicle, motors, breadboard etc.
It seems to work better when all those stuff that might cause a magnetic field are moved away.

Is my next step to mount the compass on the vehicle (to be near all those things that might affect it) and calibrate it?

Sadly, motors are bad news - you may calibrate it whilst it is static, but once those spinning fields start operating, phut! goes your calibration.

So which are my options? Do you suggest that i should place the compass as far as possible from all the these things that might affect it?

I could modify my vehicle and place the compass lets say 20-30 cms away from the motors. How can i measure the distance that the compass wont be affected from magnetic interferences?

That's a really difficult question.
It depends on the size and types of your motors.
Trial-and-error - try separating your motors and sensor, and get some idea of stability of magnetometer readings with and without the motors running at different speeds and directions at different distances.

I'm not sure if mu-metal is readily available, but that's what used to be used to shield CRTs in older oscilloscopes - could try some around the motors.

I'm not sure if mu-metal is readily available

Yes you can get it in thin laminated sheets that you can cut with scissors. I used some at work a few months ago, the youngsters had never come across it before. It was to shield magnetic emissions from a power supply for a sensitive digital demodulator. It was very successful.

Google around for it but I paid about $20 for an A4 sheet.

Ah! Mike's input has reminded me - did you decouple adequately?

Well it's on a break out board so there are some caps on it already. A few more wouldn't go amiss. Especially on the motors. The usual site:-
http://www.thebox.myzen.co.uk/Tutorial/De-coupling.html

Do you suggest that i should try MU metal on the battery and the motors?

Not the battery there is no field from that but it could help with the motors.