You are on page 1of 26

SPE 2321 LECTURE 9

Programmable Logic Controllers


(PLCs)
The Basics of PLC Operation
• The PLC processor makes decisions based on a ladder logic program
written by the user.
• In order to use the program properly, the PLC must communicate
with the various field devices it is tasked with monitoring and
controlling.
• It then compares the actual conditions of the field devices with
what the program instructs them to do, and updates the output
devices accordingly
Operational Sequence

• The operational sequence is as follows:


• Input switch is pressed.
• Input module places a “1” in the input data table,
• The ladder logic program sees the “1” and caused a “1” to be put
into the output data table.
• The output data table causes the output module to energize
associated point.
• The output device energizes.
The Scan Cycle
• PLCs operate by continually scanning programs and repeat this process
many times per second.
• When a PLC starts, it runs checks on the hardware and software for faults,
also called a self-test.
• If there are no problems, then the PLC will start the scan cycle.
• The scan cycle consists of three steps: input scan, executing program(s),
and output scan.
• Input Scan: A simple way of looking at this is the PLC takes a snapshot of
the inputs and solves the logic.
• The CPU reading the status of its inputs
• The PLC looks at each input card to determine if it is ON or OFF and saves
this information in a data table for use in the next step.
• This makes the process faster and avoids cases where an input changes
from the start to the end of the program.
The Scan Cycle

• Execute Program (or Logic Execution): The application program is


executed using the status of the inputs .
• Since the PLC knows which inputs are ON/OFF from the previous
step, it will be able to decide whether the first output should be
turned ON.
• Output Scan: When the ladder scan completes, the outputs are
updated using the temporary values in memory.
• The PLC updates the status of the outputs based on which inputs
were ON during the first step and the results of executing a
program during the second step.
• The PLC now restarts the process by starting a self-check for faults.
The Scan Cycle

PLC Scan Cycle


The Scan Cycle
Logic Scan
• Ladder logic programs are modeled after relay logic.
• In relay logic, each element in the ladder will switch as quickly as
possible.
• Program elements can only be examined one at a time in a fixed
sequence.
• The ladder logic scan begins at the top rung.
• At the end of the rung, it interprets the top output first, and then
the output branched below it.
• On the second rung, it solves branches, before moving along the
ladder logic rung.
IEC 61131-3 Programming Standards
IEC – (International Electrotechnical Commission)

• The IEC 61131-3 standard was published in 1993 as an attempt to unify


the numerous and different languages and dialects associated with
Programmable Logic Controllers (PLCs) from different manufacturers.
• With the PLC being used in practically all industries (automobile
production lines, brewing, water treatment, assembly lines, etc.), a
standard for PLC programming languages is necessary.
• Although the ladder program is a widely accepted language due to its
intuitive and similar structure to relay logic programs, the ladder symbols
and facilities also vary between different PLC products.
• Furthermore, due to very expansive industrial control applications in the
present day, other programming languages are included in the standard,
each armed with specific features to address different issues of the
control problem, either individually or collectively.
IEC 61131-3 Programming Standards
• Essentially, IEC 61131-3 improves control software quality. Supported by
numerous PLC members and rapidly extending to other industrial controllers,
the standard offers many benefits to the users of compliant controllers.
• IEC 61131-3 compliant software offers the following:
• a well-structured program development
• strong data typing ("Strong typing" generally refers to use of
programming language types in order to both capture invariants of the
code, and ensure its correctness, and definitely exclude certain classes of
programming errors)
• full execution control
• support for complex sequential behaviour
• well-defined data structures
• flexible language selection. (The system designer is free to select the
language that is most suitable to solve a part of an application
program. Different parts of a program can be expressed in any of the
languages)
• vendor-independent software element. (Software written for IEC
61131-3 compliant controller can be portable and run on controllers
from different vendors)
IEC 61131-3 Programming Standards

• There are five languages included under this standard. They are:
• Ladder Diagrams
• Instruction List
• Structured Text
• Sequential Function Chart
• Function Block Diagram
Ladder Diagrams
• A ladder diagram/program is rather similar to a relay ladder
diagram/program.
• It implements a logic via a combination of switches, which can be
normally open or normally closed, and an associated set of coils.
• The rungs in a PLC program implement the logic for the sequence control.
• Switches are connected such that the coil is activated when the necessary
logical conditions are satisfied.

Ladder implementation of inverse logic


Instruction List (IL)
• IL is a low-level language which has a structure similar to a simple
machine assembler.
• It is ideal for solving straightforward problems where there are few
decision points and where there are a limited number of changes in
program execution flow.
• It may be used to write tight, optimized code for performance
critical sections of a program.
• As with other machine assembler code, it can be difficult to follow
the flow and structure of the program.
• Conversion from IL to other languages is not always possible, but
converting other languages to IL can always be achieved. An
example of an IL program (illustrated alongside the ladder program)
is shown in the Figure.
Instruction List (IL)

Instruction list compared to ladder diagram


