ok here is a short-ish code. (hope its short enough to post like this)
The following code is for Panning a servo using the left joystick on a Ps2 remote.
using ABBII, SSC32, APro28.
My question is: im finding that the reaction of the servo is slow in either direction, it will not return to center when j stick is zero’d. the speed is variable regarding the travel of the stick but its not reading the true values of the stick, by this i mean it either moves left or right with slow variable speed (as mentioned) but will not react to the true direction of the input.
any thoughts on this.?
[code];-------------Constants
;PS2 Controller / BotBoard II
DAT con P12
CMD con P13
SEL con P14
CLK con P15
SSC32 con p11
DeadZone con 28 ; must be >= 28
PadMode con $79
;Arm
Servo3Pin con 1
Servo3_PulseDef con 1500
Servo3_PulseMin con 850
Servo3_PulseMax con 2150
;-------------Variables
index var Byte
DualShock var Byte(7)
LastButton var Byte(2)
Time var Word
XCoord var Sbyte
YCoord var Sbyte
ZCoord var Sbyte
WCoord var Sbyte
Servo3_Pulse var word
;-------------Init
;DualShock
pause 500
clear
high CLK
again
low SEL
shiftout CMD,CLK,FASTLSBPRE,$1\8,$43\8,$0\8,$1\8,$0\8] ;CONFIG_MODE_ENTER
high SEL
pause 1
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_LOCK
high SEL
pause 100
low SEL
shiftout CMD,CLK,FASTLSBPRE,$01\8,$4F\8,$00\8,$FF\8,$FF\8,$03\8,$00\8,$00\8,$00\8] ;SET_DS2_NATIVE_MODE
high SEL
pause 1
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
pause 1
low SEL
shiftout CMD,CLK,FASTLSBPRE,$01\8,$43\8,$00\8,$00\8,$5A\8,$5A\8,$5A\8,$5A\8,$5A\8] ;CONFIG_MODE_EXIT_DS2_NATIVE
high SEL
pause 1
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_MODE_EXIT
high SEL
pause 1
low SEL
shiftout CMD,CLK,FASTLSBPRE,$1\8]
shiftin DAT,CLK,FASTLSBPOST,[DualShock(0)\8]
high SEL
pause 1
;serout S_OUT,i57600,"PadMode : ",HEX2 DualShock(0),13]
Sound 9,[100\4435]
if DualShock(0) <> PadMode then again
LastButton(0) = 255
LastButton(1) = 255
pause 500
;--------------------------------------------------------------------
;-------------Main loop
main
;DS2
low SEL
shiftout CMD,CLK,FASTLSBPRE,$1\8,$42\8]
shiftin DAT,CLK,FASTLSBPOST,[DualShock(0)\8, DualShock(1)\8, DualShock(2)\8, DualShock(3)\8, |
DualShock(4)\8, DualShock(5)\8, DualShock(6)\8]
high SEL
pause 1
XCoord = DualShock(5) - 128
if XCoord > DeadZone then
XCoord = XCoord - DeadZone
elseif XCoord < -DeadZone
XCoord = XCoord + DeadZone
else
XCoord = 0
endif
if XCoord then
Servo3_Pulse = Servo3_Pulse + XCoord / 8
if Servo3_Pulse > Servo3_PulseMax then
Servo3_Pulse = Servo3_PulseMax
elseif Servo3_Pulse < Servo3_PulseMin
Servo3_Pulse = Servo3_PulseMin
endif
serout SSC32,i38400,"#",DEC Servo3Pin,"P",DEC Servo3_Pulse," T100",13]
endif
pause 36
LastButton(0) = DualShock(1)
LastButton(1) = DualShock(2)
goto main
[/code]