Greater Than (GRT)

0 comments
The GRT instruction tests whether Source A is greater than Source B.

Available Languages
-    Ladder Diagram

-    Function Block

-    Structured Text
 This instruction is not available in structured text. *

* There is no equivalent structured text instruction. Use other structured text programming to achieve the same result.

Operands
-    Ladder Diagram
Operand
Type
Format
Description
Notes
Source A
SINT
INT
DINT
REAL
String type

Immediate
tag
value to test against Source B
If you enter a SINT or INT tag, the value converts to a DINT value by sign-extension.

String types are:
-          default STRING data type
-          any new string type you create

To test the characters of a string, enter a string type for both Source A and Source B.
Source B
SINT
INT
DINT
REAL
String type
Immediate
tag
value to test against Source A

-    Function Block
Operand
Type
Format
Description
GRT tag
FBD_COMPARE
structure
GRT structure

-    Structured Text
Use the greater than signs ">" as an operator within an expression. This expression evaluates whether sourceA is greater than sourceB.

IF sourceA > sourceB THEN
 <statements>;

FBD_COMPARE Structure
Input Parameter
Data Type
Description
EnableIn
BOOL
Enable input. If cleared, the instruction does not execute and outputs are not updated.
Default is set.
SourceA
REAL
Value to test against SourceB
Valid = any float
SourceB
REAL
Value to test against SourceA
Valid = any float

Output Parameter
Data Type
Description
EnableOut
BOOL
Enable output.
Dest
BOOL
Result of the instruction. This is equivalent to rung-condition-out of the ladder diagram GEQ instruction.

Example
If value_1 is greater than value_2, set light_1. If value_1 is less than or equal to value_2, clear light_1.

-    Ladder Diagram



-    Function Block



-    Structured Text
light_1 := (value_1 > value_2);

- Download to PDF



Read More »

Greater Than or Equal To (GEQ)

0 comments
The GEQ instruction tests whether Source A is greater than or equal to Source B.

Available Languages
-    Ladder Diagram

-    Function Block


-    Structured Text
 This instruction is not available in structured text. *

* There is no equivalent structured text instruction. Use other structured text programming to achieve the same result.

Operands
-    Ladder Diagram

Operand
Type
Format
Description
Notes
Source A
SINT
INT
DINT
REAL
String type

Immediate
tag
value to test against Source B
If you enter a SINT or INT tag, the value converts to a DINT value by sign-extension.

String types are:
-          default STRING data type
-          any new string type you create

To test the characters of a string, enter a string type for both Source A and Source B.
Source B
SINT
INT
DINT
REAL
String type
Immediate
tag
value to test against Source A

-    Function Block

Operand
Type
Format
Description
GEQ tag
FBD_COMPARE
structure
GEQ structure

-    Structured Text
Use adjacent greater than and equal signs ">=" as an operator within an expression. This expression evaluates whether sourceA is greater than or equal to sourceB.

IF sourceA >= sourceB THEN
 <statements>;

FBD_COMPARE Structure

Input Parameter
Data Type
Description
EnableIn
BOOL
Enable input. If cleared, the instruction does not execute and outputs are not updated.
Default is set.
SourceA
REAL
Value to test against SourceB
Valid = any float
SourceB
REAL
Value to test against SourceA
Valid = any float


Output Parameter
Data Type
Description
EnableOut
BOOL
Enable output.
Dest
BOOL
Result of the instruction. This is equivalent to rung-condition-out of the ladder diagram GEQ instruction.

Example
If value_1 is greater than or equal to value_2, set light_b. If value_1 is less than value_2, clear light_b.

-    Ladder Diagram





-    Function Block


-    Structured Text
light_b := (value_1 >= value_2);


- Download to PDF


Read More »

Equal To (EQU)

0 comments
The EQU instruction tests whether Source A is equal to Source B.

Available Languages
-    Ladder Diagram


-    Function Block


-    Structured Text
 This instruction is not available in structured text. *

* There is no equivalent structured text instruction. Use the operator in an expression.

Operands
-    Ladder Diagram




Operand
Type
Format
Description
Notes
Source A
SINT
INT
DINT
REAL
String type






