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

Page 43

Advertising
background image

Chapter 4

Defining Formulas

4–28

Here is how the example formula works: First, the formula calculates the
arctangent value of the ratio

GAGE2 / GAGE2.3

, which is the vertical

distance between the object and the workpiece center divided by the
corresponding horizontal distance (see Figure 4.13). Note that if the operand

GAGE2.3

equals 0 (zero), the formula fails (you cannot divide by 0).

Figure 4.13 Example application: Using operands GAGE2 and GAGE2.3

X

Object

Vertical distance
(operand GAGE2)
from workpiece center
to object center

Horizontal distance
(operand GAGE2.3)
from workpiece center
to object center

Then the formula conditionally adds 180 to the measure (

+ 180 *

(GAGE2.3 < 0)

)

, to provide for angular measurements greater than

90

°

when necessary (remember that the arctangent operator result is always

given as between –90

°

and 90

°

– see Figure 4.10, page 4–26).

If, for example, the value of

GAGE2.3

is negative, it means the object is

somewhere to the left of the workpiece center, which implies an angle greater
than 90

°

(see Figure 4.14). In this case, the conditional expression

(GAGE2.3 < 0)

is then true, which yields the value 1 for the conditional

expression. The value 1 is multiplied by 180 in the formula and added to the
arctangent result. As shown in Figure 4.14, the arctangent value of the
ratio

(GAGE2 / GAGE2.3)

is –55. However, since the operand

GAGE2.3

is negative (since the object is to the left of the workpiece

center), 180 is added to the value –55, for a result of 125.

Figure 4.14 Example application: Finding angular results greater than 90

°

X

q

q

= –55

°

(arctangent

measure of the
object relative to the
workpiece center)

Angle of object, relative to
workpiece center (125

°

)

Advertising