Sei sulla pagina 1di 28

KE-90.

4600 Process Automation project


work - ABB 800xA PLC programming
(This material is built using ABB T314 course materials, T314-6 Variables and Data types, T314-10 FBD, T314-11 ST, T314-13 CM & T314-14 SFC.)

Contents
1 Data Types ................................................................................................................................................. 3
1.1 Variable data types ............................................................................................................................ 3
1.1.1 Simple Data Types ..................................................................................................................... 3
1.1.2 Structured Data Types ............................................................................................................... 3
1.1.3 System defined I/O Data Types ................................................................................................. 4
1.2 Global variables ................................................................................................................................. 5
1.3 Local variables ................................................................................................................................... 5
2 Function Block Diagram ............................................................................................................................. 6
2.1 FBD Editor .......................................................................................................................................... 6
2.1.1 Execution Rules ......................................................................................................................... 6
2.1.2 Functions in FBD ........................................................................................................................ 7
2.1.3 FBD Pane ................................................................................................................................... 7
2.1.4 Toolbar Buttons ......................................................................................................................... 8
2.1.5 Inserting a Function / Function Block ........................................................................................ 9
2.1.6 EN Input Parameter ................................................................................................................... 9
2.1.7 Editing Parameter Properties .................................................................................................. 10
2.1.8 Making Connections ................................................................................................................ 10
2.1.9 Inverting Connections ............................................................................................................. 12
2.1.10 Adding Comments ................................................................................................................... 12
2.1.11 Structure Pane ......................................................................................................................... 12
3 Structured Text (ST) ................................................................................................................................. 13
3.1 Structured Text Editor ..................................................................................................................... 13
3.2 Basic Language Elements ................................................................................................................ 13
3.2.1 Assignment Statements ........................................................................................................... 14
3.2.2 Comment Statements ............................................................................................................. 15
3.2.3 Operators ................................................................................................................................ 15
3.2.4 Precedence .............................................................................................................................. 15

1

3.2.5 Conditional Structures ............................................................................................................. 16
3.2.6 Iteration Structures ................................................................................................................. 17
3.2.7 RETURN Statement .................................................................................................................. 17
3.3 Functions and Function Blocks ........................................................................................................ 17
3.3.1 Functions ................................................................................................................................. 17
3.3.2 Function Blocks ........................................................................................................................ 18
3.3.3 How to Declare Function Block Instances ............................................................................... 18
3.3.4 How to Call a Function Block Instance ..................................................................................... 19
3.4 Common Mistakes and their Error Messages ................................................................................. 20
3.4.1 Identifier, constant or opening parenthesis expected ............................................................ 20
3.4.2 Variable name is not unique .................................................................................................... 21
3.4.3 Identifier too long or invalid .................................................................................................... 21
3.4.4 Undefined function block ........................................................................................................ 22
3.4.5 Type mismatch in assignment ................................................................................................. 22
3.4.6 Incompatible types in expression ............................................................................................ 22
4 Sequential Function Charts (SFC) ............................................................................................................ 23
4.1 SFC Editor ........................................................................................................................................ 23
4.2 Steps and Transitions ...................................................................................................................... 23
4.2.1 Steps ........................................................................................................................................ 24
4.2.2 Transition ................................................................................................................................. 24
4.3 Sequence Constructs ....................................................................................................................... 24
4.3.1 Simultaneous Sequences ......................................................................................................... 24
4.3.2 Sequence Selection ................................................................................................................. 25
4.4 Jumps and Destinations ................................................................................................................... 25
5 Control Modules ...................................................................................................................................... 25
5.1 Control Modules as Code Containers .............................................................................................. 26
5.1.1 Code ........................................................................................................................................ 26
5.1.2 Graphics ................................................................................................................................... 26
5.2 Representation of Control Modules ................................................................................................ 26
5.2.1 When to use what? ................................................................................................................. 27
5.3 Control Module Diagram (CMD) Editor ........................................................................................... 27
5.3.1 How to Create a Control Module Instance .............................................................................. 28
5.3.2 Graphical Connections ............................................................................................................. 28

