Programmable Logic Control
PLC Basics & Advanced Levels
What IS PLC
• Programmable Logic Controllers (PLCs) are
small industrial computers with modular
components designed to automate
customized control processes. PLCs are often
used in factories and industrial plants to
control motors, pumps, lights, fans, circuit
breakers and other machinery. To understand
the purpose of PLCs better, let’s look at a brief
history of PLCs.
History
• Industrial automation began long before PLCs. In
the early to mid 1900s, automation was usually
done using complicated electromechanical relay
circuits. However, the amount of relays, wires
and space needed to create even simple
automation was problematic. Thousands of
relays could be necessary to automate a simple
factory process! And if something in the logical
circuit needed to be changed?
History
• In 1968 the first programmable logic controller came
along to replace complicated relay circuitry in industrial
plants. The PLC was designed to be easily programmable
by plant engineers and technicians that were already
familiar with relay logic and control schematics. Since
the beginning PLCs have been programmable using
ladder logic which was designed to mimic control circuit
schematics. The ladder diagrams look like control
circuits where power is flowing from left to right
through closed contacts to energize a relay coil.
Ladder Logic Example
• As you can see, ladder logic looks like simple
control circuit schematics where input sources
like switches, push-buttons, proximity sensors,
etc are shown on the left and output sources
are shown on the right. The ability to program
complicated automated processes with an
intuitive interface like ladder logic made the
transition from relay logic to PLCs much
simpler for many in the industry.
How Do PLCs Work?
• PLCs can be described as small industrial computers
with modular components designed to automate
control processes. PLCs are the controllers behind
almost all modern industrial automation. There are
many components to a PLC, but most of them can
be put in the following three categories:
• Processor (CPU)
• Inputs
• Outputs
How Do PLCs Work?
• PLCs are complex and powerful computers. But, we can
describe the function of a PLC in simple terms. The PLC
takes inputs, performs logic on the inputs in the CPU and
then turns on or off outputs based on that logic. We will
get into more detail later but for now, think of it like this:
• The CPU monitors the status of the inputs (ex. switch on,
proximity sensor off, valve 40% open, etc.)
• The CPU takes the information that it gets from the inputs,
performs logic on the inputs
• The CPU operates the outputs logic (ex. turn off motor,
open valve, etc.)
PLC Function Flowchart
• Let’s use a familiar example to illustrate how PLCs work. Your
dishwasher. Many dishwashers have microprocessors that function
similarly to PLCs. The dishwasher has inputs, outputs and, of course,
a CPU. Some of the inputs into the dishwasher controller would be
the buttons on the front, the water sensors and the door switch.
Some of the dishwasher outputs would be the water valves, the heat
elements and the pumps. Now let’s think about how the dishwasher
uses those different components.
NOTE: Remember, the CPU is the processor in the dishwasher that is
programmed to make all the decisions we will see below. This is just
like a PLC processor (CPU) which makes logical decisions based on
input status.
PLC Function Flowchart
• User pushes the cycle mode button (input
detected)
• User pushes the start button (input detected)
• CPU verifies that the door is closed (input
detected)
• Fill valve opens and the dishwasher begins filling
with water (output activated)
• CPU waits until proper water level is reached
(input detected)
PLC Function Flowchart
• Fill valve closes, and water flow stops (output
activated/de-activated)
• Heating element is turned on (output activated)
• CPU waits until proper water temperature is
reached (input detected)
• Soap dispenser opens (output activated)
• Water pump turns on to force water through
sprayers (output activated)
PLC Function Flowchart
• CPU begins timing depending on cycle type (logic
timer activated)
• Water pump turns off (output deactivated)
• Heating element is turned off (output
deactivated)
• Drain valve opens and the dishwasher begins
draining the dirty water (output activated)
• CPU waits until it detects the water level to be
low enough (input activated/de-activated)
PLC Function Flowchart
• Drain valve closes (output
activated/deactivated)
• Fill valve opens again to rinse dishes (output
activated)
• Water pump turns on to force water through
sprayers (output activated)
• CPU begins timing (logic timer activated)
• Water pump turns off (output deactivated)
PLC Function Flowchart
• Drain valve opens and the dishwasher begins
draining rinse water (output activated)
• CPU waits until it detects the water level to be low
enough (input activated/de-activated)
• Drain valve closes (output activated/deactivated)
• Heating element turns on to heat the air inside the
dishwasher and dry the dishes (output activated)
• CPU waits until proper interior temperature is
reached (input activated)
PLC Function Flowchart
• CPU begins timing (logic timer activated)
• Heating element is turned off (output
activated/deactivated)
Discrete and Analog I/O
• Inputs and outputs are often abbreviated with the term
“I/O”. In the dishwasher example above, we treated every
input and output as a discrete or digital signal. Discrete
signals are signals that can only be on or off. These are the
simplest and most common type of I/O. In our example we
did not use any analog I/O. Although, there may be some use
of analog I/O within a dishwasher control system, I wanted to
keep this example simple. With analog signals, instead of
only on/off or open/closed possibilities, you may have 0 –
100%, 4 – 20mA, 0 – 100 degrees Celsius, or whatever it is
you measuring as an input or driving as an output.
Discrete and Analog I/O
• You may have heard of the Programmable Automation Controller
(PAC). The term was first coined by the market research firm ARC in
2001 to differentiate the original PLCs from the newer, more
powerful, more flexible controllers that were entering the market.
There is disagreement about the definition differences between
PAC and PLC, and often the terms are used interchangeably in the
industry. I often use the terms interchangeably myself. This article,
here, from Control Engineering may help you understand the
differences between PLCs and PACs. In my opinion PACs are always
the better choice unless the system is very simple and minimizing
cost of the project is vital. The modern user interface, extra power
and memory of most PACs make them easily superior to most PLCs.
The Need for PLCs
• Hardwired panels were very time consuming to
wire, debug and change.
• GM identified the following requirements for
computer controllers to replace hardwired panels.
• Solid-state not mechanical
• Easy to modify input and output devices
• Easily programmed and maintained by plant
electricians
• Be able to function in an industrial environment
The First Programmable Logic Controllers
(PLCs)
• Introduced in the late 1960’s
• Developed to offer the same functionality as the
existing relay logic systems
• Programmable, reusable and reliable
• Could withstand a harsh industrial environment
• They had no hard drive, they had battery backup
• Could start in seconds
• Used Ladder Logic for programming
Programmable Logic Controller
• A programmable logic controller (PLC) is a
specialized computer used to control
machines and process.
• It uses a programmable memory to store
instructions and specific functions that include
On/Off control, timing, counting, sequencing,
arithmetic, and data handling
Advantages of PLC Control Systems
• Flexible
• Faster response time
• Less and simpler wiring
• Solid-state - no moving parts
• Modular design - easy to repair and expand
• Handles much more complicated systems
• Sophisticated instruction sets available
• Allows for diagnostics “easy to troubleshoot”
• Less expensive
Advantages of a PLC Control System
• Eliminates much of the hard wiring that was
associated with conventional relay control
circuits.
• The program takes the place of much of the
external wiring that would be required for
control of a process.
Advantages of a PLC Control System
• Increased Reliability: Once a program has
been written and tested it can be downloaded
to other PLCs.
• Since all the logic is contained in the PLC’s
memory, there is no chance of making a logic
wiring error. Conversely ......
Advantages of a PLC Control System
• More Flexibility: Original equipment
manufacturers (OEMs) can provide system
updates for a process by simply sending out a
new program.
• It is easier to create and change a program in a
PLC than to wire and rewire a circuit. End-
users can modify the program in the field.
Advantages of a PLC Control System
• Lower Costs: Originally PLCs were designed to
replace relay control logic. The cost savings
using PLCs have been so significant that relay
control is becoming obsolete, except for
power applications.
• Generally, if an application requires more than
about 6 control relays, it will usually be less
expensive to install a PLC.
Advantages of a PLC Control System
• Communications Capability: A PLC can
communicate with other controllers or
computer equipment.
• They can be networked to perform such
functions as: supervisory control, data
gathering, monitoring devices and process
parameters, and downloading and uploading
of programs.
Advantages of a PLC Control System
• Faster Response Time: PLCs operate in real-
time which means that an event taking place
in the field will result in an operation or
output taking place.
• Machines that process thousands of items per
second and objects that spend only a fraction
of a second in front of a sensor require the
PLC’s quick response capability.
Advantages of a PLC Control System
• Easier To Troubleshoot: PLCs have resident
diagnostic and override functions allowing
users to easily trace and correct software and
hardware problems
• The control program can be watched in real-
time as it executes to find and fix problems
PLC Architecture
PLC System
PLC Architecture
• An open architecture design allows the system to be
connected easily to devices and programs made by
other manufacturers.
• A closed architecture or proprietary system, is one
whose design makes it more difficult to connect
devices and programs made by other manufacturers.
• NOTE: When working with PLC systems that are
proprietary in nature you must be sure that any
generic hardware or software you use is compatible
with your particular PLC.
I/O Configurations
• Fixed I/O
• Is typical of small PLCs
• Comes in one package, with no separate
removable units.
• The processor and I/O are packaged together.
• Lower in cost – but lacks flexibility.
I/O Configurations
I/O Configurations
• Modular I/O
• Is divided by compartments into which
separate modules can be plugged.
• This feature greatly increases your options and
the unit’s flexibility.
• You can choose from all the modules available
and mix them in any way you desire.
I/O Configurations
I/O Configurations
• Modular I/O
• When a module slides into the rack, it makes
an electrical connection with a series of
contacts - called the backplane. The backplane
is located at the rear of the rack.
I/O Configurations
Power Supply
• Supplies DC power to other modules that plug
into the rack.
• In large PLC systems, this power supply does
not normally supply power to the field
devices.
• In small and micro PLC systems, the power
supply is also used to power field devices.
Processor (CPU)
• Is the “brain” of the PLC.
• Consists of a microprocessor for implementing the
logic, and controlling the communications among the
modules.
• Designed so the desired circuit can be entered in relay
ladder logic form.
• The processor accepts input data from various sensing
devices, executes the stored user program, and sends
appropriate output commands to control devices.
Processor (CPU)
I/O Section
• Consists of:
• Input modules
• Output modules.
I/O Section
• Input Module
• Forms the interface by which input field
devices are connected to the controller.
• The terms “field” and “real world "are used to
distinguish actual external devices that exist
and must be physically wired into the system.
I/O Section
I/O Section
• Output Module
• Forms the interface by which output field
devices are connected to the controller.
• PLCs employ an optical isolator which uses
light to electrically isolate the internal
components from the input and output
terminals.
I/O Section
Programming Device
• A personal computer (PC) is the most
commonly used programming device
• The software allows users to create, edit,
document, store and troubleshoot programs
• The personal computer communicates with
the PLC processor via a serial or parallel data
communications link
Programming Device
Programming Device
• Hand-held programming devices are sometimes
used to program small PLCs
• They are compact, inexpensive, and easy to use,
but are not able to display as much logic on
screen as a computer monitor
• Hand-held units are often used on the factory
floor for troubleshooting, modifying programs,
and transferring programs to multiple
machines.
Programming Device
PLC Mixer Process Control Problem
• Mixer motor to automatically stir the liquid in
the vat when the temperature and pressure
reach preset values
• Alternate manual pushbutton control of the
motor to be provided
• The temperature and pressure sensor
switches close their respective contacts when
conditions reach their preset values
PLC Mixer Process Control Problem
Process Control Relay Ladder Diagram
• Motor starter coil is energized when both the
pressure and temperature switches are closed
or when the manual pushbutton is pressed
PLC Input Module Connections
• The same input field devices are used
• These devices are wired to the input module
according to the manufacturer’s labeling
scheme
PLC Output Module Connections
• Same output field device is used and wired to
the output module
• TRIACswitches motor ON and OFF in
accordance with the control signal from the
processor
PLC Ladder Logic Program
• The format used is similar to that of the hard-
wired relay circuit
PLC Ladder Logic Program
PLC Ladder Logic Program
PLC Ladder Logic Program
• I/O address format will differ, depending on
the PLC manufacturer. You give each input and
output device an address. This lets the PLC
know where they are physically connected
Entering And Running The PLC Program
PLC Operating Cycle
• During each operating cycle, the controller
examines the status of input devices, executes
the user program, and changes outputs
accordingly
• The completion of one cycle of this sequence
is called a scan. The scan time, the time
required for one full cycle, provides a measure
of the speed of response of the PLC
PLC Operating Cycle
PLC Operating Cycle
PLC Operating Cycle
Modifying A PLC Program
• The change requires that the manual
pushbutton control should be permitted to
operate at any pressure but not unless the
specified temperature setting has been
reached.
Modifying A PLC Program
• If a relay system were used, it would require
some rewiring of the system, as shown, to
achieve the desired change.
Modifying A PLC Program
• If a PLC is used, no rewiring is necessary! The
inputs and outputs are still the same. All that
is required is to change the PLC program
PLCs Versus Personal Computers
PC Based Control Systems
• Advantages
• Lower initial cost
• Less proprietary hardware and software
required
• Straightforward data exchange with other
systems
• Speedy information processing - Easy
customization
PLC Size Classification
• Criteria
• Number of inputs and outputs (I/O count)
• Cost
• Physical size
PLC Size Classification
IEC 61131-3
• The IEC (International Electro technical
Commission) is a worldwide organization for
standardization comprising all national electro
technical committees (IEC National
Committees)
• This part of IEC 61131 specifies syntax and
semantics of programming languages for
programmable controllers as defined in part 1
of IEC 61131.
IEC 61131-3
• This part of IEC 61131 specifies the syntax and semantics of a
unified suite of programming languages for programmable
controllers (PCs).
• These consist of two textual languages, IL (Instruction List) and
ST (Structured Text), and two graphical languages, LD (Ladder
Diagram) and FBD (Function Block Diagram).
• Sequential Function Chart (SFC) elements are defined for
structuring the internal organization of programmable
controller programs and function blocks. Also, configuration
elements are defined which support the installation of
programmable controller programs into programmable
controller systems.
1.4.1 Software model
1.4.2 Communication model
1.4.2 Communication model
1.4.2 Communication model
1.4.3 Programming model
• The elements of programmable controller programming languages, and the sub
clauses in which they appear in this part, are classified as follows:
• Data types (2.3)
• Variables (2.4)
• Program organization units (2.5)
• Functions (2.5.1)
• Function blocks (2.5.2)
• Programs (2.5.3)
• Sequential Function Chart (SFC) elements (2.6)
• Configuration elements (2.7)
• Global variables (2.7.1)
• Resources (2.7.1)
• Access paths (2.7.1)
• Tasks (2.7.2)
1.4.3 Programming model
• Combination of programmable controller
language elements
• LD - Ladder Diagram (4.2)
• FBD - Function Block Diagram (4.3)
• IL - Instruction List (3.2)
• ST - Structured Text (3.3) OTHERS –
• Other programming languages (1.4.3)
2.2.2 Character string literals
Elementary data types
Program Organization Unit(POU)
• This is an object that holds logic that is used to
develop your application. These can be declared as
various different types (which changes their
behavior), but POUs ultimately serve one function
—to hold and execute your code. As well as being
declared as different types (which we'll come on
to), POUs can also be declared as using a different
language. This doesn't mean a different spoken
language like English, but a different programming
language
Task
• A Task is exactly what it sounds like; it's a Task
that tells your application to run a set of POUs
or gather IO data. In some PLCs, Tasks perform
various other tasks too and may not be called
"Tasks" at all (looking at you Siemens, OB1,
OB35, etc. are basically Tasks).
• In most PLCs, Tasks can be defined with a
range of various parameters such as
Task
• Task Mode: The mode the task is operating in, such
as Cyclic Execution, Event Driven, Freewheeling. It's
probably best to look up the different modes available
and what they mean to the PLC you are using, as they're
not always done in the same way.
• Watchdog Timeout: The time in which the entire
task MUST complete. Failing to complete the task in this
time will raise an internal flag that drops all outputs to a
safe state. Some PLCs allow you to configure what
happens on Watchdog failure; some don't. Refer to the
documentation for your own PLC.
Task
• An important rule to remember is that if a POU cannot be
traced back to a Task, it will not be executed. For example:
• Task >> Main (PRG) >> Sub (PRG) >> Area_1 (FB) >>
Function (FB)
• The above shows "Task" calling "Main" which is calling
"Sub" and so on. If "Area_1" was deleted, "Function"
would have no route to a Task and would therefore no
longer be executed in the program. Most (not all) PLC
programming environments tell you that a POU is
orphaned from a Task.
PROGRAM
• A PRG is a type of POU in most PLCs (Not all, again looking at
Siemens in which PRG doesn't exist). At least one PRG must exist
as Tasks can only call a PRG. Because a PRG is simply a type of
POU, it performs in the same manner as any other POU and can
be declared in different languages.
• A PRG can call another PRG as well as call any other type of POU.
A PRG can also declare its own Variables (Covered later).
• Note: In some PLCs, PRGs can declare their own variables, but
they are not maintained between PLC scans (a complete
execution of a task); this means that any value written to the
variable is lost at the end of the scan. These types of variables
are usually referred to as Temp Variables.
Function Block
• A Function Block is probably the most common
POU used in a PLC. They are used to create
blocks of code that can be used over and over
again by simply dropping the FB into a POU or
another FB. FBs are made up of Input and
Output parameters (we'll cover these in more
detail) that allow data from outside the FB to
be brought in and data made by the FB to be
passed back out to the caller. For example
Function Block
Function Block
• The above shows FB_1 being called on line 1 (a PRG is
calling it). The input data has Sensor_1 being passed to it.
The FB_1 object is performing a task and then
outputting Output, which is being passed to Output in the
PRG that is calling the FB.
• Line 2 is showing FB_1_CALL.Counter being used, but we
cannot see "Counter" as a parameter of FB_1? This is
because "Counter" is a Static Variable (A variable that is
used to hold information rather than pass it anywhere). In
most PLCs, Static Variable information is accessible if
the Instance of that data is also declared
What is Instance Data?
• Instance data is the data that belongs to an FB. In
the example above, FB_1_CALL holds all instance
data of FB_1. This is why declaring
"FB_1_CALL.Counter" works correctly. FB_1 is the
name of the FB, FB_1_CALL is the data for that
specific call of that FB.
• If FB_1 was called again on Line 3, you would need
to give it a different set of instance data by declaring
a different identifier for it, such as "FB_1_CALL2".
FUNCTION
• A function is very similar to a Function Block, but it does
not hold its own data for more than 1 PLC scan; all
variables are temporary
• PLCs handle functions in different ways; for example
CoDeSys allows you to leave interface pins unassigned
whereas Siemens does not. Most PLCs also enforce that a
variable is returned when the Function completes. This
variable must be declared when the Function is created.
It's very common to see functions returning
a Byte or Word which contains a status on whether the
Function completed without issue.
VARIABLE
• A Variable is a container that holds information; there are many different types,
and it depends on the PLC in use. The main Variable types (also known as Data
Types) are:
• BOOL: Digital Data (True / False)
• BYTE: Numerical Data / Bitwise Data (0 - 255)
• INT: Numerical Data (-32768 - 32767)
• UINT: Numerical Data (0 - 65535)
• SINT: Numerical Data (-128 - 127)
• USINT: Numerical Data (0 - 255)
• DINT: Numerical Data (-2147483648 - 2147483647)
• WORD: Numerical Data / Bitwise Data (0 - 65535)
• DWORD: Numerical Data / Bitwise Data (0 - 4294967295)
• REAL: Numerical Data (-3.402823e+38 - 3.402823e+38)
• ARRAY: Array of Any Data type (Declared as "ARRAY [0..10] OF Data Type)
VARIABLE
• Most PLCs support the above, and some PLCs will
support a selection of the below also:
• LWORD: Numerical Data / Bitwise Data (0 -
18446744073709551615)
• UDINT: Numerical Data (0 - 4294967295)
• LINT: Numerical Data ( -9,223,372,036,854,775,808 -
9,223,372,036,854,775,807)
• ULINT: Numerical Data (0 - 18446744073709551615)
• VARIANT: Object (Anything)
• NULL: Object (Nothing)
VARIABLE
• The additional variables are generally only supported by 64bit PLCs and
Runtimes. Variant & Null data types are advanced and not common in PLCs.
• In addition to the above Data Types, there are also different Variable
attributes (modes if you like):
• CONSTANT - Variable that is hard coded and cannot be changed at runtime
• RETAIN - Variable that remembers its last value between loss of power supply
to the PLC. Most PLCs have a limit on the maximum amount of data that can
be retained. Older PLCs may retain everything by default or have special
ranges of registers that are retained, so make sure you check.
• PERSISTENT - A variable that retains it's last value even after a re-initialization
of the PLC or the PLC is warm started. The only way to reload the default data
is to cold start the PLC or perform a full download.
• Note: Persistent variables can be dangerous if used incorrectly, especially if
indirect addressing / pointers are being used.
INTERFACE
• An interface is the declaration of variables a PRG, FB or FC is expecting to use.
There are a few keywords that can be used to declare interfaces:
• VAR_INPUT - Data passed into the POU
• VAR_OUTPUT - Data passed out of the POU
• VAR_IN_OUT - Data that is passed in and out of the POU to the same variable
(If you know a bit about computer programming, think of this as passing by
reference)
• VAR - Data that is local to the POU, Some PLCs allow access to the data by
explicit reference only (For example, "POU.VARIABLE")
• VAR_STATIC - The same as VAR, but does not allow access to the data from
outside the block
• VAR_TEMP - Temporary data, the values stored in TEMPs is lost when the block
is exited
• END_VAR - A required termination declaration after declaring your variables.
VAR_GLOBAL
• GLOBAL Variables are special variables that are accessible
anywhere in a project. They serve as a great way of passing
information between different areas of your project.
• Some people use Globals for everything and don't declare
any VARs in POUs. I advise against this as it gets messy
quickly!
• Globals are usually defined in a special Global Variable list
or Symbol table, depending on the PLC you are using.
• (Siemens use DBs, variables stored in DBs that are not
Instance DBs are the equivalent of Global Variables)
POU Languages
• LADDER
• Ladder is probably the most commonly used
language. It's easy to read and follow and fault
find
POU Languages
• FUNCTION BLOCK DIAGRAM
• FBD is very, very similar to Ladder; it tends to
be used for projects that are made up of many
separate functions (hence the name). Logic
that compares Bool values is easier in Ladder
than it is in FBD.
POU Languages
• STRUCTURED TEXT
• Structured Text is one of (if not, the most)
flexible of the languages. It's quick to program
in and easy to read but can get messy quickly
if formatting rules aren't followed.
POU Languages
• Sequential Function Chart
• This language is excellent for sequencing (hence
the name!). However, it is one of the more
difficult to understand. In the example below, it
is important to note that the "ProcessTimer"
step must be called in any scenario; else, the
timer will not update and will hold its last value.
It is very easy to get stuck with SFC and leave
variables in states that were not intended.
POU Languages
• CONTINUOUS FUNCTION CHART
• CFC is very similar to FBD, but you are not confined
to networks (horizontal placeholders); you are free
to draw your logic however you like. This language is
useful for electricians transferring to PLC logic, as it
reads the same as a drawing. There are a few things
to be careful of, though; the logic may not flow as
expected. There are small numbers that show the
logic flow, it's important to keep track of what is
happening and where.
LIBRARIES
• Libraries are a collection of POUs and Variable
lists that can be moved from project to project.
This allows you to have a standard set of POUs,
tried and tested, that can be dropped into a
project when required.
• Libraries can be nested, too, so a library can
call another library if required. Any large-scale
software house will almost definitely have a
standard library set.
What is Tag?
• Tag is a name you assign to an address of
device/PLC.
• It is also called "variable" or "symbol"
depending on the manufacture of the
device/PLC.
Ladder Logic Basics
• Ladder logic is a programming language that is used to
program a PLC (Programmable Logic Controller). It is a
graphical PLC programming language which expresses logic
operations with symbolic notation using ladder diagrams,
much like the rails and rungs of a traditional relay logic circuit.
• Ladder logic is a fast and simple way of creating logic
expressions for a PLC in order to automate repetitive machine
tasks and sequences. It is used in a multitude of industrial
automation applications. Some industrial automation
application examples where PLC ladder logic is used include….
Ladder Logic Basics
• Material Handling Conveyor System.
• Pallet Packing and Strapping.
• Ball Mill Lubrication System.
• Logistics Package Conveying and Sorting.
• Cement Batching.
• Beverage Bottling and Labeling.
• Hopper and Tank Level Control.
• Air and Liquid Flow and Pressure Control.
• In the good ol’ days, machine and process automation was accomplished
using a hard wired control system known as relay logic. With the advent
of microprocessors and the invention of the PLC, relay logic quickly
became superseded by programming languages such as ladder logic.
Why is Ladder Logic Popular?
• Ladder logic is the most popular method of PLC programming
because it has an easy to use graphics based interface and the
programming language resembles an electrical schematic
drawing. Engineers, electricians and students find the
transition from an electric circuit to ladder logic relatively
easy.
• When programming ladder logic in a PLC, the graphic, drag and
drop nature of ladder diagrams helps you formulate code
quickly and easily. Ladder logic also helps you easily trouble
shoot your code because you can visually see the flow of logic
from the LHS start rail, through the logic symbols and to the
RHS end rail.
Learning the Basics of Ladder Logic
• It’s relatively easy to learn the basic concepts of ladder logic
programming, even if you don’t have experience with electric circuits.
Take comfort in knowing that ladder logic is the quickest and easiest PLC
programming language to learn.
• In order to help you learn the basics of ladder logic we will cover the
following….
• Introduce the ladder diagram.
• Examine the seven basic parts of a ladder diagram.
• Identify the binary and logic concepts used in ladder logic.
• Reveal the hidden ladder logic functions that are automatically built
into the structure of the ladder diagram.
• Discover the five fundamental logic functions that are essential to
know.
What is a Ladder Diagram in a PLC?
• A ladder diagram is the symbolic representation of the control
logic used for programming of a PLC. Ladder diagrams have
horizontal lines of control logic called rungs and vertical lines at
the start and end of each rung called rails. It looks just like a
ladder, hence the name “ladder diagram”.
• There are two main differences between an electrical
schematic and a ladder diagram:
• The control logic in an electrical schematic is represented using
components whereas in a ladder diagram symbols are used.
• The control logic execution in an electrical schematic is as per
the operation of an electrical circuit whereas in a ladder diagram
it relies on the methodical nature of the PLC scan
Why is a ladder diagram used for PLC
programming?
• Ladder diagrams are used to formulate PLC logic
expressions in graphical form. They use symbols to
represent conditional, input and output expressions.
Ladder diagrams are similar to relay control circuits and
are used due to their ease of programming compared to
text based programming languages.
• Early control system designers were accustomed to relay
logic control circuits and ladder diagrams closely mimic
these. They preferred to use ladder diagrams for PLC
programming instead using text based programming
languages of the day like C, BASIC, Pascal and FORTRAN.
Why is a ladder diagram used for PLC
programming?
• Factory maintenance staff already understand how to read relay control
circuits. They can use their knowledge of relay control circuits to help
troubleshooting control system problems that implement PLC
programming with ladder diagrams.
• Ladder Diagram (LD) is the official name given in the international PLC
programming standard IEC-61131. But, these days the terms ladder
diagram, ladder logic diagram, ladder drawing, ladder control, ladder
circuit, control logic diagram and logic diagram (to name a few) are all
used to describe relay logic circuits and ladder logic programming.
• So don’t get too caught up in the specific definition of each of these
expressions, they kind of generally all mean the same thing. At the end of
the day most people will know what you are talking about anyway.
Personally, I use the term ladder logic for PLC programming and relay
logic for relay control circuits.
How to Draw Ladder Logic Diagrams?
• Ladder logic diagrams are drawn in a similar way to relay logic
circuit. They use rails and rungs to create the logic framework.
The logic operations are drawn in using symbolic notation.
• The rails in a relay logic circuit represent the supply wires of a
relay logic control circuit. However, in ladder diagrams, the rails
represent the start and end of each line of symbolic code.
• The rungs in a relay logic circuit represent the wires that
connect the components together. However, in a ladder
diagrams, the rungs represent the logic flow through the
symbolic code.
How to Draw Ladder Logic Diagrams?
• When implementing a ladder logic program in a PLC there are
seven basic parts of a ladder diagram that critical to know. They
are rails, rungs, inputs, outputs, logic expressions, address
notation/tag names and comments. Some of these elements
are essential and others are optional.
• To help understand how to draw ladder logic diagrams the
seven basic parts of a ladder diagram are detailed below…..
• Rails – There are two rails in a ladder diagram which are drawn
as vertical lines running down the far most ends of the page. If
they were in a relay logic circuit they would represent the active
and zero volt connections of the power supply where the power
flow goes from the left hand side to the right hand side.
How to Draw Ladder Logic Diagrams?
• Rungs – The rungs are drawn as horizontal lines and connect the rails
to the logic expressions. If they were in a relay logic circuit they would
represent the wires that connect the power supply to the switching
and relay components. Each rung is numbered in ascending sequential
order.
• Inputs – The inputs are external control actions such as a push button
being pressed or a limit switch being triggered. The inputs are actually
hardwired to the PLC terminals and represented in the ladder diagram
by a normally open (NO) or normally closed (NC) contact symbol.
• Outputs – The outputs are external devices that are being turned on
and off, such as an electric motor or a solenoid valve. The outputs are
also hardwired to the PLC terminals and are represented in the ladder
diagram by a relay coil symbol.
How to Draw Ladder Logic Diagrams?
• Logic Expressions – The logic expressions are used in combination
with the inputs and outputs to formulate the desired control
operations.
• Address Notation & Tag Names – The address notation describes the
input, output and logic expression memory addressing structure of
the PLC. The tag names are the descriptions allocated to the
addresses.
• Comments – Last but by not least, the comments are an extremely
important part of a ladder diagram. Comments are displayed at the
start of each rung and are used to describe the logical expressions
and control operations being executed in that rung, or groups of
rungs. Understanding ladder diagrams is made a lot easier by using
comments.
How Does Ladder Logic Work?
• Ladder logic works in a similar way to relay logic, but without
all the laborious relay control wiring. In simple terms, the field
input and output devices are wired directly to the PLC and the
ladder logic program decides what outputs to activate,
depending on the status of the input signals.
• Just like relay logic, ladder logic has supply rails, relay coils, relay
contacts, counters, timers, PID loop controllers and much more.
The difference is that with relay logic the logic expressions are
created with relay control circuits. This can amount to large
amounts of relays and wiring. However, with ladder logic the
logic expressions are programmed in the PLC. So, the only
wiring required is for the input and output devices.
How to Read Ladder Logic?
• Ladder logic is read from the left hand rail to the right
hand rail and from the first rung to the last rung. In
short – LEFT TO RIGHT AND TOP TO BOTTOM. The
rungs contain input symbols that either pass or block
the logic flow. The result of the rung is expressed in the
last symbol, known as the output.
• To start reading ladder logic we need to know some
basic binary concepts, how they apply to ladder
logic, how ladder logic is executed and the basic logic
functions that are built into each rung. Let’s begin….
The Binary Concept Applied to Ladder Logic
• Microprocessors, like the ones found in PLCs and personal
computers operate on the binary concept. You’ve probably heard
of the term ‘binary’. It refers to the principle that things can be
thought of in one of two states. The states can be defined as:
• True or False
• 1 or 0
• On or Off
• High or Low
• Yes or No
• Microprocessors love binary…..
10101011101000111010001010100010100100101010010011.
The Binary Concept Applied to Ladder Logic
• I don’t know about you, but my head hurts just looking at that!
Luckily ladder logic uses symbolic expressions and a graphical
editor for writing and reading ladder diagrams making it easier for
us mere humans to comprehend.
• In a PLC, binary events are expressed symbolically using ladder
logic in the form of a normally open contact (NO) and normally
closed contact (NC).
• The normally open contact (NO) is TRUE when the event is active
and FALSE when the event is NOT active. While the normally
closed contact (NC) is FALSE when the event is active and TRUE
when the event is NOT active.
• Let me explain NO and NC contacts a little further …..
The Binary Concept Applied to Ladder Logic
• Normally Open Contact (NO) in Ladder Logic
• The event associated with a normally open contact (NO) can be
TRUE or FALSE. When the event is TRUE then it is highlighted green
and the logic flow can move past it to the next logic expression. Just
like the current flow in an electric circuit when a switch is turned on.
• Let’s call a certain PLC input event ‘A’. This PLC input event could be
something like a button being pushed, a limit switch being activated
or a temperature switch being triggered.
• PLC input event ‘A’ follows the binary concept and has one of two
states, TRUE or FALSE. The ladder logic truth table for a normally
open contact (NO) which denotes PLC input event ‘A’ is shown
below….
The Binary Concept Applied to Ladder Logic
• Normally Closed Contact (NC) in Ladder Logic
• The event associated with a normally closed contact
(NC) can be TRUE or FALSE. The result of the
normally closed contact (NC) is basically the opposite
state of an event that occurs. So, if PLC input A is
FALSE the result will be TRUE. And vise versa when
PLC input A is TRUE the result will be FALSE.
• The normally closed contact (NC) is considered to be
a ladder logic NOT function. It is sometimes referred
to as reverse logic. Check out the truth table below….
The Binary Concept Applied to Ladder Logic
• If we translate a NOT function into a ladder
logic diagram we express it symbolically in the
form of a normally closed contact (NC) as
seen in ladder logic truth table shown
below….
How Ladder Logic is Executed?
• In order to successfully read ladder logic we need a basic understanding of
how a PLC works and how ladder logic is executed in a PLC. You see, the PLC
follows a certain execution procedure and if not adhered to it can lead to the
ladder logic being read incorrectly.
• Ladder logic works in a similar way to relay logic, but without all the
laborious wiring. It has supply rails, relay coils, relay contacts, counters,
timers, PID loop controllers and much more. In simple terms, all the field
input and output devices are wired to the PLC and the ladder logic program
decides what outputs to trigger depending on the status of the input signals.
• In basic terms, PLCs execute ladder logic by first reading all the input states
and storing them into memory. Secondly, scanning through and evaluating
each rung of ladder logic, from left to right and top to bottom. Lastly, at the
end of the scan, the resultant logic is executed and the outputs are written
to.
Ladder Logic Basic Functions
• In a ladder diagram the normally open (NO) and normal closed (NC)
contacts merely tell us what state an event is in, TRUE or FALSE. On
their own they cannot decide what action to take to automate
something.
• We need binary’s best friend ‘logic’ to help out.
• Logic is the ability to decide what action needs to be taken depending
on the state of one or more events. We use the binary and logic
concepts every day in our own lives. For example, if I feel cold then I
put my sweater on, but if I feel hot then I take my sweater off.
• Binary concept – Cold or Hot, Sweater On or Sweater Off.
• Logic concept – IF, THEN logic functions.
• Binary Logic in action!
Ladder Logic Basic Functions
• The binary and logic concepts are what makes ladder logic
work. The hidden key to unlock your understanding of how
ladder logic works is: The logic functions in ladder logic are
automatically built into the structure of the ladder diagram.
• Let me show you……
• Ladder Logic IF, THEN Functions
• Let’s take a real world event, allocate it to a normally open
contact (NO) and call it ‘A’. In ladder logic the real world events
are defined as PLC inputs.
• Now, let’s call the result of the logic function ‘Y’. In ladder logic
the result of a rung logic function is defined as a PLC output.
Ladder Logic Basic Functions
• When we take these two fundamental
elements and insert them into a rung in a
ladder diagram we get your first line of code!
• It’s equivalent to “Hello World” in text based
programming languages…..
Ladder Logic Basic Functions
• Now, let’s expose the hidden inbuilt functions
by highlighting them in blue in order to
illustrate the relationship between the ladder
diagram rung structure and its inbuilt IF, THEN
functions….
Ladder Logic Basic Functions
• We can write out the logic expression in the
above as rung as IF A THEN Y.
• Because PLC input A follows the binary concept it
has two possible states, TRUE or FALSE. Therefore
it results in two possible logic iterations:
• IF A = FALSE THEN Y = FALSE
• IF A = TRUE THEN Y = TRUE
• We also can express this in a truth table….
Ladder Logic Basic Functions
• If we translate this into a ladder logic diagram we express it
symbolically in the form of a normally open contact (NO) for
the input and a relay coil for the output. Remember the logic
flow is from left to right and follows the same concept of
current flow in an electric circuit.
• The ladder logic truth table is shown below….
Ladder Logic Basic Functions
• The AND function examines multiple PLC inputs and has one resulting
output. If we translate an AND function into a ladder diagram we can
express it symbolically in the form of two PLC inputs A and B using
normally open (NO) contacts and a PLC output Y using a relay coil.
• They are all connected in line, just like a series connection in an electric
circuit. This time we have also highlighted the hidden AND function to
illustrate the relationship between the ladder logic functions and the
ladder diagram rung structure….
Ladder Logic Basic Functions
• We can write out the logic expression above as IF A AND B THEN Y.
• The AND function examines if all the PLC inputs are TRUE, then the
corresponding result is also TRUE. However if any one of the PLC inputs is
FALSE then the corresponding result is also FALSE.
• Because PLC input A and B follows the binary concept and are part of the
AND function there are four possible logic iterations. Check out the truth
table below….
Ladder Logic Basic Functions
• The number of logic iterations increases with the number of PLC inputs
(2PLC Inputs
). But that doesn’t matter too much with the AND function
because the result can only be TRUE if all the PLC inputs are TRUE.
• If we translate an AND function into a ladder logic truth table we get the
table below….
Ladder Logic Basic Functions
• Ladder Logic OR Function
• The OR function examines multiple PLC inputs and has one resulting
output. If we translate an OR function into a ladder diagram we can
express it symbolically in the form of two PLC inputs A and B using
normally open contacts (NO) and a PLC output Y using relay coil.
• The inputs are placed in the rung in what is known as a branch. This is the
equivalent of a parallel connection in an electric circuit. The output is then
connected in line with the rung. This time we have also highlighted the
hidden OR function when we create a branch (parallel connection) with
PLC input B across PLC input A….
Ladder Logic Basic Functions
• We can write out the logic expression above as IF A OR B THEN Y.
• The OR function examines if any of the PLC inputs are TRUE, then the
corresponding result is also TRUE. However, all the PLC inputs must be
FALSE in order for the corresponding result is also be FALSE.
• Because PLC input A and B follows the binary concept and are part of the
OR function there are four possible logic iterations. Check out the truth
table below….
Ladder Logic Basic Functions
• Remember, the number of logic iterations increases with the number of
PLC inputs (2PLC_inputs
). But that doesn’t matter too much with the OR
function because the result can be TRUE if any of the PLC inputs are TRUE.
• If we translate an OR function into a ladder logic truth table we get the
table below….
Ladder Logic Basic Functions
• Wow, you’ve flown through the binary and logic functions. Remember…
• For basic ladder logic programming we express binary events using
normally open contacts (NC) and normally closed contacts (NC).
• The five basic, yet essential, logic functions in ladder logic are:
• NOT
• IF
• THEN
• AND
• OR
Exercise 1
Do your Best
What is a Functional Block Diagram?
• A Functional Block Diagram (abbreviated as FBD) is a
graphical representation of a functional process via blocks
and diagrams that is easier for a reader to understand and
interpret. An FBD helps us determine the function
between output variables and input variables via a set of
rudimentary blocks and diagrams that are connected with
arrows known as “connections.”
• A Functional Block Diagram can help us create
relationships between one or more than one variable
(both input and output) to establish our understanding of
functional processes aligned in a system.
Where are Functional Block Diagrams Being
Used?
• These diagrams help us understand the
functions and relationships between two or
more variables widely used in software
engineering, system engineering, and graphical
programming language. For software engineers
and programmers, FBD is an essential tool that
helps them understand and create correlations
between two or more variables by connecting
them with a connection arrow.
History and Development of an FBD
• A functional block diagram is also known as a functional flow diagram. As
its name implies, it is a step-by-step representation of a functional flow
that helps to simplify work processes and create a better understanding of
them. The idea was given by Frank Gilbreth in 1921, preceded by other
engineers and scientists who developed a multi-tier process model to
simplify multiple functions and the relationships between them.
• The latest functional block diagram continued to develop in the 1960s
until NASA intervened and leveraged the concept to visualize and
represent the time sequence of units in space systems
• And now, the Functional Block Diagram holds an advantageous position
and is being widely used in various fields of Business Process
Redesign, Business Process Management, Computer System Engineering,
and System Engineering.
Functional Block Diagram Fundamentals
• Though a functional block diagram simplifies the
work processes, breaks down a huge process into
smaller units, and helps us understand the
relationship between two or more variables, it could
still be trickier to understand and interpret the
model. Thus, for your ease and convenience, we
have mentioned the basics of an FBD.
• All the functions are put in a functional block which
is demonstrated by a box. A square box is a symbol
of a function, as illustrated below.
Functional Block Diagram Fundamentals
• A functional block can have two or more two inputs and
outputs. All these inputs and outputs can be connected
with other inputs and outputs of the other functional
block, thus establishing a relationship between the
output of one function and the input of another as
illustrated by the diagram below.
• Functional blocks are standard but can be customized.
Since you will be using the same functional block in your
PLC program, you can use a functional block specific to
one function and use it several times in other instances.
Types of Function Blocks
• Bit Logic Function Blocks
• The basis of a function block is “logic” and is
known to be the simplest form of algorithms.
Within logic, there are two different gateway
mechanisms or logic: AND logic and OR logic.
OR Logic Operation
AND Logic Operation
Types of Function Blocks
• Bistable Function Blocks
• Bistable function blocks are known to be the
simplest form of memory. It is up to you if you
want to reset or set an output. The output will
learn and remember the last point of the set
input.
Set/Reset function block (set dominant)
Reset/Set function block (reset dominant)
Types of Function Blocks
• Edge Detection
• The next type of function block is Edge
Detection. This type of function block is very
useful and widely being used in PLC
programming and electronics. It got its name
because the input detects a progressive edge
the output will be set. And it gets detected
because the output develops a pulse when a
positive edge is detected.
R_TRIG function block for detecting rising
edge signals
F_TRIG function block for detecting falling
edge signals
Types of Function Blocks
• Timer Function Blocks
• They are also being used in PLC engineering
on a wide scale. There are three types of timer
function blocks. These types of blocks include
an on-delay timer, off-delay timer, and pulse
timer. You will need to use only one timer and
derive all the timers out of that timer.
Pulse Timer (TP) function block
On Delay Timer (TON) function block
Off Delay Timer (TOF) function block
Types of Function Blocks
• Counter Function Blocks
• The fact about the counter function block is
that it takes inputs and outputs and contains
other types of data. There are three types of
Counter Function Blocks. These types include
Up Counter, Down Counter, and Up-Down
Counter blocks.
Up Counter (CTU) function block
Down Counter (CTD) function block
Up Down Counters (CTUD) function block
Exercise 2
Do your best
Exercise 3
Do Your Best
Various Communication Protocols in PLC
• Communication is an important role player
in PLC. Apart from traditional hardware IO’s,
communication protocols provide more
diversity and flexibility to exchange data with
various means.
Communication Protocols in PLC
• You must be familiar with OSI layers and
different types of communication hardware
ports used in PLC, to understand the whole
cycle of communication in a better way.
OSI LAYERS
OSI LAYERS
OSI MODEL
Ethernet/IP
• It is a protocol that works under Common Industrial
Protocol (CIP), which is an open application layer
protocol. It is an advanced version of standard
Ethernet, which is useful only for in-home and
commercial purposes; but not for industrial
applications.
• It defines all the devices on a network as a series of
objects and binds all of them to work on the same
standard. This protocol was developed by Rockwell
Automation.
Ethernet/IP
• Similar protocols with these standards
are Profinet, ControlNet, DeviceNet and
RAPIEnet. They are different in it’s OSI layers
and have their individual functions which
differentiate themselves from each other.
They have been manufactured by different
vendors.
Modbus
• Modbus is a protocol that is used for transmitting
information over a serial lines or Ethernet, based on
master-slave technology.
• Here we have two types of devices in this
communication. The devices which request information
are called Modbus Master and the devices which
provide the information are called Modbus Slaves.
• It is further categorized into Modbus RTU, Modbus
ASCII, and Modbus TCPIP. This protocol was developed
by Modicon (now Schneider Electric).
Profibus
• It is similar to Modbus RTU, which also works
on serial line communication. The only
difference is that it is owned by Siemens
Automation.
DF-1
• It is an asynchronous byte oriented protocol
that is used to communicate with only
Rockwell devices based on RS-232.
Interbus
• It is a serial network protocol which works on
RS-232/RS-485 and works on RTU standard.
• It was developed by Phoenix Contact.
HostLink
• It is a serial network protocol that works on
RS-232/RS-485 and works on RTU standard.
• It works only on Omron PLCs. It was
developed by Omron.
Data Highway (DH+)
• It is a protocol developed by Rockwell Automation and uses
transformer-coupled differential signals; meaning that the transmitter
and receiver stations need not be at the same ground potential.
• It works with the differential signaling concept. It uses two wires for
data transfer and the data is represented with voltage differences in the
two wires. Here the data is carried with differential voltages, the noise
will be easily removed in the two wires.
• It uses half-duplex transmission for communication. It is a very old
protocol and is used only in Rockwell PLCs. Nowadays, it has become
obsolete and rarely used.
• It works on token-passing protocol and uses trunk lines with drops.
Point to Point (PP)
• As the name suggests, it is a communication
protocol which is used to communicate
between only two connected devices.
• It is byte-oriented and is full duplex.
Actual Sensor Interface (ASI)
• It is a protocol that is used to connect all the
sensors and actuators in a field with a single
two-conductor cable.
• It reduces the wiring and manpower done to
connect the field equipment to the PLC. It
works in master-slave technology
Open Smart Grid Protocol
• This protocol has been developed to connect all the
electrical devices in a power grid through
communication and make it a smart grid system.
• The devices are meters, direct load control
modules, solar panels, gateways, and other smart
grid devices.
• Due to use of communication, all the information is
transmitted in a safe and efficient way; to make the
whole power grid system a better way to operate.
CAN (Controller Area Network) Open
• This protocol is an application layer protocol that communicates
with various devices using peer messaging. It is a multi-master
slave communication system and has an object dictionary that
contains all the functions of a device.
• This is an actual communication mean and has standard
communication objects for real-time data (PDO’s), configuration
data (SDO’s), timestamp, sync message, emergency message,
boot-up message, NMT message, and error control message,
and other data.
• In a hardware configuration, one point to remember is that it
requires termination at the end device to establish the whole
link communication.
HART (Highway Addressable Remote
Transducer)
• HART is a protocol in which digital data is
superimposed on the traditional analog signal of
4-20 mA; so that the user gets both the analog
information as well as digital information.
• HART-enabled field transmitters and actuators
are of great use in industrial automation; as the
user gets all the information and calibration
settings sitting at one corner in the office.
Register Mapping

PLC Basics and Advanced standard EGY.pptx

  • 2.
    Programmable Logic Control PLCBasics & Advanced Levels
  • 3.
    What IS PLC •Programmable Logic Controllers (PLCs) are small industrial computers with modular components designed to automate customized control processes. PLCs are often used in factories and industrial plants to control motors, pumps, lights, fans, circuit breakers and other machinery. To understand the purpose of PLCs better, let’s look at a brief history of PLCs.
  • 4.
    History • Industrial automationbegan long before PLCs. In the early to mid 1900s, automation was usually done using complicated electromechanical relay circuits. However, the amount of relays, wires and space needed to create even simple automation was problematic. Thousands of relays could be necessary to automate a simple factory process! And if something in the logical circuit needed to be changed?
  • 5.
    History • In 1968the first programmable logic controller came along to replace complicated relay circuitry in industrial plants. The PLC was designed to be easily programmable by plant engineers and technicians that were already familiar with relay logic and control schematics. Since the beginning PLCs have been programmable using ladder logic which was designed to mimic control circuit schematics. The ladder diagrams look like control circuits where power is flowing from left to right through closed contacts to energize a relay coil.
  • 7.
    Ladder Logic Example •As you can see, ladder logic looks like simple control circuit schematics where input sources like switches, push-buttons, proximity sensors, etc are shown on the left and output sources are shown on the right. The ability to program complicated automated processes with an intuitive interface like ladder logic made the transition from relay logic to PLCs much simpler for many in the industry.
  • 8.
    How Do PLCsWork? • PLCs can be described as small industrial computers with modular components designed to automate control processes. PLCs are the controllers behind almost all modern industrial automation. There are many components to a PLC, but most of them can be put in the following three categories: • Processor (CPU) • Inputs • Outputs
  • 9.
    How Do PLCsWork? • PLCs are complex and powerful computers. But, we can describe the function of a PLC in simple terms. The PLC takes inputs, performs logic on the inputs in the CPU and then turns on or off outputs based on that logic. We will get into more detail later but for now, think of it like this: • The CPU monitors the status of the inputs (ex. switch on, proximity sensor off, valve 40% open, etc.) • The CPU takes the information that it gets from the inputs, performs logic on the inputs • The CPU operates the outputs logic (ex. turn off motor, open valve, etc.)
  • 10.
    PLC Function Flowchart •Let’s use a familiar example to illustrate how PLCs work. Your dishwasher. Many dishwashers have microprocessors that function similarly to PLCs. The dishwasher has inputs, outputs and, of course, a CPU. Some of the inputs into the dishwasher controller would be the buttons on the front, the water sensors and the door switch. Some of the dishwasher outputs would be the water valves, the heat elements and the pumps. Now let’s think about how the dishwasher uses those different components. NOTE: Remember, the CPU is the processor in the dishwasher that is programmed to make all the decisions we will see below. This is just like a PLC processor (CPU) which makes logical decisions based on input status.
  • 11.
    PLC Function Flowchart •User pushes the cycle mode button (input detected) • User pushes the start button (input detected) • CPU verifies that the door is closed (input detected) • Fill valve opens and the dishwasher begins filling with water (output activated) • CPU waits until proper water level is reached (input detected)
  • 12.
    PLC Function Flowchart •Fill valve closes, and water flow stops (output activated/de-activated) • Heating element is turned on (output activated) • CPU waits until proper water temperature is reached (input detected) • Soap dispenser opens (output activated) • Water pump turns on to force water through sprayers (output activated)
  • 13.
    PLC Function Flowchart •CPU begins timing depending on cycle type (logic timer activated) • Water pump turns off (output deactivated) • Heating element is turned off (output deactivated) • Drain valve opens and the dishwasher begins draining the dirty water (output activated) • CPU waits until it detects the water level to be low enough (input activated/de-activated)
  • 14.
    PLC Function Flowchart •Drain valve closes (output activated/deactivated) • Fill valve opens again to rinse dishes (output activated) • Water pump turns on to force water through sprayers (output activated) • CPU begins timing (logic timer activated) • Water pump turns off (output deactivated)
  • 15.
    PLC Function Flowchart •Drain valve opens and the dishwasher begins draining rinse water (output activated) • CPU waits until it detects the water level to be low enough (input activated/de-activated) • Drain valve closes (output activated/deactivated) • Heating element turns on to heat the air inside the dishwasher and dry the dishes (output activated) • CPU waits until proper interior temperature is reached (input activated)
  • 16.
    PLC Function Flowchart •CPU begins timing (logic timer activated) • Heating element is turned off (output activated/deactivated)
  • 17.
    Discrete and AnalogI/O • Inputs and outputs are often abbreviated with the term “I/O”. In the dishwasher example above, we treated every input and output as a discrete or digital signal. Discrete signals are signals that can only be on or off. These are the simplest and most common type of I/O. In our example we did not use any analog I/O. Although, there may be some use of analog I/O within a dishwasher control system, I wanted to keep this example simple. With analog signals, instead of only on/off or open/closed possibilities, you may have 0 – 100%, 4 – 20mA, 0 – 100 degrees Celsius, or whatever it is you measuring as an input or driving as an output.
  • 18.
    Discrete and AnalogI/O • You may have heard of the Programmable Automation Controller (PAC). The term was first coined by the market research firm ARC in 2001 to differentiate the original PLCs from the newer, more powerful, more flexible controllers that were entering the market. There is disagreement about the definition differences between PAC and PLC, and often the terms are used interchangeably in the industry. I often use the terms interchangeably myself. This article, here, from Control Engineering may help you understand the differences between PLCs and PACs. In my opinion PACs are always the better choice unless the system is very simple and minimizing cost of the project is vital. The modern user interface, extra power and memory of most PACs make them easily superior to most PLCs.
  • 19.
    The Need forPLCs • Hardwired panels were very time consuming to wire, debug and change. • GM identified the following requirements for computer controllers to replace hardwired panels. • Solid-state not mechanical • Easy to modify input and output devices • Easily programmed and maintained by plant electricians • Be able to function in an industrial environment
  • 20.
    The First ProgrammableLogic Controllers (PLCs) • Introduced in the late 1960’s • Developed to offer the same functionality as the existing relay logic systems • Programmable, reusable and reliable • Could withstand a harsh industrial environment • They had no hard drive, they had battery backup • Could start in seconds • Used Ladder Logic for programming
  • 21.
    Programmable Logic Controller •A programmable logic controller (PLC) is a specialized computer used to control machines and process. • It uses a programmable memory to store instructions and specific functions that include On/Off control, timing, counting, sequencing, arithmetic, and data handling
  • 22.
    Advantages of PLCControl Systems • Flexible • Faster response time • Less and simpler wiring • Solid-state - no moving parts • Modular design - easy to repair and expand • Handles much more complicated systems • Sophisticated instruction sets available • Allows for diagnostics “easy to troubleshoot” • Less expensive
  • 23.
    Advantages of aPLC Control System • Eliminates much of the hard wiring that was associated with conventional relay control circuits. • The program takes the place of much of the external wiring that would be required for control of a process.
  • 25.
    Advantages of aPLC Control System • Increased Reliability: Once a program has been written and tested it can be downloaded to other PLCs. • Since all the logic is contained in the PLC’s memory, there is no chance of making a logic wiring error. Conversely ......
  • 27.
    Advantages of aPLC Control System • More Flexibility: Original equipment manufacturers (OEMs) can provide system updates for a process by simply sending out a new program. • It is easier to create and change a program in a PLC than to wire and rewire a circuit. End- users can modify the program in the field.
  • 29.
    Advantages of aPLC Control System • Lower Costs: Originally PLCs were designed to replace relay control logic. The cost savings using PLCs have been so significant that relay control is becoming obsolete, except for power applications. • Generally, if an application requires more than about 6 control relays, it will usually be less expensive to install a PLC.
  • 31.
    Advantages of aPLC Control System • Communications Capability: A PLC can communicate with other controllers or computer equipment. • They can be networked to perform such functions as: supervisory control, data gathering, monitoring devices and process parameters, and downloading and uploading of programs.
  • 33.
    Advantages of aPLC Control System • Faster Response Time: PLCs operate in real- time which means that an event taking place in the field will result in an operation or output taking place. • Machines that process thousands of items per second and objects that spend only a fraction of a second in front of a sensor require the PLC’s quick response capability.
  • 35.
    Advantages of aPLC Control System • Easier To Troubleshoot: PLCs have resident diagnostic and override functions allowing users to easily trace and correct software and hardware problems • The control program can be watched in real- time as it executes to find and fix problems
  • 37.
  • 38.
  • 39.
    PLC Architecture • Anopen architecture design allows the system to be connected easily to devices and programs made by other manufacturers. • A closed architecture or proprietary system, is one whose design makes it more difficult to connect devices and programs made by other manufacturers. • NOTE: When working with PLC systems that are proprietary in nature you must be sure that any generic hardware or software you use is compatible with your particular PLC.
  • 40.
    I/O Configurations • FixedI/O • Is typical of small PLCs • Comes in one package, with no separate removable units. • The processor and I/O are packaged together. • Lower in cost – but lacks flexibility.
  • 41.
  • 42.
    I/O Configurations • ModularI/O • Is divided by compartments into which separate modules can be plugged. • This feature greatly increases your options and the unit’s flexibility. • You can choose from all the modules available and mix them in any way you desire.
  • 43.
  • 44.
    I/O Configurations • ModularI/O • When a module slides into the rack, it makes an electrical connection with a series of contacts - called the backplane. The backplane is located at the rear of the rack.
  • 45.
  • 46.
    Power Supply • SuppliesDC power to other modules that plug into the rack. • In large PLC systems, this power supply does not normally supply power to the field devices. • In small and micro PLC systems, the power supply is also used to power field devices.
  • 47.
    Processor (CPU) • Isthe “brain” of the PLC. • Consists of a microprocessor for implementing the logic, and controlling the communications among the modules. • Designed so the desired circuit can be entered in relay ladder logic form. • The processor accepts input data from various sensing devices, executes the stored user program, and sends appropriate output commands to control devices.
  • 48.
  • 49.
    I/O Section • Consistsof: • Input modules • Output modules.
  • 50.
    I/O Section • InputModule • Forms the interface by which input field devices are connected to the controller. • The terms “field” and “real world "are used to distinguish actual external devices that exist and must be physically wired into the system.
  • 51.
  • 52.
    I/O Section • OutputModule • Forms the interface by which output field devices are connected to the controller. • PLCs employ an optical isolator which uses light to electrically isolate the internal components from the input and output terminals.
  • 53.
  • 54.
    Programming Device • Apersonal computer (PC) is the most commonly used programming device • The software allows users to create, edit, document, store and troubleshoot programs • The personal computer communicates with the PLC processor via a serial or parallel data communications link
  • 55.
  • 56.
    Programming Device • Hand-heldprogramming devices are sometimes used to program small PLCs • They are compact, inexpensive, and easy to use, but are not able to display as much logic on screen as a computer monitor • Hand-held units are often used on the factory floor for troubleshooting, modifying programs, and transferring programs to multiple machines.
  • 57.
  • 58.
    PLC Mixer ProcessControl Problem • Mixer motor to automatically stir the liquid in the vat when the temperature and pressure reach preset values • Alternate manual pushbutton control of the motor to be provided • The temperature and pressure sensor switches close their respective contacts when conditions reach their preset values
  • 59.
    PLC Mixer ProcessControl Problem
  • 60.
    Process Control RelayLadder Diagram • Motor starter coil is energized when both the pressure and temperature switches are closed or when the manual pushbutton is pressed
  • 61.
    PLC Input ModuleConnections • The same input field devices are used • These devices are wired to the input module according to the manufacturer’s labeling scheme
  • 62.
    PLC Output ModuleConnections • Same output field device is used and wired to the output module • TRIACswitches motor ON and OFF in accordance with the control signal from the processor
  • 63.
    PLC Ladder LogicProgram • The format used is similar to that of the hard- wired relay circuit
  • 64.
  • 65.
  • 66.
    PLC Ladder LogicProgram • I/O address format will differ, depending on the PLC manufacturer. You give each input and output device an address. This lets the PLC know where they are physically connected
  • 67.
    Entering And RunningThe PLC Program
  • 68.
    PLC Operating Cycle •During each operating cycle, the controller examines the status of input devices, executes the user program, and changes outputs accordingly • The completion of one cycle of this sequence is called a scan. The scan time, the time required for one full cycle, provides a measure of the speed of response of the PLC
  • 69.
  • 70.
  • 71.
  • 72.
    Modifying A PLCProgram • The change requires that the manual pushbutton control should be permitted to operate at any pressure but not unless the specified temperature setting has been reached.
  • 73.
    Modifying A PLCProgram • If a relay system were used, it would require some rewiring of the system, as shown, to achieve the desired change.
  • 74.
    Modifying A PLCProgram • If a PLC is used, no rewiring is necessary! The inputs and outputs are still the same. All that is required is to change the PLC program
  • 75.
  • 76.
    PC Based ControlSystems • Advantages • Lower initial cost • Less proprietary hardware and software required • Straightforward data exchange with other systems • Speedy information processing - Easy customization
  • 77.
    PLC Size Classification •Criteria • Number of inputs and outputs (I/O count) • Cost • Physical size
  • 78.
  • 79.
    IEC 61131-3 • TheIEC (International Electro technical Commission) is a worldwide organization for standardization comprising all national electro technical committees (IEC National Committees) • This part of IEC 61131 specifies syntax and semantics of programming languages for programmable controllers as defined in part 1 of IEC 61131.
  • 80.
    IEC 61131-3 • Thispart of IEC 61131 specifies the syntax and semantics of a unified suite of programming languages for programmable controllers (PCs). • These consist of two textual languages, IL (Instruction List) and ST (Structured Text), and two graphical languages, LD (Ladder Diagram) and FBD (Function Block Diagram). • Sequential Function Chart (SFC) elements are defined for structuring the internal organization of programmable controller programs and function blocks. Also, configuration elements are defined which support the installation of programmable controller programs into programmable controller systems.
  • 85.
  • 86.
  • 87.
  • 88.
  • 89.
    1.4.3 Programming model •The elements of programmable controller programming languages, and the sub clauses in which they appear in this part, are classified as follows: • Data types (2.3) • Variables (2.4) • Program organization units (2.5) • Functions (2.5.1) • Function blocks (2.5.2) • Programs (2.5.3) • Sequential Function Chart (SFC) elements (2.6) • Configuration elements (2.7) • Global variables (2.7.1) • Resources (2.7.1) • Access paths (2.7.1) • Tasks (2.7.2)
  • 90.
    1.4.3 Programming model •Combination of programmable controller language elements • LD - Ladder Diagram (4.2) • FBD - Function Block Diagram (4.3) • IL - Instruction List (3.2) • ST - Structured Text (3.3) OTHERS – • Other programming languages (1.4.3)
  • 91.
  • 92.
  • 93.
    Program Organization Unit(POU) •This is an object that holds logic that is used to develop your application. These can be declared as various different types (which changes their behavior), but POUs ultimately serve one function —to hold and execute your code. As well as being declared as different types (which we'll come on to), POUs can also be declared as using a different language. This doesn't mean a different spoken language like English, but a different programming language
  • 94.
    Task • A Taskis exactly what it sounds like; it's a Task that tells your application to run a set of POUs or gather IO data. In some PLCs, Tasks perform various other tasks too and may not be called "Tasks" at all (looking at you Siemens, OB1, OB35, etc. are basically Tasks). • In most PLCs, Tasks can be defined with a range of various parameters such as
  • 95.
    Task • Task Mode:The mode the task is operating in, such as Cyclic Execution, Event Driven, Freewheeling. It's probably best to look up the different modes available and what they mean to the PLC you are using, as they're not always done in the same way. • Watchdog Timeout: The time in which the entire task MUST complete. Failing to complete the task in this time will raise an internal flag that drops all outputs to a safe state. Some PLCs allow you to configure what happens on Watchdog failure; some don't. Refer to the documentation for your own PLC.
  • 96.
    Task • An importantrule to remember is that if a POU cannot be traced back to a Task, it will not be executed. For example: • Task >> Main (PRG) >> Sub (PRG) >> Area_1 (FB) >> Function (FB) • The above shows "Task" calling "Main" which is calling "Sub" and so on. If "Area_1" was deleted, "Function" would have no route to a Task and would therefore no longer be executed in the program. Most (not all) PLC programming environments tell you that a POU is orphaned from a Task.
  • 97.
    PROGRAM • A PRGis a type of POU in most PLCs (Not all, again looking at Siemens in which PRG doesn't exist). At least one PRG must exist as Tasks can only call a PRG. Because a PRG is simply a type of POU, it performs in the same manner as any other POU and can be declared in different languages. • A PRG can call another PRG as well as call any other type of POU. A PRG can also declare its own Variables (Covered later). • Note: In some PLCs, PRGs can declare their own variables, but they are not maintained between PLC scans (a complete execution of a task); this means that any value written to the variable is lost at the end of the scan. These types of variables are usually referred to as Temp Variables.
  • 98.
    Function Block • AFunction Block is probably the most common POU used in a PLC. They are used to create blocks of code that can be used over and over again by simply dropping the FB into a POU or another FB. FBs are made up of Input and Output parameters (we'll cover these in more detail) that allow data from outside the FB to be brought in and data made by the FB to be passed back out to the caller. For example
  • 99.
  • 100.
    Function Block • Theabove shows FB_1 being called on line 1 (a PRG is calling it). The input data has Sensor_1 being passed to it. The FB_1 object is performing a task and then outputting Output, which is being passed to Output in the PRG that is calling the FB. • Line 2 is showing FB_1_CALL.Counter being used, but we cannot see "Counter" as a parameter of FB_1? This is because "Counter" is a Static Variable (A variable that is used to hold information rather than pass it anywhere). In most PLCs, Static Variable information is accessible if the Instance of that data is also declared
  • 101.
    What is InstanceData? • Instance data is the data that belongs to an FB. In the example above, FB_1_CALL holds all instance data of FB_1. This is why declaring "FB_1_CALL.Counter" works correctly. FB_1 is the name of the FB, FB_1_CALL is the data for that specific call of that FB. • If FB_1 was called again on Line 3, you would need to give it a different set of instance data by declaring a different identifier for it, such as "FB_1_CALL2".
  • 102.
    FUNCTION • A functionis very similar to a Function Block, but it does not hold its own data for more than 1 PLC scan; all variables are temporary • PLCs handle functions in different ways; for example CoDeSys allows you to leave interface pins unassigned whereas Siemens does not. Most PLCs also enforce that a variable is returned when the Function completes. This variable must be declared when the Function is created. It's very common to see functions returning a Byte or Word which contains a status on whether the Function completed without issue.
  • 103.
    VARIABLE • A Variableis a container that holds information; there are many different types, and it depends on the PLC in use. The main Variable types (also known as Data Types) are: • BOOL: Digital Data (True / False) • BYTE: Numerical Data / Bitwise Data (0 - 255) • INT: Numerical Data (-32768 - 32767) • UINT: Numerical Data (0 - 65535) • SINT: Numerical Data (-128 - 127) • USINT: Numerical Data (0 - 255) • DINT: Numerical Data (-2147483648 - 2147483647) • WORD: Numerical Data / Bitwise Data (0 - 65535) • DWORD: Numerical Data / Bitwise Data (0 - 4294967295) • REAL: Numerical Data (-3.402823e+38 - 3.402823e+38) • ARRAY: Array of Any Data type (Declared as "ARRAY [0..10] OF Data Type)
  • 104.
    VARIABLE • Most PLCssupport the above, and some PLCs will support a selection of the below also: • LWORD: Numerical Data / Bitwise Data (0 - 18446744073709551615) • UDINT: Numerical Data (0 - 4294967295) • LINT: Numerical Data ( -9,223,372,036,854,775,808 - 9,223,372,036,854,775,807) • ULINT: Numerical Data (0 - 18446744073709551615) • VARIANT: Object (Anything) • NULL: Object (Nothing)
  • 105.
    VARIABLE • The additionalvariables are generally only supported by 64bit PLCs and Runtimes. Variant & Null data types are advanced and not common in PLCs. • In addition to the above Data Types, there are also different Variable attributes (modes if you like): • CONSTANT - Variable that is hard coded and cannot be changed at runtime • RETAIN - Variable that remembers its last value between loss of power supply to the PLC. Most PLCs have a limit on the maximum amount of data that can be retained. Older PLCs may retain everything by default or have special ranges of registers that are retained, so make sure you check. • PERSISTENT - A variable that retains it's last value even after a re-initialization of the PLC or the PLC is warm started. The only way to reload the default data is to cold start the PLC or perform a full download. • Note: Persistent variables can be dangerous if used incorrectly, especially if indirect addressing / pointers are being used.
  • 106.
    INTERFACE • An interfaceis the declaration of variables a PRG, FB or FC is expecting to use. There are a few keywords that can be used to declare interfaces: • VAR_INPUT - Data passed into the POU • VAR_OUTPUT - Data passed out of the POU • VAR_IN_OUT - Data that is passed in and out of the POU to the same variable (If you know a bit about computer programming, think of this as passing by reference) • VAR - Data that is local to the POU, Some PLCs allow access to the data by explicit reference only (For example, "POU.VARIABLE") • VAR_STATIC - The same as VAR, but does not allow access to the data from outside the block • VAR_TEMP - Temporary data, the values stored in TEMPs is lost when the block is exited • END_VAR - A required termination declaration after declaring your variables.
  • 107.
    VAR_GLOBAL • GLOBAL Variablesare special variables that are accessible anywhere in a project. They serve as a great way of passing information between different areas of your project. • Some people use Globals for everything and don't declare any VARs in POUs. I advise against this as it gets messy quickly! • Globals are usually defined in a special Global Variable list or Symbol table, depending on the PLC you are using. • (Siemens use DBs, variables stored in DBs that are not Instance DBs are the equivalent of Global Variables)
  • 108.
    POU Languages • LADDER •Ladder is probably the most commonly used language. It's easy to read and follow and fault find
  • 110.
    POU Languages • FUNCTIONBLOCK DIAGRAM • FBD is very, very similar to Ladder; it tends to be used for projects that are made up of many separate functions (hence the name). Logic that compares Bool values is easier in Ladder than it is in FBD.
  • 112.
    POU Languages • STRUCTUREDTEXT • Structured Text is one of (if not, the most) flexible of the languages. It's quick to program in and easy to read but can get messy quickly if formatting rules aren't followed.
  • 114.
    POU Languages • SequentialFunction Chart • This language is excellent for sequencing (hence the name!). However, it is one of the more difficult to understand. In the example below, it is important to note that the "ProcessTimer" step must be called in any scenario; else, the timer will not update and will hold its last value. It is very easy to get stuck with SFC and leave variables in states that were not intended.
  • 116.
    POU Languages • CONTINUOUSFUNCTION CHART • CFC is very similar to FBD, but you are not confined to networks (horizontal placeholders); you are free to draw your logic however you like. This language is useful for electricians transferring to PLC logic, as it reads the same as a drawing. There are a few things to be careful of, though; the logic may not flow as expected. There are small numbers that show the logic flow, it's important to keep track of what is happening and where.
  • 118.
    LIBRARIES • Libraries area collection of POUs and Variable lists that can be moved from project to project. This allows you to have a standard set of POUs, tried and tested, that can be dropped into a project when required. • Libraries can be nested, too, so a library can call another library if required. Any large-scale software house will almost definitely have a standard library set.
  • 119.
    What is Tag? •Tag is a name you assign to an address of device/PLC. • It is also called "variable" or "symbol" depending on the manufacture of the device/PLC.
  • 120.
    Ladder Logic Basics •Ladder logic is a programming language that is used to program a PLC (Programmable Logic Controller). It is a graphical PLC programming language which expresses logic operations with symbolic notation using ladder diagrams, much like the rails and rungs of a traditional relay logic circuit. • Ladder logic is a fast and simple way of creating logic expressions for a PLC in order to automate repetitive machine tasks and sequences. It is used in a multitude of industrial automation applications. Some industrial automation application examples where PLC ladder logic is used include….
  • 121.
    Ladder Logic Basics •Material Handling Conveyor System. • Pallet Packing and Strapping. • Ball Mill Lubrication System. • Logistics Package Conveying and Sorting. • Cement Batching. • Beverage Bottling and Labeling. • Hopper and Tank Level Control. • Air and Liquid Flow and Pressure Control. • In the good ol’ days, machine and process automation was accomplished using a hard wired control system known as relay logic. With the advent of microprocessors and the invention of the PLC, relay logic quickly became superseded by programming languages such as ladder logic.
  • 122.
    Why is LadderLogic Popular? • Ladder logic is the most popular method of PLC programming because it has an easy to use graphics based interface and the programming language resembles an electrical schematic drawing. Engineers, electricians and students find the transition from an electric circuit to ladder logic relatively easy. • When programming ladder logic in a PLC, the graphic, drag and drop nature of ladder diagrams helps you formulate code quickly and easily. Ladder logic also helps you easily trouble shoot your code because you can visually see the flow of logic from the LHS start rail, through the logic symbols and to the RHS end rail.
  • 123.
    Learning the Basicsof Ladder Logic • It’s relatively easy to learn the basic concepts of ladder logic programming, even if you don’t have experience with electric circuits. Take comfort in knowing that ladder logic is the quickest and easiest PLC programming language to learn. • In order to help you learn the basics of ladder logic we will cover the following…. • Introduce the ladder diagram. • Examine the seven basic parts of a ladder diagram. • Identify the binary and logic concepts used in ladder logic. • Reveal the hidden ladder logic functions that are automatically built into the structure of the ladder diagram. • Discover the five fundamental logic functions that are essential to know.
  • 124.
    What is aLadder Diagram in a PLC? • A ladder diagram is the symbolic representation of the control logic used for programming of a PLC. Ladder diagrams have horizontal lines of control logic called rungs and vertical lines at the start and end of each rung called rails. It looks just like a ladder, hence the name “ladder diagram”. • There are two main differences between an electrical schematic and a ladder diagram: • The control logic in an electrical schematic is represented using components whereas in a ladder diagram symbols are used. • The control logic execution in an electrical schematic is as per the operation of an electrical circuit whereas in a ladder diagram it relies on the methodical nature of the PLC scan
  • 125.
    Why is aladder diagram used for PLC programming? • Ladder diagrams are used to formulate PLC logic expressions in graphical form. They use symbols to represent conditional, input and output expressions. Ladder diagrams are similar to relay control circuits and are used due to their ease of programming compared to text based programming languages. • Early control system designers were accustomed to relay logic control circuits and ladder diagrams closely mimic these. They preferred to use ladder diagrams for PLC programming instead using text based programming languages of the day like C, BASIC, Pascal and FORTRAN.
  • 126.
    Why is aladder diagram used for PLC programming? • Factory maintenance staff already understand how to read relay control circuits. They can use their knowledge of relay control circuits to help troubleshooting control system problems that implement PLC programming with ladder diagrams. • Ladder Diagram (LD) is the official name given in the international PLC programming standard IEC-61131. But, these days the terms ladder diagram, ladder logic diagram, ladder drawing, ladder control, ladder circuit, control logic diagram and logic diagram (to name a few) are all used to describe relay logic circuits and ladder logic programming. • So don’t get too caught up in the specific definition of each of these expressions, they kind of generally all mean the same thing. At the end of the day most people will know what you are talking about anyway. Personally, I use the term ladder logic for PLC programming and relay logic for relay control circuits.
  • 127.
    How to DrawLadder Logic Diagrams? • Ladder logic diagrams are drawn in a similar way to relay logic circuit. They use rails and rungs to create the logic framework. The logic operations are drawn in using symbolic notation. • The rails in a relay logic circuit represent the supply wires of a relay logic control circuit. However, in ladder diagrams, the rails represent the start and end of each line of symbolic code. • The rungs in a relay logic circuit represent the wires that connect the components together. However, in a ladder diagrams, the rungs represent the logic flow through the symbolic code.
  • 128.
    How to DrawLadder Logic Diagrams? • When implementing a ladder logic program in a PLC there are seven basic parts of a ladder diagram that critical to know. They are rails, rungs, inputs, outputs, logic expressions, address notation/tag names and comments. Some of these elements are essential and others are optional. • To help understand how to draw ladder logic diagrams the seven basic parts of a ladder diagram are detailed below….. • Rails – There are two rails in a ladder diagram which are drawn as vertical lines running down the far most ends of the page. If they were in a relay logic circuit they would represent the active and zero volt connections of the power supply where the power flow goes from the left hand side to the right hand side.
  • 129.
    How to DrawLadder Logic Diagrams? • Rungs – The rungs are drawn as horizontal lines and connect the rails to the logic expressions. If they were in a relay logic circuit they would represent the wires that connect the power supply to the switching and relay components. Each rung is numbered in ascending sequential order. • Inputs – The inputs are external control actions such as a push button being pressed or a limit switch being triggered. The inputs are actually hardwired to the PLC terminals and represented in the ladder diagram by a normally open (NO) or normally closed (NC) contact symbol. • Outputs – The outputs are external devices that are being turned on and off, such as an electric motor or a solenoid valve. The outputs are also hardwired to the PLC terminals and are represented in the ladder diagram by a relay coil symbol.
  • 130.
    How to DrawLadder Logic Diagrams? • Logic Expressions – The logic expressions are used in combination with the inputs and outputs to formulate the desired control operations. • Address Notation & Tag Names – The address notation describes the input, output and logic expression memory addressing structure of the PLC. The tag names are the descriptions allocated to the addresses. • Comments – Last but by not least, the comments are an extremely important part of a ladder diagram. Comments are displayed at the start of each rung and are used to describe the logical expressions and control operations being executed in that rung, or groups of rungs. Understanding ladder diagrams is made a lot easier by using comments.
  • 132.
    How Does LadderLogic Work? • Ladder logic works in a similar way to relay logic, but without all the laborious relay control wiring. In simple terms, the field input and output devices are wired directly to the PLC and the ladder logic program decides what outputs to activate, depending on the status of the input signals. • Just like relay logic, ladder logic has supply rails, relay coils, relay contacts, counters, timers, PID loop controllers and much more. The difference is that with relay logic the logic expressions are created with relay control circuits. This can amount to large amounts of relays and wiring. However, with ladder logic the logic expressions are programmed in the PLC. So, the only wiring required is for the input and output devices.
  • 133.
    How to ReadLadder Logic? • Ladder logic is read from the left hand rail to the right hand rail and from the first rung to the last rung. In short – LEFT TO RIGHT AND TOP TO BOTTOM. The rungs contain input symbols that either pass or block the logic flow. The result of the rung is expressed in the last symbol, known as the output. • To start reading ladder logic we need to know some basic binary concepts, how they apply to ladder logic, how ladder logic is executed and the basic logic functions that are built into each rung. Let’s begin….
  • 134.
    The Binary ConceptApplied to Ladder Logic • Microprocessors, like the ones found in PLCs and personal computers operate on the binary concept. You’ve probably heard of the term ‘binary’. It refers to the principle that things can be thought of in one of two states. The states can be defined as: • True or False • 1 or 0 • On or Off • High or Low • Yes or No • Microprocessors love binary….. 10101011101000111010001010100010100100101010010011.
  • 135.
    The Binary ConceptApplied to Ladder Logic • I don’t know about you, but my head hurts just looking at that! Luckily ladder logic uses symbolic expressions and a graphical editor for writing and reading ladder diagrams making it easier for us mere humans to comprehend. • In a PLC, binary events are expressed symbolically using ladder logic in the form of a normally open contact (NO) and normally closed contact (NC). • The normally open contact (NO) is TRUE when the event is active and FALSE when the event is NOT active. While the normally closed contact (NC) is FALSE when the event is active and TRUE when the event is NOT active. • Let me explain NO and NC contacts a little further …..
  • 136.
    The Binary ConceptApplied to Ladder Logic • Normally Open Contact (NO) in Ladder Logic • The event associated with a normally open contact (NO) can be TRUE or FALSE. When the event is TRUE then it is highlighted green and the logic flow can move past it to the next logic expression. Just like the current flow in an electric circuit when a switch is turned on. • Let’s call a certain PLC input event ‘A’. This PLC input event could be something like a button being pushed, a limit switch being activated or a temperature switch being triggered. • PLC input event ‘A’ follows the binary concept and has one of two states, TRUE or FALSE. The ladder logic truth table for a normally open contact (NO) which denotes PLC input event ‘A’ is shown below….
  • 137.
    The Binary ConceptApplied to Ladder Logic • Normally Closed Contact (NC) in Ladder Logic • The event associated with a normally closed contact (NC) can be TRUE or FALSE. The result of the normally closed contact (NC) is basically the opposite state of an event that occurs. So, if PLC input A is FALSE the result will be TRUE. And vise versa when PLC input A is TRUE the result will be FALSE. • The normally closed contact (NC) is considered to be a ladder logic NOT function. It is sometimes referred to as reverse logic. Check out the truth table below….
  • 138.
    The Binary ConceptApplied to Ladder Logic • If we translate a NOT function into a ladder logic diagram we express it symbolically in the form of a normally closed contact (NC) as seen in ladder logic truth table shown below….
  • 139.
    How Ladder Logicis Executed? • In order to successfully read ladder logic we need a basic understanding of how a PLC works and how ladder logic is executed in a PLC. You see, the PLC follows a certain execution procedure and if not adhered to it can lead to the ladder logic being read incorrectly. • Ladder logic works in a similar way to relay logic, but without all the laborious wiring. It has supply rails, relay coils, relay contacts, counters, timers, PID loop controllers and much more. In simple terms, all the field input and output devices are wired to the PLC and the ladder logic program decides what outputs to trigger depending on the status of the input signals. • In basic terms, PLCs execute ladder logic by first reading all the input states and storing them into memory. Secondly, scanning through and evaluating each rung of ladder logic, from left to right and top to bottom. Lastly, at the end of the scan, the resultant logic is executed and the outputs are written to.
  • 140.
    Ladder Logic BasicFunctions • In a ladder diagram the normally open (NO) and normal closed (NC) contacts merely tell us what state an event is in, TRUE or FALSE. On their own they cannot decide what action to take to automate something. • We need binary’s best friend ‘logic’ to help out. • Logic is the ability to decide what action needs to be taken depending on the state of one or more events. We use the binary and logic concepts every day in our own lives. For example, if I feel cold then I put my sweater on, but if I feel hot then I take my sweater off. • Binary concept – Cold or Hot, Sweater On or Sweater Off. • Logic concept – IF, THEN logic functions. • Binary Logic in action!
  • 141.
    Ladder Logic BasicFunctions • The binary and logic concepts are what makes ladder logic work. The hidden key to unlock your understanding of how ladder logic works is: The logic functions in ladder logic are automatically built into the structure of the ladder diagram. • Let me show you…… • Ladder Logic IF, THEN Functions • Let’s take a real world event, allocate it to a normally open contact (NO) and call it ‘A’. In ladder logic the real world events are defined as PLC inputs. • Now, let’s call the result of the logic function ‘Y’. In ladder logic the result of a rung logic function is defined as a PLC output.
  • 142.
    Ladder Logic BasicFunctions • When we take these two fundamental elements and insert them into a rung in a ladder diagram we get your first line of code! • It’s equivalent to “Hello World” in text based programming languages…..
  • 143.
    Ladder Logic BasicFunctions • Now, let’s expose the hidden inbuilt functions by highlighting them in blue in order to illustrate the relationship between the ladder diagram rung structure and its inbuilt IF, THEN functions….
  • 144.
    Ladder Logic BasicFunctions • We can write out the logic expression in the above as rung as IF A THEN Y. • Because PLC input A follows the binary concept it has two possible states, TRUE or FALSE. Therefore it results in two possible logic iterations: • IF A = FALSE THEN Y = FALSE • IF A = TRUE THEN Y = TRUE • We also can express this in a truth table….
  • 145.
    Ladder Logic BasicFunctions • If we translate this into a ladder logic diagram we express it symbolically in the form of a normally open contact (NO) for the input and a relay coil for the output. Remember the logic flow is from left to right and follows the same concept of current flow in an electric circuit. • The ladder logic truth table is shown below….
  • 146.
    Ladder Logic BasicFunctions • The AND function examines multiple PLC inputs and has one resulting output. If we translate an AND function into a ladder diagram we can express it symbolically in the form of two PLC inputs A and B using normally open (NO) contacts and a PLC output Y using a relay coil. • They are all connected in line, just like a series connection in an electric circuit. This time we have also highlighted the hidden AND function to illustrate the relationship between the ladder logic functions and the ladder diagram rung structure….
  • 147.
    Ladder Logic BasicFunctions • We can write out the logic expression above as IF A AND B THEN Y. • The AND function examines if all the PLC inputs are TRUE, then the corresponding result is also TRUE. However if any one of the PLC inputs is FALSE then the corresponding result is also FALSE. • Because PLC input A and B follows the binary concept and are part of the AND function there are four possible logic iterations. Check out the truth table below….
  • 148.
    Ladder Logic BasicFunctions • The number of logic iterations increases with the number of PLC inputs (2PLC Inputs ). But that doesn’t matter too much with the AND function because the result can only be TRUE if all the PLC inputs are TRUE. • If we translate an AND function into a ladder logic truth table we get the table below….
  • 149.
    Ladder Logic BasicFunctions • Ladder Logic OR Function • The OR function examines multiple PLC inputs and has one resulting output. If we translate an OR function into a ladder diagram we can express it symbolically in the form of two PLC inputs A and B using normally open contacts (NO) and a PLC output Y using relay coil. • The inputs are placed in the rung in what is known as a branch. This is the equivalent of a parallel connection in an electric circuit. The output is then connected in line with the rung. This time we have also highlighted the hidden OR function when we create a branch (parallel connection) with PLC input B across PLC input A….
  • 150.
    Ladder Logic BasicFunctions • We can write out the logic expression above as IF A OR B THEN Y. • The OR function examines if any of the PLC inputs are TRUE, then the corresponding result is also TRUE. However, all the PLC inputs must be FALSE in order for the corresponding result is also be FALSE. • Because PLC input A and B follows the binary concept and are part of the OR function there are four possible logic iterations. Check out the truth table below….
  • 151.
    Ladder Logic BasicFunctions • Remember, the number of logic iterations increases with the number of PLC inputs (2PLC_inputs ). But that doesn’t matter too much with the OR function because the result can be TRUE if any of the PLC inputs are TRUE. • If we translate an OR function into a ladder logic truth table we get the table below….
  • 152.
    Ladder Logic BasicFunctions • Wow, you’ve flown through the binary and logic functions. Remember… • For basic ladder logic programming we express binary events using normally open contacts (NC) and normally closed contacts (NC). • The five basic, yet essential, logic functions in ladder logic are: • NOT • IF • THEN • AND • OR
  • 153.
  • 154.
    What is aFunctional Block Diagram? • A Functional Block Diagram (abbreviated as FBD) is a graphical representation of a functional process via blocks and diagrams that is easier for a reader to understand and interpret. An FBD helps us determine the function between output variables and input variables via a set of rudimentary blocks and diagrams that are connected with arrows known as “connections.” • A Functional Block Diagram can help us create relationships between one or more than one variable (both input and output) to establish our understanding of functional processes aligned in a system.
  • 156.
    Where are FunctionalBlock Diagrams Being Used? • These diagrams help us understand the functions and relationships between two or more variables widely used in software engineering, system engineering, and graphical programming language. For software engineers and programmers, FBD is an essential tool that helps them understand and create correlations between two or more variables by connecting them with a connection arrow.
  • 158.
    History and Developmentof an FBD • A functional block diagram is also known as a functional flow diagram. As its name implies, it is a step-by-step representation of a functional flow that helps to simplify work processes and create a better understanding of them. The idea was given by Frank Gilbreth in 1921, preceded by other engineers and scientists who developed a multi-tier process model to simplify multiple functions and the relationships between them. • The latest functional block diagram continued to develop in the 1960s until NASA intervened and leveraged the concept to visualize and represent the time sequence of units in space systems • And now, the Functional Block Diagram holds an advantageous position and is being widely used in various fields of Business Process Redesign, Business Process Management, Computer System Engineering, and System Engineering.
  • 160.
    Functional Block DiagramFundamentals • Though a functional block diagram simplifies the work processes, breaks down a huge process into smaller units, and helps us understand the relationship between two or more variables, it could still be trickier to understand and interpret the model. Thus, for your ease and convenience, we have mentioned the basics of an FBD. • All the functions are put in a functional block which is demonstrated by a box. A square box is a symbol of a function, as illustrated below.
  • 162.
    Functional Block DiagramFundamentals • A functional block can have two or more two inputs and outputs. All these inputs and outputs can be connected with other inputs and outputs of the other functional block, thus establishing a relationship between the output of one function and the input of another as illustrated by the diagram below. • Functional blocks are standard but can be customized. Since you will be using the same functional block in your PLC program, you can use a functional block specific to one function and use it several times in other instances.
  • 164.
    Types of FunctionBlocks • Bit Logic Function Blocks • The basis of a function block is “logic” and is known to be the simplest form of algorithms. Within logic, there are two different gateway mechanisms or logic: AND logic and OR logic.
  • 165.
  • 166.
  • 167.
    Types of FunctionBlocks • Bistable Function Blocks • Bistable function blocks are known to be the simplest form of memory. It is up to you if you want to reset or set an output. The output will learn and remember the last point of the set input.
  • 168.
  • 169.
    Reset/Set function block(reset dominant)
  • 170.
    Types of FunctionBlocks • Edge Detection • The next type of function block is Edge Detection. This type of function block is very useful and widely being used in PLC programming and electronics. It got its name because the input detects a progressive edge the output will be set. And it gets detected because the output develops a pulse when a positive edge is detected.
  • 171.
    R_TRIG function blockfor detecting rising edge signals
  • 172.
    F_TRIG function blockfor detecting falling edge signals
  • 173.
    Types of FunctionBlocks • Timer Function Blocks • They are also being used in PLC engineering on a wide scale. There are three types of timer function blocks. These types of blocks include an on-delay timer, off-delay timer, and pulse timer. You will need to use only one timer and derive all the timers out of that timer.
  • 174.
    Pulse Timer (TP)function block
  • 175.
    On Delay Timer(TON) function block
  • 176.
    Off Delay Timer(TOF) function block
  • 177.
    Types of FunctionBlocks • Counter Function Blocks • The fact about the counter function block is that it takes inputs and outputs and contains other types of data. There are three types of Counter Function Blocks. These types include Up Counter, Down Counter, and Up-Down Counter blocks.
  • 178.
    Up Counter (CTU)function block
  • 179.
    Down Counter (CTD)function block
  • 180.
    Up Down Counters(CTUD) function block
  • 181.
  • 182.
  • 183.
    Various Communication Protocolsin PLC • Communication is an important role player in PLC. Apart from traditional hardware IO’s, communication protocols provide more diversity and flexibility to exchange data with various means.
  • 184.
    Communication Protocols inPLC • You must be familiar with OSI layers and different types of communication hardware ports used in PLC, to understand the whole cycle of communication in a better way.
  • 186.
  • 187.
  • 188.
  • 190.
    Ethernet/IP • It isa protocol that works under Common Industrial Protocol (CIP), which is an open application layer protocol. It is an advanced version of standard Ethernet, which is useful only for in-home and commercial purposes; but not for industrial applications. • It defines all the devices on a network as a series of objects and binds all of them to work on the same standard. This protocol was developed by Rockwell Automation.
  • 191.
    Ethernet/IP • Similar protocolswith these standards are Profinet, ControlNet, DeviceNet and RAPIEnet. They are different in it’s OSI layers and have their individual functions which differentiate themselves from each other. They have been manufactured by different vendors.
  • 192.
    Modbus • Modbus isa protocol that is used for transmitting information over a serial lines or Ethernet, based on master-slave technology. • Here we have two types of devices in this communication. The devices which request information are called Modbus Master and the devices which provide the information are called Modbus Slaves. • It is further categorized into Modbus RTU, Modbus ASCII, and Modbus TCPIP. This protocol was developed by Modicon (now Schneider Electric).
  • 194.
    Profibus • It issimilar to Modbus RTU, which also works on serial line communication. The only difference is that it is owned by Siemens Automation.
  • 195.
    DF-1 • It isan asynchronous byte oriented protocol that is used to communicate with only Rockwell devices based on RS-232.
  • 196.
    Interbus • It isa serial network protocol which works on RS-232/RS-485 and works on RTU standard. • It was developed by Phoenix Contact.
  • 197.
    HostLink • It isa serial network protocol that works on RS-232/RS-485 and works on RTU standard. • It works only on Omron PLCs. It was developed by Omron.
  • 198.
    Data Highway (DH+) •It is a protocol developed by Rockwell Automation and uses transformer-coupled differential signals; meaning that the transmitter and receiver stations need not be at the same ground potential. • It works with the differential signaling concept. It uses two wires for data transfer and the data is represented with voltage differences in the two wires. Here the data is carried with differential voltages, the noise will be easily removed in the two wires. • It uses half-duplex transmission for communication. It is a very old protocol and is used only in Rockwell PLCs. Nowadays, it has become obsolete and rarely used. • It works on token-passing protocol and uses trunk lines with drops.
  • 200.
    Point to Point(PP) • As the name suggests, it is a communication protocol which is used to communicate between only two connected devices. • It is byte-oriented and is full duplex.
  • 201.
    Actual Sensor Interface(ASI) • It is a protocol that is used to connect all the sensors and actuators in a field with a single two-conductor cable. • It reduces the wiring and manpower done to connect the field equipment to the PLC. It works in master-slave technology
  • 202.
    Open Smart GridProtocol • This protocol has been developed to connect all the electrical devices in a power grid through communication and make it a smart grid system. • The devices are meters, direct load control modules, solar panels, gateways, and other smart grid devices. • Due to use of communication, all the information is transmitted in a safe and efficient way; to make the whole power grid system a better way to operate.
  • 204.
    CAN (Controller AreaNetwork) Open • This protocol is an application layer protocol that communicates with various devices using peer messaging. It is a multi-master slave communication system and has an object dictionary that contains all the functions of a device. • This is an actual communication mean and has standard communication objects for real-time data (PDO’s), configuration data (SDO’s), timestamp, sync message, emergency message, boot-up message, NMT message, and error control message, and other data. • In a hardware configuration, one point to remember is that it requires termination at the end device to establish the whole link communication.
  • 206.
    HART (Highway AddressableRemote Transducer) • HART is a protocol in which digital data is superimposed on the traditional analog signal of 4-20 mA; so that the user gets both the analog information as well as digital information. • HART-enabled field transmitters and actuators are of great use in industrial automation; as the user gets all the information and calibration settings sitting at one corner in the office.
  • 208.