0% found this document useful (0 votes)
8 views14 pages

Chapter 5

Uploaded by

micheal amash
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
8 views14 pages

Chapter 5

Uploaded by

micheal amash
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 14

Chapter 5 1

Prepared by Dr. Musa Alyaman Automation and Programmable Logic Controller(0938461)


Comparison instruction overview.

Prepared by Dr. Musa Alyaman Automation and Programmable Logic Controller(0938461) 2


Prepared by Dr. Musa Alyaman Automation and Programmable Logic Controller(0938461) 3
Comparison instructions are used to test pairs of values to condition the
logical continuity of a rung. As an example, suppose a LES instruction is
presented with two values. If the first value is less than the second, then
the comparison instruction is true.

The following is a list of comparison instructions in SLC 500:


 EQU -Equal
 NEQ -Not Equal
 LES -Less Than
 LEQ -Less Than or Equal
 GRT -Greater Than
 GEQ -Greater Than or Equal
 MEQ -Masked Comparison for Equal
 LIM -Limit Test
Prepared by Dr. Musa Alyaman Automation and Programmable Logic Controller(0938461) 4
 Use the EQU instruction to test whether two values are equal.

 Use the NEQ instruction to test whether two values are not equal.

Equal (EQU)
 If source A and source B are equal, the instruction is logically true.

 If these values are not equal, the instruction is logically false.

Not Equal (NEQ)


 If source A and source B are not equal, the instruction is logically true.

 If the two values are equal, the instruction is logically false.

 Source A must be an address.

 Source B can either be a program constant or a address.

 Negative integers are stored in two’s complement form.

Prepared by Dr. Musa Alyaman Automation and Programmable Logic Controller(0938461) 5


A gas-heated, two-zone belt conveyor oven is
used to stress heavy-duty steel springs. This
unit has a maximum operating temperature of
850°F.
A counter C5:1 has a value in its preset register
equals 20, it is required to stop the conveyor
motor and start the heating coils in first oven
zone when the value of the C5:1 accumulator is
equals half of its preset register.
 Input / Output table
 conveyor Motor O:2.0/3
 Heating coil in first zone O:2.0/4

 Ladder Logic Solution

Prepared by Dr. Musa Alyaman Automation and Programmable Logic Controller(0938461) 6


 Use the LES instruction to test whether one value (source A) is less than another (source B).

 Use the GRT instruction to test whether one value (source A) is greater than another (source B).

Less Than (LES)


 If source A is less than the value at source B, the instruction is logically true.

 If the value at source A is greater than or equal to the value at source B, the instruction is logically false.

Greater Than (GRT)


 If the value at source A is greater than the value at source B, the instruction is logically true.

 If the value at source A is less than or equal to the value at source B, the instruction is logically false.

 Source A must be an address.

 Source B can either be a program constant or a address.

 Negative integers are stored in two’s complement form.

Prepared by Dr. Musa Alyaman Automation and Programmable Logic Controller(0938461) 7


A steel sheet cutting machine must
have the following two conditions to
start the cutting laser:
1) The steel roll weight must be
more than 1 KG.
2) The length of the cutting sheet
must be above 2 m.

 Input / Output table


 Weight sensor I:3.0/0
 Length sensor I:3.0/1
 Cutting laser O:2.0/0

 Ladder Logic Solution

Prepared by Dr. Musa Alyaman Automation and Programmable Logic Controller(0938461) 8


 Use the LEQ instruction to test whether one value (source A) is less than or equal to another (source B).

 Use the GEQ instruction to test whether one value (source A) is greater than or equal to another (source B).

Less Than or Equal (LEQ)


 If the value at source A is less than or equal to the value at source B, the instruction is logically true.

 If the value at source A is greater than the value at source B, the instruction is logically false.

Greater Than or Equal (GEQ)


 If the value at source A is greater than or equal to the value at source B, the instruction is logically true.

 If the value at source A is less than the value at source B, the instruction is logically false.

 Source A must be an address.

 Source B can either be a program constant or a address.

 Negative integers are stored in two’s complement form.

Prepared by Dr. Musa Alyaman Automation and Programmable Logic Controller(0938461) 9


Write Less Than or Equal (LEQ) instruction
using Less Than (LES) and Equal (EQU)
instructions.

Write Greater Than (GRT) instruction using


Greater Than or Equal (GEQ) and Not Equal
(NEQ) instructions.

Prepared by Dr. Musa Alyaman Automation and Programmable Logic Controller(0938461) 10


 The Low Limit, Test, and High Limit values can be word
addresses or constants, restricted to the following combinations.
 If the Test parameter is a program constant, both the Low Limit and High
Limit parameters must be word addresses.
 If the Test parameter is a word address, the Low Limit and High Limit
parameters can be either a program constant or a word address.

 Use the LIM instruction to test for values within or outside a


specified range, depending on how you set the limits (Normal).
 If the Low Limit has a value equal to or less than the High Limit, the
instruction is true when the Test value is between the limits or is equal to
either limit.
 If the Test value is outside the limits, the instruction is false.

 Use the LIM instruction to test for values within or outside a


specified range, depending on how you set the limits (Inverted).
 If the Low Limit has a value greater than the High Limit, the instruction is
false when the Test value is between the limits.
 If the Test value is equal to either limit or outside the limits, the instruction is
true.

Prepared by Dr. Musa Alyaman Automation and Programmable Logic Controller(0938461) 11


Write Limit Test (LIM) instruction using other comparison
instructions.

Write Equal (EQU) instruction using Limit Test (LIM) instruction.

Prepared by Dr. Musa Alyaman Automation and Programmable Logic Controller(0938461) 12


 Use the MEQ instruction to compare data at a source address with data at a compare address.

 Use of this instruction allows portions of the data to be masked by a separate word.

 Source is the address of the value you want to compare.

 Mask is the address of the mask through which the instruction moves data.

 The mask can also be a hexadecimal value (constant).

 Compare is an integer value or the address of the reference.

 If the 16 bits of data at the source address are equal to the 16 bits of data at the compare address (less masked
bits), the instruction is true.
 The instruction becomes false as soon as it detects a mismatch. Bits in the mask word mask data when reset; they
pass data when set.

Prepared by Dr. Musa Alyaman Automation and Programmable Logic Controller(0938461) 13


 Lets say we have four counters. Each counter goes from 0 to 9. Since 0 to 9 can be
represented in 4 bits then we can combine the four counters in one word of 16 bits. This
is to reduce the amount of memory counters will need.

 Counter 1 = N7:0 bit 0,1,2,3


 Counter 2 = N7:0 bit 4,5,6,7
 Counter 3 = N7:0 bit 8,19,10,11
 Counter 4 = N7:0 bit 12,13,14,15

Prepared by Dr. Musa Alyaman Automation and Programmable Logic Controller(0938461) 14

You might also like