2

1 Data Types

Variables are used to store data inside the controller memory. During execution of the control code the
data may change following changes in the process states or else due to calculations made.

When the application code is written, the programmer must create variables to store the data which is
manipulated by the application code. Variables are the containers for values within the application, its
programs, its function blocks and its control modules.

Modern controllers are capable of handling many different sorts of data. The simplest type is boolean, but
other types are possible such as integer (whole numbers), real (floating point numbers) and string
(character strings such as text messages). Additionally, in System 800xA, many other more complex data
types are possible.

Variables are declared in an application by opening the application editor from the Project Explorer tree:

1.1 Variable data types


The following rules apply when declaring a variable:

• A variable name may have up to 32 characters


• The name of the variable must not begin with a number
• No spaces are permitted in a variable name
• In general use only alphanumeric characters and the underscore character. Do not include any
special characters such as $, # or others.
• Variable names are NOT case sensitive.
• A variable may not have a ‘Key word’ as a name. Some key words are reserved by the system and
you will be warned if you have used a key word for a variable name.
• Within any one POU (application, control module, function block or program),
• variable names must be unique.

1.1.1 Simple Data Types


Bool (True/False), Dint(±2147483647), Uint (0-63335), String[length(40)], Dword (32bits), Word (16bits),
Time, Date_And_Time, Real (±1,7014*10^±38)

1.1.2 Structured Data Types


Structured data types have two or more components. The components may be simple or themselves
structured. They can also be seen as wires in a multicore cable or a basket.

3

For example, suppose you have a vessel which has the following data associated with it:

• Tank is Full
• The volume of fluid (measured in cubic meters).
• The temperature of the fluid (measured in Kelvin).
• The minimum permitted temperature of the fluid.
• The maximum permitted temperature of the fluid (both measured in Kelvin).

This data could be packed into a data type called say, TankType.

Once the “TankType” data type has been defined, variables of that type may be declared in any application.
Suppose a variable is now declared called Tank1. The individual componets of this variable may be accessed
using “dot notation”: Tank1.Full, Tank1.Volume, Tank1.Temperature, Tank1.MinTemp, Tank1.MaxTemp

1.1.3 System defined I/O Data Types


Although it is allowed to connect simple variables of type Bool and Real to digital and analogue I/O
channels respectively, it is better to use the system defined I/O data types called BoolIO and RealIO.

DintIO is used to connect to integer channels on, for example, a pulse counter module. DwordIO may be
used to access all 16 channels on a DI or DO module as a word rather than as individual IO points.

1.1.3.1 BoolIO
Use a BoolIO type when you connect to either a digital input or digital output channel. The datatype is
defined by the system and has the following components:

Name Data Type Description


Value Bool Value used by the application code
IOValue Bool Value of the I/O channel. IOValue and Value are equal if the channel is not
forced
Forced Bool Indicates whether or not the channel is forced.
Status Dword Status as a hexadecimal integer

1.1.3.2 RealIO
Use a RealIO type when you connect to an analog input or analog output channel. The Value, IOValue,
Forced and Status components are given by the system to the application. The Inverted, Max, Min, Unit and
Fraction components are given by the user of the application to the system in the “Scaling” tab. The data
type has the following components.

4

Name Data Type Description
Value Bool Value used by the application code
IOValue Bool Value of the I/O channel. IOValue and Value are equal if the channel is not
forced
Forced Bool Indicates whether or not the channel is forced.
Status DInt Status as a integer
Parameters SignalPar Measuring Range

Note that the last component ‘Parameters’ is itself a structured variable of type SignalPar. The data type
SignalPar has the following components:

Name Data Type Description


Max Real Scaled max value of measuremet
Min Real Scaled min value of measuremet
Inverted Bool If connection is reversed
Fraction Dint Number of decimals to be shown
Unit String Display the physical unit

1.2 Global variables


Global variables are stored in your Application root folder (under Applications) – clicking it gives you the
variable pop-up as seen in pic

