PDA

View Full Version : Unsolved HMC6352 Compass behaving oddly



stargazer2050
04-03-2012, 02:06 PM
hmc6352 Compass
compass is a parallax product purchased from sparkfun and resides on a little red board with 3 10k resistors on it
Quickstart propeller bd
win xp

1. this compass and an identical one that i readdressed to 0x40 work simultaneously and flawlessly on an arduino uno.
2. This compass worked for 2 days with hmc6352.spin out of the obex on the propeller.
3. now its all over the place, even running backwards, and i made no changes to my program or environment, just woke up on wrong side.
4. tried, .01uf cap vdd to grd, tried slowing clock down (its a 100khz chip. (per datasheet) (am now back to 16x and 5_000_000.
5. tried 6000msec delay (per datasheet) to get heading
6. I can identify 2 out of the 3 resistors as going from vdd to sda and vdd to scl (if i typed this right)
7. i don't know what the third one does

Q:
A. in hmc6352.spin, on what line number does the necessary "A" command reside? (just checking)
B. is there any straight line code to run this thing (like arduino) or must I use 16 subroutines out of a library to define something i ain't smart enough to do on my own? (now u know)
C. Actual ideas that might be cogent besides A and B

tnx
eddie

Mike Green
04-03-2012, 02:31 PM
The 3rd "resistor" is the 0.1uF capacitor as shown on the schematic on SparkFun's website.

This is a discontinued product for Parallax, so the webpage for it on Parallax's website is floating somewhere in hyperspace and I can't find the sample code to answer your questions about hmc6352.spin. You could attach your copy of the code or a link to an OBEX entry to a reply and I'd take a look at it. Regarding #s 1-7: This sounds like something that a call to Parallax Tech Support would get you some answers that the forum here may not be able to do.

Sorry you're having odd difficulties. Be patient

Mike Green
04-03-2012, 02:45 PM
You've posted the same question in the Sensors forum and that's not allowed (no cross-posting). Generally it won't get you faster or better answers. The duplicate post has been deleted with a comment that there's another thread here.

Mike Green
04-03-2012, 02:55 PM
There's a lot of stuff in the Object Exchange and I did try a simple search for HMC6352 without finding anything. I'm a volunteer here, like most of the people that would try to help you out. It would help for you to supply a link to the ObEx entry. I don't have the time just now to search by hand.

Mike Green
04-03-2012, 03:13 PM
http://forums.parallax.com/attachment.php?attachmentid=78421&d=1297987572 (http://forums.parallax.com/showthread.php?129690&p=978076&viewfull=1#post9780 76)

stargazer2050
04-03-2012, 03:31 PM
here's a copy of hmc6352.spin and demos in a .zip

i'm looking hard for the obex reference where i got this, i can only find it on my android!#? yipers

may not be able to get it again.

Mike Green
04-03-2012, 03:38 PM
ON
_clkmode = xtal1 + pll16x
_xinfreq = 5_000_000
#1, HOME, #8, BKSP, TAB, LF, CLREOL, CLRDN, CR, #16, CLS ' PST formmatting control
RX1 = 31
TX1 = 30
SDA = 4
SCL = 5
CS = 2
CLK = 0
DIO = 1
OBJ
time : "Timing"
term : "fullduplexserial"
adc : "jm_mcp3204_ez"
HMC6352 : "HMC6352"
pwm1 : "PWMMotorDriver"
Servo : "Servo32v7"
Stk : "Stack Length"
VAR
long sample
Long monStack[60]
Long btnStack[10]

Word Heading
Word Bearing
Word btnNum
Word typical
Word Threshold
Word switchHome

PUB Main
HMC6352.Init(SDA, SCL) ' start compass
waitcnt(clkfreq + cnt) 'let objects load
Heading := HMC6352.Heading / 10 'set initial heading
waitcnt(clkfreq + cnt)

I've stripped out everything that's commented out and anything that can't be executed because of stuff that's commented out. There's nothing left that would behave the way you described. Please post the actual code that you've been using that behaves as you've described. Also post the link to the HMC6352 object. The other objects are known to me.

The code in Main is not indented properly. Statements that are at the same nesting level should be indented the same. Don't indent successive lines just for appearance. In this case (Main), it should work, but with more complex statements (IF / REPEAT / etc.) this won't work.

Publison
04-03-2012, 03:46 PM
I'm not sure it was ever in the OBEX, otherwise it would still be there. I believe it came from the now defunct product page.

Here's what I got:

1. Original code (probably the same as yours)
2. Schematic of the Parallax board to compare.
3. PDF from the product page (http://www.parallax.com/Portals/0/Downloads/docs/prod/sens/29323_HoneywellHMC6352Compass-v1.0.pdf).

Hope that helps,

Jim

Publison
04-03-2012, 04:08 PM
It might be better the archive the entire project in the Propeller Tool so it includes all the objects in one zip file.

FILE>ARCHIVE>PROJECT

This way someone can tell if any of the other objects where changed.

Mike Green
04-03-2012, 04:09 PM
@Publison: Thanks for the links.

@stargazer2050:
The "A" command is defined in the CONstants block as GET_HEADING and is sent to the HMC6352 in line 81 when you call "Heading".

The 8 (PUBlic) routines are Init, Heading, Sleep, WakeUp, StartCalibration, EndCalibration, ReadEEPROM, and ReadRAM. All the other routines are internal (PRIvate) to the HMC6352 object. You can't use them in your program. If you use the BST compiler and specify the appropriate option, any unused routines won't even be compiled into the binary program.

These objects (like HMC6352) serve the same purpose as Arduino libraries. They provide additional functionality, particularly for I/O devices. The whole idea is not to have "straight line code", but to call the routines in the library object. These routines take care of the details of handling the device for you.

Mike Green
04-03-2012, 04:17 PM
It's impossible to tell for sure from what you've posted, but you might have a lot of cogs in use. FullDuplexSerial requires one. Servo32v7 requires one. Your main program requires one and it looks like you might use two more under some circumstances. I'm not sure if the PWM driver uses a cog and I think that the Timing object uses one. You might be running out of cogs. Just a thought.

stargazer2050
04-03-2012, 05:03 PM
Ok thanks all

Will learn to archive in propeller tool

tech support just told me to buy the 5883l, will do

will find this BST compiler

will cut back on cogs!!!

Publison
04-03-2012, 06:11 PM
hmc6352 Compass
compass is a parallax product purchased from sparkfun and resides on a little red board with 3 10k resistors on it


Eddie,

Not sure if you realize this, but the module you have from Sparkfun is not a Parallax product. They both used the HMC6352 chip, but the boards have different pinouts.

Just checking.

Jim