[go: up one dir, main page]

0% found this document useful (0 votes)
95 views70 pages

Ladder Logics Basic

The document provides an overview of ladder logic symbols used in PLC programming, explaining their operations and common uses, such as normally open (NO) and normally closed (NC) contacts, coils, timers, and counters. It emphasizes the ease of learning ladder logic due to its graphical nature, which resembles traditional relay logic circuits, making it accessible for engineers and electricians. Additionally, the document outlines the structure of ladder diagrams, including rails, rungs, inputs, outputs, and logic expressions, highlighting their significance in programming and troubleshooting PLCs.
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
95 views70 pages

Ladder Logics Basic

The document provides an overview of ladder logic symbols used in PLC programming, explaining their operations and common uses, such as normally open (NO) and normally closed (NC) contacts, coils, timers, and counters. It emphasizes the ease of learning ladder logic due to its graphical nature, which resembles traditional relay logic circuits, making it accessible for engineers and electricians. Additionally, the document outlines the structure of ladder diagrams, including rails, rungs, inputs, outputs, and logic expressions, highlighting their significance in programming and troubleshooting PLCs.
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 70

+

Ladder Logic Symbols – Operation


and Common Uses
The ladder logic symbols that are used in PLC programming have been
derived from traditional relay logic control circuits. If you have a basic
knowledge of electric circuits then getting started in ladder logic
programming should be a breeze. If not, don’t worry, ladder logic is a
graphical programming language and getting to know the basic ladder logic
symbols and concepts is quite easy.

Ladder logic symbols are the fundamental programming components


used in ladder diagrams. In PLC programming, ladder logic symbols can
be used individually or in combination to create logic instructions.
Traditionally, ladder logic symbols were created for bit logic operations,
but now include higher level functions such as timers, counters, math,
comparison, PID loops, data manipulation and data conversion.
Learning the basic ladder logic symbols will give you a solid foundation.
Generally speaking a large majority of real world applications can be
accomplished with the basic ladder logic symbols. As your desire to program
complex automation and process control Functions increases, then higher
level ladder logic symbols can be used like math operations, PID loops, data
manipulation and data conversion.
The main symbols for PLC ladder logic are the input symbols and output
symbols. Digital inputs are expressed as normally open contact (NO)
symbols or normally closed contact (NC) symbols. While digital outputs
are expressed as a coil symbol.
In ladder logic the normally open contact (NO) and normally closed
contact (NC) symbols are mainly used to define PLC digital inputs and
internal logic instructions. They have been translated into ladder logic from
switches and relay contacts used in electric circuits.
An coil in ladder logic is the symbol which mainly defines PLC digital outputs.
However, a coil can also be used with internal memory in order to trigger
internal logic instructions. The coil symbol has been translated into ladder
logic from relay coils used in electric circuits.
The NO and NC contacts are some of the fundamental symbols used in PLC
programming. Let’s take a more detailed look at them and other symbols used
in PLC programming by investigating their operation and how they are
commonly used in a ladder diagram….

Normally Open Contact (NO) Symbol

Operation:
If the condition is TRUE then the contact is CLOSED and output logic flow is
enabled. If the condition is FALSE then the contact is OPEN and output logic
flow is blocked.

Ladder
Logic Normally Open Contact (NO) Symbol – State Diagram
Common Uses:
 Start Push buttons.
 Selector switches.
 Digital instrumentation.
 Internal programming.
Normally Closed Contact (NC) Symbol

Operation:
If the condition is TRUE then the contact is OPEN and output logic flow is
blocked. If the condition is FALSE then the contact is CLOSED and output logic
flow is enabled. The NC contact symbol operation is opposite to the NO
contact symbol.

Ladder
Logic Normally Closed Contact (NC) Symbol -State Diagram
Common uses:
 Stop Push buttons.
 Fail safe instrumentation.
 Motor Thermal Overloads.
 Internal programming.

Output Coil Symbol

Operation:
If the input condition is TRUE then the output is ON. If the input condition is
FALSE then the output is OFF.
Ladder
Logic Output Coil Symbol – State Diagram
Common uses:
 Motor control.
 Actuator control.
 Indication lamps.
 Warning sirens.
 Internal programming.
 Sequence logic.

One Shot Symbol– Positive Edge Detection

Operation:
If the input condition transitions from FALSE to TRUE then the output is ON,
for the time taken to do one PLC scan.

Ladder
Logic One Shot Symbol (Positive Edge Detection) – State Diagram
Common uses:
 Counting applications.
 Math commands.
 Data Transfer commands.
 Latch output during a specific set of conditions.

Set Coil Symbol

Operation:
If the input condition transitions from FALSE to TRUE then the output is set
ON. Once the output is set ON, it stays ON, even if the input condition goes
FALSE.

Ladder
Logic Set Coil Symbol – State Diagram
Reset Coil Symbol

Operation:
If the input condition is TRUE then the output is reset to OFF. If the input
condition is FALSE it has no effect on the output. The SET and RESET coils can
share the same variable address and therefore work hand in hand.
Ladder
Logic Reset Coil Symbol – State Diagram
Common uses for Set and Reset Coil Symbols:
 Motor and actuator outputs.
 Indication lamp and warning sirens.
 Internal programming.
 Toggle logic (flip flops).
 Complex latching logic which is set and reset in multiple locations.

Timer Delay On Symbol