The columns are

• Name: every variable must have a unique name. The identifier for a variable, a function block etc.
• Data Type: The data type this variable is. There are several datatypes available
o Basic data types: bool, int, real dword etc
o I/O data types: boolIO, RealIO, DwordIO
o Data types defined by other software libraries. Typically consists of a collection of several other
data types.
• Attributes: The attribute of the variable is defined.
• Initial value: for basic data types an initial value can be given… (Eg: Boolean: ture/false) Defines the
initial value of the data type. If no value is given, the default value is used.
• I/O address Defines the I/O address to the I/O unit.
• Access variables System variables that are to be accessed from a remote system with a loose
connection must be declared in the Access Variable Editor.
• Description: In the description fields a short description can be written when declaring variables,
parameters, function blocks, and data type components.

1.3 Local variables


Are done in similar manner but they are defined in the application programs.

5

2 Function Block Diagram

2.1 FBD Editor


Function Block Diagram (FBD) is a high-level graphical programming language. It describes the POUs in
terms of processing elements and displays the signal flow between them, similar to electronic circuit
diagrams.

It represents the function block and functions by graphical symbols (boxes), their input and output
parameters by pins of the boxes and the assignment of parameters by lines between the pins. A
comprehensive basic range of function blocks and functions are available.

The FBD editor consists of the following major parts:

2.1.1 Execution Rules


The execution order of function blocks and functions is defined at first by the order of their creation. The
execution order is represented by the order of the graphic symbols (boxes) in FBD "from the left to the
right" and "from the top to the bottom".

You can change the execution order later by moving the selected function blocks and functions "up" or
"down" within the structure pane. Just drag-and-drop the function block within the structure pane.

6

2.1.2 Functions in FBD
The following basic functions corresponding to operators of textual programming languages are available in
the FBD language:

2.1.3 FBD Pane


The FBD panes are the right upper and lower sub panes within the code pane if you are working with the
FBD editor. They contain the function block diagram of the POU you are programming.

NOTE! By default only the lower sub pane is shown.

You can drag the separation line just underneath the variable declaration pane to access the upper sub
pane. The FBD panes contain:

7

• Graphic symbols of function and function block (boxes)
• Instance names of the function blocks
• Comments attached to the function blocks and functions
• Assignment of parameters in form of connection lines between the graphic symbols
• Comment of the page and footer

Use the FBD panes to:

• Inspect the function block diagram of the POU you are programming
• Select, copy and paste functions and function blocks
• Create, modify and delete function blocks and functions
• Edit instance name of function blocks and edit comments
• Assign values to the parameters of function blocks and functions

2.1.4 Toolbar Buttons


There is a special toolbar in the FBD editor,


with shortcuts to many of the commands
found in the menu bar (or in the pop-up
menus). You can see a brief explanation (tool
tip) of each button, if you hold the cursor
over the button.

8

2.1.5 Inserting a Function / Function Block
There are several ways to insert a function/ function block;

1. Use the toolbar button


2. Choose “Insert > Function/ Function block”from the POU menu
3. Right click in the code pane and choose “Insert Function / Function block”

Insert the Function / Function Block

In the dialog window a list of available functions and function block types is presented in the drop-down
list.

NOTE! Just type the first letters of the function name to jump to that entry.

It is also possible to use the Browse button to get an explorer-like overview of all libraries and
applications and their functions / function blocks. If you want to choose from a list of previously used
function block types, use the “Local FB Declarations” button.

Connect Parameters

If it is a function/function block that supports configurable input parameters, these inputs can be specified
in the dialog window. To go straight to the Connection dialog window, check “Connect Parameters”.

The “EN” checkbox makes the optional Enable parameter available (this is explained in the next section).

2.1.6 EN Input Parameter


The EN property for functions and function blocks in FBD makes it possible to write code that corresponds
to “IF statements” in the Structured Text language.

The EN parameter should be connected to a bool variable just as any other bool parameter.

