0% found this document useful (0 votes)
27 views6 pages

PLC Standar IEC 1131-3

Uploaded by

Helder Fuenmayor
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
27 views6 pages

PLC Standar IEC 1131-3

Uploaded by

Helder Fuenmayor
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 6

Copyright © IFAC Computer Aided Control Systems

Design, Gent, Belgium, 1997

IMPLEMENTATION ASPECTS OF THE PLC


STANDARD IEC 1131-3

Martin Ohman Stefan Johansson Karl-Erik A.rzen


Department of Automatic Control, Lund In8titute of Technology
Boz 118, S-221 00 Lund, Sweden, Phone: +4646 222 03 62
Email: martin«lcontrol.lth.se

Ab.!tract IEC 1131-3 is a standard for programming languages used in PLCs. It


defines a function block diagram language and a type of Grafcet, Sequential Func-
tion Charts. An object oriented prototype of these parts has been implemented.
Various execution methods are discussed. Algorithms for local and global sorting
are implemented and evaluated. The standard is found to be unclear in some parts.

Keyword.! Grafcet, IEC 1131, Programmable logic controller, Standard.

1. INTRODUCTION 2.1 Programming language.!


Programmable logic controllers (PLCs) are spe- Four language paradigms are defined. In.!truction
cialized computers, widely used in industrial au- li.!t is similar to traditional PLC code. Structured
tomation. IEC 1131-3 is a standard for program- tezt is similar to Pascal. Ladder diagram uses
ming languages used in PLCs. This paper is based relay ladder logic diagrams to implement boolean
on a master thesis project (Johansson and Oh- functions. In the function block diagram language,
man, 1995). It concerns the Function Block Di- all functions are represented as graphical blocks.
agrams (FBD) and Sequential Function Charts The function blocks are connected with lines
(SFC) parts of the standard. The purpose is to which represents the data flow. Figure 1 shows two
make a prototype implementation of the stan- programs containing function block diagrams.
dard and evaluate different implementation as-
pects. The standard is described in Section 2.
2.2 Program Organization Unit.!
In Section 3 the prototype implementation is de-
scribed. Different implementation aspects and al- Independent of the choice of language, PLC pro-
ternatives are discussed. Section 4 identifies some gramming according to IEC 1131-3 uses three
unclear parts of the standard. program organization units: functions, function
blocks and programs. They are supplied by the
manufacturer or defined by the user. A unit can
2. IEC 1131-3 not be recursive, i.e., it can not call itself. Figure 1
shows how the units function together.
This section describes IEC 1131 (IEC, 1995b),
a PLC standard defined by the International
Electrotechnical Commission (IEC). The standard
contains five parts. This paper concerns part Program 1 Program 2
three, describing the programming languages.

~
2 rFB--3--------~

~
IEC 1131-3 defines different language paradigms, F2
SFC, and some program organization units. The
standard also specifies their representation, and
Fig. 1 Program Organization Units.
rules of evaluation.

27
Function6 Functions have one or more inputs
but only one output. A function can not store
any state information, i.e., executing a function
with certain values on the inputs always gives the
same output value. Functions can be hierarchically
2] f
defined by using already defined functions. A
function can be ezten6ible, meaning that the user Fig. 2 SFC. with alternative (left) and parallel (right)
can decide the number of inputs. Functions are path•.
either typed (operate on a specified data type) or
overloaded (operate on different types).
An action can also be non-boolean. In that case
,Function block6 Function blocks can have sev- it is described with one of the four programming
eral inputs and outputs. They can store state in- languages or with an SFC. All actions must have
formation so the values of the outputs depend on unique names.
previous values.
Action block6 Action blocks are used to asso-
The user must give each instance of a function ciate actions with steps. An action block has a
block an unique name. Function blocks can be boolean input that indicates when the associated
hierarchically defined by using already defined step is active and an unspecified boolean output.
functions and function blocks. When executing a The action block can also act as a normal boolean
function or a function block all inputs must have function block. Each action block is associated
a value. with an action. A non-boolean action can be asso-
ciated with only one action block and can there-
Program6 Programs are built up by functions fore be declared directly in the action block. Steps,
and function blocks. Programs do not have inputs actions and action blocks relate in the following
or outputs. way:

2.3 Ta6k6 • A step can be connected to zero or more


The execution of programs and function blocks are action blocks.
controlled by tasks. A task can control more than • Each action block is connected to one step.
one program organization unit and a program
organization unit can indirectly be controlled by • Each action block is associated with one
more than one task, as FB1 in Figure 1. action.

