Shop OBEX P1 Docs P2 Docs Learn Events
Hitachi Compass accuracy issues? — Parallax Forums

Hitachi Compass accuracy issues?

Steve AustinSteve Austin Posts: 4
edited 2009-02-18 00:23 in Accessories
Hi. I got my Parallax-Hitachi compass working, and·am calibrating it according to the instructions, but wow, does it vary. Even while sitting absolutely still, it can vary up to 6 degrees in either direction.

Even if the calibration isn't spot-on, I would think it should stay fairly consistent sitting in the exact same position. I've tried it in a few positions around the room, just in case something in my PC, or a lamp, or ???? was interfering.

Has anybody else experienced a similar issue?

Thaks,
Steve

Comments

  • Beau SchwabeBeau Schwabe Posts: 6,566
    edited 2009-02-16 06:12
    Steve Austin,

    Even after calibration, the compass resolution is only 6-bits (or 64 positions)... that translates to roughly 5.6 Deg of resolution. ( 360 / 64 = 5.625 )
    Although the Compass documentation indicates an 11-bit resolution, I believe the 6-Bits is a result of using the ATN command within the PBASIC language.
    Using a math co processor or Propeller Chip would allow you to increase the resolution because the ATN (arctangent) could be carried out with greater precision.




    Reference:
    www.parallax.com/Store/Sensors/CompassGPS/tabid/173/CategoryID/48/List/0/Level/a/ProductID/98/Default.aspx?SortField=ProductName%2cProductName
    www.parallax.com/Store/Microcontrollers/BASICStampModules/tabid/134/txtSearch/Math/List/1/ProductID/244/Default.aspx?SortField=ProductName%2cProductName

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    Beau Schwabe

    IC Layout Engineer
    Parallax, Inc.

    Post Edited (Beau Schwabe (Parallax)) : 2/16/2009 6:18:13 AM GMT
  • Steve AustinSteve Austin Posts: 4
    edited 2009-02-16 14:15
    Beau:

    Thanks. That's a good point. I'll take that advice and put something else together for the atan calculation.

    But I also logged the raw 11-bit X and Y coordinates, three times in each of the 8 main directions, keeping it perfectly still, and although·the X coordinate stayed within 1 or 2 of some value, the Y coordinate varied by about 8 (this was true regardless of the direction). Maybe that's just the way this thing works.

    So even with a very accurate atan function, the raw X/Y input would send the values wildly off. I didn't expect perfection, of course,·but it doesn't seem very usable for robotic navigation, since it would constantly be overcorrecting to keep a reasonably straight course.

    Thanks for the suggestion.
    Steve
  • Beau SchwabeBeau Schwabe Posts: 6,566
    edited 2009-02-16 15:53
    Steve Austin,

    How clean is your power supply?, and what voltage are you supplying to the Hitachi Compass? .... Some amount of noise is expected in the lower LSB, you might be able to clean some of that noise up with a decoupling capacitor across the power pins of the compass.

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    Beau Schwabe

    IC Layout Engineer
    Parallax, Inc.
  • Steve AustinSteve Austin Posts: 4
    edited 2009-02-16 17:32
    Hmm. I don't know. Actually, I'm running this off an Arduino board (using the Vin source), and I'm following the Stamp documentation for calibration and testing. I do have a BOE too, so I'll test the X/Y accuracy on that as well. I did run the compass on the BOE at first, just to make sure it worked, but I didn't take note of the accuracy during that test. I didn't finish the calibration setup on the BOE, because I'll need the calibration for my robot's chip, which is the Arduino, and I figured it would be best to run the test on the platform I'll be using.

    I'm using the Arduino for my robot, because although I love the convenience of the programming on the Stamp, the chip it uses is pretty limited in memory, and I'd really have to add an external RAM to do all I need to do. I know - why don't you guys port the Stamp code to an AVR? Say, a Mega 168 or 328? [noparse]:)[/noparse] That'd be fantastic! Ah well, if not, I'm still a loyal Parallax customer. I love what Parallax offers, especially in terms of education.

    Anyway, I'll take the compass back to the BOE, and log the X/Y's over there too. And if that's still wacky, then I'll try a capacitor. What value would you recommend?

    Thanks, Beau.
    Steve
  • Beau SchwabeBeau Schwabe Posts: 6,566
    edited 2009-02-16 18:50
    Steve Austin,

    In most cases a .1uF or so directly across the power leads in close proximity to the Compass will be enough.· If your leads are long to the compass this will also compound any noise issues.· It is also possible that the compass can pickup·noise from the processor itself, orientation to other components as well as other forms of external noise can be as much of an issue with any compass.

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    Beau Schwabe

    IC Layout Engineer
    Parallax, Inc.
  • SRLMSRLM Posts: 5,045
    edited 2009-02-16 20:15
    You can always add a filter of some kind. See the following thread for some ideas:

    http://forums.parallax.com/showthread.php?p=759589
  • Beau SchwabeBeau Schwabe Posts: 6,566
    edited 2009-02-17 17:04
    Steve Austin,
    ·
    As SRLM·suggest, you can add a software filter to help smooth things out, but as you are probably aware, this will not increase your resolution.
    ·
    I mentioned earlier, that·it is normal to have some degree of noise in the·lower LSB's... that applies to each channel.· So assuming you start out with 11 bits of resolution, and the lower 2 bits are noise you effectively have 9 bits of·accuracy.· That's per channel, when you combine the channels whether multiplying or dividing, you compound the error, so now you would have 4 bits of noise.· Thus making the 11-bits effectively only having 7-bits of accuracy.
    ·
    For absolute best results, I would consider a heavily filtered power supply to the compass, and shielding the processor or any other circuit components susceptible to producing noise, but do not shield·the compass in any way.
    ·

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    Beau Schwabe

    IC Layout Engineer
    Parallax, Inc.
  • SRLMSRLM Posts: 5,045
    edited 2009-02-18 00:23
    Beau said...
    and shielding the processor or any other circuit components susceptible to producing noise, but do not shield the compass in any way.


    Ha! I have a thread on that too... [noparse]:)[/noparse]

    http://forums.parallax.com/showthread.php?p=742053
Sign In or Register to comment.