Operation:
If the input condition is TRUE then the timer begins. When the preset time set
point has been reached the output turns ON. If the input condition goes
FALSE, at any stage, the timer stops and the output turns OFF as well.
Ladder
Logic Timer Delay On Symbol– State Diagram
Common uses:
 Time delay for Warning Sirens.
 Star/Delta Motor Starters.
 Sequence start delays.
 De-bounce time delay to fix digital instrumentation flicker.

Timer Delay Off Symbol

Operation:
If the input condition is TRUE then the output turns ON. Then if the input
condition goes FALSE the timer begins. When the preset time set point has
been reached the output turns OFF. If the input condition goes TRUE, at any
stage, the timer stops and the output turns ON as well.
Ladder
Logic Timer Delay Off Symbol – State Diagram
Common Uses:
 Cooling Fan run on time delay.

Comparison Symbols

Operation:
If the comparison between two inputs is TRUE then the output turns ON.

Common uses:
 Product Stacking and Un-Stacking complete.
 Batching system weight set point achieved.
 Alarm & Fault activation (Temperature, Flow, Motor Current etc).

Math Symbols
Operation:
Executes the mathematical operation using the inputs with the result written
to the output.

Common uses:
 Scaling of Analogue Inputs and Outputs (Temperature, Flow,
Motor Current, Weight, Pressure etc).
 Calculating Motor Speed and Position profiles.

Up Counter

Operation:
If the input condition transitions from FALSE to TRUE then the counter is
incremented by a value of 1. The accumulated count value is written to an
output. When the count value reaches the preset value the done output is set
TRUE. The counter is set back to 0 by triggering the reset input.
Down Counter
Operation:
If the input condition transitions from FALSE to TRUE then the counter is
decremented by a value of 1. The accumulated count value is written to an
output. When the count value reaches zero the done output is set TRUE. The
counter is set back to the preset value by triggering the reset input.
Common uses for Up & Down Counters:
 Counting items for a stacking sequence.
 Counting items for a batching sequence.
 Counting items for a diverting conveying.
 Counting items to be queued in a conveyor line.
 Counting events for alarm and fault triggering.
PID Closed Loop Controller

Operation:
The process variable is measured via the input and the output is adjusted to
maintain the process variable at the set point input value.
The Proportional, Integral and Derivative input values are adjusted to tune the
performance of the PID controller.
Common uses:
 Oven Temperature control.
 Irrigation Pressure control.
 Process Flow control.

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….

 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.

Compared to text based programming languages, ladder logic programming


is a lot easier to use.

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.
So let’s begin….

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:
1. The control logic in an electrical schematic is represented using
components whereas in a ladder diagram symbols are used.
2. 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.

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.
To access the body responsible for maintaining the IEC-61131 standard
please click here.

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.
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…..
1. 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.
2. 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.
3. 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.
4. 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.
5. Logic Expressions – The logic expressions are used in
combination with the inputs and outputs to formulate the desired
control operations.
6. 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.
7. 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.
Parts of a Ladder Logic Diagram

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.

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 …..

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….

Ladder Logic Truth Table – Normally Open


Contact (NO)
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….
Truth Table – NOT Function
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….

Ladder Logic
Basics Truth Table – NOT Function

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!
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.

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 Basics – Your First Line of Code
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….

Reading Ladder Logic Diagrams – In Built 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….

Truth Table – IF, THEN


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 Basics Truth Table – Hello World


Ladder Logic AND Function
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 Basics – AND Function


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….

Truth Table – AND Function


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 Basics Truth Table – AND Function
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 Basics – OR Function
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….

Truth Table – OR Function


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 Basics Truth Table – OR Function
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:
1. NOT
2. IF
3. THEN
4. AND
5. OR
You may be surprised, but when we utilize all these functions in our ladder
logic programming we will be able to program the majority of automation
control requirements.
Ladder Logic Symbols – Operation
and Common Uses
The ladder logic symbols that are used in PLC programming have been
derived from traditional relay logic control circuits. If you have a basic
knowledge of electric circuits then getting started in ladder logic
programming should be a breeze. If not, don’t worry, ladder logic is a
graphical programming language and getting to know the basic ladder logic
symbols and concepts is quite easy.

Ladder logic symbols are the fundamental programming components


used in ladder diagrams. In PLC programming, ladder logic symbols can
be used individually or in combination to create logic instructions.
Traditionally, ladder logic symbols were created for bit logic operations,
but now include higher level functions such as timers, counters, math,
comparison, PID loops, data manipulation and data conversion.
Learning the basic ladder logic symbols will give you a solid foundation.
Generally speaking a large majority of real world applications can be
accomplished with the basic ladder logic symbols. As your desire to program
complex automation and process control Functions increases, then higher
level ladder logic symbols can be used like math operations, PID loops, data
manipulation and data conversion.
The main symbols for PLC ladder logic are the input symbols and output
symbols. Digital inputs are expressed as normally open contact (NO)
symbols or normally closed contact (NC) symbols. While digital outputs
are expressed as a coil symbol.
In ladder logic the normally open contact (NO) and normally closed
contact (NC) symbols are mainly used to define PLC digital inputs and
internal logic instructions. They have been translated into ladder logic from
switches and relay contacts used in electric circuits.
An coil in ladder logic is the symbol which mainly defines PLC digital outputs.
However, a coil can also be used with internal memory in order to trigger
internal logic instructions. The coil symbol has been translated into ladder
logic from relay coils used in electric circuits.
The NO and NC contacts are some of the fundamental symbols used in PLC
programming. Let’s take a more detailed look at them and other symbols used
in PLC programming by investigating their operation and how they are
commonly used in a ladder diagram….

