PLC Programming

Ladder Logic - what is it and how does it compare to other PLC programming languages?

MSc. Jacob K. Biedulski 8 min read Updated

Today, we will focus on Ladder Logic, also known as Ladder Diagram (LD), and compare it with other PLC programming languages compliant with the IEC 61131-3 standard.

PLC Programming Languages in the IEC 61131-3 Standard

PLCs are specialized computers designed to monitor and control automation processes. The IEC 61131-3 standard defines five programming languages supported by nearly all PLC manufacturers:

  • Ladder Diagram (LD),
  • Function Block Diagram (FBD),
  • Structured Text (ST),
  • Sequential Function Chart (SFC),
  • Instruction List (IL).

In this article, we will focus on Ladder Diagram and then compare it with the other programming languages.

What is a Ladder Diagram?

Ladder Diagram is the most popular PLC programming language, primarily because it was the first one introduced. It was developed as an alternative to hardwired relays in control cabinets. Designed with electricians in mind, its appearance resembles electrical schematics.

LD is a graphical programming language, making it very intuitive and easy to debug. It is ideally suited for implementing complex Boolean logic, which is its primary purpose.

An example of LD code controlling a motor clearly illustrates the input conditions that must be met to start the motor. This kind of visualization is one of the reasons why LD is so popular.

Ladder Diagram

How ladder logic works: rails, rungs, contacts and coils

Ladder logic is a graphical programming language that copies the way relay logic circuits were drawn before PLCs existed. A ladder logic program looks like a ladder: two vertical rails (the left one is the power rail) and horizontal rungs between them. Each rung is one logical statement. Conditions (contacts) are placed on the left and the result (an output coil) on the right, so the logic flow goes from left to right, like current flowing from the left rail to the rail on the right.

The PLC executes the ladder program in a cycle called the scan: it reads all inputs, solves the rungs from top to bottom and from left to right, and then writes the outputs to the physical devices. Because one scan usually takes a few milliseconds, the control system reacts in real-time from the operator's point of view.

Basic ladder logic symbols

SymbolNameWhat it does
--| |--Normally open contact (XIC in Allen Bradley)Passes logic when the bit is 1 (TRUE), for example when a push button is pressed
--|/|--Normally closed contact (XIO in Allen Bradley)Passes logic when the bit is 0 (FALSE)
--( )--Output coil (OTE in Allen Bradley)Sets the bit to 1 while the rung is true and to 0 when the rung is false
--(S)-- / --(R)--Set and reset coil (latch and unlatch, OTL / OTU)Latch a bit to 1 or unlatch it to 0; the bit keeps its state when the rung goes false
Box instructionTimer, counter, compare, math, moveFunction blocks such as TON, CTU or comparison instructions placed on a rung

Remember that a contact in the program examines the state of a bit, not the physical wiring. A stop button is usually wired as a normally closed contact for safety (a broken wire stops the machine), so the input is 1 when the button is not pressed and in the program you examine it with a normally open contact.

Ladder logic programming example: motor start/stop circuit

The most famous ladder logic example is the start/stop (seal-in) circuit. When the start button is pressed, the Motor output coil is energized, and its own contact in parallel with the start button keeps the rung true after the button is released. Pressing the stop button breaks the rung and the motor stops:

    Start         Stop          Motor
|----| |----+------| |----------( )----|
|           |
|    Motor  |
|----| |----+

Here Stop is the normally closed push button, examined with a normally open contact as described above. The same rung is used to control a conveyor belt, a pump or a fan, and extra contacts (a limit switch, an overload relay, a guard door) are simply added in series. To build more complex ladder logic you add timers for delays, counters for parts and compare instructions for analog values.

Why engineers and technicians still use ladder logic

  • Easy to troubleshoot - in online mode the programming software highlights energized contacts and coils, so an electrician can see which condition is missing without reading code.
  • Close to the electrical schematic - the basics of ladder logic are familiar to anyone who has worked with relay logic hardware and wiring diagrams.
  • Supported everywhere - every major PLC platform, from Allen Bradley Studio 5000 and Connected Components Workbench to Siemens TIA Portal and CODESYS, supports PLC ladder logic.
  • Ideal for binary logic - interlocks, input and output handling and machine sequences built from boolean conditions are very readable on a rung.

The weak points of ladder logic are math, loops, arrays and string handling - this is where the comparison with other languages below becomes important. If you want to try it yourself, follow our first ladder logic program in CODESYS or the guide to normally open contacts and coils on an Allen Bradley Micro800.

Elmark Automatyka

Allen-Bradley hardware used in our materials (Micro800 controllers, HMI panels and accessories) is supplied by our technology partner Elmark Automatyka, an authorized Rockwell Automation distributor.

Comparison of Ladder Diagram with Other IEC 61131-3 Languages in automation

Programming Ladder Logic vs Structured Text (ST)

Structured Text is a textual programming language preferred by individuals with experience in traditional programming (e.g., Python).

Advantages of Structured Text (ST):

  • Allows complex calculations to be written in a single line, whereas in LD, each operation requires separate instructions.
  • Supports loops (FOR, WHILE), simplifying repetitive operations.