Structured Text (ST)
• The Structured Text (ST) is a procedural language (Pascal-like) which
can be used for programming a wide range of industrial
applications.
• It is a high-level language with strong data type checking and a
formal syntax especially useful to implement calculations which can
involve simple or complex expressions.
• Common data types include: Integer, Floating-point number., String,
Boolean.
• ST has facilities for conditional evaluation of statements, for
repeating sections of code, and for calling functions and function
blocks. ST is typically used to program:
• an entire program
• actions within a Sequential Function Charts (SFC)
• transition conditions for SFC transitions
• functions or function blocks
Structured Text (ST)
Sequential Function Charts (SFC)
• SFC is a graphical language for dictating sequences.
• SFC is based on established standards and accepted industrial
practice.
• It allows alternative sequences to be selected using divergent paths.
• There is support for running sequences in parallel using
simultaneous sequences (concurrency).
• Steps and transitions can be programmed using any of the IEC
languages. SFC can be used at any design level, at the top level
within a program, or at a lower level within a function block.
• An example of this sequential connection can be seen in the
operation of a washing machine.
• When a program is selected on the washing machine, it has
multiple steps that come one after the other.
• When one step is over, the next automatically begins. The terms
‘steps’ and ‘state’ represent the same concept in SFC programming.
Sequential Function Charts (SFC)
• If we wanted to describe a traffic lamp sequence, one way we could
do this would be to represent it as a sequence of functions or states
such as red light state and green light state along with the inputs
and outputs to each state.
• Figure illustrates this idea. State 0 has an input that is triggered
after the green light has been on for 1 minute and an output of red
light on. State 1 has an input that is triggered after the red light has
been on for 1 minute and an output of green light on.
Sequential Function Charts (SFC)
Sequential Function Charts (SFC)
• The operation is described by a number of separate sequentially connected
states or steps that are represented by rectangular boxes, each representing a
particular state of the system being controlled. The initial step in a program is
represented differently from the other steps; Figure shows its representation.
• Each connecting line between states has a horizontal bar representing the
transition condition that has to be realized before the system can move from
one state to the next.
• Two steps can never be directly connected; they must always be separated by a
transition.
• Two transitions can never directly follow from one to another; they must always
be separated by a step.
• When the transfer conditions to the next state are realized, the next state or
step in the program occurs.
• The process thus continues from one state to the next until the complete
machine cycle is completed.
• Outputs/actions at any state are represented by horizontally linked boxes and
occur when that state has been realized.
Sequential Function Charts (SFC)
• Each of the rectangular boxes corresponds to a step in the SFC, and
each of the horizontal bar separating two steps corresponds to a
transition condition.
• The transition condition can be based on an event happening, such
as a sensor turning on or off, or it can be based on specified time
duration.
• The transition from one step to another in an SFC can only occur
when the transition condition holds.
• For example, the Start step can only transit to the Fill Runner step
when the condition Start Switch = 1 holds, i.e. a start switch is
activated.
• Each step of the SFC is associated with a number of actions to be
executed.
Function Block Diagrams (FBD)
• From systems engineering you might already know something also called
function block diagrams. PLC function block diagram is not that different
from it. What FBD offers is a way to put functions written with many lines
of code into boxes.
• Thereby we can easily connect them, to make a bigger PLC program
• In FBD all functions are put into function blocks. They all have one or more
inputs and outputs. The function of the block is the relation between the
state of its inputs and outputs.
• Here’s how a simple function block could look like
Function Block Diagrams (FBD)
• Depending on the function there can be any number of inputs and
outputs on the function block.
• You can connect the output of one function block to the input of
another. Thereby creating a Function Block Diagram
Function Block Diagrams (FBD)
• There are many standard function blocks provided in FBD. But you
can also make your own function blocks.
• Often, you will have to use the same piece of code in your PLC
program multiple times.
• It could be a function for controlling a valve, a motor etc. With
function blocks, you can make a function block specific for a motor
and use it several times
An ADD PLC programming instruction will take two operands, add them
and store the result in the output register. As a reminder, here’s an
example of the ADD Instruction programmed in ladder logic
Function Block Diagrams (FBD)
AND Logic Operation

• It has two inputs and one output. It is very similar to the OR


function but works a little different. Instead of one of the two
inputs, this block requires both inputs to be a true set the output.
• If both the inputs are true the output will also become true
Function Block Diagrams (FBD)
• The ADD instruction will take the value of “Integer1”, add it to the
“Integer2” and store the result (143) in the “OutputRegister”. The
same can be expected in the Function Block Diagram of this
instruction. However, the layout is different. Here’s the same
instruction implemented in FBD
Function Block Diagrams (FBD)
• CFC facilitates efficient configuration of control structures.
• Standard and preprogrammed function blocks are easily put in place
graphically.
• Their inputs and outputs are simply soft-wired together to realize the
overall system.
• There are minimum requirements on the skills of the programmer with
background syntax checks and automatic dialogs which allow a modest
programmer to generate a program in
a short period of time.

You might also like