Page 1 of 2

Compass Sensor

Posted: 21 Dec 2010, 16:19
by andrea-povo-uni
Hi, everybody.
I have a question about the compass sensor of nxt.
How can I calibrate it with Bricxcc? I've found only the function SensorHTCompass that read the current value of the sensor.
I've read on the web that I've to calibrate the sensor before using but I don't find a way to do it for nxc.

Thank you for the attention.

Re: Compass Sensor

Posted: 21 Dec 2010, 16:28
by hassenplug
I'm not sure the process, but yes, I'm pretty sure it's possible with NXC.

Steve

Re: Compass Sensor

Posted: 21 Dec 2010, 16:57
by andrea-povo-uni
I want to use the sensor to check the orientation of my nxt.
I need this information to identify the position of an object revealed by the sensor Ultrasounds. Then I can also use it to better checking the rotations of my Nxt.
I've tried to use the SensorHTCompass function but there isn't a complete correspondence between the value measured and the orientation of my nxt...

Re: Compass Sensor

Posted: 21 Dec 2010, 18:21
by hassenplug
Make sure the sensor is not too close to the NXT, or the motors.

Steve

Re: Compass Sensor

Posted: 22 Dec 2010, 08:41
by andrea-povo-uni
I've already tried to keep my compass sensor away from the brick with similar results.

Re: Compass Sensor

Posted: 22 Dec 2010, 09:51
by gloomyandy
Hi,
To calibrate the sensor you put it into calibration mode (no idea how to do this with NXC), and then rotate the sensor at a moderate speed for two full rotations, then exit calibration mode. The compass sensor can be hard to use. You tend to get disturbances from the robot motors (mount it as high as possible, often on a mast above the robot), but you can also get things like steel in your building causing problems.... Try it in different locations etc. to se if you are having problems with this...

Andy

Re: Compass Sensor

Posted: 22 Dec 2010, 18:05
by andrea-povo-uni
Hi again,
I installed the Lego Mindstorm NXT v.1.1.
I imported the compass block (I found it at http://www.hitechnic.com/cgi-bin/commer ... ey=NMC1034). But I cannot use the "calibrate" actions, it is simply in gray and I cannot select it! Does anyone know how to active the calibration actions?

Thanks a lot for the answer!

Re: Compass Sensor

Posted: 22 Dec 2010, 20:22
by loopymech
I tried the NXT-G block from HT and I see the same grayed-out selection from the Action drop-down; looks like you might have to use the data hub...

This is from the help that came with the NXT-G block (Help_Compass Sensor.htm):

"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."

Hope that helps!

-Loopymech

Re: Compass Sensor

Posted: 22 Dec 2010, 20:51
by mattallen37
Open a new program and drag the block into it. Go to the block settings panel, and in the "port" line, all the way to the right, there is a triangle. Click on that. Then on the left, there is a check box "MUX -> sensor" Check that, then uncheck it. Again, click on the triangle on the right, and you should have the calibrate option.

Don't ask me why you need to do that for it to work, or how I somehow figured it out, I have no idea.

Re: Compass Sensor

Posted: 22 Dec 2010, 20:58
by mattallen37
Oh, and you CAN calibrate it in NXC. On the product page, it says this.
Locn 0x41 is the mode control. Defaults to 0, which is measurement mode. Change to 0x43 to set calibration mode. Must be changed back to 0 when calibration is completed. (If cal. fails, locn. 0x41 will be set to 2 after the host has set it to 0 at the end of the failed calibrate attempt.)
I would have replaced the term "Locn" with "register", but whatever.