Here is the completed code. The issue still happens where the robot runs really stuttering-ly. I have no idea why and any help would be appreciated.
Code:
LED con P0
;PS2 Controller / BotBoard II
DAT con P12
CMD con P13
SEL con P14
CLK con P15
temp1 var byte
index var byte
temp var byte(6)
cntr var byte
mode var byte
rhori var word
rvert var word
lhori var word
lvert var word
flservo var sword
frservo var sword
blservo var sword
brservo var sword
lfservo var sword
lbservo var sword
rfservo var sword
rbservo var sword
ffservo var sword
bbservo var sword
ssservo var sword
small var byte
large var byte
high CLK
test
low SEL
shiftout CMD,CLK,FASTLSBPRE,[$1\8,$43\8,$0\8,$1\8,$0\8] ;Config Enable
high SEL
low SEL
shiftout CMD,CLK,FASTLSBPRE,[$01\8,$44\8,$00\8,$01\8,$03\8,$00\8,$00\8,$00\8,$00\8] ;Set Mode and Fix(Analog
high SEL
pause 100
low SEL
shiftout CMD,CLK,FASTLSBPRE,[$01\8,$4D\8,$00\8,$00\8,$01\8,$ff\8,$ff\8,$ff\8,$ff\8] ;Vibration Enable
high SEL
low SEL
shiftout CMD,CLK,FASTLSBPRE,[$01\8,$4F\8,$00\8,$FF\8,$FF\8,$03\8,$00\8,$00\8,$00\8] ;Enable Pressure
high SEL
low SEL
shiftout CMD,CLK,FASTLSBPRE,[$01\8,$43\8,$00\8,$00\8,$5A\8,$5A\8,$5A\8,$5A\8,$5A\8] ;Press_trans_start
high SEL
low SEL
shiftout CMD,CLK,FASTLSBPRE,[$01\8,$43\8,$00\8,$00\8,$00\8,$00\8,$00\8,$00\8,$00\8] ;Config Exit
high SEL
main
' This section find the mode the PSX controller is in.
low SEL
shiftout CMD,CLK,FASTLSBPRE,[$1\8]
shiftin DAT,CLK,FASTLSBPOST,[mode\8]
high SEL
low SEL
shiftout CMD,CLK,FASTLSBPRE,[$1\8,$42\8]
for index = 0 to 2
shiftin DAT,CLK,FASTLSBPOST,[temp(index)\8]
next
high SEL
low SEL
shiftout CMD,CLK,FASTLSBPRE,[$1\8,$42\8,$0\8,small\8,large\8]
for index = 3 to 6
shiftin DAT,CLK,FASTLSBPOST,[temp(index)\8]
next
high SEL
' This section does the mixing for throttle steering on a diff steered vehicle.
rhori = (255 + temp(3))
rvert = (255 + temp(4))
lhori = (255 + temp(5))
lvert = (255 + temp(6))
flservo = 383 - (lvert-383)
frservo = 383 + (lvert-383)
blservo = 383 - (lvert-383)
brservo = 383 + (lvert-383)
lfservo = 383 - (lhori - 383)
lbservo = 383 + (lhori - 383)
rfservo = 383 - (lhori - 383)
rbservo = 383 + (lhori - 383)
ffservo = 383 + (rvert - 383)
bbservo = 383 - (rvert - 383)
ssservo = 383 - (rhori - 383)
if flservo < 255 then
flservo = 255
endif
if flservo > 510 then
flservo = 510
endif
if frservo < 255 then
frservo = 255
endif
if frservo > 510 then
frservo = 510
endif
if blservo < 255 then
blservo = 255
endif
if blservo > 510 then
blservo = 510
endif
if brservo < 255 then
brservo = 255
endif
if brservo > 510 then
brservo = 510
endif
if lfservo < 255 then
lfservo = 255
endif
if lfservo > 510 then
lfservo = 510
endif
if lbservo < 255 then
lbservo = 255
endif
if lbservo > 510 then
lbservo = 510
endif
if rfservo < 255 then
rfservo = 255
endif
if rfservo > 510 then
rfservo = 510
endif
if rbservo < 255 then
rbservo = 255
endif
if rbservo > 510 then
rbservo = 510
endif
if ffservo < 255 then
ffservo = 255
endif
if ffservo > 510 then
ffservo = 510
endif
if bbservo < 255 then
bbservo = 255
endif
if bbservo > 510 then
bbservo = 510
endif
if ssservo < 255 then
ssservo = 255
endif
if ssservo > 510 then
ssservo = 510
endif
flservo = 4 * (flservo - 383)
frservo = 4 * (frservo - 383)
blservo = 4 * (blservo - 383)
brservo = 4 * (brservo - 383)
lfservo = 4 * (lfservo - 383)
lbservo = 4 * (lbservo - 383)
rfservo = 4 * (rfservo - 383)
rbservo = 4 * (rbservo - 383)
ffservo = 4 * (ffservo - 383)
bbservo = 4 * (bbservo - 383)
ssservo = 4 * (ssservo - 383)
' The following can be used as a debug to see the values of the joysticks and buttons.
' serout S_OUT,i57600,[13]
' for index = 1 to 6
' serout S_OUT,i57600,[" ",dec3 temp(index)\3]
' next
' serout S_OUT,i57600,[" ",dec3 rhori\3]
' serout S_OUT,i57600,[" ",dec3 rvert\3]
' serout S_OUT,i57600,[" LH ",dec3 lhori\3]
' serout S_OUT,i57600,[" LV ",dec3 lvert\3]
' serout S_OUT,i57600,[" LS ",sdec3 lservo\6]
' serout S_OUT,i57600,[" RS ",sdec3 rservo\6]
' The following code relates to the internal vibrator motors and is not used in this application.
small = 0 'temp(7)
large = 0 'temp(8)
' This section is where the servo style motor controller is directed.
servo 0, flservo, 1
servo 1, frservo, 1
servo 2, blservo, 1
servo 3, brservo, 1
servo 4, lfservo, 1
servo 5, lbservo, 1
servo 6, rfservo, 1
servo 7, rbservo, 1
servo 8, ffservo, 1
servo 10, ssservo, 1
servo 11, bbservo, 1
goto main