Immediate
tag
value to test against Source B
If you enter a SINT or INT tag, the value converts to a DINT value by sign-extension.

REAL values are rarely absolutely equal. If you need to determine the equality of two REAL values, use the LIM instruction.

String types are:

-          default STRING data type
-          any new string type you create

To test the characters of a string, enter a string type tag for both Source A and Source B.
Source B
SINT
INT
DINT
REAL
String type
Immediate
tag
value to test against Source A

-    Function Block

Operand
Type
Format
Description
EQU tag
FBD_COMPARE
structure
EQU structure

-    Structured Text
Use the equal sign "=" as an operator within an expression. This expression evaluates whether sourceA is equal to sourceB.

IF sourceA = sourceB THEN
 <statement>;


FBD_COMPARE Structure


Input Parameter
Data Type
Description
EnableIn
BOOL
Enable input. If cleared, the instruction does not execute and outputs are not updated.
Default is set.
SourceA
REAL
Value to test against SourceB
Valid = any float
SourceB
REAL
Value to test against SourceA
Valid = any float
 
Output Parameter
Data Type
Description
EnableOut
BOOL
Enable output.
Dest
BOOL
Result of the instruction. This is equivalent to rung-condition-out of the ladder diagram EQU instruction.




Example
If value_1 is equal to value_2, set light_a. If value_1 is not equal to value_2, clear light_a.

-    Ladder Diagram


-    Function Block


-    Structured Text
light_a :=(value_1 = value_2);


- Download to PDF

Read More »

Compare (CMP)

0 comments
The CMP instruction performs a comparison on the arithmetic operations you specify in the expression.

Available Languages
-    Ladder Diagram





Operands
-    Ladder Diagram

Operand
Type
Format
Description
Expression
SINT
INT
DINT
REAL
string
Immediate
tag
an expression consisting of tags and/or immediate values separated by operators.

A SINT or INT tag converts to a DINT value by sign-extension.

-    Structured Text
Structured text does not have a CMP instruction, but you can achieve the same results using an IF...THEN construct and expression.

IF BOOL_expression THEN
 <statement>;
END_IF;

Determining the order of operation
The operations you write into the expression are performed by the instruction in a prescribed order, not necessarily the order you write them. You can override the order of operation by grouping terms within parentheses, forcing the instruction to perform an operation within the parentheses ahead of other operations.

Operations of equal order are performed from left to right.

Order
Operation
1
( )
2
ABS, ACS, ASN, ATN, COS, DEG, FRD, LN, LOG, RAD, SIN, SQR, TAN, TOD, TRN
3
**
4
- (negate), NOT
5
*, /, MOD
6
<, <=, >, >=, =, <>
7
- (subtract), +
8
AND
9
XOR
10
OR

Using strings in an expression
To use strings of ASCII characters in an expression, follow these guidelines:

-    An expression lets you compare two string tags.
-    You cannot enter ASCII characters directly into the expression.
-    Only the following operands are permitted:

Operator
Description
=
equal
< 
less than
<=
less than or equal
> 
greater than
>=
greater than or equal
<> 
not equal

Example



If the CMP instruction finds the expression true, the rung-condition-out is set to true.







If you enter an expression without a comparison operator, such as value_1 + value_2, or value_1, the instruction evaluates the expression as:


If the expression is:
The rung-condition-out is set to:
non zero
zero
true
false


- Download to PDF

Read More »

Compare Instructions

0 comments
The compare instructions let you compare values by using an expression or a specific compare instruction.

Available Instructions
 
If you want to:
Use this instruction:
compare values based on an expression
test whether two values are equal
EQU
test whether one value is greater than or equal to a second value
GEQ
test whether one value is greater than a second value
GRT
test whether one value is less than or equal to a second value
LEQ
test whether one value is less than a second value
LES
test whether one value is between two other values
LIM
pass two values through a mask and test whether they are equal
MEQ
test whether one value is not equal to a second value
NEQ



You can compare values of different data types, such as floating point and integer.

The bold data types indicate optimal data types. An instruction executes at its fastest and with it lowest memory requirements if all the parameters of the instruction use the same optimal data type, typically DINT or REAL

- Download to PDF

Read More »