Rockwell Automation 5370-CVIM2 Module User Manual

Page 367

Advertising
background image

5

Chapter

Chapter 7

Inspection Tools

7–129

In this example formula, the decimal value 87

10

is bit–xored with the

decimal value 119

10,

which produces a result of 32

10

. The whole expression

is then modified by the “

bnot

” operator, the effect of which is to invert all bit

positions in a 32–bit version of the decimal 32

10

, changing it to a 32–bit

“1’s” complement result, as follows:

87

10

= 1010111

2

119

10

= 1110111

2

0100000

2

= 32

10

XOR

1111 1111 1111 1111 1111 1111 1101 1111

2

= 4294967263

10

BNOT

0000 0000 0000 0000 0000 0000 0010 0000

2

= 32

10

However, since the 32–bit number resulting from the “

bnot

” operation is too

large, because of internal restrictions, that number can be “masked” down to
a more useful size by bit–anding it with an 8–bit mask of “1’s” (that is,
255

10

). The complete example formula would then appear as follows:

(bnot87bxor119)band255

This will yield a value of 223

10

, as shown below:

1111 1111 1111 1111 1111 1111 1101 1111

2

= 4294967263

10

0000 0000 0000 0000 0000 0000 1111 1111

2

= 255

10

0000 0000 0000 0000 0000 0000 1101 1111

2

= 223

10

bor –– The “

bor

” (bit or) logic operator is inserted between two expressions

(such as inspection results values) in a formula. The values of the
expressions (“inputs”) on both sides of the “

bor

” operator are converted to

binary equivalents and are “ored” at the binary level. The binary result of the
logic operation (“output”) is then converted back to decimal form.

In a simple example, two values are “bit–ored,” as follows:

87bor119

In this example, the ASCII value of the uppercase character “W” (87

10

) is

bit–ored with the ASCII value of the lowercase “w” (119

10

). The effect is to

convert the uppercase “W” to lowercase “w” by changing bit 5 to 1, as
follows:

87

10

= 1010111

2

119

10

= 1110111

2

1110111

2

= 119

10

OR

bxor –– The “

bxor

” (bit “exclusive” or) logic operator is inserted between

two expressions (such as inspection results values) in a formula. The values
of the expressions (“inputs”) on both sides of the “

bxor

” operator are

converted to binary equivalents and are “xored” at the binary level. The

Advertising