8/13/2019 PLC Instructions 2 IITD
1/19
Programmable Logic controller 1
Programmable
Logic Controllers
8/13/2019 PLC Instructions 2 IITD
2/19
PLC File Structure
Programmable Logic controller 2
8/13/2019 PLC Instructions 2 IITD
3/19
Comparison Instructions
Use these input instructions when you want tocompare values of data.
EQU: Test whether two values are equal (=)
NEQ: Test whether one value is not equal to a
second value (>
8/13/2019 PLC Instructions 2 IITD
4/19
Comparison Instructions
Use these input instructions when you want tocompare values of data.
GEQ: Test whether one value is greater than or
equal to a second value (=>)
MEQ: Test portions of two values to see whether
they are equal
LIM: Test whether one value is within the limit range
of two other values
Programmable Logic controller 4
8/13/2019 PLC Instructions 2 IITD
5/19
Comparison Instructions
EQU [Equal] This input instruction is true when
Source A = Source B.
The EQU instruction compares two userspecified values. If the values are
equal, it allows rung continuity. The
rung goes true and the output is
energized
You must enter a word address for
Source A. You can enter a program
constant or a word address for Source
B.
Programmable Logic controller 5
8/13/2019 PLC Instructions 2 IITD
6/19
Comparison Instructions
NEQ [Not Equal] Use the NEQ instruction to test whether
two values are not equal.
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 Amust be a word address.
Source Bcan be a word address or
program constant
Programmable Logic controller 6
8/13/2019 PLC Instructions 2 IITD
7/19
8/13/2019 PLC Instructions 2 IITD
8/19
Comparison Instructions
LEQ [Less Than or Equal] This conditional input instruction tests
whether one value (source A) is less
than or equal to another (source B).
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 islogically false.
Programmable Logic controller 8
8/13/2019 PLC Instructions 2 IITD
9/19
Comparison Instructions
GRT [Greater Than] This input instruction compares two
user specified values.
If the value stored in Source A is
greater than the value stored in Source
B, it allows rung continuity. The rung
will go "true" and the output will be
energized (provided no other
instructions affect the rung's status). If the value at Source A is less than or
equal to the value at Source B, the
instruction is logically false.
Programmable Logic controller 9
8/13/2019 PLC Instructions 2 IITD
10/19
Comparison Instructions
GEQ [Greater Than or Equal To] If the value stored in Source A is
greater than or equal to the value
stored in Source B, it allows rung
continuity. The rung will go true and theoutput will be energized (provided no
other instructions affect the rung's
status).
If the value at Source A is less than thevalue at Source B, the instruction is
logically false.
Programmable Logic controller 10
8/13/2019 PLC Instructions 2 IITD
11/19
Comparison Instructions
MEQ [Masked Equal] This conditional instruction compares
16-bit data of a source address to 16-bit
data at a reference address through a
mask.
If the values match, the instruction is
true.
This instruction allows portions of the
data to be masked by a separate word.
Programmable Logic controller 11
8/13/2019 PLC Instructions 2 IITD
12/19
Comparison Instructions
LIM [Limit Test] Use the LIM instruction to test for
values within or outside a specified
range, depending on how you set the
limits. 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.
Programmable Logic controller 12
8/13/2019 PLC Instructions 2 IITD
13/19
Program Control Instructions
Use these instructions to change the order inwhich the processor scans a ladder program.
Typically these instructions are used to minimize
scan time, create a more efficient program, and to
troubleshoot a ladder program.
JMP, LBL: Jump forward/backward to a corresponding
label instruction
JSR, SBR, RET: Jump to a designated subroutine and
return
Programmable Logic controller 13
8/13/2019 PLC Instructions 2 IITD
14/19
Control Instructions
JMP [Jump to Label] When the rung condition for this output
instruction is true, the processor jumps
forward or backward to the corresponding
label instruction (LBL) and resumes
program execution at the label.
More than one JMP instruction can jump
to the same label.
Jumping forward to a label saves
program scan time by omitting a program
segment until needed.
Jumping backward lets the controller
execute program segments repeatedly.
Programmable Logic controller 14
8/13/2019 PLC Instructions 2 IITD
15/19
Control Instructions
LBL [Label] This input instruction is the target of the
JMP instruction having the same label
number.
You must program this instruction as thefirst instruction of a rung. This instruction
has no control bits. It is always evaluated
as true or logic 1.
You can program multiple jumps to the
same label by assigning the same label
number to multiple JMP instructions, but
assigning the same label number to two
or more labels causes a compile time
error.
Programmable Logic controller 15
8/13/2019 PLC Instructions 2 IITD
16/19
Control Instructions
JSR [Jump to Subroutine] When rung conditions are true for this
output instruction, it causes the
processor to jump to the targeted
subroutine file. You can only jump to the first
instruction in a subroutine.
Each subroutine must have a unique
file number (decimal, 3-255).
Programmable Logic controller 16
8/13/2019 PLC Instructions 2 IITD
17/19
Control Instructions
SBR [Subroutine] Use a subroutine to store recurring
sections of program logic that must
be executed from several points
within your application program. A subroutine saves memory because
you program it only once.
The instruction must be programmed
as the first instruction of the first rungof a subroutine.
Use of this instruction is optional, but
recommended.
Programmable Logic controller 17
8/13/2019 PLC Instructions 2 IITD
18/19
Control Instructions
RET [Return] This output instruction marks the end
of subroutine execution or the end of
the subroutine file.
It causes the processor to resumeexecution in the main program file at
the instruction following the JSR
instruction where it exited the
program.
Programmable Logic controller 18
8/13/2019 PLC Instructions 2 IITD
19/19
Control Instructions
RET [Return] The rung containing the RET
instruction may be conditional if this
rung precedes the end of the
subroutine. In this way, the processoromits the balance of a subroutine
only if its rung condition is true.
Without a RET instruction, the END
statement (always present in thesubroutine) automatically returns
program execution to the JSR
instruction in your calling ladder
program.Programmable Logic controller 19