Le code ci-dessous pilote le robot à 3 axes.
Trois servo-moteurs sont mis en oeuvre à l'aide du module SMC Pro.
L'écran affiche les positions des moteurs.
______________________________________________________
SET PICBUS HIGH
LCDINIT
beep 0
'
30 dim touche as byte
'____________________
dim position0 as byte : position0 = 88
dim position1 as byte : position1 = 88
dim position2 as byte : position2 = 88
'_____________________
70 touche = ADKEYIN(4)
if touche = 0 then goto 70
beep 15
LOCATE 0,0 : PRINT "clavier";dec(touche)
LOCATE 1,1 : print dec(position0);dec(position1);dec(position2)
'LOCATE 1,1 : print dec(position0): print dec(position1): print dec(position 2)
if touche = 6 then gosub PTOUCHE1' base droite
if touche = 1 then gosub PTOUCHE2' base gauche
if touche = 7 then gosub PTOUCHE3' av-bras haut
if touche = 2 then gosub PTOUCHE4' av-bras bas
if touche = 8 then gosub PTOUCHE5' bras haut
if touche = 3 then gosub PTOUCHE6' bras bas
if touche = 10 then gosub PTOUCHE10' initialisation
goto 70
'________ ____________________________
'SOUS-PROGRAMMES D'APPUI DE TOUCHES
'_____________________________________
'MOTEUR No 0___P1 & P2
PTOUCHE1:
position0=position0 - 1
serout 13,30,0,1,[0,0,255]' vitesse
delay 30
serout 13,30,0,1,[0,1,position0] ' angle
return
'
PTOUCHE2:
position0=position0 + 1
serout 13,30,0,1,[0,0,255]' vitesse
delay 30
serout 13,30,0,1,[0,1,position0] ' angle
return
'_____________________
'MOTEUR No 1___P3 & P4
PTOUCHE3:
position1=position1 - 1
serout 13,30,0,1,[1,0,255]' vitesse
delay 30
serout 13,30,0,1,[1,1,position1] ' angle
return
PTOUCHE4:
position1=position1 + 1
serout 13,30,0,1,[1,0,255]' vitesse
delay 30
serout 13,30,0,1,[1,1,position1] ' angle
return
'_______________________
'MOTEUR No 2___P5 & P6
PTOUCHE5:
position2=position2 - 1
serout 13,30,0,1,[2,0,255]' vitesse
delay 30
serout 13,30,0,1,[2,1,position2] ' angle
return
PTOUCHE6:
position2=position2 + 1
serout 13,30,0,1,[2,0,255]' vitesse
delay 30
serout 13,30,0,1,[2,1,position2] ' angle
return
'________________________________________
PTOUCHE10: '____Initialisation position médiane
serout 13,30,0,1,[1,0,190] ' vitesse
delay 100
serout 13,30,0,1,[1,1,117 ]' BRAS inf angle INIT 117 degrés
serout 13,30,0,1,[2,0,190] ' vitesse
delay 100
serout 13,30,0,1,[2,1,100 ]' BRAS sup angle INIT 100 degrés
serout 13,30,0,1,[0,0,190] ' vitesse
delay 100
serout 13,30,0,1,[0,1,88 ]' BASE angle INIT 88 degrés
position0=88
position1=117
position2=100
RETURN