Rockwell Automation 5370-CMPK Color CVIM Module MATH-PAK User Manual

Page 40

Advertising
background image

Chapter 4

Defining Formulas

4–25

operator/operand expressions, and 4) operator/operand portions of the
formula – that is, operators of the type that are followed by a parenthetical
listing of operands.

Example usage: Use the square root operator with a parenthetical expression
which adds the squares of gage 2 and gage 3, possibly to calculate a distance
(by the Pythagorean theorem):

SQR (SQ (GAGE2)

+

SQ (GAGE3))

Distance operator:

DST

Format/Usage: The distance operator (

DST

) computes the distance between

two points, given the x- and y-coordinates of the two points.

The format for the

DST

operator:

DST

(X

1

,

Y

1

, X

2

, Y

2

), where X

1

and Y

1

are assumed to be the x- and y-coordinates of the first point, and X

2

and Y

2

are assumed to be the x- and y-coordinates of the second point.

To use the distance operator, enter the

DST

operator – which includes the

open parenthesis “(” – then enter four operands or expressions, separated by
commas, and then enter the close parenthesis “).”

Example usage: Use the distance operator to find the distance between two
objects identified and located by two different windows:

DST

(WIN1.12,

WIN1.13,

WIN2.12,

WIN2.13)

Operands

WIN1.12

and

WIN1.13

indicate the x- and y-coordinates,

respectively, of the center of gravity of the object identified by color in
window 1 (see Figure 4.9). Similarly, operands

WIN2.12

and

WIN2.13

indicate the x- and y-coordinates, respectively, of the center of

gravity of the object identified by color in window 2.

Figure 4.9 Example of using the DST function

Window 1

Window 2

Distance from
window 1 object
to window 2
object

Object
identified by
color in
Window 1

Object
identified by
color in
Window 2

Advertising