Normally Open Contact (NO) Symbol

Operation:
If the condition is TRUE then the contact is CLOSED and output logic flow is
enabled. If the condition is FALSE then the contact is OPEN and output logic
flow is blocked.

Ladder
Logic Normally Open Contact (NO) Symbol – State Diagram
Common Uses:
 Start Push buttons.
 Selector switches.
 Digital instrumentation.
 Internal programming.
Normally Closed Contact (NC) Symbol

Operation:
If the condition is TRUE then the contact is OPEN and output logic flow is
blocked. If the condition is FALSE then the contact is CLOSED and output logic
flow is enabled. The NC contact symbol operation is opposite to the NO
contact symbol.

Ladder
Logic Normally Closed Contact (NC) Symbol -State Diagram
Common uses:
 Stop Push buttons.
 Fail safe instrumentation.
 Motor Thermal Overloads.
 Internal programming.

Output Coil Symbol

Operation:
If the input condition is TRUE then the output is ON. If the input condition is
FALSE then the output is OFF.
Ladder
Logic Output Coil Symbol – State Diagram
Common uses:
 Motor control.
 Actuator control.
 Indication lamps.
 Warning sirens.
 Internal programming.
 Sequence logic.

One Shot Symbol– Positive Edge Detection

Operation:
If the input condition transitions from FALSE to TRUE then the output is ON,
for the time taken to do one PLC scan.

Ladder
Logic One Shot Symbol (Positive Edge Detection) – State Diagram
Common uses:
 Counting applications.
 Math commands.
 Data Transfer commands.
 Latch output during a specific set of conditions.

Set Coil Symbol

Operation:
If the input condition transitions from FALSE to TRUE then the output is set
ON. Once the output is set ON, it stays ON, even if the input condition goes
FALSE.

Ladder
Logic Set Coil Symbol – State Diagram
Reset Coil Symbol

Operation:
If the input condition is TRUE then the output is reset to OFF. If the input
condition is FALSE it has no effect on the output. The SET and RESET coils can
share the same variable address and therefore work hand in hand.
Ladder
Logic Reset Coil Symbol – State Diagram
Common uses for Set and Reset Coil Symbols:
 Motor and actuator outputs.
 Indication lamp and warning sirens.
 Internal programming.
 Toggle logic (flip flops).
 Complex latching logic which is set and reset in multiple locations.

Timer Delay On Symbol

Operation:
If the input condition is TRUE then the timer begins. When the preset time set
point has been reached the output turns ON. If the input condition goes
FALSE, at any stage, the timer stops and the output turns OFF as well.
Ladder
Logic Timer Delay On Symbol– State Diagram
Common uses:
 Time delay for Warning Sirens.
 Star/Delta Motor Starters.
 Sequence start delays.
 De-bounce time delay to fix digital instrumentation flicker.

Timer Delay Off Symbol

Operation:
If the input condition is TRUE then the output turns ON. Then if the input
condition goes FALSE the timer begins. When the preset time set point has
been reached the output turns OFF. If the input condition goes TRUE, at any
stage, the timer stops and the output turns ON as well.
Ladder
Logic Timer Delay Off Symbol – State Diagram
Common Uses:
 Cooling Fan run on time delay.

Comparison Symbols

Operation:
If the comparison between two inputs is TRUE then the output turns ON.

Common uses:
 Product Stacking and Un-Stacking complete.
 Batching system weight set point achieved.
 Alarm & Fault activation (Temperature, Flow, Motor Current etc).

Math Symbols
Operation:
Executes the mathematical operation using the inputs with the result written
to the output.

Common uses:
 Scaling of Analogue Inputs and Outputs (Temperature, Flow,
Motor Current, Weight, Pressure etc).
 Calculating Motor Speed and Position profiles.

Up Counter

Operation:
If the input condition transitions from FALSE to TRUE then the counter is
incremented by a value of 1. The accumulated count value is written to an
output. When the count value reaches the preset value the done output is set
TRUE. The counter is set back to 0 by triggering the reset input.
Down Counter
Operation:
If the input condition transitions from FALSE to TRUE then the counter is
decremented by a value of 1. The accumulated count value is written to an
output. When the count value reaches zero the done output is set TRUE. The
counter is set back to the preset value by triggering the reset input.
Common uses for Up & Down Counters:
 Counting items for a stacking sequence.
 Counting items for a batching sequence.
 Counting items for a diverting conveying.
 Counting items to be queued in a conveyor line.
 Counting events for alarm and fault triggering.
PID Closed Loop Controller

Operation:
The process variable is measured via the input and the output is adjusted to
maintain the process variable at the set point input value.
The Proportional, Integral and Derivative input values are adjusted to tune the
performance of the PID controller.
Common uses:
 Oven Temperature control.
 Irrigation Pressure control.
 Process Flow control.
Relay Logic Vs Ladder Logic
Relay logic is a hard wired control system using instrumentation,
switches, timers, relays, contactors, motors and actuators. Traditional
machine and process automation was accomplished using relay logic.
Automating a machine using relay logic requires a mass of wiring and
magnitude of devices to perform even the simplest of tasks.
Some of the other problems with implementing relay logic are:

 Requires a lot of switchboard space.


 Installation is very labor intensive.
 Trouble shooting is extremely difficult.
 Modifications to the control functionality are complicated and
seriously tedious.
Relay Logic Vs Ladder Logic – Relay Logic Panel

