by jeffchifu » Mon Nov 29, 2010 8:50 am
by jeffchifu
Mon Nov 29, 2010 8:50 am
' Template program for PS2 wireless controller
' Richard Ibbotson November 2007
' PS2 wireless controller in DS2 mode connected to ETX/ERX
DIM rr AS BYTE ' first variable is reserved
DIM txchar AS BYTE ' store for character to send to controller
DIM rxchar AS BYTE
'Empty the ERX buffer
begin:
ERX 19200, rxchar, bemt1
bemt1:
ERX 19200, rxchar, bemt2
bemt2:
' Set the PS2 controller to DS2 mode
'-----------------------------------------------------------------------
' Motion Startup Stuff, note this is special for double knee joints
PTP SETON
PTP ALLON
DIR G6A,1,0,0,0,1,0
DIR G6B,1,1,1,1,1,1
DIR G6C,0,0,0,0,0,0
DIR G6D,0,1,1,1,0,1
'GETMOTORSET G6A,1,1,1,1,1,1
'GETMOTORSET G6B,1,1,1,0,0,0
'GETMOTORSET G6C,1,1,1,0,0,1
'GETMOTORSET G6D,1,1,1,1,1,1
SPEED 5
MOTOR G6A
MOTOR G6B
MOTOR G6C
MOTOR G6D
'Example Gyro Setup Code
GYROSET G6A,0,0,0,0,0,0
GYROSET G6D,0,0,0,0,0,0
GYRODIR G6A,0,1,1,0,1,1
GYRODIR G6D,0,1,1,0,1,1
GYROSENSE G6A,0,200,200,0,0,0
GYROSENSE G6D,0,200,200,0,0,0
GOSUB Standard_pose
'-----------------------------------------------------------------------
MUSIC "CDE"
MAIN:
'Read the PS2 buttons
txchar ="C"
ETX 19200, txchar
GETC:
ERX 19200, rxchar, GETC
TEMPO 230
MUSIC "DDDDDD"
GOTO main
txchar ="e"
ETX 19200, txchar
GETe:
ERX 19200, rxchar, GETe
TEMPO 230
MUSIC "DDDDDD"
GOTO MAIN
'================================================
Standard_Pose:
MOVE G6A, 100,85,90,90,90,100
MOVE G6D, 100,85,90,90,90,100
MOVE G6B, 100,30,80,100,100,100
MOVE G6C, 100,30,80,100,100,100
WAIT
RETURN
'================================================
Hi Bot,
I tried to use "C".It doesn't work to control.
thanks
jeff
' Template program for PS2 wireless controller
' Richard Ibbotson November 2007
' PS2 wireless controller in DS2 mode connected to ETX/ERX
DIM rr AS BYTE ' first variable is reserved
DIM txchar AS BYTE ' store for character to send to controller
DIM rxchar AS BYTE
'Empty the ERX buffer
begin:
ERX 19200, rxchar, bemt1
bemt1:
ERX 19200, rxchar, bemt2
bemt2:
' Set the PS2 controller to DS2 mode
'-----------------------------------------------------------------------
' Motion Startup Stuff, note this is special for double knee joints
PTP SETON
PTP ALLON
DIR G6A,1,0,0,0,1,0
DIR G6B,1,1,1,1,1,1
DIR G6C,0,0,0,0,0,0
DIR G6D,0,1,1,1,0,1
'GETMOTORSET G6A,1,1,1,1,1,1
'GETMOTORSET G6B,1,1,1,0,0,0
'GETMOTORSET G6C,1,1,1,0,0,1
'GETMOTORSET G6D,1,1,1,1,1,1
SPEED 5
MOTOR G6A
MOTOR G6B
MOTOR G6C
MOTOR G6D
'Example Gyro Setup Code
GYROSET G6A,0,0,0,0,0,0
GYROSET G6D,0,0,0,0,0,0
GYRODIR G6A,0,1,1,0,1,1
GYRODIR G6D,0,1,1,0,1,1
GYROSENSE G6A,0,200,200,0,0,0
GYROSENSE G6D,0,200,200,0,0,0
GOSUB Standard_pose
'-----------------------------------------------------------------------
MUSIC "CDE"
MAIN:
'Read the PS2 buttons
txchar ="C"
ETX 19200, txchar
GETC:
ERX 19200, rxchar, GETC
TEMPO 230
MUSIC "DDDDDD"
GOTO main
txchar ="e"
ETX 19200, txchar
GETe:
ERX 19200, rxchar, GETe
TEMPO 230
MUSIC "DDDDDD"
GOTO MAIN
'================================================
Standard_Pose:
MOVE G6A, 100,85,90,90,90,100
MOVE G6D, 100,85,90,90,90,100
MOVE G6B, 100,30,80,100,100,100
MOVE G6C, 100,30,80,100,100,100
WAIT
RETURN
'================================================
Hi Bot,
I tried to use "C".It doesn't work to control.
thanks
jeff