Shop OBEX P1 Docs P2 Docs Learn Events
Vector 2x Heading seems to be off - any ideas? — Parallax Forums

Vector 2x Heading seems to be off - any ideas?

DShannonDShannon Posts: 26
edited 2005-03-10 15:44 in BASIC Stamp
Just hooked up the Vector2x to my BS2. Code is below (circuit and code is same as http://www.robotics.com/arobot/vector.html)

Seems as though my headings are off by about 90 degrees.

The only thing I can think off is that I have YFlip grounded along with RES (as per the schemtatic at the above link (and attached).

Any ideas????



' {$STAMP BS2}
' {$PBASIC 2.5}
'

'compass signals.
slct CON 2 'select signal.
sdo CON 3 'serial data out.
sclk CON 4 'clock signal.
rst CON 5 'reset signal.

'Other.
heading VAR Word 'heading variable.

setup:
OUTPUT slct 'set pin direction.
OUTPUT sclk
OUTPUT rst
INPUT sdo

GOSUB compinit 'initialize the compass.

main:
GOSUB getcomp 'get the compass heading.

DEBUG DEC ? heading 'Display heading.
DEBUG CR

PAUSE 1000 'wait a sec.

GOTO main 'loop for ever.

'
'this routine initializes the Vector 2x compass.
'
compinit:
HIGH sclk
HIGH slct 'make sure this is high.
LOW rst 'lower reset pin.
PAUSE 15 'wait 15 ms.
HIGH rst 'raise reset pin.
PAUSE 200 'wait a bit.
RETURN 'done.

'
'This routine gets the heading from the Vector 2x
'compass and places it in the variable heading.
'
getcomp:
LOW slct 'start the Vector 2x.
PAUSE 200 'wait for heading.
heading = 0 'clear variable.
SHIFTIN sdo,sclk,MSBPRE,[noparse][[/noparse]heading\16]
'get the data from Vector 2x.

HIGH sclk 'reset pins.
HIGH slct

RETURN 'done.
320 x 156 - 5K

Comments

  • DShannonDShannon Posts: 26
    edited 2005-03-09 18:03
    Any ideas? Thanks!!!
  • Jon WilliamsJon Williams Posts: 6,491
    edited 2005-03-09 18:41
    How close is the compass to the metalic objects or magnetic fields (circuits, motors, etc.)?· Also, have you consulted the compass docs, or are you using someone else's code on faith?·(Don't -- always consult the component docs)

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    Jon Williams
    Applications Engineer, Parallax
    Dallas, TX· USA
  • JonbJonb Posts: 146
    edited 2005-03-09 18:42
    Could there be something near you that is giving off a magnetic field?
    The compasses are able to detect very weak magnetic fields and could be thrown off by a piece of steel for example. Has anyone ever told you you they thought you had a "magnetic personnality" smile.gif
  • DShannonDShannon Posts: 26
    edited 2005-03-09 19:15
    Thanks Jon,Jon,

    The compass is at least 2 ft away from any circuits, motors, or metallic objects.
    I find it interesting that the readings are 90degrees off, vs varying amounts, which is what I would expect if there was a magnetic field nearby.


    The manual states to take XFLIP pin high, and YFLIP pin low.

    I do not have XFLIP connected to any pins , and YFLIP is grounded to VSS. Is this the same as having XFLIP high and YFLIP low?
  • JonbJonb Posts: 146
    edited 2005-03-09 19:22
    Xflip->10k resistor->+5v = HIGH
    and ya tying to ground is tying low smile.gif

    you could also drive it high with a stamp pin and resistor in series. Resistor is used to limit current.

    Post Edited (Jonb) : 3/9/2005 7:27:03 PM GMT
  • DShannonDShannon Posts: 26
    edited 2005-03-09 19:25
    can I just connect XFLIP to a STAMP pin 10 (without the resistor) and code:

    HIGH 10

    I think this should work?
  • JonbJonb Posts: 146
    edited 2005-03-09 19:27
    If you dont put a resistor you could fry the pin. Depends on if th xflip is supposed to be HIGH all the time or just momentarily. If its supposed to be tied High all the time just tie it to +5v with a resistor. But yes saying High 10 would work, but might not be the right way to do it. Doing it in your program would mean that you dont need it tied HIGH all the time. If it is always needing to be tied to HIGH, then resistor in series to +5v.

    GL!

    Post Edited (Jonb) : 3/9/2005 7:34:36 PM GMT
  • DShannonDShannon Posts: 26
    edited 2005-03-09 19:51
    Great. Thanks JonB - I'll use a resistor in series to +5v.

    Also, going to mount this vector 2x in my car - any optimum localtion? thinking in the center console, away from the radio, speakers, etc.....
  • JulianJulian Posts: 2
    edited 2005-03-10 15:41
    The wire diagram is fine.· Remember that the "front" of the board is the side with· pins P11-P14.· If you are assuming the front of the board is either of the two short sides without pins, that would be the cause of your 90 degree offset.

    Any magnetic distortions would cause heading errors that would vary as the unit was rotated in a circle, not a 90 degree offset.

    Julian Benton
    Applications Engineer
    PNI Corporation
    jbenton@pnicorp.com
  • DShannonDShannon Posts: 26
    edited 2005-03-10 15:44
    OOHHH Thanks Julian! I was assuming the front of the board (and from I thought I read from the manual) was the short side on top by the coil. Hence, the 90 degree offset.

    So it seems that I do not need to tie XFLIP to anything.....
Sign In or Register to comment.