PLC programming language fundamentals for improved operations

PLC programming language fundamentals for improved operations

Programmable logic controller (PLC) programming languages help keep manufacturing operations running smoothly. Learn about the five types of PLC programming languages and how they’re used.

PLC programming insights

  • Programmable logic controller (PLC) programming languages have evolved along with PLCs themselves and are the foundation for how these machines operate efficiently.
  • There are five PLC languages. Two are graphical: ladder logic (LAD) and function block diagram (FBD). Two are text languages: Structured text (ST) and instruction list (IL). Sequential function charts (SFC) is a graphical method of organizing programs for sequential or parallel processing.


To make a programmable logic controller (PLC) do what the user wants, it must be programmed. Programming can be done offline, after which the PLC program is downloaded to the PLC. Before the download process, however, the software checks the program for errors and compiles it into machine code.

Programs also can be edited online. When downloading a program, the processor must be stopped, and all control ceases; editing online allows changes to be made while the program is running, without interruption.

PLC program organization

Organization of a program is very important from a functional standpoint and so that operations can be found easily. Different platforms provide the ability to create tasks, programs, routines and sections.

All PLC platforms have a routine that is designated to run first. It is important when learning a new platform to identify which routine this is. This is sometimes known as the main routine.

As with data memory, the program itself can be organized in different ways. Major PLC platforms all have some form of subroutine, though they may be called by different names.

It is very important to consider whether memory will be global (available to all programs and routines) or local (only available to part of the program) before beginning a program. Think about whether or not you will have multiple instances of the same code.More powerful PLCs also may allow multiple programs to be placed into a task. While the programs are still scanned one at a time, this PLC capability allows data tables or tag lists to be assigned to one program, rather than being global. Programs then are scheduled to run in a specific order under the task. This also allows programs to be duplicated under different names, but with the same tag names. This allows for rapid code development, since a program can be written and tested then copied, addresses and all.

PLC programming languages (IEC 61131-3)

PLCs have evolved in different ways depending on the manufacturer. Programming software and methods of handling data can differ immensely from platform to platform. Because of this, the International Electrotechnical Commission (IEC) created an open standard in 1982 that defines what equipment, software, communications, safety and other aspects of programmable controllers should look like. After the national committees had reviewed the first draft, they decided it was too complex to treat as one document.

he standard currently is divided into 9 parts and a tenth part is being worked on.

The third part, IEC 61131-3, defines the languages that are used in programming. It describes two graphical languages and two text languages, along with another graphical method of organizing programs for sequential or parallel processing.

The graphical languages are ladder logic (LAD) and function block diagram (FBD). The text languages are structured text (ST) and instruction list (IL). The organizational method described above is sequential function charts (SFC), which is also graphical. An additional extension language is continuous function charts, (CFC), which allows graphic elements to be positioned freely; it can be considered as an extension of SFC.

The following examples illustrate the five IEC programming languages; the addresses used are generic, and the logic shows selection of auto and manual modes, along with a timer enabling cycle. These examples do not come from an actual programming language or brand, but are meant to illustrate uses of the languages.

Ladder logic (LAD) programming example

Ladder logic evolved from electrical circuit drawings, which resemble the shape of a ladder when drawn. As a graphical language, the instructions represent electrical contacts and coils. The vertical sides of the ladder diagram are known as “rails,” and the horizontal circuits are often called “rungs.”

Function block diagram (FBD) programming example

The function blocks (FBs) evolved from Boolean algebra, the AND and OR representing basic logic. More complex blocks are used for math, loading, comparing and transferring data, timing and counting.

Some functions, such as XOR (Exclusive OR), cannot be represented in ladder logic. Also, because of the complex nature of some FBD drawings, logic can often extend across many pages. Off-page connector symbols are used to show these connections.Instruction list (IL) programming example

Graphical languages are usually converted into a text language called Instruction List before being compiled into another low-level code called machine language. Before the advent of personal computers, handheld programmers were used to type instructions into the PLC before compilation. These devices often had pictures of ladder logic contacts on the keys.Structured text (ST) programming example

Structured text resembles high-level programming languages, such as Pascal or C. Variables are declared as a data type at the beginning of routines as well as configuration of other parameters. Comments are shown in this program as starting with “//”; this may differ depending on the brand.

Linear programming languages, such as structured text, use constructs like “If-Then- Else”, “Do-While”, and “Jump” to control program flow. In these languages, syntax is very important, and it can be difficult to find errors in programming. Debug tools allowing for partial execution of the code one section at a time are common.Sequential function charts (SFC) example

SFC makes use of blocks containing code that typically activates outputs or performs specific functions. In many platforms, the blocks or “steps” can contain code written in other IEC programming languages, such as Ladder or FBD. The program moves from block to block by means of “transitions”, which often take the form of inputs.

SFC is based on Grafcet, a model for sequential control developed by researchers in France in 1975. Much of Grafcet is, in turn, based on binary Petri Nets, also called place/transition nets. Petri Nets were developed in 1939 to describe chemical processes.

Steps in an SFC diagram can be active or inactive, and actions are only executed for active steps. Steps can be active for one of two reasons; either it is defined as an initial step, or in was activated during a scan cycle and not deactivated since. When a transition is activated, it activates the step(s) immediately after it and deactivates the preceding step.

#snsinstitutions #snsdesignthinkers #designthinking

To view or add a comment, sign in

More articles by Sandeep Krishnan

  • Why Consistency Matters More Than Talent

    Consistency is one of the most underrated yet powerful qualities a person can develop. While talent, intelligence, and…

  • Planar Transformer – A Key Enabler for High-Power, High-Frequency Power Electronics

    Planar transformers are rapidly becoming a preferred choice in modern power electronics, especially in applications…

  • The Power of Mentorship in Sports

    Behind every great athlete lies not only talent and hard work, but also the guidance of a mentor who believed in them…

  • PLECS Software

    Exploring PLECS Software: A Game-Changer for Power Electronics and Control In the field of electrical and electronics…

  • ANSYS Software

    ANSYS software is a powerful, industry-standard tool used in engineering simulations to model, analyze, and predict how…

  • Starting a New Design Journey: LM2576 Buck Converter with Altium Designer

    I'm thrilled to share that I’m officially kicking off a new hardware design project—a DC-DC Buck Converter using the…

  • A Proud Moment for Portugal: Lessons in Leadership, Teamwork, and Resilience from the Nations League Victory

    As a passionate football enthusiast and someone who deeply values what sports can teach us, I couldn’t be happier to…

  • RELAYS WORKING AND IT'S APPLICATION

    Relays are electrically operated switches that play a crucial role in controlling circuits with the help of a low-power…

  • MATLAB

    In this Cleve’s Corner, I’ll describe some milestones in the evolution of MATLAB from those simple beginnings…

  • ARM processor

    ARM processors are a family of central processing units (CPUs) based on a reduced instruction set computer (RISC)…

Others also viewed

Explore content categories