Shop OBEX P1 Docs P2 Docs Learn Events
Problem with Compass HMC5883L on BS2 — Parallax Forums

Problem with Compass HMC5883L on BS2

MCAMCA Posts: 13
edited 2013-10-30 13:51 in BASIC Stamp
Hi!

I’ve connected a HMC5883L compass to my BS2 using the setup and program code found at the of the kickstart-page, http://learn.parallax.com/KickStart/29133.

I was expecting to have compass readings, but what happens is that the values of x, y, and z are only jumping between about -10 to -30, 0 to -10 and 5 to 15 respectively no matter how I turn the compass.

I even brought it outside. The only interference would come from the laptop, I guess, and even though there were some disturbance I think I should be able to get reasonable values, that at least would change with direction.

My setup is attached on picture, as well as the typical debug window output.

Happy if someone can help!
bs2 compass.jpg
DSC_0073.jpg


BR, Adam
916 x 222 - 19K
1024 x 768 - 128K

Comments

  • banjobanjo Posts: 443
    edited 2013-06-26 09:46
    Hi, i don't have the sensor myself but when looking at the documentation it looks like the BS2 demo software is only showing raw values. The prop software also shows headings. Perhaps someone else jumps in to help further with this.

    From the documentation:
    "The HMC5883L_demo.bs2 program reads raw X,Y,Z values from the Compass Module using the default I2C interface, and displays the values in the BASIC Stamp Editor’s Debug Terminal. The software is a free download from www.parallax.com/basicstampsoftware."
  • MCAMCA Posts: 13
    edited 2013-06-26 13:00
    You're on to something there, banjo! Thanks for the hint. Now to figure out how to do the conversion from "The value stored in these two registers is a 16-bit value in 2’s complement form, whose range is 0xF800 to 0x07FF "...
  • MCAMCA Posts: 13
    edited 2013-07-01 13:36
    I have read up a Little about two's complement and other stuff, but actually I am no less confused. From what I can tell (without digging into I2C), the conversion in the program to SDEC should give the raw output from the compass. And whatever that is in terms of numbers it should be a large interval, right? Then it can be scaled down to the application. What I get is at most an interval of about DEC 30 on one of the axis (and that does not even correspond to any rotation, just changing seemingly randomly for each measurement).
    Something is above my head here... any other pointers, plz!? BR / Adam
  • MCAMCA Posts: 13
    edited 2013-10-30 13:51
    I got the company where I bought it (lawicel-shop.se) to send me a new one as it seemed to be defective; and the happy news is now it's working perfectly with the new one!

    BR Adam
Sign In or Register to comment.