4MELFA-BASIC V
MELFA-BASIC V functions
4-102
•Program example 2
Correction when posture components are close to +/-180 degrees
Program
Explanation
1 If Deg(P2.C)<0 Then GoTo *MINUS
’Checks the sign of the posture component (C) of P2 and, if it is -
(negative), jump to the label MINUS line.
2 If Deg(P3.C)<-178 Then P3.C=P3.C+Rad(+360)
’If the posture component (C) of P3 is close to -180 degrees,
adds 360 degrees to correct it to a positive value.
3 If Deg(P4.C)<-178 Then P4.C=P4.C+Rad(+360)
’If the posture component (C) of P4 is close to -180 degrees,
adds 360 degrees to correct it to a positive value.
4 If Deg(P5.C)<-178 Then P5.C=P5.C+Rad(+360)
’If the posture component (C) of P5 is close to -180 degrees,
adds 360 degrees to correct it to a positive value.
5 GoTo *DEFINE
’Jumps unconditionally to the label DEFINE line.
6 *MINUS
’Specifies the label MINUS line as the jump destination.
7 If Deg(P3.C)<+178 Then P3.C=P3.C-Rad(+360)
’If the posture component (C) of P3 is close to +180 degrees,
adds 360 degrees to correct it to a negative value.
8 If Deg(P4.C)<+178 Then P4.C=P4.C-Rad(+360)
’If the posture component (C) of P4 is close to +180 degrees,
adds 360 degrees to correct it to a negative value.
9 If Deg(P5.C)<+178 Then P5.C=P5.C-Rad(+360)
’If the posture component (C) of P5 is close to +180 degrees,
adds 360 degrees to correct it to a negative value.
10 *DEFINE
’Specifies the label DEFINE line as the jump destination.
11 Def Plt 1, P2, P3, P4, P5, 3, 5, 2
’Defines the pallet. Pallet No. = 1, start point = P2, end point A =
P3, end point B = P4, diagonal point = P5, quantity A = 3,
quantity B = 5,
pallet pattern = 2 (Same direction).
12 M1=1
’Substitutes value 1 in numeric variable M1. (M1 is used as a
counter.
13 *LOOP
’Designates label LOOP at the jump destination.
14 Mov P1, -50 *1)
’Moves with joint interpolation from P1 to a position retracted
50mm in hand direction.
15 Ovrd 50
’Sets movement speed to half of the maximum speed.
16 Mvs P1
’Moves linearly to P1. (Goes to grasp workpiece.)
17 HClose 1
’Closes hand 1. (Grasps workpiece.)
18 Dly 0.5
’Waits 0.5 seconds.
19 Ovrd 100
’Sets movement speed to maximum speed.
20 Mvs , -50 *1)
’Moves linearly from current position (P1) to a position retracted
50mm in hand direction. (Lifts up workpiece.)
21 P10=(Plt1,M1)
’Operates the position in pallet No. 1 indicated by the numeric
variable M1, and substitutes the results in P10.
22 Mov P10, -50 *1)
’Moves with joint interpolation from P10 to a position retracted
50mm in hand direction.
23 Ovrd 50
’Sets movement speed to half of the maximum speed.
24 Mvs P10
’Moves linearly to P10. (Goes to place workpiece.)
25 HOpen 1
’Opens hand 1. (Places workpiece.)
26 Dly 0.5
’Waits 0.5 seconds.
27 Ovrd 100
’Sets movement speed to maximum speed.
28 Mvs , -50
’Moves linearly from current position (P10) to a position retracted
50mm in hand direction. (Separates from workpiece.)
29 M1=M1+1
’Increments numeric variable M1 by 1. (Advances the pallet
counter.)
30 If M1<=15 Then *LOOP
’If numeric variable M1 value is less than 15, jumps to label
LOOP and repeat process. If more than 15, goes to next step.
31 End
’Ends the program.