+ Reply to Thread
Results 1 to 16 of 16

Thread: Can't get HMC5883L Compass to work in spin - works in bs2

  1. #1

    Default Can't get HMC5883L Compass to work in spin - works in bs2

    I am trying to get the HMC5883L Compass working for an AZ drive system. Using the spin demo code from:

    https://sites.google.com/site/parall...-axis-hmc5883l

    It works fine except the Y axis reading is always -4096 which is an overflow or underflow or math error. HOWEVER, if I run the bs2 code from that page it works fine - no Y axis error.

    The same is true for the programs listed on the HMC5883L part page. Can anyone tell me why the spin code gives an error and the bs2 code doesn't?

  2. #2

    Default Re: Can't get HMC5883L Compass to work in spin - works in bs2

    You may have copied the demo code incorrectly. I just hooked up an HMC5883L as shown on the demo code page, copied and pasted the demo program from the demo code page, and compiled and ran it with correct results. Note that the math engine isn't needed and the OBJ line for it can be commented out. I used BST and its terminal window rather than the Propeller Tool and the Propeller Serial Terminal since I'm using a Mac.

  3. #3

    Default Re: Can't get HMC5883L Compass to work in spin - works in bs2

    Yes, it works with BST but not with the Propeller Tool and the Propeller Serial Terminal. But I need it working with the Propeller.

    I have still been playing with the propeller demo code - I added some print binary on the x, y, & z variables. Y raw is always 1111 0000 0000 0000. I changed the clock speed to see if I am reading to fast or slow no change.

  4. #4

    Default Re: Can't get HMC5883L Compass to work in spin - works in bs2

    I booted up my Windows XP under Parallels Desktop on the Mac, ran the Propeller Tool and PST and the compass works just as well as with the Mac BST. The only thing different from your setup is that I still commented out the reference to "SL32_INTEngine_2" because it's not used. Maybe later I'll try it with that OBJ reference in there.

  5. #5

    Default Re: Can't get HMC5883L Compass to work in spin - works in bs2

    I don't know exactly what the problem is, but I got mine working this way:
    Part 1:
    http://tymkrs.tumblr.com/post/222373...hmc5883l-29133
    Part 2:
    http://tymkrs.tumblr.com/post/222588...83l-29133-part

    And I believe I did use the demo code. I might have altered it slightly just to get rid of some extraneous spaces... but I used it in PropTool and PST.
    Whisker is a hardware and wetware hacker, and produces geeky content on a daily basis. Atdiy is a cardiovascular nurse by day and an electronics n00b at night. Together we're the Toymakers (Tymkrs) and we post videos/blogs on electronics, DIY projects, and whatever else we happen upon! Visit us at http://tymkrs.com, http://zombietech.tv, and http://firstspin.tv! Our projects are on http://tymkrs.com/forum and you can chat with us daily at #tymkrs!

  6. #6

    Default Re: Can't get HMC5883L Compass to work in spin - works in bs2

    I tried the commenting out the SL32_INTEngine_2 and still no joy. I have cut and paste the program several times, no joy. I tried the program from the product page "HMC5883L_demo.spin" - no joy.

    I understand how the program works and I see no errors. It is interesting that the Y axis is read out last - the X and Z axis do work. It's almost like the last read is having a problem. I even modified the program to only read the Y axis with no success. Yet the BS2 program works fine.

    Are you running at 80MHz?? Is it possible, I have a module on the edge so that the propeller fails yet the BS2 works?

  7. #7

    Default Re: Can't get HMC5883L Compass to work in spin - works in bs2

    You might want to ensure you're using the latest Propeller Tool (latest is v1.3; be careful as some searches for the Propeller downloads page result in an old page with old software), and that you've got a solid power source for the Prop and sensor. If you're using a Prop board that derives its power from USB you may wish to try it with a secondary power source, and/or select a different USB port on your PC. Try a different ground connection.

    -- Gordon

  8. #8

    Default Re: Can't get HMC5883L Compass to work in spin - works in bs2

    Running 1.3 using regulated power supply. Trial several USB ports. Just tried only reading z and y axis on the assumption of a timing issue -- z reads fine y no joy.

  9. #9

    Default Re: Can't get HMC5883L Compass to work in spin - works in bs2

    If you feel comfortable interfacing the compass to the Prop with appropriate 3.3<->5V level shifting, you might try feeding the sensor 5V rather than 3.3V.

    On the chance that pullup resistors would benefit you could try some 2.2K to 6.8K resistors between V+ and clock and data. I'm guessing the board has these pullups, but I don't see a schematic in the documentation so it's hard to know.

    You've never mentioned what Propeller board you're using or how you've connected it.

    You wrote above "Yes, it works with BST." Does that mean you actually tried it with BST and found it functional, using the same Propeller hardware you're using with Propeller Tool?

    -- Gordon

  10. #10

    Default Re: Can't get HMC5883L Compass to work in spin - works in bs2

    I literally took the HMC5883 out of the anti-static bag, plugged it into a mini-breadboard, ran jumpers from my standard QuickStart board as shown on the web page, plugged the USB cable into a USB port and the board, started up Windows and ran the Propeller Tool (1.3). I cut and pasted the program text from the web page you mentioned, commented out the line for the math engine and ran the program. It worked exactly "as advertised". Maybe you have a bad sensor ... it's rare, but not impossible. Call Parallax Tech Support.

  11. #11

    Default Re: Can't get HMC5883L Compass to work in spin - works in bs2

    I have verified that the code in the first post works on the PPDB with a VIN of 3V3. I tried the "DOWNLOAD" and Cut and Paste method, and the both worked as advertised.

    Try and do a "CLEAR" on the PST after the program has started running. I have noticed some extraneous data hanging out on the right hand side after start up, and it never changes until I hit "CLEAR".

    Jim

    EDIT: I used Propeller Tool 1.3
    Infernal Machine

  12. #12

    Default Re: Can't get HMC5883L Compass to work in spin - works in bs2

    Just a note, the Kickstart program for the BS2 shows SCL as Pin1 and SDA as Pin0, where as,
    The Propeller program shows SCL as Pin0 and SDA as Pin1... It got me the first time, and it looks like it got Tymkrs too.


    -Tommy

  13. #13

    Default Re: Can't get HMC5883L Compass to work in spin - works in bs2

    I got it. I tried Gordon's suggestion of powering the compass with 5 volts and running the data line through a voltage divider into the propeller. It worked. I then tried again hooking everything backup at 3.3 volts and it still works. The only thing I can think of is that there was some kind of latchup situation that was cleared running at 5 volts.

    Thank you all for your suggestions and help.

  14. #14

    Default Re: Can't get HMC5883L Compass to work in spin - works in bs2

    Quote Originally Posted by Ttailspin View Post
    Just a note, the Kickstart program for the BS2 shows SCL as Pin1 and SDA as Pin0, where as,
    The Propeller program shows SCL as Pin0 and SDA as Pin1... It got me the first time, and it looks like it got Tymkrs too.
    As an FYI, this is so the setup is more consistent with the "master" demos the KickStarts are often derived from. Most users don't have both a BS2 and Prop, but they may go from the KickStart to the full demo. In this case, the data/clock lines mirror whatever is in the full demo. This isn't always the case, but it's an attempt to have a little more internally consistency. It also means any inconsistencies in the source material are reflected.

    -- Gordon

  15. #15

    Default Re: Can't get HMC5883L Compass to work in spin - works in bs2

    I don't think I have mentioned what a great book you put together GordonMcComb,
    Microcontroller KickStarts is well organized, easy to follow, and just all around useful, Thanks.
    I have tried every example except the Altimeter and GPS modules, and have had no problems.(other than my own laziness to double check my wiring)...

    -Tommy

  16. #16

    Default Re: Can't get HMC5883L Compass to work in spin - works in bs2

    I had an interesting problem with a HMC5843 and the Propeller Demo Board a while back. You may want to read this thread and see if it applies to you as well.

    http://forums.parallax.com/showthrea...ler-Demo-Board...

    Jim...

+ Reply to Thread

Similar Threads

  1. HMC5883L Compass Module
    By Wheat19 in forum BASIC Stamp
    Replies: 3
    Last Post: 06-19-2014, 06:53 AM
  2. Multiple HMC5883L compass units on one I2C line?
    By StephenMoore in forum Sensors
    Replies: 5
    Last Post: 09-12-2012, 09:57 PM
  3. main improvement of Compass Module 3-Axis HMC5883L
    By qiuqiuaaa in forum General Discussion
    Replies: 6
    Last Post: 02-16-2012, 02:08 PM
  4. Replies: 0
    Last Post: 01-10-2012, 01:41 AM
  5. Any luck with the HMC5883L Compass Module?
    By BonanzaMan in forum Propeller 1 Multicore Microcontroller
    Replies: 0
    Last Post: 12-29-2011, 06:38 PM

Tags for this Thread

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts