Ladder Logic Basics
Ladder Logic Basics
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.
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.
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.
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.
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.
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….
Page 5 of 13
Ladder Logic Basics Truth Table – NOT Function
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.
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.
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.
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
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.
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.
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.
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:
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