Using expressions – Rockwell Automation 1775-S5_SR5,D17756.5.5 User Manual PLC-3 FAMILY I/0 User Manual

Page 98

Advertising
background image

Programming DH and DH+

Message Procedures

Chapter 6

6-7

Expressions use operators to combine two or more numeric values into a
single value. Table 6.C lists the operators that you can use in an
expression. We list these operators from highest priority (1) to lowest
priority (10). The result of an expression depends on the order the scanner
executes the operations. The order of execution depends on the type of
operator and on left-to-right placement within the expression.

The result of an expression is a 32-bit value. If the high-order bits are not
significant (that is, if they can be truncated without changing the value of
the expression), then a data field that is less than 32 bits long can store the
value. Attempting to put a value into a field that is too small results in
error code 189 (see appendix B).

Table 6.C

Expression Operators

Operator

Order of Execution

Description

/

1

bit operator

.NOT.

1

logical complement

~ or .BNOT.

1

bitwise 32Ćbit complement

*

2

multiplication of 32 bits

%

2

division of 32 bits

+

3

addition of 32 bits

-

3

subtraction of 32 bits

<<

4

left arithmetic shift

>>

4

right arithmetic shift

& or .BAND.

5

bitwise 32Ćbit AND

^ or .BXOR.

6

bitwise 32Ćbit EXCLUSIVE OR

| or .BOR.

7

bitwise 32Ćbit OR

.EQ.

8

compare equals

.GT.

8

compare greater than

.GE.

8

compare greater or equal

.LT.

8

compare less than

.LE.

8

compare less or equal

.NE.

8

compare not equal

.AND.

9

logical AND

.OR.

10

logical OR

You can nest expressions within other expressions by enclosing the inner
expression within parentheses.

Using Expressions

Advertising