EMA3062
Lecture 3 – Basics of PLC
Programming
Lecture 3’s sequence
3.1 Program Scan
3.2 PLC Programming Languages
3.3 Relay Type Instructions
3.4 Branch Instructions
3.5 Internal Relay Instructions
3.6
0 Modes Of Operation
3.1. Program Scan
▪ During each program scan cycle, the processor reads all the inputs, takes
these values, and energizes or de-energizes the outputs according to the
user program.
3.1. Program Scan
▪ The time it takes to complete a scan cycle is a measure of how fast the
controller can react to changes in inputs.
▪ If a controller must react to an input
signal that changes states twice during
the scan time, it is possible that the PLC
will never be able to detect this change.
▪ The scan time is a function of:
❑ The speed of the processor module
❑ The length of the ladder program
❑ The type of instructions executed
❑ The actual ladder true/false conditions
3.1. Program Scan
▪ Overview of the data flow during the scan process.
3.1. Program Scan
▪ The controller evaluates ladder logic rung instructions based on the rung
condition preceding the instruction (rung-condition-in).
3.1. Program Scan
▪ Scan process applied to a single rung program.
3.1. Program Scan
▪ Scan process applied to a
multiple rung program.
3.1. Program Scan
▪ Vertical versus horizontal scan patterns.
Horizontal scanning order
Vertical scanning order
Lecture 3’s sequence
3.1 Program Scan
3.2 PLC Programming Languages
3.3 Relay Type Instructions
3.4 Branch Instructions
3.5 Internal Relay Instructions
3.6
0 Modes Of Operation
3.2. PLC Programming Languages
▪ PLC programming language refers to the method by which the user
communicates information to the PLC.
Standard IEC 61131 languages associated with PLC programming
3.2. PLC Programming Languages
▪ Ladder diagram language is the most used PLC language and is designed
to mimic hardwired relay logic.
Hardwired relay control circuit Equivalent ladder diagram program
3.2. PLC Programming Languages
▪ Functional block diagram
programming uses instructions
that are programmed as blocks
wired together to accomplish
certain functions.
3.2. PLC Programming Languages
▪ Ladder diagram and functional block diagram programming used to
produce the same logical output.
Ladder diagram
Equivalent function block diagram
3.2. PLC Programming Languages
▪ Sequential function chart (SFC)
programming language is like a
flowchart of your process.
The program is split into steps with
multiple operations happening in
parallel branches.
3.2. PLC Programming Languages
▪ Instruction list programming language consists of a series of instructions
that refer to the basic AND, OR, and NOT logic gate functions.
Equivalent instruction
Hardwired relay control circuit
list program
3.2. PLC Programming Languages
▪ Structured text is a high-level language primarily used to implement
more complex procedures that cannot be easily expressed with
graphical languages.
Ladder diagram
Equivalent structured text program
Lecture 3’s sequence
3.1 Program Scan
3.2 PLC Programming Languages
3.3 Relay Type Instructions
3.4 Branch Instructions
3.5 Internal Relay Instructions
3.6
0 Modes Of Operation
3.3. Relay Type Instructions
▪ The ladder diagram language is a symbolic set of instructions used to
create the controller program.
Representations of contacts and coils are the
basic symbols of the logic ladder diagram
instruction set.
3.3. Relay Type Instructions
▪ The Normally Open Contact instruction looks and
operates like a normally open relay contact.
Associated with each Normally
Open Contact instruction is a
memory bit linked to the status
of an input device or an internal
logical condition in a rung.
3.3. Relay Type Instructions
▪ The memory bit is set to 1 or 0 depending on the status of the input.
A 1 corresponds to a true status or on condition.
If the instruction memory bit is a 1 (true) this instruction will
allow rung continuity through itself, like a closed relay contact.
3.3. Relay Type Instructions
A 0 corresponds to a false status or off condition.
If the instruction memory bit is a 0 (false) this instruction will
not allow rung continuity through itself and will assume a
normally open state, just like an open relay contact.
3.3. Relay Type Instructions
▪ Simulated Normally Open Contact instruction operation.
3.3. Relay Type Instructions
▪ The Normally Closed Contact instruction looks and
operates like a normally closed relay contact.
This instruction asks the PLC’s processor to
examine if the contact is open.
It does this by examining the bit at the memory
location specified by the address for a 0 or 1.
3.3. Relay Type Instructions
As with any other input the memory bit is set to 1 or 0 depending on the status of the input.
A 1 corresponds to a true status or on condition.
The instruction is interpreted as false when the bit is 1
and will not allow rung continuity through itself.
3.3. Relay Type Instructions
A 0 corresponds to a off condition.
The instruction is interpreted as true when the bit is
0 and will not allow rung continuity through itself.
3.3. Relay Type Instructions
▪ Simulated Normally Closed Contact instruction operation.
3.3. Relay Type Instructions
▪ The Coil instruction looks and
operates like a relay coil.
This instruction signals the PLC to energize (switch on)
or de-energize (switch off ) the output.
The instruction is associated with a memory bit that energizes the output
when set to 1 and de-energizes the output when reset to 0.
3.3. Relay Type Instructions
Coil instruction is set to 1 to
energize the output.
A true logic path is established by
the input instructions in the rung.
3.3. Relay Type Instructions
▪ Simulated Coil instruction operation.
3.3. Relay Type Instructions
▪ Action of the field device and PLC bit.
A signal present makes the
NO bit (1) true; a signal
absent makes the NO bit
(0) false. The reverse is
true for an NC bit.
3.3. Relay Type Instructions
▪ Simulated operation of the field input device and the PLC bit.
3.3. Relay Type Instructions
▪ The main function of the ladder logic diagram program is to control
outputs based on input conditions.
Each contact or coil symbol is referenced with an address that identifies what is being
evaluated and what is being controlled.
The same contact instruction can
be used throughout the program
whenever that condition needs to
be evaluated.
Not place the same addressed Coil
instruction on multiple rungs within
the same program.
3.3. Relay Type Instructions
▪ For an output to be activated or energized, at least one left-to-right true
logical path must exist.
A complete closed path is referred
to as having logical continuity.
When logical continuity exists
in at least one path, the rung
condition and Coil instruction
are said to be true.
3.3. Relay Type Instructions
▪ Simulated operation of logic continuity.
3.3. Relay Type Instructions
The logic states (0 or 1) indicate whether an
instruction is true or false and is the basis of
controller operation.
3.3. Relay Type Instructions
The time aspect relates to the repeated scans
of the program, wherein the input table is
updated with the most current status bits.
Lecture 3’s sequence
3.1 Program Scan
3.2 PLC Programming Languages
3.3 Relay Type Instructions
3.4 Branch Instructions
3.5 Internal Relay Instructions
3.6
0 Modes Of Operation
3.4. Branch Instructions
▪ Branch instructions are used to create parallel paths of input condition
instructions (OR logic).
The rung will be true
if either instruction A
or B is true.
3.4. Branch Instructions
▪ Parallel branches can be used to allow more than one combination of
input conditions.
Either A and not B, or C provides logical continuity and energizes output D.
3.4. Branch Instructions
▪ Simulated program, either A and not B, or C provides logical continuity
and energizes output D.
3.4. Branch Instructions
▪ Output branching allows a true logic path to control multiple outputs.
Either A or B provides a true logical path to
all three output instructions: C, D, and E.
Additional input instructions can be
programmed in the output branches.
3.4. Branch Instructions
▪ Simulated program, either A or B provides a true logical path to all three
output instructions: C, D, and E.
3.4. Branch Instructions
▪ Input and output branches can be nested to avoid redundant instructions
and to speed up processor scan time.
A nested branch starts or
ends within another branch.
3.4. Branch Instructions
In some PLC models, the
programming of a nested
branch cannot be done
directly.
It is possible, however,
to program a logically
equivalent branching
condition.
3.4. Branch Instructions
▪ There may be limitations
to the number of series
contact instructions that
can be included in one
rung of a ladder diagram
as well as limitations to
the number of parallel
branches.
3.4. Branch Instructions
The PLC will not allow for programming
of vertical contacts.
Reprogrammed to eliminate
vertical contact.
3.4. Branch Instructions
The processor examines the ladder logic rung
for logic continuity from left to right.
If programmed as shown, contact
combination FDBC would be ignored.
Reprogrammed circuit.
Lecture 3’s sequence
3.1 Program Scan
3.2 PLC Programming Languages
3.3 Relay Type Instructions
3.4 Branch Instructions
3.5 Internal Relay Instructions
3.6
0 Modes Of Operation
3.5. Internal Relay Instructions
▪ An internal output
does not directly
control an output
field device.
The advantage of using internal outputs is that there are many situations in
which an output instruction is required in a program but no physical connection
to a field device is needed.
3.5. Internal Relay Instructions
▪ Internal relay used for a program that requires more series contacts than
the rung allows.
This PLC allows for only
7 series contacts when
12 are required for the
programmed logic.
3.5. Internal Relay Instructions
▪ Simulated internal relay program.
3.5. Internal Relay Instructions
▪ Example 1: The hardwired manual/automatic circuit shown in
figure can be programmed using a PLC. The operation of the
process is summarized as follows:
✓ The Pump (M) is started by pressing the Start button and
stopped when Stop button is pressed.
✓ When the Selector switch (Manual/Auto) is in the manual
position, the Solenoid valve (SV) is always energized.
✓ When the selector switch is in the automatic position, the
solenoid valve is energized only when the Pressure switch
(PS) is closed.
✓ Energize the Pilot light (PL) when the solenoid valve is
operating.
3.5. Internal Relay Instructions
▪ Example 2: Write a ladder
program that will implement
the hardwired reciprocating
motion machine process control
schematic shown. The sequence
of operation is as follows:
✓ The Workpiece starts on the left and moves to the right when the Start button is
momentarily actuated.
✓ When it reaches the rightmost limit (LS2), the Motor automatically reverses and
brings the workpiece back to the leftmost position again, and the process repeats.
✓ The Reverse pushbutton provides a means of starting the motor in reverse so that
leftmost limit (LS1) can take over automatic control.
✓ Stop button is used to stop system operation at any time.
3.5. Internal Relay Instructions
▪ Example 3: Write a ladder program that will implement the following
continues filling operation:
✓ Start the Conveyor when Start button is momentarily pressed.
✓ Stop the Conveyor when Stop button is momentarily pressed.
✓ Energize the Run status light when the process is operating.
✓ Energize the Standby status light when the process is stopped.
✓ Stop the conveyor and energize the Standby light when the right edge
of the box is first sensed by the Photo switch.
✓ With the box in position and the conveyor stopped, open the Solenoid
valve and allow the box to fill. Filling should stop when the Level
sensor goes true.
✓ Energize the Full light when box is full. The Full light should remain
energized until the box is moved clear of the Photo switch.
Lecture 3’s sequence
3.1 Program Scan
3.2 PLC Programming Languages
3.3 Relay Type Instructions
3.4 Branch Instructions
3.5 Internal Relay Instructions
3.6
0 Modes Of Operation
3.6. Modes Of Operation
▪ A processor has basically two modes of operation: the program mode
and some variation of the run mode.
A three-position keyswitch may be
used to select different processor
modes of operation.
3.6. Modes Of Operation
▪ The program mode is used to enter a new program,
edit or update an existing program, upload files and
download files, document (print out) programs, or
change any software configuration file in the program.
▪ The run mode is used to execute the user program.
▪ The test mode is used to operate or monitor the user
program without energizing any outputs.
▪ The remote position allows the PLC to be remotely
changed between program and run mode by a
personal computer connected to the PLC processor.