When the EN input is true, the function or function block will be executed, otherwise not. When the EN
input becomes false, all outputs will keep their values from the previous cycle of execution.

NOTE! If a function has an EN input, it must be connected.

The EN parameter can be turned on/off when inserting a new function or function block (see Insert
Function/Function Block dialog section), or when editing the parameter properties (see below).

2.1.7 Editing Parameter Properties


Some functions or function blocks supports configurable parameters. For instance the number of inputs on
an AND function can be modified. By clicking with the right mouse button on a function (box) you will see a
menu. Select “Edit Parameter Properties” to change the size or type of the function.

Activate the checkbox Enable parameter, if required.

Insert / Delete Parameter

Right click on a parameter (pin) of the function block or function. Select “Insert Parameter” to add a new,
last parameter (pin). Select “Delete Parameter” to delete the parameter (pin).

NOTE! This is only possible if the function or function block is expandable

2.1.8 Making Connections


If a parameter is to be connected to another parameter, one of them must be an output parameter and the
other one an input parameter.

NOTE! An output parameter can be assigned to any number of input parameters but never to another
output parameter.

There are basically two ways of connecting the parameters (pins) of a function or function block: Either you
connect the parameters one-by-one or you connect them all at once.

Connect each Parameter Separately

Right click on the parameter (pin) of the function block or function (box) to which you want to assign a
variable or a constant and select “Connect…”from the context menu.

10

Fill in the “To” field with a constant value or a variable name. To
display a list of all available variables, press Ctrl+J.

NOTE! If you want to connect an OUT parameter to several


variables, separate the names with ‘,’ (comma). For example:
Start1, Start2 Press “OK” to close the dialog window or
“Apply/Next” to apply the connection and go the next
parameter.

The “Direction” setting together with the value in the “Next:”


drop-down list determine what will happen when the “Next”
button is pressed. In the example in the figure pressing
“Apply/Next” will move the selection forward to the next
unconnected parameter.

If the user enters a name that is not recognized by the system


(i.e. not declared) and presses “OK” or “Apply/Next”, the system will ask the user if the unknown name
should be declared by the system.

Access to Variables with Structured Data Types

You gain access to the components by using the


syntax:

<main_identifier>.<component>

For instance: NxxTemp is a RealIO variable. Type


“NxxTemp” as main identifier and then a “.” to see
the structured variables.

Connect All Parameters

To connect several of the parameters in one


action, it is best to bring up the Parameter
Connections editor. Right click and select “Edit
Parameter List”.

Fill in the name of the variable in the actual


“Parameter” field. Use the button to get a tree-
like overview of the POU and its variables.

Connect from one Function Block to Another

To connect two parameters to each other, select one parameter (pin) by clicking on it with the left mouse
button. Press the Ctrl key while clicking with the left mouse button on the other parameter (pin) that you
want to connect to.

NOTE! Be sure that you select one input parameter and one output parameter.

11

Connect to a Previous Selection

To connect a parameter to another parameter, select the first parameter by clicking on it with the left
mouse button. Click on another parameter (pin) that you want to connect to with the right mouse button.

By this, you select the second parameter, though the selection of the first one remains, and you open the
context menu. Select “Connect to Previous Selection” from the context menu to accomplish the
connection.

2.1.9 Inverting Connections


To invert inputs to a function or function block right click on the input parameter, and select “Invert” from
the menu. A small circle (bubble) will appear on the input parameter.

2.1.10 Adding Comments


It is possible to write comments to functions/function blocks and pages.

Edit Comments of Function Blocks and Functions

Select the function block or function to which you


want to assign or edit a comment. Select “Edit
Comment…” from the context menu and type in your
comment.

Edit Page Comments

If you want to add a comment for a page in FBD, just right click and select
“Edit Page Comment…” from the context menu.

2.1.11 Structure Pane


The structure pane is the left sub pane within the code pane. It contains a list
of all function blocks and functions of the current POU.

Use the structure pane to:

• Get an overview of the POU.


