PDA

View Full Version : Vector 2x Heading seems to be off - any ideas?



DShannon
03-09-2005, 12:17 PM
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,[heading\16]
'get the data from Vector 2x.

HIGH sclk 'reset pins.
HIGH slct

RETURN 'done.

DShannon
03-10-2005, 02:03 AM
Any ideas? Thanks!!!

Jon Williams
03-10-2005, 02:41 AM
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

Jonb
03-10-2005, 02:42 AM
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" http://forums.parallax.com/images/smilies/smile.gif

DShannon
03-10-2005, 03:15 AM
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?

Jonb
03-10-2005, 03:22 AM
Xflip->10k resistor->+5v = HIGH
and ya tying to ground is tying low http://forums.parallax.com/images/smilies/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

DShannon
03-10-2005, 03:25 AM
can I just connect XFLIP to a STAMP pin 10 (without the resistor) and code:

HIGH 10

I think this should work?

Jonb
03-10-2005, 03:27 AM
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

DShannon
03-10-2005, 03:51 AM
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.....

Julian
03-10-2005, 11:41 PM
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 (mailto:jbenton@pnicorp.com)

DShannon
03-10-2005, 11:44 PM
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.....