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

5 PLC Programming Languages 2

Uploaded by

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

5 PLC Programming Languages 2

Uploaded by

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

PLC PROGRAMMING LANGUAGES

There are 5 languages that are all a part of the IEC (International Electrotechnical Commission)
Section 61131-3 Standard. This IEC Standard allows some ground rules that standardize PLC’s
and their languages. Let’s take a deeper look into all these popular PLC Programming
Languages.

The 5 most popular types of PLC Programming Languages are:

1. Ladder Diagram (LD)

2. Sequential Function Charts (SFC)

3. Function Block Diagram (FBD)

4. Structured Text (ST)

5. Instruction List (IL)

Let’s show you a little bit about each of these. I will start with Ladder Diagram which is a
graphical type of PLC Programming Language.

1. Ladder Diagram (LD)

Ladder Diagram was originally modeled from relay-logic which used physical devices, such as
switches and mechanical relays to control processes. Ladder Diagram utilizes internal logic to
replace all, except the physical devices that need an electrical signal to activate them.
Ladder Diagram is built in the form of horizontal rungs with two vertical rails that represent the
electrical connection on relay-logic schematics.

You can program all the necessary input conditions to affect the output conditions, whether
logical or physical.
1-1. Ladder Diagram Advantages

The main advantages of the Ladder Diagram language are:

1. The rungs allow it to be organized and easy to follow.

2. It also lets you document comments that are readily visible.

3. It supports online editing very successfully.

1-2. Ladder Diagram Disadvantages

The main disadvantage is that there are some instructions that are not available, which might
make it more difficult for programming such as motion or batching.

The next PLC Programming Language that I will talk to you about is the Sequential Function
Charts which uses a graphical type of programming.

2. Sequential Function Charts (SFC)

If you have any experience with flowcharts, then this PLC Programming language will feel
familiar to you. In Sequential Function Charts, you use steps and transitions to achieve your end
results.
Steps act as a major function in your program. These steps house the actions that occur when you
program them to happen. This decision can be based on timing, a certain phase of the process, or
a physical state of an equipment.

Transitions are the instructions that you use to move from one step to another step by setting
conditions of true or false.

Unlike traditional flowcharts, the Sequential Function Charts can have multiple paths. You can
use branches to initiate multiple steps at one time.
2-1. Sequential Function Charts Advantages

A couple of the advantages of Sequential Function Charts are:

1. Processes can be broken into major steps that can make troubleshooting faster and easier.
2. You have direct access in the logic to see where a piece of equipment faulted.

3. It can be faster to design and write the logic due to the ability to use repeated executions of
individual pieces of logic.
2-2. Sequential Function Charts Disadvantages

Even when you consider the advantages of the Sequential Function Charts, this PLC
Programming Language does not always fit every application.

Now we are on to our third PLC Programming Language.

3. Function Block Diagram (FBD)

The Function Block Diagram which is also a graphical type of language. The Function Block
Diagram describes a function between inputs and outputs that are connected in blocks by
connection lines.
Function Blocks were originally developed to create a system that you could set up many of the
common, repeatable tasks, such as counters, timers, PID Loops, etc.

You program the blocks onto sheets and then the PLC constantly scans the sheets in numerical
order or is determined by connections which you program between the blocks.

3-1. Function Block Diagram Disadvantages

The code can get disorganized using this PLC Programming Language because you can place the
function blocks anywhere on the sheet. This can also make it more difficult to troubleshoot.
3-2. Function Block Diagram Advantages

1. The Function Block Diagram does work well with motion controls.

2. The visual method is easier for some users.

3. The biggest advantage of Function Block Diagram is that you can take many lines of
programming and put it into one or several function blocks.

4. Structured Text (ST)

The 4th PLC Programming Language is the Structured Text. This language is a textual based
language.

Structured Text is a high-level language that is like Basic, Pascal and “C”.

It is a very powerful tool that can execute complex tasks utilizing algorithms and mathematical
functions along with repetitive tasks.

The code uses statements that are separated by semicolons and then either inputs, outputs, or
variables are changed by these statements.

You must write out each line of code and it uses functions such as FOR, WHILE, IF, ELSE,
ELSEIF AND CASE.
If you have experience with Basic or C languages, this PLC Programming Language will come
easier than some of the other types of PLC languages.

4-1. Structured Text Advantages

Some of the advantages of Structured Text are:


1. It is very organized and good at computing large mathematical calculations.

