Shop OBEX P1 Docs P2 Docs Learn Events
Anybody who has ever equiped your Activitybot with the compass module ? — Parallax Forums

Anybody who has ever equiped your Activitybot with the compass module ?

JarvanJarvan Posts: 31
edited 2013-12-02 15:12 in Learn with BlocklyProp
I tried to utilize a compass module to adjust the direction that my Activiybot moves forward to. but the it seems that module didn't work well indoor.
And I tested the compass moudle with the example code indoor and I got the data below.
compass.jpg
595 x 485 - 39K

Comments

  • Duane DegnDuane Degn Posts: 10,588
    edited 2013-11-30 20:17
    Is north in your diagram true north of magnetic north?

    Either way, it's not uncommon for a compass not to align precisely with magnetic north. You just add a correction factor to your code to compensate for the difference.

    Which compass module are you using? The HMC5883L?
  • ercoerco Posts: 20,256
    edited 2013-11-30 20:55
    Duane Degn wrote: »
    Either way, it's not uncommon for a compass not to align precisely with magnetic north. You just add a correction factor to your code to compensate for the difference.

    +1. See http://en.wikipedia.org/wiki/Magnetic_declination

    That drawing looks a LOT like yours. :)
  • JarvanJarvan Posts: 31
    edited 2013-11-30 21:01
    Hi Duane,
    Yes, it's HMC5883L.
    The north in diagram is turn north. but it has nothing to do with the true north or magnetic north.
    Note the range between 0 degrees to 180 degrees. it should be a half , right ?
  • edited 2013-11-30 22:55
    Hi Jarvan,

    This is typically caused by a magnetic field that is close to the sensor. It could be in many places, just a few examples include: the compass printed circuit board, carrier board, breadboard, iron bars in a concrete foundation, and metal reinforcements in your prototyping table.

    Mounting the sensor 25 cm above the robot sometimes helps, but not always. Another technique is software calibration, which can be very effective. We have a library in development that has a calibration routine and procedure. It still has some bugs though. I will try to fix the bug, and also contact you offline to find out if you are interested in testing it.

    Andy
  • ajwardajward Posts: 1,130
    edited 2013-12-01 02:19
    Jarvan wrote: »
    Hi Duane,
    Yes, it's HMC5883L.
    The north in diagram is turn north. but it has nothing to do with the true north or magnetic north.
    Note the range between 0 degrees to 180 degrees. it should be a half , right ?

    That is an odd data set for a compass, far outside what would be expected for magnetic declination. I would take the 'bot outside, move the module as far away the chassis as possible and recheck the output.

    Amanda
  • JarvanJarvan Posts: 31
    edited 2013-12-01 05:28
    ajward wrote: »
    That is an odd data set for a compass, far outside what would be expected for magnetic declination. I would take the 'bot outside, move the module as far away the chassis as possible and recheck the output.

    Amanda

    I got the odd data both in the office and at home, in order to make a comparision , I run the compass app , I find it's also odd. then I took my cellphone outside, and the data became normal. I wonder whether the compass module can work normally indoors.

    Jarvan
  • Duane DegnDuane Degn Posts: 10,588
    edited 2013-12-01 08:27
    Jarvan wrote: »
    Hi Duane,
    Yes, it's HMC5883L.
    The north in diagram is turn north. but it has nothing to do with the true north or magnetic north.
    Note the range between 0 degrees to 180 degrees. it should be a half , right ?

    Sorry, I didn't look closely at the numbers. You're right it sure looks strange.

    To go with what Andy said, have you looked at the magnitude of the raw vector? It should tell you if the magnetic field is stronger than normal and how strong it is.

    It might also be a good idea to display how far from horizontal the magnetic field is.

    I've recently been playing with the HMC5883L (in Spin) and I used the ATan2 method in F32 to compute this angle. I first found the length of the xy vector and then used "theta := F32.ATan2(zVector, xyVector)" to figure out how far from horizontal the field was. Up here in Idaho I'm getting about -53.6 degrees from horizontal.

    I think by monitoring both the strength of the field and the direction (including vertical component) you could get a better idea when there's an interference source nearby.
  • edited 2013-12-01 12:24
    Pages 5...7 in this document explain the problem and show how to correct it:

    http://www.parallax.com/sites/default/files/downloads/29133-Compass-Module-Application-Note-2.pdf

    Andy

    P.S. After correcting for interference, a constant value can also be added to the heading align it with either magnetic or true north.
  • edited 2013-12-02 15:12
    Jarvan,

    On closer inspection of your plot from post #1, well, that's some pretty significant field distortion.

    Could you please post the code you used gather the data for your plot in post #1?

    Also, if you are using a mechanical compass as a reference, are you keeping it well away from the bot when you take your test measurements?

    Thanks, Andy
Sign In or Register to comment.