A Program To Calculate Distance Between Points18-13 - Panasonic VR2 Series Operating Instructions Manual

Industrial robot
Table of Contents

Advertisement

18-6. A program to calculate distance between points
A program to calculate distance between points by calculating differences of X, Y and Z of two points respectively, and
then find the distance from the square root of sum of the squares of X, Y and Z.
2
[ Equation:
(x
-x
)
+(y
1
2
Program (PtoPlen.prg)
The following is a program to calculate distance between points (point-1 and point-2) and then add the result to "GR001".
The coordinate of the point-1 is assigned to "GD001" and that of the point-2 to "GD002".
Program
SUB GD001 GD002
GETEL LR001 = GD.X#(1:GD001)
MUL LR001 LR001
GETEL LR002 = GD.Y#(1:GD001)
MUL LR002 LR002
ADD LR001 LR002
GETEL LR003 = GD.Z#(1:GD001)
MUL LR003 LR003
ADD LR001 LR003
SQRT LR001 LR001
ADD GR001 LR001
*1)
RET
● Application example
TOOL 1:TOOL0001
MOVEL P1
MOVEL P2
CNVSET GD001 P1
CNVSET GD002 P2
CALL PtoPLen.prg
*1)
Please note that in the above sample program, result of the calculation (distance) is added to the GR variable. Since the
maximum value of the GR variable is "99999.99", in case of calculation distance longer than 100 m, it is necessary to use
the GL variable. (See the following example.)
ADD GR001 LR001
2
2
]
-y
)
+(z
-z
)
1
2
1
2
Difference between GD001 and GD002.
Take X element of GD001.
Raise the X element to the second power.
Take the Y element of GD001.
Raise the Y element to the second power.
Add the square of the Y element to the square of the X
element.
Take the Z element of GD001.
Raise the Z element to the second power.
Add the square of the Z element to the sum of the square of
the X element and of the Y element.
Calculate the square root of the sum to find the distance.
Add the distance to GR001.
End of the program
CNVSET LL001 LR001
ADD GL001 LL001
18-13
Description

Advertisement

Table of Contents
loading

This manual is also suitable for:

Ya-1na seriesYa-1pa series

Table of Contents