2. It will enable you to cover some instructions that are not available in some other languages
like the Ladder Diagram.

4-2. Structured Text Disadvantages

The disadvantages of the Structured Text PLC programming language are:

1. The syntax can be difficult.

2. It is hard to debug.

3. It is difficult to edit online.

5. Instruction List (IL)

I will now show you the 5th and final PLC Programming Language which is Instruction List.
The Instruction List is also a textual based language.

The Instruction List language resembles Assembly Language. When you use this PLC
Programming Language, you will use mnemonic codes such as LD (Load), AND, OR, etc.

The Instruction List contains instructions with each instruction on a new line with any comments
you might want to annotate at the end of each line.

5-1. Instruction List Advantages


The Instruction List language is valuable for applications that need code that is compact and time
critical.

5-2. Instruction List Disadvantages

The main disadvantages of this PLC Programming Language are:

1. There are few structuring possibilities with the “Goto” command being one of them.

2. There can also be many errors that are more difficult to deal with in comparison to many of
the other languages that I have previously reviewed.
So, have you decided which PLC Programming Language you consider to be the most popular?

After reading many reviews and opinions and with my own experiences, the Ladder Diagram is
by far the most popular PLC programing language .

The main reason for this is that the Ladder Diagram language naturally followed the technology
advancement from a physical relay logic to a digital and logical one. This allowed the engineers
and skilled workers to follow and troubleshoot and make that transition.

In summary, there is certainly a place for all the PLC Programming Languages that we have
reviewed. Your background, experience and the application you are working with are really
going to be the key to which PLC Programming Language you choose.
PLC programming language fundamentals for improved operations, maintenance
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.

Courtesy: Automation LLC

Learning Objectives

 Understand the five different types of programmable logic controller (PLC) languages.
 Learn how PLC programming languages work how they have evolved over the years.

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.
Figure 1: Example of a programmable logic controller (PLC) program organization. Courtesy:
Automation LLC
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. They originally split it into five sections:

The 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.”
Figure 2: Example of ladder logic (LAD) PLC programming. Courtesy: Automation LLC

The “X” addresses represent physical inputs, while the “Y” address is a physical output. The
“M”s are internal memory bits.

Because of the variety of addressing schemes as described previously, register representations


can mean different things on different platforms.

When monitoring ladder logic in real time, usually contacts and coils change color to
indicate their state in the logic. If a path of continuity exists from the left rail to the coil, the
address will be said to be “On” or “True”.

The timer shown in the diagram also may show a time base. If the above timer’s preset is three
seconds, the time base would then be 10 ms.

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.

Figure 3: Example of a function block diagram (FBD) PLC programming. Courtesy: Automation
LLC

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.
Figure 4: Example of an instruction list (IL) PLC programming. Courtesy: Automation LLC

Since IL is text-based, it is easy to manipulate in third-party text or spreadsheet editors, such as


Microsoft Excel. Instruction List can usually be imported or exported to and from PLC software
in the form of .csv (comma-delimited) files or XML (eXtensible Markup Language). This makes
it easy to create tables of addresses or tags with a common structure in IL, and then convert it
into many repetitive rungs or blocks with different addresses. When writing large amounts of
repetitive code, this can save a lot of time.

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.
Figure 5: Example of structured text (ST) PLC programming. Courtesy: Automation LLC

While writing PLC code in Structured Text can be difficult, it is also a much more powerful
language than ladder logic or function block. Libraries can be developed to perform complex
tasks such as searching for data using structured query language (SQL) or building complicated
mathematical algorithms.

At the same time, since the program proceeds step by step, it is more difficult to respond to
multiple inputs at the same time; program control can be complex with many loops.

Different PLC platforms may use a different designation for these IEC languages.

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.

Figure 6: Example of a sequential function chart (SFC) PLC programming. Courtesy:


Automation LLC

Actions associated with steps can be of various types, the most common being set (S), reset (R)
and continuous (N). N actions are active for as long as the step is while set and reset operate as in
the other PLC languages.

Actions within the steps and the logic transitions between them can be written in other PLC
languages. Structured text is common in the action blocks, while ladder is often used for
transitions. Steps and transitions are labeled as S# and T#. The top of the program will always
contain an initial step; the program starts here, and this is also where it returns after completion.
A program will scan the logic in a step continuously until its associated transition logic becomes
true; after this the step is deactivated and the next step is activated.

You might also like