beautypg.com

B&B Electronics VFG3000 - Manual User Manual

Page 194

background image

T

ESTING

B

ITS

V

LINX

F

IELDBUS

G

ATEWAY

M

ANAGER

U

SER

M

ANUAL

P

AGE

178

T

ESTING

B

ITS

Fieldbus Gateway Manager allows you to test the value of a bit within a data value by using
the bit selection operator, which is represented by a single period. The left-hand side of the
operator should be the value in which the bit is to be tested, and the right-hand side should be
an expression indicating the bit number to test. This right-hand value should be between 0 and
31. The result of the operator is equal to 0 or 1 depending on the value of the bit in question.

O

PERATOR

P

RIORITY

E

XAMPLE

Bit Selection

Group 1

Input.2

The example shown tests bit 2 (ie. the bit with a value of 4) within the indicated tag.

If you want to test for a bit being equal to zero, you can use the logical NOT operator…

O

PERATOR

P

RIORITY

E

XAMPLE

Logical NOT

Group 2

!Input.2

This example is equal to 1 if bit 2 of the indicated tag is equal to 0, and vice versa.

M

ULTIPLE

C

ONDITIONS

If you want to define an expression that is true if a number of conditions are all true, you can
use the logical AND operator. Similarly, if you want to define an expression that is true if any
of a number of conditions are true, you can use the logical OR operator. The examples below
show each operator in use…

O

PERATOR

P

RIORITY

E

XAMPLE

Logical AND

Group 11

A>10 && B>10

Logical OR

Group 12

A>10 || B>10

The logical AND operator produces a value of 1 if and only if the expressions on the
left-hand and right-hand sides are true, while the logical OR operator produces a value of 1 if
either expression is true. Note that—unlike the bitwise operators referred to elsewhere in this
section—the logical operators stop evaluating once they know what the answer will be. This
means that in the above example for logical AND, the right-hand side of the operator will
only be evaluated if A is greater than 10, as, if this were not true, the result of the AND
operator must already be zero. While this property makes little difference in the examples
given above, if the left-hand or right-hand expressions call a program or make a change to a
data value, this behavior must be taken into account.