0% found this document useful (0 votes)
114 views

Ladder Logic Basics

This document discusses ladder logic, which is a programming language used to program PLCs (Programmable Logic Controllers). Ladder logic uses graphical representations called ladder diagrams to express logic operations similarly to relay logic circuits. It is a popular programming method because the diagrams resemble electrical schematics and are relatively easy for engineers to understand. The document then describes the basic components of ladder logic diagrams including rails, rungs, inputs, outputs and logic expressions and how to read and understand ladder logic programs.

Uploaded by

BILLY
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
114 views

Ladder Logic Basics

This document discusses ladder logic, which is a programming language used to program PLCs (Programmable Logic Controllers). Ladder logic uses graphical representations called ladder diagrams to express logic operations similarly to relay logic circuits. It is a popular programming method because the diagrams resemble electrical schematics and are relatively easy for engineers to understand. The document then describes the basic components of ladder logic diagrams including rails, rungs, inputs, outputs and logic expressions and how to read and understand ladder logic programs.

Uploaded by

BILLY
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 13

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

Page 1 of 13
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, C++ etc.

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.

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.

Page 2 of 13
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


Page 3 of 13
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.

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 use binary representation but 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.

Page 4 of 13
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 vice 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.

Page 5 of 13
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.

Page 6 of 13
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.
Even though PLC ladder logic was modelled after the conventional relay ladder, there is no
electrical continuity in PLC ladder logic. PLC ladder rungs should have logical continuity in
order for the output to be energized. Therefore, PLC programming is a logical procedure.
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 is 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:

Page 7 of 13
IF A = FALSE THEN Y = FALSE
IF A = TRUE THEN Y = TRUE
We also can express this in a truth table.
Truth Table

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


Note: In a ladder logic program, there is no physical conductor that carries the input signal
through to the output. Each rung in the ladder diagram is a program statement. This program
statement consists of a condition or sometimes conditions, along with some type of action.
Inputs are the conditions, and the action, or output, is the result of the conditions. As in case of
physical wiring hardware devices connected in series or parallel, PLC also combines ladder
program instructions in series or parallel. However, rather than working in series or parallel,
the PLC combines instructions logically using logic operators like: AND, OR, and NOT. These
operators are used to combine the instructions on a PLC rung to make the outcome of each
rung either true or false.

Page 8 of 13
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.

Page 9 of 13
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

Page 10 of 13
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

Page 11 of 13
Ladder Logic NOT Function
The NOT function examines a single PLC input and has one resulting output. If we translate a
NOT function into a ladder diagram we can express it symbolically in the form of a PLC input
A implemented using a normally closed (NC) contact and the PLC output Y using a relay coil.
Both are connected in line, just like a series connection in an electric circuit.

Ladder Logic Basics – NOT Function


Because the PLC input, A, follows the binary concept and is part of the NOT function there
are two possible logic iterations. Check out the truth table below.
Truth Table – AND Function
INPUT OUTPUT
A Y
TRUE FALSE
FALSE TRUE

Remember, for basic ladder logic programming we express binary events using normally
open contacts (NO) and normally closed contacts (NC).
The basic, yet essential, logic functions in ladder logic are:
1. AND
2. OR
3. NOT
4. NAND
5. NOR
6. EX-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.

Assignment 1:
Using similar logic as above examples, determine the control behaviour of NAND, NOR and
EX-OR functions and implement their behaviour using PLC ladder logic.

Page 12 of 13
Solution:

Ladder Logic Basics – NAND Function

Ladder Logic Basics – NOR Function

Ladder Logic Basics – X-OR Function

In the next section we will jump straight into the most common symbols that you can’t do
without when ladder logic programming. We’ll also examine their operation and outline some
of their most popular uses.

Page 13 of 13

You might also like