A task has three inputs: single, interval, and • Each boolean action is associated with one
priority. It can execute once on the rising edge or more action blocks.
of 6ingle or periodically with the period time of
• Each non-boolean action is associated with
interval. The priority of the task is set by priority.
one action block.

2.4 Sequential Function Chart6 Figure 12 shows that the boolean action A2 is
A Sequential Function Chart (SFC) is an extended associated with the action blocks AB1 and AB3.
state machine, also known as a Grafcet (David The non-boolean action A1 is constructed directly
and AlIa, 1992). In the standard, SFC is a way of in the action block AB2 and associated only with
structuring programs and function blocks. A unit that action block.
that is not structured is said to be a single action,
executed continuously. Action qualifier An action block uses an action
qualifier to control the action. The action will
An SFC consists of two main elements, 6tep6 and
execute depending on the action qualifiers on the
tran6ition6, shown in Figure 2. Steps can be active
associated action blocks and the status of the
or inactive. The state of the SFC is determined
associated steps. The action qualifiers are e.g.,
by which steps that are active. A transition has
normal meaning that the action is active while the
a boolean input, tran6ition condition, that can
action block is active or dored meaning that the
be described by any of the four languages or by
action is activated when the action block becomes
a boolean variable. A transition will fire when
active.
the step above it is active and the transition
condition is true. An SFC can contain parallel and
alternative paths, shown in Figure 2.
3. IMPLEMENTATION
Action6 It is possible to associate an action with In this section the prototype implementation is
a step. An action can be a single boolean variable. described. The implementation is done in G2,

28
a graphical and object oriented programming filled red circle indicates when a step is active. The
environment from Gensym Corporation. G2 was state of the step is written to a boolean output
chosen since it is good as a rapid prototyping tool. that can be connected to an action block.
Different implementation methods are discussed.
Transitions are represented graphically as a hori-
Most ideas can be used generally, when working in
zontal bar. They have a boolean input that acts
an object oriented environment. Some solutions,
as a transition condition. Figure 4 shows an SFC.
however, are G2 specific.
A hierarchy of classes containing function blocks,
connections, steps, transitions, tasks, and global
A2
variables has been developed. The user constructs
the programs on a workspace with graphical ob-
jects that are instances of these classes. Class def-
initions and methods are hidden for the user.

3.1 Function block$


Since programs and functions can be seen as
special cases of function blocks, only function
block$ have been implemented. Programs are im- AB3
plemented as function blocks with no inputs or
outputs and functions as single output function
blocks without internal state information. Figure 3
shows a function block diagram.

Fig. 4 An SFC with step., transitions, action blocks and


3.2 Hierarchical function block$ actions.
Hierarchical function blocks have a subworkspace
where their internal structure is defined, see FB4
3.4 Global variable$ and action$
in Figure 3. G2 automatically makes a link from
the function block to its subworkspace. It would Global variables of different data types are im-
be natural to include the internal structure in the plemented. Actions are a subclass of boolean vari-
class definition, but this is not possible in G2. ables. To get the value of a variable, special get-var
functions are used. If the action only function as a
boolean variable it has a graphical representation
and is placed on an arbitrary workspace by the
user. If the action is defined with function blocks
or SFC, however, it can only be associated with
FBS
one action block. The action is then constructed
FB2 FB4
on a subworkspace of that action block. The stan-
dard defines when an action should be active de-
pending on the action qualifiers of the associated
active action blocks. This functionality is imple-
mented in a method of the class action.

FB4.1 3.5 Algebraic loop$


The order in which the function blocks are exe-
cuted must follow specific rules. A function block
Fig. S A hierarchical function block diagram. can not be executed until the function blocks con-
nected to all its inputs have been executed. This
rule causes problems when building a loop. In Fig-
3.3 Sequential Function Chart$ ure 5 FBI must be executed before FB2 to give
SFC elements include steps, transitions and the input of FB2 a value. For the same reason
branches. Branches are used to build alternative FB2 must be executed before FBI. This problem
and parallel paths. All the elements have meth- is called an algebraic loop.
ods, used to determine whether a step should be
The problem is solved by introducing so called loop
activated or deactivated.
elemenu. The user decides where to break the loop
All steps and transitions have an input and an and insert a loop element. A loop element has the
output, used to connect them with each other. special property that it can be executed before
Steps are represented graphically as rectangles. A function blocks connected to its input. It reads