The advent of the microprocessor meant that relay logic control functionality
could be programmed and stored in a computer. In the late 1960’s some really
brainy people realized this and pressed ahead to create a device called
a Programmable Logic Controller (PLC).
Relay logic in a PLC is the method of formulating logical expressions in
order to automate machinery and processes in industrial applications.
The programming language that is used to create relay logic in a PLC is
called Ladder Logic.
This was a massive breakthrough in the industrial automation industry which
would eventually render relay logic control systems near redundant.

In an automated control system the main advantages of a PLC over relays


are:
 Easier to develop complex logical expressions with ladder
logic software.
 Increased reliability with PLC life easily reaching +10years,
 Easier and cheaper to modify or expand the control system at
a later date.
 Reduced design, installation and component costs.
 Virtually maintenance free compared to relays.
 Superior monitoring and reporting functionality making
process trouble shooting and optimization easier.

Relay Logic Vs Ladder Logic – PLC Ladder Logic

To understand the difference between relay logic and ladder logic it’s really
important that you understand relay logic and how a relay
works. Understanding relay logic is a good stepping stone to understanding
ladder logic. After all, ladder logic was originally derived from relay logic.
Makes sense, right?
How Do Relay Logic Systems Work?
Relay logic systems are a network of hard wired electrical components.
The relay is the fundamental component and it works by switching
electric circuits on and off to form logic operations that in turn provide
process control to the system. You can think of relay logic systems as a
mechanical computer that does computation with 1’s and 0’s by
switching relays instead of using a silicon chip.
The fundamental component of a relay logic is the relay. So let’s look at how
relays work in a little more detail…

What Is A Relay?
A relay is an electromechanical device that consists of two basic components,
a relay coil and relay contact. The relay contact is used to switch a circuit on or
off and the relay coil is used to change the state of the relay contact. The three
main types of relays are spring return relays, latching relays and multipole
relays.

Why Are Relays Used In Control Circuits?


Relays are used because they allow electric isolation between the switching
circuit (contact) and control signal circuit (coil) via means of electromagnetics.
That means relays can be used to connect circuits with different voltage and
current levels to control equipment like motors and actuators. A relay can also
switch multiple circuits with different states at the same time making them
ideal for logic control circuits in industrial automation.

What Functions Does A Relay Perform?


Relays perform 3 main functions in an electric circuit:

 Allowing control circuits to switch a load circuit even if the


voltages of both circuit are different.
 Able to switch a high current device using a low current electronic
control signal.
 Relays can be wired in combination to perform logical operations
using a network of electric circuits known as relay logic.
How a Relay Works
A relay is an electromechanical device that consists of two basic
components….

 Relay coil.
 Relay Contact.
A relay coil is essentially copper wire wound around a chunk of iron that is
used to produce an electromagnetic field that can attract metal. Think of a
junk yard crane that is used to pick up scrap metal. It uses the same principle
to generate a magnetic field that attracts metal.
A relay contact is basically a switch that is used to turn an electric circuit on or
off.
Hang on a minute! If the contacts of a relay turn an electric circuit on or off
why do we need the coil?

Well, the relay coil’s purpose is to change the state of the relay contacts. Just
like your finger is used to change the state of a light switch from off to on. So,
we are changing the state of the contacts using an electrical signal instead of
your using your finger.

Electromechanical Relay

To energize the coil we need to connect it to a voltage source, which is


sometimes called a relay input.

Some common DC voltage relays are 5V relay, 12V relay and 24V relay. Some
common AC voltage relays are 120VAC relay and 240VAC relay.
The voltage rating is usually written on the casing of the relay. The coil voltage
rating needs to be adhered to otherwise the relay coil may fail to change the
state of the contacts or overheat and burn out.

When we energize the relay coil with it’s rated voltage it allows current to flow
within the relay coil and produces and electromagnetic field. This
electromagnetic field is used to attract the relay contact towards the relay coil,
thus changing the state of the relay contacts.
The relay contacts are either configured normally open (NO) or normally
closed (NC). Quite often a relay will have changeover contacts.

So what is a changeover contact?

A changeover contact is the combination of both normally open (NO) and


normally closed (NC) contacts in the same contact block. The changeover
contact allows selection of either the normally open (NO) or the normally
closed (NC) contact depending on the way it is wired. It is sometimes called a
double throw contact.

The contact voltage and current rating is usually written on the casing of the
relay. The contact voltage and current rating needs to be adhered to otherwise
the relay contact may overheat and burn out.

If the relay coil voltage rating and contact voltage and current rating are not
written on the relay casing then check the relay base. Sometimes it’s a
combination of both the case and base. If all else fails then consult the data
sheet.

Relay Coil
With Contact Voltage & Current Rating

Relay Operation
If a relay is wired to a normally open (NO) contact and the relay is energized
then the contact will change state from OPEN to CLOSED…..
Basic
Relay Operation with Normally Open (NO) Contact

If a relay is wired to a normally closed (NC) contact and the relay is energized
then the contact will change state from CLOSED to OPEN…..

Basic
Relay Operation with Normally Closed (NC) Contact

If a relay with changeover contacts is wired in a normally open (NO)


configuration and the relay is energized then the contact will change state
from OPEN to CLOSED…..
Basic
Relay Operation with Changeover Contacts wired Normally Open (NO)

If a relay with changeover contacts is wired in a normally closed (NC)


configuration and the relay is energized then the contact will change state
from CLOSED to OPEN. Notice that the wiring of the contacts has changed
sides…..

