Page 2 of 2
Re: NXC: how to calibrate the HT Compass sensor?
Posted: 08 Jul 2011, 21:55
by afanofosc
From the HiTechnic page for this device:
The HiTechnic compass sensor will only operate correctly in a horizontal plane so you must keep the compass level for it to read correctly. This is very important so remember this when you build it into your robot.
I've attached a compass calibration program that I got from HiTechnic (written in NXC):
John Hansen
Re: NXC: how to calibrate the HT Compass sensor?
Posted: 08 Jul 2011, 22:04
by HaWe
thank you John, it's the same program published above, and it's working fine!
jasonlh, nice video, rather impressive! :)
Re: NXC: how to calibrate the HT Compass sensor?
Posted: 08 Jul 2011, 22:12
by aswin0
Compasses are very sensitive to tilt. How sensitive depends on the location on earth and the position in relation to magnetic north. The reason for this is that the magnetic north is a spot in a 3D space (below the surface of the earth). An electronic compass uses two, or three, perpendicular sensors that measure magnetic force. (That is why they are called magnetometers). North is determined by taking the arctangens of these forces. When you rotate the compass the force on each of the sensors change and so does the arctangens. Tilting the compass is the same as rotating the compass, only the axis of rotation is different, the effect on the sensor is the same.
So, if you have a robot that is free to tilt, or when the environment can cause a tilt, you have a problem using a simple electronic compass. The only way to overcome this is to use a compass that measures magnetic force over three axes and an accelerometer that can give tilt info over three axis. You then need to use tilt info to convert magnetic force readings to the earth frame of reference. Only then you can use arctangens to calculate heading. Some of the more expensive electronic compasses have a built in accelerometer for this reason.
Re: NXC: how to calibrate the HT Compass sensor?
Posted: 08 Jul 2011, 23:31
by nxtreme
For those of you wanting accurate compass readings regardless of tilt, SparkFun Electronics just released a
three axis magnetometer broken out for $15 US. Sure, it requires a bit of hacking as it's not directly plug and play with the NXT, but it is cheap as far as magnetometers go!
Re: NXC: how to calibrate the HT Compass sensor?
Posted: 08 Jul 2011, 23:41
by HaWe
build me a NXT-plugable one, please, and sell it to me, if you please! ^^
Re: NXC: how to calibrate the HT Compass sensor?
Posted: 08 Jul 2011, 23:56
by mattallen37
I am quite sure it is a raw device, so you would need to do
all the calculations on the NXT (no automatic "heading" output).
I think you want something more like
this one. It should be fairly easy to get it working with the NXT. The only HW you probably need is a cut NXT wire and a couple resistors.
Re: NXC: how to calibrate the HT Compass sensor?
Posted: 09 Jul 2011, 00:01
by mattallen37
Here is another related item. It is a triple axis magnetic sensor combined with a triple axis accelerometer. You would still need to do all the calculations on the NXT, but it would take care of the need for an accel sensor.
Re: NXC: how to calibrate the HT Compass sensor?
Posted: 09 Jul 2011, 00:32
by nxtreme
doc-helmut wrote:build me a NXT-plugable one, please, and sell it to me, if you please! ^^
I've actually contemplated that very thing many, many times. Creating NXTified breakout boards for sensors exactly like this one*. However, I don't have the time and I don't live in a country that ships cheaply or nicely. In fact, one book seller once said that the country I live in is the absolute worst when it comes to shipping. I'll keep it in mind though and if I ever can, I will.
mattallen37 wrote:I am quite sure it is a raw device, so you would need to do
all the calculations on the NXT (no automatic "heading" output).
I think you want something more like
this one. It should be fairly easy to get it working with the NXT. The only HW you probably need is a cut NXT wire and a couple resistors.
That's the point of having an ARM processor under the hood, isn't it? 48MHz should be more than enough to do the calculations on board, even if the code is running in a VM! And the compass you linked to is ten times the cost...
*In fact, that'd be my dream job. Not a great paying one, but money's not everything anyways...
Re: NXC: how to calibrate the HT Compass sensor?
Posted: 09 Jul 2011, 01:51
by mattallen37
nxtreme wrote:mattallen37 wrote:I am quite sure it is a raw device, so you would need to do
all the calculations on the NXT (no automatic "heading" output).
I think you want something more like
this one. It should be fairly easy to get it working with the NXT. The only HW you probably need is a cut NXT wire and a couple resistors.
That's the point of having an ARM processor under the hood, isn't it? 48MHz should be more than enough to do the calculations on board, even if the code is running in a VM! And the compass you linked to is ten times the cost...
Oh, indeed I know that, and I have no doubt it could do an excellent job at that. What I would be much more concerned about though, is writing the right code, and making it work like it should.
Yes I did see the price, but I meant that more as a reference.
Re: NXC: how to calibrate the HT Compass sensor?
Posted: 09 Jul 2011, 03:05
by nxtreme
Yes, I do understand how the price could be worth it to some people. Maybe even doc, who appears to be anemic to writing I2C functions (no offense intended!), would prefer a "fully cooked" compass module. Now, if someone would just buy me a house in Canada, a hotplate (for reflowing boards) and Eagle license, doc would have his board in three weeks!