Shop OBEX P1 Docs P2 Docs Learn Events
HM55B Compass Interface — Parallax Forums

HM55B Compass Interface

JRod1JRod1 Posts: 7
edited 2009-02-06 16:34 in Propeller 1
Hello Everyone,

This tiny little compass is kicking my butt. Either I'm missing something really obvious or this compass is defective (possible, but not probable). Here's what I've done so far.

Hardware:

1. Powered by 5 volts from the· usb prop board.
2. Continuity checked for ALL connections
3. Oscilliscope used to confirm that at least there is some activity (waveforms) on the clock, enable and data pins, although I don't have enough enough channels to determine timing. I will say that the waveform·at the data pins isn't a great looking squarewave. The rising edge looks good but the falling edge looks more like the discharge curve from and RC network.
4. Data in to the compass is wired to pin 20 of prop, Data out from the compass is wired to pin 20 through a 1K resistor

Software

I have attached a copy of my test spin code. I am transmitting debug data to a host PC. All I'm getting are zeroes. So, I downloaded a trial copy of Hanno's Viewport program and used it to monitor more variables. All variables have a value of zero at all times. Some of you will notice a variable called loop that is declared but not used. Orginally I used it as a loop counter in my repeat loop just to confirm that the loop was executing. It was and Viewport very nicely showed the value of loop incrementing. However deg and heading variables remained at zero.

At this point, I don't even care if I've made a very stupid, embarrassing mistake. I'll gladly be publicly humiliated so long as I get this to work.

Thanks,

Jonathan

Comments

  • Mike GreenMike Green Posts: 23,101
    edited 2009-02-05 15:53
    1) There won't be valid data from the HM55B driver for a millisecond or so. That wouldn't explain your problem, but you do need a delay after the start call.

    2) The fuzzy edges of the waveforms may be as much a factor of the oscilloscope as the devices under test. The Propeller switches very quickly and I'm sure there's some extra capacitance and resistance in the wiring and the 'scope leads.

    3) I don't see anything in your code that would explain what you're seeing. Are you sure you've connected things properly, not mixed up the clock and chip select pins?
  • Beau SchwabeBeau Schwabe Posts: 6,568
    edited 2009-02-05 16:20
    JRod1

    Please visit the Object Exchange and make sure that you have the latest version of the Compass object (v1.2)

    http://obex.parallax.com/objects/48/



    I ran your code with a few pin modifications to point to my equipment and the code works fine.· The only object that I omitted was your conduit object, because I didn't have that one, but the serial data reported back to the debug terminal was correct.

    Are you sure that your TX and RX are not swapped?· That's a common mistake that I make.


    I have attached the latest Compass object with the pin modifications I made on my end, so you can see exactly what I was running.






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

    IC Layout Engineer
    Parallax, Inc.

    Post Edited (Beau Schwabe (Parallax)) : 2/5/2009 4:26:38 PM GMT
  • JRod1JRod1 Posts: 7
    edited 2009-02-06 12:40
    Thanks for the speedy replies.

    I have success! But not for the reasons you might think.

    Beau - I am using the latest version of the object. I am new to prop programming so I appreciate·you··testing my code.

    Mike - good advice. I checked my wiring ·AGAIN for the millionth time. Still OK smile.gif .· I reduced the clock speed to 40 Mhz

    _CLKMODE = XTAL1 + PLL8X
    · _XINFREQ = 5_000_000


    and I started getting data, and the data looks valid (ie. I get· deg= 68. I rotate the compass 90 degress and I get a value of 130). This was unexpected and I can only think that it's the length of my wiring that may be contrubuting to this phenomenon. The total length of cable from the prop pins to the compass is 24 inches because I have the compass mounted on· a wooden dowel to move it away from motors and the metal chasis.

    Finally I have a question about your experiences with accuracy. With the compass stationary and repeated polling , I can get return values that range from 68-71 with an occasional 61 measurement. When I rotate the compass 90 degrees I don't get 68+90, I get a reading of about 133. Now I don't care if the compass is calibrated to match a traditional compass. It's not important for me to know if the robot is truely moving N, S, E, or W. What is important is for me to know if the robot has made a 90 degree turn, a 45, a 180, etc. I thought that the calibration techniques were designed to match up the digital compass with a traditional magnetic compass. Am I wrong? Will calibration help me?

    Thanks very much for sharing you insights and experiences. I have spent hours reading the posts in this forum and as a result, I have had many questions answered without having to post anything.
  • Beau SchwabeBeau Schwabe Posts: 6,568
    edited 2009-02-06 16:34
    JRod1,

    In my experiences, it is normal to have that much error with the compass module.· Calibration can help tremendously.· I have attached a Compass Calibration program that will hook into your existing program without adding an additional cog, just simply adds a feature set to calibrate the compass with.· I have also re-attached your program with the added compass calibration code.



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

    IC Layout Engineer
    Parallax, Inc.
Sign In or Register to comment.