vector 2x compass
Archiver
Posts: 46,084
I am looking for info on interfacing a stamp2 with a vector compass.
Any suggestions?
Any suggestions?
Comments
ACJacques
'VEC2X-SX HDG SLAVE mode for BS2SX V.1.2 Fev.1999
'code writed by ACJacques
'HDG slave mode
'SS and PC of Vector2X are tied together to save Stamp pins
'serout 17417 = 2400 baud for LCD (check exact corrected value in the
'newest BS2SX documentation.)
'the only difference in this code for the old BS2 code is the mode of
'clocking out data
'BS2SX and V2X doesnt work with BS2 SHIFTOUT command. I believe because
'timing
'restrictions in the V2X. Then I "manually" clocked the data with HIGH
'and LOW commands
'variable and pin / constant definitions
'con are BS2 pin numbers - V2X pins are names .all other pins are open
'except VCC and GND
heading var word
c var word 'for next count variable
led con 0 'positive of LED to blink each reading. Connect other LED
'pin to GND
xflip con 3 'optional to control position of module 'V2X pin
names going to BS2 pin names
yflip con 4 'optional to control position of module
reset con 5 'optional for initialization
sspc con 6 'ss and pc are tied together here
eoc con 7
sclk con 8
sdo con 9
res con 10 'optional speed resolution
'configure here position of module V2X pin are internal pulled up
low xflip
'low yflip
low res 'optional low res to increase reading speed + speed if
'enabled (GND)
'compass inicialization - may be ommited in some applications - make a
'test disabling all comands bellow to main loop.
high reset
high sspc
pause 500
low reset
pause 10
high reset
pause 500
'main loop
loop1
low led
low sspc
pause 10 'low PC and SS for 10 msec
high sspc
loop2
if in7 = 0 then loop2 'EOC test
pause 10
low sspc
pause 3 'reccomended pause here is 5 but 3 works fine in my application
heading = 0
for c= 1 to 16 ' loop to clock out 16 data bits
high sclk
low sclk
heading = heading*2 + in9 'shifting data
next
high sclk
high sspc
high led
'heading = heading & $03ff 'enable 6 bits masking if necessary
debug home
debug "HDG=",dec3 heading,cr
'serout 15,17417,[noparse][[/noparse]254,1,"HDG=",dec3 heading ,254,12] 'lcd output 16x2
'scott edward module
goto loop1
=========================end of code=============================
jpdel@v... wrote:
>
> I am looking for info on interfacing a stamp2 with a vector compass.
> Any suggestions?
>
>
>
> Your use of Yahoo! Groups is subject to http://docs.yahoo.com/info/terms/