Touch CUBLOC Code
Const Device = CB220
Const FingerID = 2

Dim f_pos_1 As Byte
Dim f_pres_1 As Byte
Dim i As Byte
Input 5                        'P0 / Pin 5 as Input
Opencom 0,9600,3,32,32        'open RS-232 channel to Xport
Opencom 1,9600,3,32,32        'open serial channel to Servo Controller
Bclr 1,1                     'clear channel 1 tx buffer

For i=0 To 254
    Put 1,255,1
    Put 1,0,1
    Put 1,i,1
    Delay 10
Next

On timer(5) Gosub a2d        'every 100 ms
On Recv0 Gosub servo_move    'on UDP in from Xport

Do
Loop

a2d:
f_pres_1=Adin(0)>>2            'scale 0-1023 to 0-255
Put 0,FingerID,1            'identify which finger this is
Put 0,f_pres_1,1             'send finger pressure to Xport
Return

servo_move:
f_pos_1=Get(0,1)            'get commanded finger position from Xport
Put 1,255,1                    'send 0xFF to servo controller
Put 1,0,1                    'servo #0
Put 1,f_pos_1,1                'send finger position to servo controller
Return
Unless otherwise stated, the content of this page is licensed under Creative Commons Attribution-ShareAlike 3.0 License