Relay
Operation with Changeover Contacts wired Normally Closed (NC)

Types of Relays
There are several types of relays each with their specific characteristics and
uses. The 3 types that are used frequently in industrial applications are spring
return relays, latching relays and multipole relays.

Spring Return Relay


The most common relays are spring return relays. They have one relay coil and
use a spring to return the relay contact back to it’s normal state after the relay
coil is de-energized and the electromagnetic field has collapses.

The relay coil must be energized at all times in order for the state of the relay
contact to remain in it’s changed state. As soon as the coil is de-energized
then the relay contact returns back to it’s normal state.

Can you see the spring in the “Electromechanical Relay” picture above? The
spring is at the very top of the relay.

Latching Relay
A latching relay is a type of relay that can change and maintain the state of the
contact without the need for the coil to be constantly energized. It utilizes two
separate coils, each of which are responsible for a certain state of the contact
either open or closed. A short voltage pulse to energize either coil in the
latching relay is all that is required to change the state of the contact.

Multi Pole Relay


A multi pole relay is any type of relay with more than one contact. Each relay
contact is called a pole. So a relay with two contacts will be called a two pole
relay and a relay with four contacts will be called a four pole relay.

When using multi pole relays multiple coils are not required to change the
state of the contacts. The state of all the relay contacts is changed at the same
time by a single relay coil.
Two Pole Relay

In short, the operation of a single pole relay is the same as a multi pole relay,
we just have more contacts to play with!

This is handy when we are activating more than one device. Especially when
the devices need different voltage levels or the combined current draw of
multiple devices exceeds the current rating of a single contact. It’s also handy
having multi pole relays when the process control logic gets complex.

How do you connect a Relay?


In order to connect a relay we need to wire the coil to a voltage supply
(generally switched) and the contacts to the load device like a light, motor,
solenoid valve or another relay. This can be done by connecting the relay coil
and contact wires to the terminals of a relay base. The relay base terminal
allocation for connection is usually drawn on the relay casing, labelled on the
relay base or detailed in the relay data sheet.
How to connect a Relay

The common on a relay is the terminal associated with the part of the contact
that does not switch when the relay coil is energized. In a relay with a
changeover contact it is the terminal “common” to both the NO and NC
contacts. When the common is wired correctly it is connected to the load
supply voltage.

Common On A Relay

Relay Logic Circuits


The fundamental elements of relay logic circuits are….

 Power supply.
 Relay components.
 Connection wires.
The power supply voltage needs to match the rated relay coil voltage. Also,
the power supply needs to be big enough to accommodate the current draw
of all the relays when they are energized.

The relays are selected according to the power supply’s output voltage,
functionality and current rating of the contacts required.

Because relay logic is a hard wired system some sort of wiring diagram or relay
schematic diagram is required to make sense of it all.

Now please take note, there are many ways to draw an electric circuit.
Depending on which country you are from will determine which standard relay
wiring diagram you will need to use. The way circuits are laid out and the
component symbols will vary from one drawing standard to the next. Also,
some drawing standards arrange their control circuits from left to right and
some use top to bottom. Check out the sample drawings below….
Power and Relay
Schematic Diagram Examples

For the purposes of this explanation a left to right arrangement will be used
because it ties in with ladder logic diagrams later on.

A relay schematic diagram consists of a supply voltage rail on the left hand
side and a zero voltage rail on the right hand side drawn as vertical lines.

The relay components and other devices are packed in between connected by
wires, drawn as horizontal lines, to form a circuit.

Relay Logic Symbols


The relay coil and relay contacts can be drawn as per the relay logic symbols
diagram below….
Relay
Logic Vs Ladder Logic – Relay Logic Symbols

How to Read a Relay Schematic


The most basic of relay logic circuits uses a power supply, a relay, a switch and
a device that needs to be switched ON or OFF all wired together as shown in
the simple relay diagram below….

Relay Logic Vs Ladder Logic – Relay Logic Circuit Example


The above relay logic circuit example shows a lamp (Lamp No.1) being
switched on via a relay (Relay No.1).

The first line has a rotary switch connected to the coil of Relay No.1 with the
relay coil labelled as R1.

The second line has a normally open contact from Relay No.1 also labelled R1
which is connected to Lamp No.1.

To aid in understanding relay schematics the sequence of events is read from


the first horizontal line downwards and from the left hand side power rail to
the right hand side power rail.

We read from left to right because the potential difference between the left
and right hand side power rails creates current flow in that direction. In the
example relay schematics a green line is used to highlight current flow in the
circuit.

So, in the first line we start at the left hand side power rail and follow the
horizontal line until we get to the normally open Rotary Switch.

If the rotary switch is in the OPEN state there is an open circuit and current
cannot flow to the right hand side of the circuit. So the relay coil (R1) stays de-
energized.

If we go to the second line we notice that the normally open relay contact (R1)
stays OPEN because Relay No.1 coil (R1) is de-energized. Therefore there is
also an open circuit on the second line so no current can flow to the lamp and
it stays OFF….
Basic Relay Logic Circuit Example – With Rotary Switch Off

What happens when we turn the Rotary Switch on?

When the Rotary Switch is turned ON it’s state changes from OPEN to
CLOSED.

If we look at the first line and start at the left hand side power rail then follow
the horizontal line until we get to the Rotary Switch we can observe that it is in
the CLOSED state and current can flow to the right hand side of the circuit.

So in this case the relay coil (R1) is energized and then we reach the end of the
right hand side rail.

