Can't get HMC5883L Compass to work in spin - works in bs2
reppig
Posts: 35
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/parallaxinretailstores/home/compass-module-3-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?
https://sites.google.com/site/parallaxinretailstores/home/compass-module-3-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?
Comments
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.
Part 1:
http://tymkrs.tumblr.com/post/22237323716/parallax-compass-module-3-axis-hmc5883l-29133
Part 2:
http://tymkrs.tumblr.com/post/22258810035/parallax-compass-module-3-axis-hmc5883l-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.
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?
-- Gordon
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
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
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
Thank you all for your suggestions and help.
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
Microcontroller KickStarts is well organized, easy to follow, and just all around useful, Thanks. :thumb::thumb:
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
http://forums.parallax.com/showthread.php?133813-Issue-with-Propeller-Demo-Board...
Jim...