• Select, copy and paste function blocks and functions.
• Create, modify and delete function blocks and functions.
• Edit instance name of function blocks, edit comments.

12

• Change the pagination and page comments.
• Navigate within the program.
• Change the order of execution in the FBD code pane.

The structure pane consists of the following sizable and movable columns:

• Item shows the type name of the function block or function with their properties in parentheses
• Comment shows the comment attached to the function block or function
• Page Comment shows the comment on the top of the corresponding Function Block Diagram page
• Page No is given at the first function block or function of every page of the Function Block Diagram
• Instance shows the name of function blocks

3 Structured Text (ST)


Structured Text (ST) is a high-level programming language. It is compact, highly structured and contains a
comprehensive range of constructs for assignments, function/function block calls, expressions, conditional
statements, iterations and more.

The code is simple to write and easy to read, because of its logical and structured layout. The compactness
of the language gives an excellent overview of the code and less scrolling in the editor.

3.1 Structured Text Editor


The code pane is used for writing code in Structured Text. It is a simple text editor. Tabs and spaces are
used to structure the code for easy reading.

The code pane may be divided into several ‘tabs’. Each tab is also referred to as Code Blocks. When the
code is compiled the execution order of the code is firstly in tab order (left to right) and then from top to
bottom inside the tabs.

Instances of variables and function blocks are declared in the declaration pane.

3.2 Basic Language Elements


This section gives a very brief review of the structured text language.

13

3.2.1 Assignment Statements


An assignment statement assigns a value to a variable.

The statement has two parts:

Result := In1 AND In2 OR In3;

The left hand side, before the assignment operator (:=) is called the assigned variable. The right hand side is
an expression which is evaluated to give a value to the assigned variable.

In the above example the expression results in a Boolean – true/false value. (It is a Boolean expression).
The AND and the OR are referred to as operators (In this case Boolean operators).

NOTE! The := symbol is used for the assignment of operators and a statement must be ended with a semi-
colon.

Another example of an assignment statement:

AverageFlow := (Flow1 + Flow2)/2;

The variable AverageFlow is assigned the value given by the result of the calculation on the right. Flow1 is
firstly added to Flow2 and then the total is divided by 2.

The expression on the right is a Real expression because it results in a Real value (floating point value). The
symbols + and / are called arithmetic operators because they perform arithmetic operations on the variable
values which follow them.

14

3.2.2 Comment Statements
(*…*) Comment according to IEC 1131-3.