Now let’s go to the left hand side of the second line where we notice that the
normally open relay contact (R1) has also changed state to CLOSED because
the relay coil is energized.

Therefore there is a closed circuit on the second line so current can flow to the
right hand side of the circuit and Lamp No1 turns ON….
Basic Relay Logic Circuit Example – With Rotary Switch On

Let’s spice it up and add another line to the relay logic circuit.

This time we’ll use a second relay contact from Relay No1 and wire it as a
normally closed contact. Then we’ll add a second lamp (Lamp No2) to the
new circuit.

In this case the operation of that lamp will be reversed. So when the Rotary
Switch is OFF, Lamp No.2 is ON and when the Rotary Switch is ON, Lamp No.2
is OFF.

Wait, what????

Don’t believe me then check out the relay logic circuit below….
Relay Reverse Logic – With Rotary Switch Off

The new relay contact in the third line is now a normally closed instead of
normally open.

When Relay No.1 coil is de-energized it’s normally closed contact is in it’s
normal state, that is CLOSED.

When Relay No.1 coil is energized it’s normally closed contact changes state
to OPEN.

A normally closed contact behaves the opposite of a normally open contact.


It’s sometimes referred to as reverse relay logic or just reverse logic. See
below….
Relay Reverse Logic – With Rotary Switch On

Ladder Logic Control


Remember the statement earlier on this page – Ladder Logic was originally
derived from Relay Logic.

So, what is the difference between relay logic and ladder logic?

The big difference between relay logic and ladder logic is that relay logic
needs to hard wire each and every control circuit for every single control
function. Whereas ladder logic uses the assistance of a microprocessor
based device called a Programmable Logic Controller (PLC).
And, how does a PLC differ from relay logic?

The difference between a PLC and relay logic is that a PLC is a


programmable device whereas relay logic is a network of hardwired
electrical devices. Both a PLC and relay logic can perform logical
computation, but a PLC does it using a microprocessor and relay logic
does it using electric circuits.
So essentially what we are doing is getting a mass of relays and wires and
replacing them with a tiny box that has awesome computing power.
Even with a PLC and ladder logic programming we still need to hard wire
certain devices such as the switches and lamps just like in the relay logic
examples above. But the wiring is greatly reduced because only the input and
output devices need hard wiring. The control relays that are used to form the
control functionality and logic functions are replaced by the ladder logic
program stored internally within the PLC memory.

Relay Logic Vs Ladder Logic – Programmable Logic Controller

The format of a ladder logic diagram is similar to that of a relay logic circuit.

There is power rail on the left hand side and a power rail on the right hand
side drawn as vertical lines.

The logic programming is inserted in between the power rails and connected
with horizontal lines to form a logic expression.

Each line of the ladder logic diagram is called a rung.


STOP…. rails and rungs….That’s why the term “Ladder” is used in Ladder
Logic…. Light bulb moment!

However the symbols used are a bit different to the relay logic circuit
drawings. Check out the table below to compare the differences of the basic
components…

Relay
Logic Vs Ladder Logic Symbols

If we were to use a latching relay which uses two coils, one to latch (or set) the
relay and the other to un-latch (or reset) the relay. The relay symbols are
represented as below….

Ladder Logic Latching Relay

To outline the difference let’s use the example above where a switch is turning
two lamps ON and OFF alternatively.
If we use a PLC with a ladder logic program we firstly need to hard wire the
switch to the input terminals of the PLC. Then we need to hard wire the lamps
to the output terminals. Lastly, we need to write our ladder logic program and
load it into the PLC memory.

The diagram below shows a ladder logic diagram when the Rotary Switch is
OFF….

Ladder Logic Diagram – Rotary Switch Off

The diagram below shows a ladder logic diagram when the Rotary Switch is
on.

Remember the normally closed contact is reverse logic!


Ladder Logic Diagram – Rotary Switch On

Ladder Logic Advantages


Some of the advantages that ladder logic control systems have over relay logic
control systems are:

 Installation time is greatly reduced with ladder logic control


systems due to the reduced amount of hard wiring required. In
other words, we only need to hard wire the input and output
devices. The control logic is implemented using software not hard
wired relays.
 Modifications to the control logic can easily be done using
software to modify the ladder logic program rather than hardware
and wiring modifications that would normally be the case with
relay logic control.
 The same PLC can be used for a wide range of control system
applications by simply loading a different ladder logic program
into the PLC memory.
 Control system expansion is simplified with a PLC by adding
expansion modules as opposed to complex hardware and wiring
modifications that would be the case with relay logic control.
 Ladder logic is microprocessor based which has faster execution
times, is far more reliable and longer lasting than relay logic
control systems which have a large amount of mechanical
components.
 Ladder logic control systems are far more compact than relay
logic control systems.
So, in the battle of relay logic vs ladder logic we can confirm that ladder
logic is definitely winning. In fact it can be said that relay logic control systems
for larger installations are all but dead. Some countries still have regulations
for burner control panels to be relay logic controlled, but these will no doubt
be eventually replaced with PLC based control systems.
For some smaller installations where you have a handful of devices to control
with basic functionality it’s still handy to use relay logic for controlling the
application. But with the cheap price of PLC’s and the ease of ladder logic
programming they are increasingly attractive for even the smaller applications.