29
implementation, steps are executed first and then
function blocks. This is, however, not the most
correct order of execution, see Section 4.2.
To determine the order of execution between ele-
ments, lists are built when a task is initialized. A
step list is built with all steps in random order.
A function block list is built with all the function
blocks in the correct execution order. Each func-
Fig. 5 Algebraic loop.
tion block is placed in the list after the function
blocks connected to its input. Hierarchical func-
the old value from the input and writes it to the tion blocks can be dealt with in two ways: local
output. Therefore, the user can use them, instead and global sorting.
of variables, as a memory. In Figure 6 the algebraic
loop problem is solved by inserting a loop element Local sorting In local sorting each hierarchical
and FB1 can now be executed before FB2. function block have its own lists containing all
the function blocks and steps on its subworkspace.
Figure 8 shows the main function block list of the
FBD in Figure 3 and the local list of FB4.

,,

Fig. 8 The function block list of the function block


diagram in Figure 3 and the local list of FB4 .
Fig. 8 Loop element.
The main advantage with local lists is that if
changes are made in a hierarchical function block,
3.6 Ezecution of SFC
only a new local list for that function block have to
The standard specifies that all steps should be be built. This corresponds to separate compiling
updated synchronously. This is achieved by going of program units.
through all the steps twice. First it is checked
which steps can be activated and they are marked Global sorting In global sorting one have a
with a flag " next" , see Figure 7. Then all marked global function block list and step list for each top
steps are activated. The order in which the steps level function block containing function blocks and
are treated is not important. This method makes steps at all levels. No hierarchical function blocks
sure that each token can pass only one transition are inserted in the lists, only the function blocks
at a time. and steps on their subworkspaces. Figure 9 shows
the global list of the FBD in Figure 3. Note that
FB4 is not in the list.

Fig. 9 The global function block list of the function block


diagram in Figure 3.

The main advantage with global lists is that


imaginary loops that seem to exist from a local
point of view are removed. If the function block
diagram in Figure 10 would be sorted locally, the
user would have to insert a loop element. The
global list shows that this is not needed with
global sorting. Removing loops gives you a faster
implementation by saving clock cycles.
Fig. T Execution of an SFC.
A disadvantage with global lists is that the imple-
mentation is more complex. When a hierarchical
3.7 Ezecution order function block is disabled, all function blocks on
It is not specified in the standard if SFC elements its subworkspace should be disabled. If they are
or function blocks should be executed first. In the spread out in a global list this will be difficult.

30
.- --.
FB2
-fB2.tt -
does not support pointers. Instead, each functi
block stores the name of its task and when a ta
----'
is activated G2 effectively inserts all associat
.- --. function blocks in a list.
fB 2.2!- -
~ __ .J

4. UNCLEAR MATTERS IN IEC 1131-3


