EQ (=)

The EQ instruction performs an operation that compares the first input to the second input to determine equality for Integer, Real, Time, Date, and String data types.
Operation details:
  • Equality testing of Time values is not recommended for TON, TP, and TOF instruction blocks.
  • Using the Real data type for equality comparisons is not recommended because numbers are rounded differently in mathematical operations than appeared in the variable output display. Consequently, two output values might appear equal in the display, though evaluated as false. For example, when comparing 23.500001 to 23.499999, they both display as 23.5 in the variable input display, but are not equal in the controller.
Languages supported: Function block diagram, ladder diagram, structured text.
This instruction applies to the Micro810, L20E, L50E, and L70E controllers.
EQ
EQ
EQ parameters
Parameter
Parameter Type
Data Type
Description
EN
Input
BOOL
When set to true, the instruction is enabled.
  • TRUE: Execute the current computation.
  • FALSE: There is no computation.
Applies to ladder diagram programs.
i1
Input
BOOL
SINT
USINT
BYTE
INT
UINT
WORD
DINT
UDINT
DWORD
LINT
ULINT
LWORD
REAL
LREAL
TIME
DATE
STRING
All inputs must be the same data type.
The Time input applies to the structured text, ladder diagram, and function block diagram languages.
The Real data type is not recommended.
i2
Input
BOOL
SINT
USINT
BYTE
INT
UINT
WORD
DINT
UDINT
DWORD
LINT
ULINT
LWORD
REAL
LREAL
TIME
DATE
STRING
o1
Output
BOOL
TRUE if i1 = i2.

Compare Real Values using SUB (-), ABS, and LT (<) example

Using the Real data type for equality comparisons is not recommended because of the differences in the way numbers are rounded. Two output values might appear equal in a
FactoryTalk Design Workbench
display, but will evaluate as false.
For example, when comparing 23.500001 to 23.499999, they both display as 23.5 in the variable input display, but are not equal in the controller.
To test whether two Real data type values are equal, you can use an SUB instruction to get the difference between the values, and then determine if the difference is Less Than an established precision value. See the following LD program example for comparing two Real data type values.
Compare Real Values using SUB (-), ABS, and LT (<) example
Compare Real Values using SUB (-), ABS, and LT (<) example

EQ examples

EQ function block diagram example
EQ function block diagram example
EQ ladder diagram program example
EQ ladder diagram program example
(* ST Equivalence: *) aresult := (10 = 25); (* aresult is FALSE *) mresult := ('ab' = 'ab'); (* mresult is TRUE *)
Provide Feedback
Have questions or feedback about this documentation? Please submit your feedback here.
Normal