In the next section we’ll build on ladder logic basics and uncover the seven
essential rules that you must know to in order to program a Programmable
Logic Controller (PLC) with ladder logic diagrams along with the basics of
implementing PLC ladder logic programming.
Ladder Logic Programming
In the very early days of PLC programming ladder diagrams were configured
and loaded into a PLC using dedicated hand held programmers. These hand
held programmers were extremely slow and tedious to use.

Programming was made a lot easier with the introduction of PC’s and interface
software using text based operating systems such as the Microsoft
platform MS-DOS. The eventual move away from text based operating
systems and into graphical operating systems such as Microsoft Windows has
in turn led to the development of graphical PLC programming software.
In fact, the latest software uses many of the operating features that common
word processing software utilizes….

 Menu bar and tool bar system.


 Drop down boxes.
 Drag and drop capability.
 Directory like layout and organization.
 Comprehensive search functionality.
 Advanced editing functionality.
 Multiple window for multitasking.
 Data tables for variable declaration.
 On the fly variable declaration.
 Graphical and tabular debugging features.
The latest versions of programming software from the major PLC
manufacturers such as Allen Bradley, Siemens, Omron, Schneider, Unitronics,
Idec, Koyo and Mitsubishi have made even advanced PLC programming easier
than ever.

Ladder logic programming is based on the use of ladder diagrams. Therefore


writing such programs for a Programmable Logic Controller (PLC) are very
similar to drawing electric relay control circuits. Ladder diagrams consist of
two vertical lines that represent the power rails. The circuit components are
connected as horizontal lines between the two vertical lines…the rungs of a
ladder.

Writing Ladder Logic Programs


In order to learn ladder logic programming there is no need to have
experience in other text based programming languages such as C, BASIC,
Pascal and FORTRON. However if you are an Electrician, Electrical/Electronic
Engineer or Student then you will have a basic understanding of electric
circuits and ladder logic programming will be a breeze. If not, don’t worry,
the concepts of ladder logic programming are simple enough to grasp and
you’ll be writing your first line of code in no time at all!
Ladder logic diagrams are structured to look like an electric circuit schematic.
The logic flow is from left to right and simulates the current flow in an electric
circuit. The basic logic expressions can be arranged to form AND, OR and NOT
logic operations by implementing normally open/closed contacts and
series/parallel connections.

There is always a left hand side rail and right hand side rail with inputs, logic
expressions, internal variables and outputs packed in between. Each element is
interconnected to form a line of code, called a rung.

Multiple rungs of code end up looking like a ladder….. Hence the name
“Ladder Logic”.

The ladder logic diagram below shows the basic components and how they
are arranged when writing a ladder logic program…..
Ladder Logic Diagram
Because ladder logic is a graphical programming language these days the
programming software is drag and drop, so it makes it very user friendly. The
programming software to write ladder logic code is obtained from the
manufacturer and is installed onto your PC. Some manufacturers have free
programming software and some require a software license. Be careful
because software license=$$$$.

Ladder Logic Programming Rules


Every PLC manufacturer has slightly different ladder logic programming rules
when it comes to building the logical expressions contained within a rung.
Even a manufacturer with multiple PLC models can have varying rules
depending on processing power of each PLC model. But there are seven basic
rules that all PLC manufacturers use for ladder logic programming….

1. A PLC scans each rung in the ladder diagram from the left hand side to the
right hand side and from the top to the bottom.

2. The PLC scan runs in a repeated cyclic manner where the inputs are
monitored, the rung logic evaluated and then the state of the outputs are
executed. The scan time is expressed in milliseconds (ms).

3. The logic state of the outputs is evaluated as the program scans through the
rungs. But they are only updated at the very end of each PLC scan,
simultaneously.

4. There must be at least one input or logic expression at the start of each
rung.

5. There must be at least one output at the end of each rung.

6. Each rung in the ladder diagram represents one logic operation in the
overall control operation.

7. An input, output or logic expression can be used more than once in the
ladder diagram. The same tag name and address is used to label it if used
more than once.

To learn more about the PLC scan cycle click here.


Memory Structure For Ladder Logic
Programming
The memory structure for Ladder Logic Programming is just like that of a
computer. It is made up of bits, bytes, words and double words.

 Bit – The smallest memory unit. It is either 1 (True) or 0 (False).


 Byte – Is made up of 8 bits.
 Word – Is made up of 16 bits or 2 Bytes.
 Double Word – Is made up of 32 bits, 4 Bytes or 2 Words.
Ladder Logic Programming Memory Structure

Defining Variables For Use In Ladder Logic


Programming
In order for the PLC to process the ladder logic rungs each symbol needs to be
allocated to a variable name weather it’s an input, output or internal data.
There are three essential elements that must be defined when declaring a
variable and one optional element.

1. Variable Name – The name must be unique and is used to make


the ladder logic easily readable by human beings, such as
yourself. There will be restrictions on the length and sometimes
characters that can be used.
2. Address – the address can be either an Input, Output, Internal or
System memory address. The address nomenclature is dependent
on the PLC manufacturer.
3. Data Type – The data type used will depend on the symbol being
used and the programming operation required. Defining a
variable as a BOOL (Boolean) means it has a binary value, an INT
(integer) means it has a whole number value and a REAL (floating
point) means it has a number value with a decimal point.
4. Comment – Adding a comment is optional, but can assist in
describing the variable if the amount of characters in the variable
name was insufficient.
The table below shows some standard data types, PLC memory allocation and
common uses for each data types.
Ladder
Logic Data Types
Different PLC manufacturers use slightly different naming conventions for
variables and memory allocation. It’s just a matter of checking the PLC’s help
file to determine what to use. Some examples of variable addressing
nomenclature for different PLC manufacturers is shown in the table below….

