NXC: how to calibrate the HT Compass sensor?

Discussion specific to the intelligent brick, sensors, motors, and more.
HaWe
Posts: 2500
Joined: 04 Nov 2014, 19:00

NXC: how to calibrate the HT Compass sensor?

Post by HaWe »

hi,
I just tested my new platform by odometry, HTgyro, and HTcompass, and all are fine - except the compass (real weird values, such as +/- 45°-60° although turned +/- 90°).
It was long time out of use, so I guess it has to be recalibrated (last time I used it - about 4 years ago - it it was quite ok).

Does anybody know how the calibration has to be done by NXC?
jasonlh
Posts: 7
Joined: 12 May 2011, 05:39

Re: NXC: how to calibrate the HT Compass sensor?

Post by jasonlh »

From the HiTechnic page http://www.hitechnic.com/cgi-bin/commer ... ey=NMC1034
Calibrating the Compass Sensor

The HiTechnic compass sensor will be influenced by local magnetic interference in the same way as any other magnetic compass. Objects such as metal items, motors, batteries and wires can cause magnetic interference. Local magnetic interference may cause the compass to output a heading several degrees different than the actual magnetic heading. This is called compass deviation. To correct for deviation, the HiTechnic compass sensor has a built in calibration function that calculates correction offsets and stores them in the compass.

Calibration is optional and usually not required for normal operation. To minimize the need for calibration make sure you mount the compass at least 4 – 6 inches (10 – 15 cm) away from the NXT and NXT motors.

To calibrate the compass under program control, select calibration mode (value 2 wired to the Action plug input) and then program your robot to rotate (turn in a tight circle) between 1 ½ and 2 times (more than 360 degrees) so it completes a full turn in about 20 seconds. Once the turns have been completed, set the Action to a Read function (Absolute or Relative) and the compass will be calibrated. The compass will retain the calibration settings until another calibration is performed, even if it is unplugged.
Or if you use mightor's driver suite, he has that added for you.


However, I just got my compass, and was also noticing some odd readings while testing it out. I finally figured out that it's very sensitive to it's horizontal attitude. In other words, I could hold it steady at a constant bearing, but the value would change if I rotated the sensor up or down from horizontal. I haven't seen anyone else comment on this so I'm not sure if it's just mine or a common issue. I could understand the value changing a bit if I tilted the compass a lot, but I'm just talking a few degrees here. I'd think once I put this on a moving robot, just normal jostling around as the robot drove would cause this same error. Could this possible be part of your problem too?

Thanks,
Jason
HaWe
Posts: 2500
Joined: 04 Nov 2014, 19:00

Re: NXC: how to calibrate the HT Compass sensor?

Post by HaWe »

it's really a compass issue, nothing else (some years ago it worked rather sufficiently at least outside the house in the garden, but as time goes by...).
(Maybe refer to the Gyro noise thread where I decribed both readings.)

All electrical and ferromagnetical parts are more than 20 cm away from the compass (and no motors are running during compass test readings).
The compass is mounted 100% horizontally. Of course, maybe the HT compass is meanwhile defective although not in use for several years.

As it's a NXC question, and because (re-)calibration shall become an integral part of my navigator robot I would need NXC code - have you or anyone got one?
aswin0
Posts: 201
Joined: 29 Sep 2010, 06:58

Re: NXC: how to calibrate the HT Compass sensor?

Post by aswin0 »

Doc,

Some compasses need to be degaussed from time to time. I don't think the HT sensor has a degaussing method.
Anyway, here is a paper describing a calibration algorhithm, just in case you do not want to use the on board method.
My blog: nxttime.wordpress.com
HaWe
Posts: 2500
Joined: 04 Nov 2014, 19:00

Re: NXC: how to calibrate the HT Compass sensor?

Post by HaWe »

I can't write code for i2c devices.
jasonlh
Posts: 7
Joined: 12 May 2011, 05:39

Re: NXC: how to calibrate the HT Compass sensor?

Post by jasonlh »

Check the bottom of this thread for some NXC code to calibrate your compass. Hope it helps!

http://sourceforge.net/apps/phpbb/mindb ... 96292a8673
HaWe
Posts: 2500
Joined: 04 Nov 2014, 19:00

Re: NXC: how to calibrate the HT Compass sensor?

Post by HaWe »

very kind, thx a lot! I'll check it immediately!
mattallen37
Posts: 1818
Joined: 02 Oct 2010, 02:19
Location: Michigan USA
Contact:

Re: NXC: how to calibrate the HT Compass sensor?

Post by mattallen37 »

doc-helmut wrote:I can't write code for i2c devices.
Surely you can learn to write I2C related code. If you want, I'll share my I2C library with you. It's a general purpose I2C library, and you may learn a thing or two from examining it (or use it as it is). It doesn't have special purpose functions, just general sensor read and write abilities.
Matt
http://mattallen37.wordpress.com/

I'm all for gun control... that's why I use both hands when shooting ;)
HaWe
Posts: 2500
Joined: 04 Nov 2014, 19:00

Re: NXC: how to calibrate the HT Compass sensor?

Post by HaWe »

matt,
I'll glady contact you if I'll have again a problem like that.

jasonlh,
the calibration worked! At least for outdoors. "North" is indicated correctly outdoors.
Unfortunately is shows that a compass is often not suitable for indoors:
As I know exactly where direction "North" is, indoors the compass indicates "North" where actually NorthWest is.
Also the relative bearings still have a big deviation.
Not very well for my indoors navigation. :(
jasonlh
Posts: 7
Joined: 12 May 2011, 05:39

Re: NXC: how to calibrate the HT Compass sensor?

Post by jasonlh »

Glad that helped. Now I'm curious how much the error I was seeing was due to being inside my house too? I'll have to play a bit more with it this weekend.

When inside, maybe you could use a "compass" like this!


(I thought you might like this after reading some of your posts about odometry).

Slightly off topic, but I can't find any old posts about how sensitive the compass is to tilt? Does anyone know a good link discussing this? I guess I just don't understand how the solid state compass works, but I can't wrap my mind around why a little tilt would be such a big deal? I also got a GPS sensor and was going to use in conjunction with the compass to navigate around my neighborhood. Do I also need to use an accelerometer to determine if the robot is level when using the compass? What do I do if I need to travel up or down a slight hill, is the error linear to the tilt?

Thanks!
Jason
Post Reply

Who is online

Users browsing this forum: No registered users and 7 guests