FAO Bruce Bates
Hi Bruce here's the two programes I have for my setup the first one is for
the Polaroid 6500 sensor the second for the PaK VIII which I use to drive
the servo's. All I want to do is take the out put from the 6500 and use it
to tell the Pak VIII to stop the motors, turn them until path is clear or
move forward until the path becomes obstructed. Sorry I could not send them
as a zip file I tried but it did not appear to work. Once again thanks very
much for your time it's very much appreciated.
John
__________________________________________________________
'Polriod 6500 set-up programme
TIMEOFFLIGHT var word
DISTANCE var word
ECHO con 13
INIT con 14
SETTLETIME con 1
CYCLE_DELAY con 2
pause 20
X VAR WORD
pause 1000
gosub forward
pause 5
gosub back
pause 5
gosub left
pause 5
gosub forward
pause 5
gosub right
forward:
for x=1 to 10
pulsout 8,850
pulsout 9,650
pause 20
back:
next
return
for x=1 to 10
pulsout 8,650
pulsout 9,850
pause 20
next
return
left:
for x=1 to 10
pulsout 8,850
pulsout 9,850
pause 20
next
return
right:
for x=1 to 10
pulsout 8,650
pulsout 9,650
pause 200
SENSE:
high INIT
'see the 6500 app notes for timing info
pause SETTLETIME
rctime ECHO,0,TIMEOFFLIGHT
'waits for ECHO to go low,
'which signals a return ping.
'threshold is 1.4 volts
gosub ECHORECEIVED
low INIT
pause CYCLE_DELAY
ECHORECEIVED:
DISTANCE = TIMEOFFLIGHT * 7 / 200 + 22
' this conversion approximates centimetres,
' accounting for the offset imposed by the
' blinking signal generated by the 6500
debug dec? DISTANCE
'print distance on screen
return
____________________________________________________________
' Servo BoE-BoT demo for PAK-VIII
'Data on BSII pin0, Clk on pin 1
datap con 0
datapin var in0
clk con 1
' Register names
DURLOW con %000
DURHIGH con %001
HIGHDUR con %010
LOWDUR con %011
PSCALE con %100
PSBASE con %101
N con %110
CTRL con %111
center0 con 150
center1 con 152
output clk
output datap
fpx var word
fpb var byte
' parameters for Fcommand
chan var nib
register var nib
debug "reset",cr
gosub freset 'always reset!
gosub FTotalReset 'hard reset
top:
' disable channel 0 and 1
chan=0
register=6
fpx=1
gosub Fcommand
chan=1
gosub Fcommand
gosub servocenter
'turn on and enable chan 0 and 1
for chan=0 to 1
fpb=3
gosub FJam
next
'set both servos to 2mS (200)
'since servos are "back to back"
'the robot will rotate
chan=0
register=1
fpx=200
gosub Fcommand
chan=1
gosub Fcommand
pause 10000 'rotate for 10 seconds
chan=1
register=1
fpx=100 'go in one direction (reverse servo#1)
gosub Fcommand
pause 10000
gosub servocenter
stopp:
goto stopp
end
'center both servos
servocenter:
chan=0
register=1
fpx=center0 '150 x 10 = 1.5mS
gosub Fcommand
chan=1
fpx=center1
gosub Fcommand
register=2
fpx=2000 '2000 x 10 = 20mS
gosub Fcommand
chan=0
goto Fcommand 'let Fcommand return
' reset the PAK-VIII I/O
Freset:
LOW DATAP
LOW CLK
HIGH CLK
HIGH DATAP
LOW CLK
return
' 0 is 0, 1 is 1, 2 is hi-z, 3 is normal
' note: 3 enables channel to run!
FJam:
fpb=chan + (fpb<<3)+%01000000
goto FsendByte
Fcommand:
'inputs chan = channel, register = register
fpb=(register<<3) + chan
gosub FsendByte
fpb=fpx.lowbyte
gosub FsendByte
fpb=fpx.highbyte
goto FsendByte
FreadReg:
fpb=(register<<3) + chan + %10000000
gosub FsendByte
'fall into FreadWord
FreadWord:
shiftin datap,clk,MSBPRE,[noparse][[/noparse]fpx.lowbyte,fpx.highbyte]
return
FtotalReset:
fpb=$FF
FsendByte:
shiftout datap,clk,MSBFIRST,[noparse][[/noparse]fpb]
return
FreadByte:
shiftin datap,clk,MSBPRE,[noparse][[/noparse]fpb]
return
Fprescale:
' set fpb to the prescale constant
fpb = fpb + $c0
goto FsendByte
the Polaroid 6500 sensor the second for the PaK VIII which I use to drive
the servo's. All I want to do is take the out put from the 6500 and use it
to tell the Pak VIII to stop the motors, turn them until path is clear or
move forward until the path becomes obstructed. Sorry I could not send them
as a zip file I tried but it did not appear to work. Once again thanks very
much for your time it's very much appreciated.
John
__________________________________________________________
'Polriod 6500 set-up programme
TIMEOFFLIGHT var word
DISTANCE var word
ECHO con 13
INIT con 14
SETTLETIME con 1
CYCLE_DELAY con 2
pause 20
X VAR WORD
pause 1000
gosub forward
pause 5
gosub back
pause 5
gosub left
pause 5
gosub forward
pause 5
gosub right
forward:
for x=1 to 10
pulsout 8,850
pulsout 9,650
pause 20
back:
next
return
for x=1 to 10
pulsout 8,650
pulsout 9,850
pause 20
next
return
left:
for x=1 to 10
pulsout 8,850
pulsout 9,850
pause 20
next
return
right:
for x=1 to 10
pulsout 8,650
pulsout 9,650
pause 200
SENSE:
high INIT
'see the 6500 app notes for timing info
pause SETTLETIME
rctime ECHO,0,TIMEOFFLIGHT
'waits for ECHO to go low,
'which signals a return ping.
'threshold is 1.4 volts
gosub ECHORECEIVED
low INIT
pause CYCLE_DELAY
ECHORECEIVED:
DISTANCE = TIMEOFFLIGHT * 7 / 200 + 22
' this conversion approximates centimetres,
' accounting for the offset imposed by the
' blinking signal generated by the 6500
debug dec? DISTANCE
'print distance on screen
return
____________________________________________________________
' Servo BoE-BoT demo for PAK-VIII
'Data on BSII pin0, Clk on pin 1
datap con 0
datapin var in0
clk con 1
' Register names
DURLOW con %000
DURHIGH con %001
HIGHDUR con %010
LOWDUR con %011
PSCALE con %100
PSBASE con %101
N con %110
CTRL con %111
center0 con 150
center1 con 152
output clk
output datap
fpx var word
fpb var byte
' parameters for Fcommand
chan var nib
register var nib
debug "reset",cr
gosub freset 'always reset!
gosub FTotalReset 'hard reset
top:
' disable channel 0 and 1
chan=0
register=6
fpx=1
gosub Fcommand
chan=1
gosub Fcommand
gosub servocenter
'turn on and enable chan 0 and 1
for chan=0 to 1
fpb=3
gosub FJam
next
'set both servos to 2mS (200)
'since servos are "back to back"
'the robot will rotate
chan=0
register=1
fpx=200
gosub Fcommand
chan=1
gosub Fcommand
pause 10000 'rotate for 10 seconds
chan=1
register=1
fpx=100 'go in one direction (reverse servo#1)
gosub Fcommand
pause 10000
gosub servocenter
stopp:
goto stopp
end
'center both servos
servocenter:
chan=0
register=1
fpx=center0 '150 x 10 = 1.5mS
gosub Fcommand
chan=1
fpx=center1
gosub Fcommand
register=2
fpx=2000 '2000 x 10 = 20mS
gosub Fcommand
chan=0
goto Fcommand 'let Fcommand return
' reset the PAK-VIII I/O
Freset:
LOW DATAP
LOW CLK
HIGH CLK
HIGH DATAP
LOW CLK
return
' 0 is 0, 1 is 1, 2 is hi-z, 3 is normal
' note: 3 enables channel to run!
FJam:
fpb=chan + (fpb<<3)+%01000000
goto FsendByte
Fcommand:
'inputs chan = channel, register = register
fpb=(register<<3) + chan
gosub FsendByte
fpb=fpx.lowbyte
gosub FsendByte
fpb=fpx.highbyte
goto FsendByte
FreadReg:
fpb=(register<<3) + chan + %10000000
gosub FsendByte
'fall into FreadWord
FreadWord:
shiftin datap,clk,MSBPRE,[noparse][[/noparse]fpx.lowbyte,fpx.highbyte]
return
FtotalReset:
fpb=$FF
FsendByte:
shiftout datap,clk,MSBFIRST,[noparse][[/noparse]fpb]
return
FreadByte:
shiftin datap,clk,MSBPRE,[noparse][[/noparse]fpb]
return
Fprescale:
' set fpb to the prescale constant
fpb = fpb + $c0
goto FsendByte