Ladder Logic Programming Data Table

Start Ladder Logic Programming


To start programming you’ll need to get your hands on some software from
the PLC manufacturer. Some PLC manufactures have yearly licensing fees $$
for their programming software and others have free programming software.

Regardless of what PLC programming software you use every PLC will have an
area in their programming software where the ladder logic programming is
done, usually called the “Main Program”. Now-a-days PLC development
software for ladder logic is drag and drop….it makes it so easy. Grab the
symbol in the toolbar and drag it onto the rung. Next add a variable to the
symbol. Most PLC development software allows you to declare variable as you
add symbols.

Remember to add lots of descriptive comments to each rung. It helps with


readability and trouble shooting.

It’s a good idea to keep each rung as simple as possible. Cramming too much
into a rung can save on memory but it can create a really complex network of
logic that can come back and bite you if you need to return at a later date to
upgrade or modify your program.

Trust me….you’ll spend ages trying to figure out the monster you’ve
created….ouch!

A well written PLC program will ensure your machine or plant will be highly
productive, efficient and with low downtime.

Ladder Logic Programming with Sub-


Routines
If the program starts to get quite large then addition of sub-routines are
recommended. Some PLC models will also have additional areas where the
sub-routine programming is done. Either way subroutines can help your
ladder logic programming to be easier to read and assist in troubleshoot by
providing a way to organize your code into kind of a filing system.

It’s up to you with regards to naming your subroutines. Remember to create


sub routines so that you can group all the same type of code in the one place.
Some examples of possible sub routines that can be created are…..

 Main Program
 Sequence Steps
 Motor control
 Fault logic
 Interlock logic
 Analogue scaling
Upload And Download Your Ladder Logic
Program
Once your ladder logic program is complete you will need to compile the
program. The compile, button is usually located in the toolbar. Compiling the
program is just checking for syntax, memory and program structural errors. If
there are any issues then error messages will be generated that directly points
you to the source of the problem.

Once all the errors are fixed it’s time to download to the PLC. The download
button is also usually located in the toolbar of the PLC programming software.

PLC Upload Vs Download


The PLC is taken to be the point of reference when we talk about program
upload and download. Therefore a PLC Download is transferring the program
from your PC to the PLC. While a PLC Upload is transferring the program from
the PLC to your PC.

PLC Upload Vs Download

Remember To Set Your Ladder Logic


Programming To RUN MODE
So you’ve written the ladder logic program, compiled and downloaded to the
PLC, but nothing is happening ……….You need to put the PLC into run mode.

Run mode simply starts the PLC scan cycle.


Some PLC’s have a key switch, others have a soft switch done through the PLC
development software (usually some buttons in the toolbar). Either way there
should be a RUN light that illuminates on the face of the PLC……now you’re
cooking!

Debugging Your Ladder Logic Program


Ladder logic is great for debugging your program. When you place the PLC
development software in ONLINE mode the symbols in each rung highlight in
real time when their respective conditions are TRUE. So if your rung is fully
highlighted all way up to your output, then the output is TRUE…… Just like
current flow in an electric circuit.

To assist in testing and commissioning you can also force the state of binary
variables to TRUE or FALSE and also force analogue variables to a specific
value. This can be very useful, but remember to release all the forced variables
after you’ve finished testing your program.

Most PLC programming software have the facility to create variable tables
which display the variable information and status or value. This gives you a
handy display area for analyzing the status and value of the variables instead
of scrolling up and down through your rungs of code.

With the latest programming software multiple windows, with the program
and variables table, can be displayed simultaneously which comes in super
handy when debugging.

Ladder Logic Programming IEC 61131


Standards
International PLC programming standards are contained in IEC 61131 in which
ladder logic programming standards are outlined in IEC 61131 section 3 (IEC
61131-3).

Don’t panic….you don’t have to start learning the IEC 61131-3 standards. All
the IEC61131-3 standard means is that if you learn ladder logic then you’ll be
able to apply it to any manufacturers PLC’s. Good news, right!!

You see, ladder logic and PLC’s have become an extremely popular alternative
for automation control system compared to traditional methods. As it’s
popularity grew, so did the amount of companies manufacturing PLCs. Soon
there were a multitude of manufacturers each with their own version of a PLC
programming language. So the International Electrotechnical Commission
published a PLC programming standard to bring commonality to the various
versions of each programming language found in all the different
manufactures PLC’s.

The ladder logic programming language is denoted by (LD) in the IEC 61131-3
standard. There are other programming languages that are contained in the
IEC 61131-3 standard, but you will find that the most common PLC
language is ladder logic. It is by far the best “foot in the door” when it comes
to PLC programming and it can accomplish the majority of application control
tasks.
Nowadays most PLC manufacturers fully or partially support the IEC6111
standard. There is no obligation for manufactures to comply with the IEC
61131 standard and in fact some PLC manufacturers have designed their
programming software to be more user friendly than the IEC 61131-3
standard. So it’s good to be aware that the IEC 61131 standard for PLC
programming exists, but there’s no need to get too caught up in it all!

Ladder Logic Programming Samples


The best way to progress from this point is to dive into some ladder logic
programming samples. We can think of a sample ladder logic program as a
piece of the overall programming puzzle. If we create enough ladder logic
programming pieces and join them together we can form a complete
program.

In the next section we will begin to investigate programming examples with


one of the most important pieces of ladder logic you’ll ever use.

You might also like