Recommendation:
ST is ideal for large-scale calculations and data manipulation. However, for the primary language of a project, LD is recommended. Why? LD is more understandable for maintenance personnel, who often are not programmers.

Ladder logic vs Structured Text

Ladder Diagram vs Function Block Diagram

Function Block Diagram (FBD) is another high-level, graphical programming language used in PLCs.

FBD is particularly popular in the process industry because its visual structure resembles P&ID (Piping and Instrumentation Diagrams), which illustrate the layout and connections of process equipment. This similarity makes it easier for professionals in this sector to adapt to the language.

In practice, the same conveyor control algorithm can be implemented in both Ladder Diagram and Function Block Diagram. The following example demonstrates how these two languages compare in appearance.

Ladder Diagram vs Function Block

Like Ladder Diagram, Function Block Diagram (FBD) is a graphical programming language that is intuitive, easy to understand, monitor, and debug. One of FBD's key strengths is its facilitation of continuous process control, such as implementing PID loops.

For this reason, Function Block Diagram is recommended in the process industry, particularly in environments where continuous control is standard. Its visual structure and intuitiveness make it better suited for such applications compared to Ladder Diagram.

Outside the process industry, the differences between FBD and LD become less significant. In such cases, the choice between these languages primarily depends on user preferences, company policies, or the standards followed in a specific industrial sector.

FBD is a powerful tool for the right applications, and proficiency in it can be a significant asset for any PLC programmer.

Function Block Diagram

Ladder Diagram vs. Sequential Function Chart (SFC)

Sequential Function Chart (SFC) is another high-level PLC programming language, visually resembling a flowchart.

Thanks to its structure, SFC is an excellent tool for modeling high-level sequential processes. Its visual representation makes it easy to illustrate the stages of a process, making it highly intuitive for creating flow diagrams.

However, due to its very general nature, SFC is not suitable for writing detailed control logic. For instance, in a simple conveyor control task, the logic in SFC might occupy nearly half the screen, whereas the same algorithm could be written as a single line of code in Ladder Diagram.

Ladder Diagram vs. Sequential Function Chart

That’s why SFC should not be directly compared to Ladder Diagram - both languages serve different purposes.

Sequential Function Chart is best regarded as a complementary language. You can use it to model a process at a high level and then implement the detailed control logic using Ladder Diagram. This combination ensures clarity in design and efficiency in implementation.

SFC is ideal for sequential processes requiring a clear depiction of stages, but when paired with Ladder Diagram, it creates a powerful and flexible programming system.

Ladder Diagram vs. Sequential Function Chart

Ladder Diagram vs Instruction List (IL)

Instruction List (IL) is a textual programming language similar to assembly language. Due to its difficulty in writing and debugging, this language has been deprecated.

Recommendation:
Avoid using IL in new projects and opt for LD instead.

Ladder Diagram vs Instruction List (IL)

Recommendations for Programmable Logic Controller Programmers

Based on the discussed programming languages, here are my recommendations:

  • Use Ladder Diagram as the default programming language. It is the most widely used and understood in the industry.
  • Consider specific languages for particular cases:
    • Function Block Diagram (FBD): Ideal for continuous process control.
    • Structured Text (ST): Best for calculations and data manipulation.
    • Sequential Function Chart (SFC): Excellent for modeling sequential processes.

Summary

In this article, I introduced all IEC 61131-3 languages, compared their strengths and weaknesses against Ladder Diagram, and suggested when to use each language.

Every PLC programmer should be familiar with all these languages to choose the best tool for a given task. Remember - if you only know one tool, every task might look like a nail!

Ladder logic - FAQ

Is ladder logic still used in industrial automation?

Yes. Ladder logic is still the most common way to program PLCs in machine building and discrete manufacturing, especially in North America. Most new projects combine it with Structured Text or Function Block Diagram where those languages fit better.

Is ladder logic hard to learn?

Basic ladder logic is one of the easiest ways to start PLC programming: you only need contacts, coils, timers and counters to write useful programs. Understanding the PLC scan and good program structure takes more practice, which is why hands-on exercises on a simulator or a real PLC help a lot.

What is the difference between ladder logic and a ladder diagram?

There is no difference. Ladder Diagram (LD) is the official name in the IEC 61131-3 standard, and ladder logic is the name commonly used by engineers and technicians.

To learn ladder logic and FBD step by step in Siemens TIA Portal, see the TIA Portal LAD/FBD course.

Author MSc. Jacob K. Biedulski

The ControlByte team - automation engineers who teach PLC programming on real projects.

Online courses

Want to program PLCs in practice?

Siemens, CODESYS, communication and safety courses with a certificate and instructor support. Start with a free mini-course.

See courses
Select the fields to be shown. Others will be hidden. Drag and drop to rearrange the order.
  • Image
  • SKU
  • Rating
  • Price
  • Stock
  • Availability
  • Add to cart
  • Description
  • Content
  • Weight
  • Dimensions
  • Additional information
Click outside to hide the comparison bar
Compare