Page 236 - Programmable Logic Controllers, Fifth Edition - Mobile version
P. 236
LIM MEQEQU NEQ LES GRT LEQ GEQ Ladder logic program Output L2
NEQ PL1
NOT EQUAL
Bit Timer/Counter Input/Output Compare Com
Source A N7:5
30 PL1
Figure 10-20 Compare menu tab. Source B 25
an output was turned on or off when the accumulated value Figure 10-22 NEQ logic rung.
of the timer or counter equaled its preset value. What actu-
ally occurred was that the accumulated numeric data in one of an EQU logic rung. The operation of the rung can be
memory word was compared to the preset value of another summarized as follows:
memory word on each scan of the processor. When the • When the accumulated value of counter T4:0 stored
processor saw that the accumulated value was equal to the in source A’s address equals the value in source B’s
preset value, it switched the output on or off. address, N7:40, the instruction is true and the output
Comparison instructions are used to test pairs of val- is energized.
ues to determine if a rung is true. Figure 10-20 shows the • Source A may be a word address or a floating-point
Compare menu tab for the Allen-Bradley SLC 500 PLC address.
and its associated RSLogix software. The compare in-
structions can be summarized as follows: • Source B may be a word address, a floating-point
address, or a constant value.
LIM (Limit test)—Tests whether one value is within • With the equal instruction, the floating-point data
the limit range of two other values. is not recommended because of the exactness re-
MEQ (Masked Comparison for Equal)—Tests quired. One of the other comparison instructions,
portions of two values to see whether they are equal. such as the limit test, is preferred.
Compares 16-bit data of a source address to 16-bit
data at a reference address through a mask. The not equal (NEQ) instruction is an input instruction that
EQU (Equal)—Tests whether the value of Source A compares source A to source B: when source A is not equal to
is equal to the value of Source B source B, the instruction is logically true; otherwise it is logi-
cally false. Figure 10-22 shows an example of an NEQ logic
NEQ (Not Equal)—Tests whether the value of rung. The operation of the rung can be summarized as follows:
Source A is not equal to the value of Source B
LES (Less Than)—Tests whether the value of Source A • When the value stored at source A’s address, N7:5,
is less than the value of Source B is not equal to 25, the output will be true; otherwise,
GRT (Greater Than)—Tests whether the value of the output will be false.
Source A is greater than the value of Source B • The value stored at Source A is 30.
LEQ (Less Than or Equal)—Tests whether the value of • The value stored at Source B is 25.
Source A is less than or equal to the value of Source B. • Since the two values are not the same the output
GEQ (Greater Than or Equal)—Tests whether the will be true or on.
value of Source A is greater than or equal to the value • In all input-comparison instructions, Source A must be
of Source B an address and Source B can be an address or a constant.
The equal (EQU) instruction is an input instruction The greater than (GRT) instruction is an input instruc-
that compares source A to source B: when source A is tion that compares source A to source B: when source A
equal to source B, the instruction is logically true; other- is greater than source B, the instruction is logically true;
wise it is logically false. Figure 10-21 shows an example otherwise it is logically false. Figure 10-23 shows an
Ladder logic program Output Ladder logic program Output
EQU L2 GRT L2
EQUAL PL1 GREATER THAN (A>B) PL1
Source A Source A
T4:0.ACC PL1 T4:10.ACC PL1
Source B Source B
N7:40 200
Figure 10-21 EQU logic rung. Figure 10-23 GRT logic rung.
Data Manipulation Instructions Chapter 10 217
pet73842_ch10_207-233.indd 217 03/11/15 4:02 PM