Shop OBEX P1 Docs P2 Docs Learn Events
to Al Williams — Parallax Forums

to Al Williams

ArchiverArchiver Posts: 46,084
edited 2000-11-18 19:55 in General Discussion
Thanks Al for sending confirmation on the assumption for the pin outs of the resonator used with the Pak 8. Sorry I haven't wrote back but my system crashed and I lost quite a lot of stuff, also lost your email address hence the reason I'm posting you mail this way. Hers the programme you said you'd check out for me.

' servo BoE - Bot demo for PAK - VIII

datap con 0··· ··· 'data pin I/O on BSII pin 0
datapin var in0
clk con 1··· ··· ··· ' clk pin on BSII is pin 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
center 6 con 150··· ··· ' left servo on pin 6 of the PAK VIII
center 7 con 152··· ··· 'right servo on pin 7 of the PAK VIII

output clk
output datap

fpx var word···· ··· ··· ' Integer used by some routines
fpb var byte···············' byte
'··· parameters for FCommand
chan var nib
register var nib

debug "reset",cr

gosub freset··· 'always reset!

gosub FTotalReset··· ··· ' hard reset

top:
' disable channel 6 and 7
chan=6
register=6
fpx=1
gosub FCommand
chan=7
gosub FCcommand

gosub ServoCenter

' turn on and enable 6 and 7
for chan=6 to 7
fpb=3
gosub FJam
next

' set both servos to 2mS (200)
' Since servos are "back to back"
' the robot will rotate
chan=6
register=1
fpx=200
gosub FCommand

chan=7
gosub FCommand

pause 10000··· 'rotate for 10 seconds

chan=7
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=6
register=1
fpx=center6··· ··· '150 x 10 = 1.5ms
gosub FCommand
chan=7
fpx=center7
gosub FCommand
register=2
fpx=2000··· '2000 x 10 = 20mS
gosub FCommand
chan=6
goto FCommand··· ··· ' let FCommand return

' Rest the Pak8 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 iss 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=fpxx.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 FSend Byte



Sorry for the long email, I have the feeling that I was surposed to change some other lines to suit my set-up, I've looked over and over the programme but can't see were. Hope you can help.
Many thanks
John
Sign In or Register to comment.