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

Hide thumbs Also See for Simatic S7-200:
Table of Contents

Advertisement

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-14
Valid Operands for the Compare Instructions
Inputs/Outputs
Type
IN1, IN2
BYTE
INT
DINT
REAL
Output (or OUT)
BOOL
IN1 <= IN2
IN1 <> IN2
Operands
IB, QB, VB, MB, SMB, SB, LB, AC, *VD, *LD, *AC, Constant
IW, QW, VW, MW, SMW, SW, T, C, LW, AC, AIW, *VD, *LD, *AC, Constant
ID, QD, VD, MD, SMD, SD, LD, AC, HC, *VD, *LD, *AC, Constant
ID, QD, VD, MD, SMD, SD, LD, AC, *VD, *LD, *AC, Constant
I, Q, V, M, SM, S, T, C, L, Power Flow
S7-200 Instruction Set
Chapter 6
6
89

Hide quick links:

Advertisement

Table of Contents
loading

Table of Contents