Structured Text Programming
Rockwell Automation Publication 1756-RM006K-EN-P - November 2018 517
The table provides examples of using logical operators.
Use this format Example
For this situation Use
BOOLtag If photoeye is a BOOL tag and your specification says: "If photoeye_1 is on
then..."
IF photoeye THEN...
NOT BOOLtag If photoeye is a BOOL tag and your specification says: "If photoeye is off
then..."
IF NOT photoeye THEN...
expression1 & expression2 If photoeye is a BOOL tag, temp is a DINT tag, and your specification says: "If
photoeye is on and temp is less than 100 then..."
IF photoeye & (temp<100) THEN...
expression1 OR expression2 If photoeye is a BOOL tag, temp is a DINT tag, and your specification says: "If
photoeye is on or temp is less than 100 then...".
IF photoeye OR (temp<100) THEN...
expression1 XOR expression2 If photoeye1 and photoeye2 are BOOL tags and your specification says: "If:
photoeye1 is on while photoeye2 is off or
photoeye1 is off while photoeye2 is on
then..."
IF photoeye1 XOR photoeye2 THEN...
BOOLtag := expression1 &
expression2
If photoeye1 and photoeye2 are BOOL tags, open is a BOOL tag, and your
specification says: "If photoeye1 and photoeye2 are both on, set open to true"
open := photoeye1 & photoeye2;
See also
Structured Text Components: Expressions on page 513
Relational operators compare two values or strings to provide a true or false result.
The result of a relational operation is a BOOL value.
If the comparison is The result is
True 1
False 0
Use these relational operators.
For this comparison Use this operator Optimal data type
Equal = DINT, REAL, String type
Less than < DINT, REAL, String type
Less than or equal <= DINT, REAL, String type
Greater than > DINT, REAL, String type
Greater than or equal >= DINT, REAL, String type
Not equal <> DINT, REAL, String type