Shop OBEX P1 Docs P2 Docs Learn Events
HMC6352 Compass behaving oddly — Parallax Forums

HMC6352 Compass behaving oddly

stargazer2050stargazer2050 Posts: 89
edited 2012-04-03 11:11 in Propeller 1
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

Comments

  • Mike GreenMike Green Posts: 23,101
    edited 2012-04-03 07:31
    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 GreenMike Green Posts: 23,101
    edited 2012-04-03 07:45
    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 GreenMike Green Posts: 23,101
    edited 2012-04-03 07:55
    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 GreenMike Green Posts: 23,101
    edited 2012-04-03 08:13
    attachment.php?attachmentid=78421&d=1297987572
  • stargazer2050stargazer2050 Posts: 89
    edited 2012-04-03 08:31
    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 GreenMike Green Posts: 23,101
    edited 2012-04-03 08:38
    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.
  • PublisonPublison Posts: 12,366
    edited 2012-04-03 08:46
    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.

    Hope that helps,

    Jim
  • PublisonPublison Posts: 12,366
    edited 2012-04-03 09:08
    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 GreenMike Green Posts: 23,101
    edited 2012-04-03 09:09
    @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 GreenMike Green Posts: 23,101
    edited 2012-04-03 09:17
    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.
  • stargazer2050stargazer2050 Posts: 89
    edited 2012-04-03 10:03
    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!!!
  • PublisonPublison Posts: 12,366
    edited 2012-04-03 11:11
    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
Sign In or Register to comment.