Compare Instructions; Comparing Numerical Values - Siemens SIMATIC S7-200 System Manual

Programmable controller
Hide thumbs Also See for SIMATIC S7-200:
Table of Contents

Advertisement

S7-200 Programmable Controller System Manual

Compare Instructions

Comparing Numerical Values

The compare instructions are used to compare two values:
IN1 = IN2
IN1 >= IN2
IN1 > IN2
IN1 < IN2
Compare Byte operations are unsigned.
Compare Integer operations are signed.
Compare Double Word operations are signed.
Compare Real operations are signed.
For LAD and FBD: When the comparison is true, the
Compare instruction turns on the contact (LAD) or output
(FBD).
For STL: When the comparison is true, the Compare
instruction Loads, ANDs, or ORs a 1 with the value on the
top of the stack (STL).
When you use the IEC compare instructions, you can use
various data types for the inputs. However, both input
values must be of the same data type.
Notice
The following conditions are fatal errors and cause your
S7-200 to immediately stop the execution of your
program:
H Illegal indirect address is encountered (any Compare
instruction)
H Illegal real number (for example, NAN) is encountered
(Compare Real instruction)
To prevent these conditions from occurring, ensure that
you properly initialize pointers and values that contain real
numbers before executing compare instructions that use
these values.
Compare instructions are executed regardless of the state
of power flow.
Table 6-15
Valid Operands for the Compare Instructions
Inputs/Outputs
IN1, IN2
Output (or OUT)
96
IN1 <= IN2
IN1 <> IN2
Type
Operands
BYTE
IB, QB, VB, MB, SMB, SB, LB, AC, *VD, *LD, *AC, Constant
INT
IW, QW, VW, MW, SMW, SW, T, C, LW, AC, AIW, *VD, *LD, *AC,
Constant
DINT
ID, QD, VD, MD, SMD, SD, LD, AC, HC, *VD, *LD, *AC, Constant
REAL
ID, QD, VD, MD, SMD, SD, LD, AC, *VD, *LD, *AC, Constant
BOOL
I, Q, V, M, SM, S, T, C, L, Power Flow

Hide quick links:

Advertisement

Table of Contents
loading

Table of Contents