Page 397 - Programmable Logic Controllers, Fifth Edition - Mobile version
P. 397
Ladder logic program
Greater_Than_PL
Equal_PL Output L2 Ladder logic program Output L2
EQU <Local:2:O.Data.2> GRT <Local:2:O.Data.5>
Equal Greater than (A>B)
Source A Value_1 Equal_PL Source A Value_1 Greater_Than_PL
25 1420
Source B Value_2 Source B Value_2
25
1200
Tag Name Value Style Data Type Figure 15-87 GRT instruction rung.
Equal_PL 1 Decimal BOOL
-Value_1 25 Decimal DINT
-Value_2 25 Decimal DINT
is slightly slower and uses more memory than the execu-
Figure 15-84 EQU instruction rung and its Monitor Tags tion of the other comparison instructions. The advantage of
window. the CMP instruction is that it allows you to enter complex
expressions in one instruction. Figure 15-88 shows an ex-
ample of a CMP instruction rung. In this example the com-
parison operator found in the expression is the equivalent
Ladder logic program Output of an EQU instruction. The comparison instruction is true
Not_Equal_PL L2 because Value_1 (300) is equal to Value_2 (300).
NEQ <Local:2:O.Data.3> The program of Figure 15-89 is an example of the use
Not Equal
Source A Value_1 Not_Equal_PL of comparison instructions used to test the accumulated
10 value of a counter. The operation of the program can be
Source B Value_2 summarized as follows:
25
• When the accumulated count is between 5 and 10
Figure 15-85 NEQ instruction rung.
the GRT and LES instructions will both be logically
true so the PL_1 pilot light will be on.
• When the accumulated count is equal to 15, the
Ladder logic program Output EQU instruction will be logically true so the PL_2
Less_Than_PL L2 pilot light will be on.
LES <Local:2:O.Data.4> • The PL_3 pilot light will be on at all times except
Less than (A<B) when the accumulated count is 20 at which time the
Source A Value_1 Less_Than_PL
100 NEQ instruction is logically false.
Source B Value_2 • The counter is reset automatically when the accu-
300
mulated count reaches 25 or manually anytime the
Figure 15-86 LES instruction rung. Reset_PB is actuated.
Ladder logic program Output
Equal_PL L2
CMP <Local:2:O.Data.2>
Compare
Expression Value_1 = Value_2 Equal_PL
Tag Name Value Style Data Type
Equal_PL 1 Decimal BOOL
-Value_1 300 Decimal DINT
-Value_2 300 Decimal DINT
Figure 15-88 CMP instruction rung.
378 Part 5 Math, Comparison, and Move Instructions
pet73842_ch15_333-394.indd 378 03/11/15 7:34 PM