The standard is complex and some parts are ha
Fig. 10 A loop is removed by Wling globallistl. to understand. Many issues are not specified or lJ
clearly specified, especially concerning executi
order. A couple of things are probably not mea
When an action is defined on the subworkspace of the way they are written.
an action block, the action block functions like a
hierarchical function block with an enable signal
4.1 Hierarchy
associated with the action. The function blocks
and steps should only be executed when the ac- The standard states that functions and functi
tion block is enabled. This is solved by placing blocks can be hierarchicly defined. It is not spe
function blocks and steps on the subworkspace of ified if such function or function block shall
an action block in local lists even when the rest considered as a fixed unit or if its internal stn
of the resource is sorted globally, i.e., total global ture can be changed. If a unit has a hierarchic
sorting is not implemented. structure, it is not specified if the implementati
should use local or global sorting. The followi
Ezecution procedure Execution of elements example motivates that this is an important iSSl
could also be handled by replacing the lists with a PlO controllers are commonly used in industr
procedure that would be generated automatically control systems. In 1131-3 a PID controller is ni
when the task is activated. The list would contain urally implemented as a function block that 1:
the code from all the function blocks, inserted reference signal Yre! and measured variable Y
in the correct order, using either local or global inputs and the control signal v as output. Ho
sorting. Each time a task is executed it would ever, if actuator saturations are not taken Ci
only execute the procedure. A small example was of in the right way, the result is integrator (:
made to evaluate the time difference. The example set) windup, which influences the control perfc
contains five serial inverter blocks and is executed mance negatively. A common solution to integl
100 000 times. Execution using a list took 112 tor windup is known as tracking. The approach
seconds while execution using a procedure only based on feeding back the saturated control sigl
took 7 seconds. This indicates that there is a lot to the PlO controller and to change the integ
to gain using procedures. term in the controller in such a way that the c(
trol signal generated from the controller will eqt
A6ynchronou6 datafiow Another solution would the output saturation.
be to let the execution be asynchronously con-
Hence, tracking requires an additional input
trolled by the data flow. Each function block
the PlO controller, the saturated output, often (
would then be executed as soon as the value of
noted u. Tracking also means that it is not possil
any of its inputs is changed. This does not cor-
to update the controller state until the saturat
respond well to the standard since it is stated
output is known, e.g. has been calculated. Son
that each function block should be executed ev-
times the saturation limits are known in the P
ery task cycle, independently of if its input values
controller but not always. For example, the P
have changed or not.
controller may be a part of a cascade construct,
the actuator saturation is calculated in a spec
3.8 Ta6k6 limit block, as shown in Figure 11.
To control the tasks a ta6k handler is defined. Each
time unit the task handler decreases a counter in yref PID
Calculate Out ut
each task. When the counter reaches zero the task
will execute and reset the counter to the execution y
interval.
When a task executes it runs all its associated Fig. 11 A PID controller.
function blocks. Hence, a link from the task to the
associated function blocks is needed. A natural The PID function block is internally decompol
solution would be to let the task have a static into two blocks: Calculate Output and Updatc
list of pointers to all its function blocks, but G2 tate. The only sorting strategy that will give 1

31
correct behavior from a control point of view A function can be extensible, i.e., can have a
is global sorting. Using that strategy the execu- variable number of inputs. The standard does
tion order will be PID:CalculateOutput, Limit, not state if the user has to specify the number
PID:UpdateState. Using local sorting the old of inputs when the function is created or if the
value of 14 will be used in the calculation of Updat- number can be changed during the lifetime of the
eState, i.e., an unnecessary delay of one sampling function.
interval is introduced.
According to the standard it shall be possible to do
jumps in all languages. It is probable not so good
4.2 Ezecution order to do jumps in the FBD language. The guidelines
The execution order between functions and func- (IEC, 1995a) also advices not to use them.
tion blocks, SFC-elements, action blocks, and ac-
tions is not specified. The standard states that no
element shall be evaluated until the states of all 5. CONCLUSIONS
its inputs have been evaluated. The authors be- The standard IEC 1131-3 contains most of the
lieve that this leads to the execution order shown needed information but is sometimes not easy
in Figure 12: to understand. It is well specified how SFC and
FBD function separately, but not so well how they
1. Elements connected to a transition. function together. The execution order between
2. All SFC elements. function blocks and SFC elements is the most
unclear part the standard. Probably, the parts of a
3. Action blocks, function blocks connected to
FBD connected to transitions should be executed
them and non-boolean actions.
before an SFC and parts associated with actions
4. Boolean actions. after the SFC.
In the prototype implementation, all function
blocks are sorted into lists before they are exe-
DA2 cuted. Algorithms for sorting the lists locally or
globally are implemented. Local sorting was found
to be easier to implement. However, global sort is
necessary if artificial time delays are to be avoided.
For a small example, a single procedure is writ-
ten with the code from all the function blocks in
a function block diagram. The program executed
much faster with this method. It would be inter-
esting to implement methods for generating such
procedures.
The programming environment G2 is useful as a
2 3 4 prototype tool since it is easy to learn and work
with. Since it is slow and quite expensive, it is
Fig. 12 The execution order of functions, function however unrealistic to use it to control real PLCs.
blow, steps, transitions, action blocks, and actions.

REFERENCES
4.3 Scheduling
The standard does not specify whether the David, R. and H. AlIa (1992): Petri Nets and
scheduling of tasks should be preemptive or non- Grafcet: Tools for modelling discrete events
preemptive. A function block can indirectly be systems. Prentice-Hall.
controlled by more than one task, see Figure 1. IEC (1995a): "Guidelines for the application and
If they try to execute at the same time and if implementation of programming languages for
preemptive scheduling is used, there might be programmable controllers." Technical Report,
problems. IEC.
IEC (1995b): "IEC 1131-3." Technical Report,
4.4 Mi6cellaneou6 IEC. first edition.
SFC in IEC 1131-3 does not support macro steps,
Johansson, S. and M. Ohman (1995): "Proto-
as Grafcet normally do.
type implementation of the PLC standard IEC
The standard specifies that there can be multiple 1131-3." Master thesis ISRN LUTFD2/TFRT-
instances of function blocks. Probably also func- -5547--SE, Department of Automatic Control,
tions can have multiple instances. Lund Institute of Technology, Lund, Sweden.

32

You might also like

pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy