Top 5 PLC programming languages

Top 5 PLC programming languages

Image for postPhoto by Scott Stefan on Unsplash

Before we go through the 5 PLC languages, let?s briefly mention what a PLC is. Remember Stuxnet? The exploit took advantage of the grand daddy of IoT devices, PLCs.

Programmable Logic Controllers(PLC) were designed to replace electromechanical relays. Back in the day, you had to get an electrician to risk life and limb to rewire the relays if you wanted to make an adjustment to a line. With the advent of PLCs, electricians were taught how to use programmable logic to make updates.

Programs that allow for such updates are often written on a PC, and then transferred via cable or USB to the PLC itself. These programs are stored in non-volatile memory to ensure that the processes they are designed to control continue to run smoothly. You don?t want the program that controls prison doors in high security prisons to suddenly be wiped out.

Like any other machine that can execute programs, there are a bevy of languages available to break down into machine code. The languages below have their use cases. Some are great for their simplicity within the context of electromechanics while others are great because of their complexity.

There are only 5 languages that are considered to be standard languages for use on PLCs, according to IEC section 61131?3. Here they are:

Ladder Diagram (LD)

Ladder Diagram is the oldest PLC language. This graphical programming language was modeled from relay logic to allow engineers and electricians to transition smoothly into programming PLCs.

Within Ladder, rungs and rails represent the real world electrical connections. Specifically, the vertical ?rails? represent the supply power of the device while the rungs that are connected to the rails are equal to the amount of control circuits.

High and low input conditions can be written in one terminal, which then impacts the output on the output terminals.The dearth of instructions in ladder logic makes it difficult to model motion or batching ? understandably so, because ladder logic strictly adheres to the on/off logic of hard-wired relays.

Sequential Function Charts

A sequential function chart is a graphical programming language that mimics a flow chart. You use steps and transitions to get output.

Steps are functions within the program and house events that are activated based on state and other specified conditions.

Transitions are instructions based on true/false values that move you from one step to another.

Branches are used to initiate multiple steps at a time. The branches act like threads where functions can run concurrently.

All of these steps, transitions, and branches are housed in a series of scripts that execute in a procedural manner. The visual nature of the language allows users to monitor processes that both heavily use conditional logic and run parallel instructions. PLCs that are prone to suffering from bottlenecks can be more intuitively maintained and troubleshooted using the chart to follow the logic of the program.

Function Block Diagram

Block based programming languages are a type of graphical language that minimizes code into blocks, which allows for a simple way to create executable commands.

FBD in particular describes a function between inputs and outputs that are connected by connection lines. The logic of the inputs and outputs are stored in blocks. The blocks are programmed onto sheets and the PLC scans these sheets in order or by specified connections between blocks, much like procedural languages.

The I/O focus mirrors that of ladder logic. Yet, the code that the blocks contain allow engineers to develop more complex batch control tasks among other repeatable tasks.

Instruction List

This is the PLC?s equivalent to assembly language. This gives you immediate access to the machine itself, which allows you to write code that is compressed and fast. The code is represented in the manner that the language?s name suggests: in a list of commands.

Structured Text

Structured Text is a high level language designed to program PLCs. This is essentially the C++ of the PLC world. Any PLC that requires complex data handling will most likely use ST.

7

No Responses

Write a response