(#…#) Comment that can be nested (ABB extension).

It is normally not possible to have comments within comments (nested comments):

(* This is not (* Inner Comment *) allowed *)

However there is an alternative comment symbol that allows this:

(# This is (* Inner Comment *) allowed #)

This is useful for commenting out large blocks of code containing comments.

3.2.3 Operators

3.2.4 Precedence
The priority of operators decides the order of evaluation of an expression. Below is a summary of available
operators, in descending priority:

15

If you are unsure of the evaluation order then use parenthesis to force evaluation of sub-expressions.

3.2.5 Conditional Structures


There are two main groups of conditional structures of which here is presented the “IF…Then”

NOTE! A conditional statement is always concluded with END_IF;

16

3.2.6 Iteration Structures
Several iteration constructs exist: They should be used with extreme caution. During the iteration of the
loop, the CPU remains in the loop. If a loop has a large number of iterations then the normal scan time may
be easily exceeded.

NOTE! Only use these constructs when you know exactly how many iterations are going to be done.

Operator Description
FOR i := 0 to 15 DO The FOR statement is used to allow a statement (or
Statement(s); statements) to be executed repeatedly for a given
END_FOR; number of times. The counter used in the repetition
process can be used in the statements. In the
example, the statements between the FOR and
END_FOR will be executed 16 times.
WHILE Level > 80.0 DO The WHILE statement is used in order to allow a
Statement(s); statement (or statements) to be executed
END_WHILE; repeatedly while a certain condition is True. This
separates it from the FOR statement. It has some
similarities with the REPEAT statement.
REPEAT The REPEAT statement is used in order to allow a
Statement(s); statement (or statements) to be executed
UNTIL Boolean Expression repeatedly until a certain condition is True. Note
END_REPEAT; that the test to exit the loop is placed at the end, so
a minimum of one execution of the statement(s)
will occur even if the expression is true at the time
the loop is entered.
EXIT; Use the EXIT statement whenever you want to
terminate a loop immediately and continue
execution from the first line after the iteration
statement.

3.2.7 RETURN Statement


The RETURN statement causes immediate exit from the current code block (A tab in a program or control
module or function block). No further code in that block is executed.

3.3 Functions and Function Blocks


3.3.1 Functions
Functions are called inside expressions with the following syntax:

Var := FunctionName(Parameter(s))

In the example below the square root of a flow signal is calculated by using the Sqrt() function.

17

3.3.2 Function Blocks
Function block calls do not appear in assignment statements. The call is itself a valid statement. Note that
in ST, function block input parameters are listed with the := symbol and output parameters are listed with
the => symbol. The example below shows the code for calling a delay off timer:

The above timer function block is the same as the following in FBD form:

Function blocks are declared in a similar way to variables, by


giving them a name (an instance name). This name is then used
to call them in the code. In the ST editor you must declare
function blocks explicitly in the “Function Block” declaration tab
in the editor by giving a name and a type:

3.3.3 How to Declare Function Block Instances


As an absolute minimum a function block instance must be given a name and a function block type:

1. Mark the “Function Blocks” tab in the declarations pane of the POU.
2. Type in an instance name for the function block in the “Name” column.
3. Type in the required function block type in the “Function Block Type” column. Place the cursor in
the field and press ‘Ctrl + J’ to see a list of all available function block types.

NOTE! Function Block Types are defined in the libraries.

18

If the library that contains the function block type that you want has not been connected to the application
then it will not appear in the list.

3.3.4 How to Call a Function Block Instance


In the example below a delay off timer has been declared in the “Function Block” declaration tab, called
MixTimer of type TOf:

Four variables which will be used to connect to the function


block have also been declared in the “Variables” declaration
tab:

1. Call the function block instance by typing its instance name in the code pane followed by an
opening parenthesis ‘(‘


The system will then offer a dialogue for you to make connections.

19

2. Fill in the parameters that are to be connected to the function block instance in the parameter
column by any of the following methods:

Type the name of the variable to be connected directly into the “Parameter” field. (After a few
characters the system will try to help you finish by supplying first matching variable name).
3. Use the “Insert from List” method by clicking on the Insert Variable … icon in the menu bar or use
the “Insert Path from Tree” Icon to browse the application for the variable:


4. Click on the “Exit and Close” icon in the dialogue.


5. The result (for this example) looks like:

3.4 Common Mistakes and their Error Messages


3.4.1 Identifier, constant or opening parenthesis expected

Double clicking on the


error message line places the cursor at the end of the statement with the problem: Usually a missing semi-
colon (;)at the end of a statement.

20

3.4.2 Variable name is not unique


Two variables have been declared with the same name. (Note that this results in two error one for each
non-unique name).

Note also that some other items are classed as ‘variables’ by the system:

• Instance names for function blocks


• Instance names for control modules
• Sequence Step names
• Code Block names
• Sequence Transition names
• Parameters (in function block types and control module types)

This means that within any POU all of the above must have unique names.

3.4.3 Identifier too long or invalid


This error message is given under two circumstances:

1. Variable naming rules have been disobeyed - the name begins with a number.

2. A key word has been used - both words “On” and “Off” are reserved.


21

3.4.4 Undefined function block
The programmer has declared the function block with the name MixTimer but has referenced MuxTimer in
the code.

3.4.5 Type mismatch in assignment


This occurs when the programmer has mixed data types in an assignment statement

In this case the programmer has attempted to add a “real” and a “dint” to get a “dint” result. (You can’t
multiply apples with pears!)

3.4.6 Incompatible types in expression


This occurs when an operation has been attempted on different types that are not compatible for that
operation:

In the above a real has been added to a bool.

22

4 Sequential Function Charts (SFC)
The Sequential Function Chart (SFC) programming language allows the user to describe the sequential
behavior of the control program graphically. This is quoted as the
fifth IEC 61131-3 language but it’s not really a new language just
a specialized editor for coding sequences.

The SFC standard has been evolved from Grafcet, a graphical


method of describing sequential behavior.

A sequence is a unit with a complete sequence surrounded by an


unconditional loop; the first step is reactivated when the
sequence is finished. A sequence can be divided into separate
types of structures. It is possible to structure the sequence view
into several hierarchical levels with the subsequence function.

4.1 SFC Editor


The SFC programming editor is divided into four panes, which are very similar to the other language
program editors. The main difference is the structure pane, used to describe the sequential flow with steps
and transitions.

It is not possible to have a sequence without any steps or transitions. The sequence must consist of at least
one step and one transition.

4.2 Steps and Transitions


The sequence element always has a step followed by a transition. This is the smallest part of a sequence
and is a complete entity. You may not have a step on its own or a transition on its own, neither can you
have two steps together or two transitions together.

23

4.2.1 Steps
A step is a basic element, which is activated by its preceding transition. The step becomes active until its
succeeding transition is true, and then next step is activated.

Each step has a name, that can be changed, and each step can have up to three associated set of actions. It
is not possible to change the action names.

The step is used to hold instructions which perform actions on the process devices.
NOTE! The instructions must be programmed in the Structured Text language.

Double clicking on any step will result in that step being


“opened” in the editor:

Each of the boxes represents one code block (or tab) in a


program editor, written in Structured Text. There are
three blocks called ‘Entry’, ‘Active’ and ‘Exit’.

• Instructions written in the Entry block (P1 = Pulse rising edge) are executed once and once only on
entry into the step. (During transition from the previous step)
• Instructions written in the Active block (N = Non-stored) are executed on each scan whilst the step
is active.
• Instructions written in the Exit block (P0 = Pulse falling edge) are executed once and once only on
exit from the step. (During transition to the next step).

4.2.2 Transition
The transition from one step to the next holds a Boolean expression. (Note that it is NOT a code block as
such and requires a slightly different syntax).

A Boolean expression is any sequence of terms and operators that results in a single Boolean result – True
or False. The sequence will transit from one step to the next when the transition following the currently
active step goes true.

4.3 Sequence Constructs


4.3.1 Simultaneous Sequences
The simultaneous sequence structure allows simultaneous and
independent execution of two or more branches of sequence actions.
Each branch starts and ends with a step. The last transition cannot
activate its succeeding step unless the last step of both branches is active.

When the transition Tr7 becomes true, Step S7 is left and each of the
three steps S8, S9 and S10 become active. When a parallel branch is left all preceding steps must be active
AND the following transition must become true. In the above steps S12, S9 and S13 must be active together
with Tr9 being true before the exit from the branch takes place.

24

4.3.2 Sequence Selection
A series of transition conditions are monitored when the prior step is active.
The next step to become active is determined by which transition becomes
true. That branch is selected and the execution continues in that branch.

The execution can only continue in one of the branches. The branch with
the highest priority (graphically, the left to right branch order corresponds
to the priority order) and a true transition condition will be chosen.

4.4 Jumps and Destinations


Unstructured links inside the sequence structures are necessary in some cases to deal with extraordinary
situations and when, for example, changing the process production mode.

A jump is a link from a named single transition to a named single step,


located anywhere in the same sequence structure. Multiple jumps
can be connected to a step. A jump can be considered as a sequence
selection. It is a transition where the execution is transferred from
the preceding step to the jump destination step, when the transition
condition becomes true.

NOTE! It is not possible to jump between different sequences.

A forward jump is typically used when some sort of exception occurs.


A backward jump is typically used when a sequence loop is needed
inside the overall sequence loop.

5 Control Modules
Control module types and their instances represent an extension to those code containers (POU) described
by IEC 61131-3. You can think of control modules as super function blocks that have the ability to hold code
and also graphics.

The coding techniques and editors are the same as for function block types and programs, with very little
difference, so all the knowledge of programming with traditional programs can be carried forward into the
world of control modules.

However because of the addition of graphics as part of the module, the beginner must learn about a new
graphics editor called the Control Module Diagram Editor (CMD Editor). Just as an FBD editor is used to
build programs with function blocks, so the CMD editor is used to build applications with control modules.

25

5.1 Control Modules as Code Containers

Control Modules are code containers that can contain:

• Code – written in any of the five language editors


• Graphics – configured in the CMD Editor
• Other control modules – nesting leads to the ability to create deep hierarchies

5.1.1 Code
Code is written in a code editor which is
exactly the same as that for programs. This
means that the code inside control modules
may be written in Structured Text, Function
Block, Ladder, Instruction list or Sequential
Flow Chart. Code may be separated into
code blocks (tabs). In this respect there is
nothing new to learn.

The top pane has four tabs for the


declaration of Parameters, Variables,
Externals Variables and Function Blocks. It is
identical to the editor for a function block type that was used in the previous sections.

5.1.2 Graphics
The graphical part of a control module is written in its own editor called the Control Module Diagram Editor
(CMD Editor)

The graphical part is drawn within the green boundary, using the
tools in the toolbox to the left. The tools available are:

• Graphical Primitives Text, Rectangle, Oval, Arc, and


Polyline/Polygon
• Interaction Objects Command Button, Option Button,
Check Box, Input Field, Window interaction
• Composite objects Image Selector, String Selector, History
Graph, Bar Graph
• Connective Node and Graphical Connection

All of these objects may be connected to variables for dynamic


display and interactions by an engineer or technician. In the same way as the FBD editor is used for
instantiating function blocks, the CMD editor is used for instantiating control modules.

5.2 Representation of Control Modules


In general control module types are defined in libraries. These libraries are connected to applications.
Instances are created in applications. The types in a connected library become available to the applications
that have that library connected

26

Note that types are shown with green icons, whereas instances are shown with blue icons.

5.2.1 When to use what?


As a general guideline, traditional programming is typically suitable for small applications whereas control
modules are recommended for large applications. Control modules support object-oriented programming
and code re-use to a greater extent and therefore make a large application more flexible and easier to
maintain.

Control modules have many advantages over traditional


programs:

• Faster execution due to more efficient compiler


• Reduced memory usage in the controller
• Better data flow within the application ensuring that
all values are updated in each scan.
• Provision of configurable graphics for creating diagnostics, commissioning and maintenance
windows and views.
• Object oriented philosophy can be closely followed with control modules because they allow
almost unlimited nesting without performance penalties.

5.3 Control Module Diagram (CMD) Editor


The CMD editor is a tool that allows the engineer to configure the graphical representation for an
application or a control module type. Any graphical component is drawn in the CMD editor.

Instances of previously defined control module types are placed graphically in the application using the
CMD editor. Open the CMD editor for an application by marking the respective application, and then
clicking right for the context menu.

27

5.3.1 How to Create a Control Module Instance


1. Open the CMD editor and open the module in which the instance is to be placed.
2. Right click and select “Create > Control Module…”
3. Select the library which contains the type that you want and select then the type. Give the
instance a name (distinguish between the instance name and the type name).
4. Click “OK”.
5. A cursor will appear in the CMD editor, click left and drag to instantiate the module.

5.3.2 Graphical Connections


Many modules have nodes available for graphical connection. Connections between nodes may be done
graphically rather than explicitly declaring the variables. The diagram below shows four instances from the
library ‘ControlStandardLib’ suitable for creating a simple PID flow control loop:

These modules are prepared with nodes and may be connected graphically.

1. Click right in the view and select “Create > Graphical Connection”
2. The cursor will appear.
3. Click once on the node where the connection is to start
4. Move the cursor to the destination node and double click to finish.

28

Potrebbero piacerti anche