Professional Documents
Culture Documents
3bse021358 Cio Iec61131
3bse021358 Cio Iec61131
Trademarks
Registered trademarks from other companies are:
Microsoft™, Windows™, Windows NT™ from Microsoft Corporation.
PostScript™ and Acrobat Reader™ from Adobe Systems Inc.
FIX™ from Intellution and 3964R™ from Siemens.
3BSE021358R4001
Contents
3BSE021358R4001 5
Contents
4 Programming Languages 35
4.1 Overview . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 35
4.2 Common Elements . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 37
Identifiers . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 37
Data Types . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 38
Constant Literals . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 39
Variables . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 40
4.3 Ladder Diagrams . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 41
Easy to Understand . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 42
Weak Software Structure . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 43
Limited Support for Sequences . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 44
Difficult to Reuse Code . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 45
4.4 Instruction List . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 46
IL Language Structure . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 46
IL Instruction Set . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 47
Best System Performance . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 49
Weak Software Structure . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 49
Machine-dependent Behavior . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 49
4.5 Structured Text . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 50
Statements . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 50
Operators in Expressions . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 51
Conditional Statements . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 51
Calling Function Blocks . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 53
Suitable for Complex Calculations and Looping . . . . . . . . . . . . . . . . . . . . 53
High Threshold for Programmers . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 53
4.6 Function Block Diagram . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 54
Syntax for Function Block Diagrams . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 54
Standard Function Block Types . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 55
Similar to Electrical Diagrams . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 60
Boolean Functions and Feedback are Easy to Implement . . . . . . . . . . . . . 60
Not Suitable for Conditional Statements . . . . . . . . . . . . . . . . . . . . . . . . . . 61
4.7 Sequential Function Chart . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 62
Chart Structure . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 62
Steps and Transitions . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 64
Action Descriptions . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 64
Sequence Selection and Simultaneous Sequences . . . . . . . . . . . . . . . . . . . 65
Subsequences . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 67
Advice on Good Programming Style . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 67
Powerful Tool for Design and Structuring . . . . . . . . . . . . . . . . . . . . . . . . . 68
Other Programming Languages are Needed . . . . . . . . . . . . . . . . . . . . . . . . 68
6 3BSE021358R4001
Contents
3BSE021358R4001 7
Contents
8 3BSE021358R4001
Chapter 1: Evolution of Control Systems 1.1 Introduction
Chapter 1
Evolution of Control Systems
1.1 Introduction
Almost all industrial plants need some kind of controller to ensure safe and
economical operation. At the simplest level, the plant may consist of an elec-
tric motor driving a cooling fan to control the temperature in a room. At the
other extreme, the plant could be an entire nuclear reactor for producing elec-
trical energy for thousands of people. Apart from their size and complexity, all
control systems may be divided into three well-separated functional parts: the
transducers, the controller and the actuators.
Transducers Actuators
Plant
Parameters Status
The controller monitors the actual status of the plant processes through a num-
ber of transducers. The transducers convert physical properties into electrical
signals that are connected to the controller inputs. Digital transducers measure
conditions with distinct states, such as on/off or high/low, while analog trans-
ducers measure conditions which have a continuous range, such as tempera-
ture, pressure, flow or liquid level.
3BSE021358R4001 9
1.2 History Chapter 1: Evolution of Control Systems
Based on the status of the inputs the controller uses a built-in or programmed
algorithm to calculate the status of the outputs. The electrical signals from out-
puts are converted into process behavior via the actuators. Most actuators cre-
ate movements of valves, motors, pumps and other devices by using electrical
or pneumatic energy.
The operator interacts with the controller by providing control parameters.
Some controllers can display process status via a screen.
1.2 History
The first control systems were developed during the industrial revolution at the
end of the 19th century. The control function was implemented by using
ingenious mechanical devices automating some of the most repetitive and crit-
ical tasks on the assembly lines. These devices had to be individually adapted
to each task and due to their mechanical nature they also suffered from a short
life-time.
In the 1920s, mechanical control devices were replaced by electrical relays and
contactors. Relay logic made it possible to develop larger and much more so-
phisticated control functions. Since then, electrical relays have been used in a
large number of control systems around the world. Relays have proven to be a
very cost-effective alternative, especially for automating small machines with
a limited number transducers and actuators. In today’s industry, relay
logic is seldom chosen for new control systems but a large number of older
systems are still in use.
The silicon-based integrated circuit, IC, paved the way for a new generation of
control systems in the 1970s. Compared with relays, ICs based on TTL or
CMOS integrated circuits are much smaller, faster and also have a longer life-
time.
In most control systems based on relays and ICs, the control algorithm is per-
manently defined by the electrical wiring. Systems with wired logic are easy
to implement but unfortunately it is difficult and time-consuming to change
their behavior.
In the early 1970s, the first commercial computers debuted as controllers in
large control systems. Since computers can be programmed they offer a great
advantage compared with the wired logic function in systems based on relays
or ICs.
10 3BSE021358R4001
Chapter 1: Evolution of Control Systems 1.2 History
Early computer systems were large, expensive, difficult to program and unfor-
tunately also very sensitive to the harsh environment in many industrial plants.
As a result of demands from the American car industry the Programmable
Logic Controller (PLC) was developed in the early 1970s. The PLC is a com-
puter designed to work in an industrial environment. The transducers and
actuators in the outside world are connected via robust interface cards. Com-
pared with an office computer, the PLC has a limited instruction repertoire,
often only logical conditions.
Early PLCs had no analog inputs and therefore they could only handle
digital control applications. In today’s industrial plants there is often a need to
handle both digital control and closed-loop analog control in the same control
system. These systems are often called Programmable Controllers since their
operation is not limited to only logical conditions.
Today, the overall control function in a plant is often distributed to a number
of local programmable controllers which are positioned in the immediate
neighborhood of the objects which are to be controlled. The different control-
lers are usually connected together into a local area network (LAN) with a
central supervising process computer which administers alarms, recipes and
operations reports.
Mechanics
Relays
ICs
Computers
PLCs
Process
computers
Fig. 2 The evolution of control systems since the end of the 19th century.
The operator plays a very important role in today’s industry and many plant
installations therefore have a computer-based Supervisory Control and Data
Acquisition System (SCADA). SCADA systems have high-resolution color
monitors on which the operator can select different application programs and
study the status of the manufacturing process.
3BSE021358R4001 11
1.3 Control Applications Chapter 1: Evolution of Control Systems
Monitoring Subsystems
A monitoring subsystem displays the process state to the operator and draws
attention to abnormal conditions which require some kind of action from the
operator. The measured process values for temperature, pressure, flow etc. are
displayed to the operator via indicators, meters, bar-graphs or via a computer
screen.
Signals can also be checked for alarm conditions. The system indicates alarms
via warning lamps or audible signals, often accompanied by a paper printout.
Many monitoring systems also keep records of the consumption of energy and
raw materials for accountancy purposes. The system may also create
automatic warnings when critical components need to be exchanged.
Sequencing Subsystems
The vast majority of all subprocesses can be described via a predefined
sequence of actions that must be executed in a certain order. In such a system
it is not possible to specify a momentary combination of input signals resulting
in a certain output signal. Instead, the output status is dependent on an entire
sequence of input signals having occurred. In order to monitor the sequence of
actions there is a need for memory functions.
12 3BSE021358R4001
Chapter 1: Evolution of Control Systems 1.4 Relay Logic
Desired Error
value SP-PV Controlled
variable
SP Control Actuator Process
algorithm
PV
Actual value
Transducer
3BSE021358R4001 13
1.4 Relay Logic Chapter 1: Evolution of Control Systems
All relay coils are normally used to activate one or more built-in switches.
These switches are connected to the actuators in the process. If one of the relay
switches is used as an alternate input contact the result will be a circuit with
memory function.
Logical AND
Logical OR
Memory
14 3BSE021358R4001
Chapter 1: Evolution of Control Systems 1.5 Computers for Process Control
Experience shows that it is easy to develop small relay systems with a limited
number of relays, but with increasing complexity the work will demand a very
experienced engineer.
A characteristic quality of relay-based control systems is the decentralization
of the logic function into a large number of discrete relays. Since relays are
electromagnetic components they have a limited life-time. Relay-based con-
trol systems therefore need continuous maintenance and service. Another dis-
advantage of relay systems is that it may be very difficult and time-consuming
to change the logical function in an existing plant.
Today, relay logic can only be justified in very small plants with less than a
dozen inputs and outputs and in plants with severe electrical interference,
where computers and programmable controllers cannot be used.
3BSE021358R4001 15
1.5 Computers for Process Control Chapter 1: Evolution of Control Systems
Programming Methods
All computer programs consist of a number of instructions which tell the com-
puter what to do when the program is run, or executed as programmers prefer
to say. Because computers process binary information, the computer’s instruc-
tions are very different from our own verbal ways of describing the actions we
want it to take. In programming, therefore, various aids are used to process and
translate our verbal function description into the computer’s own language.
These aids are ready-made computer programs which can be purchased rela-
tively cheaply.
Machine Code and Assembler
Most computers have a limited set of instructions which carry out simple op-
erations such as fetching data, storing data, adding numbers, etc. By combin-
ing a large number of such machine codes into long programs, the programmer
can get the computer to carry out very complex functions. In order for the pro-
gram to work, however, it is very important to follow the rules on how instruc-
tions should be used and combined, often called the syntax of the program.
Because machine codes are binary or hexadecimal numbers, the job of pro-
gramming is made easier by using what are known as assembler instructions.
Each of these instructions has a three-letter name (memo-code), such as LDA
for fetching data and ADD for adding two numbers. A ready-made program
known as an editor is normally used when writing assembler instructions into
the computer. An editor program has basic word processing functions for en-
tering and correcting text.
Before the assembler program can be executed, the memo-codes must first be
translated into hexadecimal machine code. The translation to machine code is
done by another program called an assembler. Assembler programs of this
kind can be bought for most types of computers. Apart from the actual trans-
lation, the assembler program can also help in checking syntax and in calcu-
lating logical jumps within a program. Assembly is normally carried out on the
same type of computer as will be used for program execution, but there are also
assembler programs, known as cross-assemblers, which can be run on other
types of computers.
Test running of assembler programs is made easier by special programs that
allow part of the program to be executed step by step. Using these so-called
debugging programs, it is also possible to simulate real-life signals so that the
function can be tested without having to connect the computer to the process.
16 3BSE021358R4001
Chapter 1: Evolution of Control Systems 1.5 Computers for Process Control
Start
Editing
using editor F6
0A
A9
LDA IN1 23
Assembling
L1 SUB C 12
E3
CMP B F8
Test-running Assembler
using debugger 76
BNE L1
06
ADD D A3
No 45
Functioning STO OUT1 D3
properly? A2
Yes
Stop
Fig. 5 In low-level programming several supporting programs are used, such as an ed-
itor, an assembler and a debugger, in order to translate the program into machine code.
3BSE021358R4001 17
1.5 Computers for Process Control Chapter 1: Evolution of Control Systems
The difference between compilers and interpreters is that the compiler first
translates the whole program before it is executed, while the interpreter trans-
lates and executes the program instructions one by one. This means that com-
piled programs are executed considerably faster than interpreted ones.
The most common high-level languages are Pascal and the closely related
language C. Both of these are normally compiling high-level languages. An
example of an interpreted language is Basic.
Instructions in a high-level language are reminiscent of mathematical func-
tions, and are therefore relatively easy to use. All high-level languages are
highly standardized, and the main parts of the programs can be written so that
they are independent of the type of computer on which they will be run. The
actual matching to the computer is done by the compiler or interpreter in the
process of converting it to machine code. Programs that are written in high-
level languages are often known as source code, while the compiled result is
called object code.
02
Source code in Pascal 0C
A7
43
Profit := Income - Cost 37
E3
IF Profit>20 THEN PRINT "Profitable" F8
Compiler 86
ELSE PRINT "Loss" 16
A2
END 45
A2
05
A3
Fig. 6 Programs written in a high-level language are totally machine- 12
7B
independent and are translated to computer-specific machine code
by a compiler program.
The programmer writing in a high-level language does not need to know the
technical details of the design of the computer or its memory. Another advan-
tage is that completed programs can be moved to another type of computer,
assuming that a suitable compiler is available.
The disadvantage of programs written in high-level languages is that they take
up more room in the memory than corresponding programs written directly in
assembler (machine code). This also means that the performance of the com-
puter is used less efficiently.
18 3BSE021358R4001
Chapter 1: Evolution of Control Systems 1.6 Programmable Controllers
PLC Engineering
station
Bus unit
I/O unit
Input modules Output modules
Transducers Actuators
Fig. 7 The components of a programmable controller system.
3BSE021358R4001 19
1.6 Programmable Controllers Chapter 1: Evolution of Control Systems
I/O Units
A characteristic quality of the programmable controller is that it is designed to
live in and interact with an industrial environment. Most controllers have a
modularized Input/Output unit (I/O) for direct connection of the transducer
and actuator signals.
The purpose of the I/O unit is to convert the process signals to the lower signal
level used in the controller and also to suppress electrical transients from the
plant equipment. This is often achieved by optical isolators containing a light-
emitting diode and a photoelectric transistor linked together in a package.
Since there are several different signal levels in a typical plant, many I/O units
allow the use of exchangeable I/O modules. Such an I/O unit can easily be cus-
tomized to the specific signal levels of the plant.
The most commonly used I/O modules are digital DC inputs and outputs with
the signal levels 24 V or 48 V. Many vendors also offer modules with AC in-
puts and outputs with signal levels of 110 V or 220V.
A growing number of programmable controllers have arithmetic functionality.
Such systems have a need for analog input and output I/O modules. Most
analog transducers represent a physical value as a current within the range
4-20 mA, with 4 mA indicating the minimum value.
Programming Methods
The first PLCs used a programming language based on relay ladder diagrams.
The program was entered via a programming terminal with keys showing
contact symbols (normally open/normally closed), relay coils and parallel
branches with which a maintenance electrician would be familiar.
The programming terminal compiled the ladder diagram into machine code
which was sent to the controller for execution. With the controller executing
the control program was presented on a screen, with energized contacts and
coils highlighted, making it possible to study the application and also, if nec-
essary, to debug the program.
Programming with ladder diagrams is a very intuitive method, especially for
people with previous knowledge of relay-based control systems. Therefore,
this method was initially preferred by American PLC vendors.
20 3BSE021358R4001
Chapter 1: Evolution of Control Systems 1.6 Programmable Controllers
In large plants and when people without previous knowledge of relay logic are
to develop the control program, Boolean instruction lists are often preferred.
Most European PLC vendors have chosen this as the standard programming
method in their systems.
A 001
A 012
ON 020
RP
A 003
= 201
Fig. 8 Examples of PLC programs using a ladder diagram and instruction list.
3BSE021358R4001 21
1.6 Programmable Controllers Chapter 1: Evolution of Control Systems
Some development tools can be used online, for displaying the actual process
signal status on the computer screen, when the control application is executing
in the programmable controller.
With ever-increasing performance in computer-based engineering stations,
several vendors now offer developing packages, in which it is also possible to
use programming methods like Structured text, Sequential Function Charts
and Function Block Diagrams, apart from ladder diagrams and instruction
lists. These methods are further described in Chapter 4.
Cyclic Execution
Industrial control systems are real-time systems, which means that changes in
the input signal require immediate action on the corresponding output signals.
An example is a machine in which some movement must be stopped when a
particular limit is reached. If the controller does not react in time, the result
may be damage to the machine or injury to the operator. The consequences of
a delayed reaction therefore become unacceptable.
In order to fulfil the demands on a real-time system, the application program
must have constant access to current input data from the process. To achieve
this the compiled program is executed cyclically at a specific frequency.
Changes in the incoming signals can therefore only affect the output signals at
the end of each completed program cycle. The required interval time of the
program is determined by the maximum allowed delay time in the process.
Read inputs
Update
outputs
22 3BSE021358R4001
Chapter 1: Evolution of Control Systems 1.6 Programmable Controllers
Because different subprocesses may have different time demands, some pro-
grammable controllers provide a function for dividing the total program into
different tasks, each with its own interval time.
Distributed Systems
In many large industrial plants there is a need for distribution of the entire
control function to several different programmable controllers and process
computers. This strategy will improve total performance and also reduce the
risk of total breakdown in the manufacturing process.
The cabling between transducers, actuators and the programmable controllers
accounts for one of the major costs in a control system. If the plant is spread
out over a large area, considerable cost savings may be achieved by using
remote I/O subsystems situated close to the actual subprocess.
Distributed control systems require a standardized communication protocol in
order to exchange information. Several PLC vendors have developed their own
proprietary protocols during the 1990s and some of these, like COMLI from
ABB, 3964R from Siemens and the vendor-independent Profibus, have slowly
emerged into de facto standards supported by more than one PLC
vendor.
Soft PLC
One problem with PLCs is that all vendors use their own proprietary controller
hardware with an associated programming language. In spite of the basic func-
tions being practically identical, the instructions have different names and the
rules governing the syntax of the programs may vary. This makes it difficult to
communicate and exchange application programs between systems of differ-
ent manufacture.
Several software vendors have presented a new type of controller called the
Soft PLC. The Soft PLC is real-time software executing a control application
in a standard PC and communicating with the plant via a standardized modular
I/O unit.
The major advantage of a Soft PLC is that all the required hardware is vendor
independent. Unfortunately, none of the software vendors has managed to
establish their Soft PLC software as an industry standard. This means that con-
trol applications developed with one Soft PLC application cannot be trans-
ferred to Soft PLCs from other vendors.
3BSE021358R4001 23
1.6 Programmable Controllers Chapter 1: Evolution of Control Systems
24 3BSE021358R4001
Chapter 2: Why Open Systems are Needed 2.1 Programming Dialects
Chapter 2
Why Open Systems are Needed
3BSE021358R4001 25
2.3 Software Cost Chapter 2: Why Open Systems are Needed
It is well-known that good software quality comes at a high cost. Most control
software is developed either by a department in the customer organisation or
by small software houses working in a close privileged relationship with the
machine or plant manufacturer. In both cases, software production and thus
cost is not governed by the free market. Consequently, software suppliers are
not motivated to strive towards more efficient development methods and tools.
The vast majority of all control code is written with the proprietary software
packages delivered by the control system vendors. Many of these packages
have very poor facilities for working with modules, for code reuse and for doc-
umentation. Software quality is therefore heavily dependent on the experience
and intellectual capacity of the programmer.
Before the IEC 61131-3 standard was established, good software engineering
was an open goal in the control application environment.
26 3BSE021358R4001
Chapter 2: Why Open Systems are Needed 2.4 Portable Software Applications
3BSE021358R4001 27
2.5 Reusable Software Chapter 2: Why Open Systems are Needed
28 3BSE021358R4001
Chapter 2: Why Open Systems are Needed 2.6 Communication with Other Systems
Most control system vendors have developed their own proprietary communi-
cation protocols for information exchange in SCADA and DCS. Some vendors
also provide software-based protocol converters enabling communication be-
tween systems from different manufacturers.
All industrial plants have computer-based Management Information Systems
(MIS) for handling of statistical and economic information. There is often a
need to connect MIS with SCADA and DCS, resulting in a total control and
management system. General Motors in the USA has developed a standard
called Manufacturing Automation Protocol (MAP) for communication be-
tween different programmable controllers and MIS. Unfortunately, the MAP
standard has so far not been particularly successful.
3BSE021358R4001 29
2.6 Communication with Other Systems Chapter 2: Why Open Systems are Needed
30 3BSE021358R4001
Chapter 3: IEC 61131-3 Standard 3.1 Main Objectives
Chapter 3
IEC 61131-3 Standard
3BSE021358R4001 31
3.2 Benefits Offered by the Standard Chapter 3: IEC 61131-3 Standard
32 3BSE021358R4001
Chapter 3: IEC 61131-3 Standard 3.3 PLCopen Trade Association
3BSE021358R4001 33
3.3 PLCopen Trade Association Chapter 3: IEC 61131-3 Standard
34 3BSE021358R4001
Chapter 4: Programming Languages 4.1 Overview
Chapter 4
Programming Languages
4.1 Overview
The IEC 61131-3 standard specifies five programming languages:
• Ladder Diagrams, LD
• Instruction List, IL
• Structured Text, ST
• Function Block Diagram, FBD
• Sequential Function Charts, SFC
IL and ST are textual languages while LD, FBD and SFC are based on graph-
ical metaphors. Since all of these languages have both advantages and disad-
vantages, it is important to have basic knowledge of the most suitable
applications for each language.
Although most control systems may be implemented with any one of the five
languages the resulting program will be more or less effective, depending on
the requirements of the control application.
A1 A3 M1
LDN A3
AND( A1
OR A2
)
A2
ST M1
LD IL
A1
A2 1
M1 := ( A1 OR A2 ) AND NOT A3; & M1
A3
ST FBD
Fig. 11 A simple Boolean condition programmed with four of the five IEC 61131-3
programming languages. SFC is normally only used for sequences.
3BSE021358R4001 35
4.1 Overview Chapter 4: Programming Languages
Historically, the five languages have evolved in parallel with the evolution of
automation systems. Relay systems documented via LD were dominant in the
1950s. Logical circuits described by FBD were used mostly in the 1960s.
PLCs debuted in the 1970s with programming in IL. Computers for process
automation were introduced in the 1980s with ST programming in languages
like Pascal and C. Improved CPU power in the 1990s finally made it possible
to work with graphical languages like SFC.
Before the IEC 61131-3 standard was established, most vendors of program-
mable controllers supported only one or two of the programming languages.
By tradition, most American vendors have preferred LD languages while
European vendors have chosen FBD or IL languages.
The choice between different programming languages is governed by several
economical, technical, and cultural factors.
• Depending on background, programmers often have a preference for a cer-
tain language. Programming with IL, LD or FBD is more popular among
engineers with experience in automation systems using those programming
languages, while ST is the natural choice for engineers with experience us-
ing computer systems with programming languages such as Pascal.
• In small applications with relatively few logical conditions, the demands for
good structure and reuse of code are less important than in larger systems.
Many older control systems use LD as a direct analogy to systems based on
relays and switches.
• In large plants involving many subprocesses the control function must be
divided into an number of program modules with a high level of encapsu-
lation in order to prevent the modules from interfering with each other.
• Program languages are often characterized by their level of abstraction. A
low-level language like IL is very closely coupled to the actual binary codes
running the processor in the control systems. Low-level languages normally
have a limited number of instructions producing very effective software
code but, unfortunately, also totally tailored for a certain brand or model of
system. High-level languages, like ST and SFC, do not produce the most
effective machine language but, on the other hand, the program may be
compiled for many different programmable controllers.
• When programmable controllers were first introduced in the 1970s, most
of the applications were for purely Boolean logical conditions. Today, a
control system must handle both digital and analog control, together with
timers, counters and sequences.
36 3BSE021358R4001
Chapter 4: Programming Languages 4.2 Common Elements
High SFC
FBD
ST
IL
LD
Low
Year
1950 1960 1970 1980 1990 2000
Fig. 12 The evolution of the five IEC 61131-3 programming languages. Today, SFC, ST
and FBD are the most commonly used techniques for developing new control systems.
Identifiers
Identifiers are used for naming different elements within the IEC language, for
example, variables, data types, function blocks and programs. An identifier is
a string of letters, digits or underscore symbols which begin with a letter or an
underscore. Space characters are not allowed in identifiers. Two or more
underscores may not be used together.
3BSE021358R4001 37
4.2 Common Elements Chapter 4: Programming Languages
Keywords are special identifiers that are used within the IEC language as indi-
vidual syntactic elements. You are not allowed to use keywords as identifiers,
for example:
Type, True, False, Program, Task, Return, Step, Function, Timer, Counter
Some compilers may be able to distinguish between keywords based on their
position but others may produce confusing results.
Programmer’s comments are delimited at the beginning and end by asterisks
(*comment*). Comments can be placed anywhere except in IL language,
which has some restrictions.
Data Types
The first PLCs could only handle Boolean data but today’s systems are being
used in an ever-widening range of industrial applications. For this reason, the
IEC standard provides a comprehensive range of elementary data types. The
most often used data types are described below.
In addition to elementary data types, programmers can define their own Struc-
tured data types containing several components of data types. Such a data type
has no physical correspondence in the plant, but it can be likened to a cable
containing a number of leads of different types, e.g. for the transfer of electri-
cal power or telephone and TV signals.
38 3BSE021358R4001
Chapter 4: Programming Languages 4.2 Common Elements
All leads are given descriptive names so that the programmer can connect to
them without having a detailed knowledge of their function.
PumpType On (boolean)
Off (boolean)
Level (real)
Name (string)
Fig. 13 Example of a structured data type containing several elementary data types.
A new structured data type is declared by delimiting the definition with TYPE
and END_TYPE.
TYPE PumpType
On: boolean
Off: boolean
Level: real
Name: string
END_TYPE
Each component in a structured data type is identified via the variable name
and the component name separated by a point, for example Pump3.On.
Constant Literals
By giving a variable the attribute constant, you prevent it from being changed
after it is given its initial value. The initial value is normally specified in the
variable declaration.
There are two classes of numerical literals: integer and real, where the latter
are distinguished from the former by the presence of a decimal point. Real
literals may end with an exponent, indicating the integer power of ten by which
the preceding number is to be multiplied.
Decimal numbers are represented in conventional decimal notation. Numbers
to bases other than 10 are represented in base 2, 8 or 16 (prefix 2#, 8# or 16#).
Boolean data are represented by the values 0 and 1 or the keywords FALSE
and TRUE.
Time literals are used either for Duration data or for Time of day. Duration data
are prefixed by the keywords TIME# or T# followed by the actual duration in
terms of days, hours, minutes, seconds and milliseconds. Time of day literals
are prefixed by the keywords TIME_OF_DAY# or TOD#.
3BSE021358R4001 39
4.2 Common Elements Chapter 4: Programming Languages
Variables
Variables is the name given to data elements whose content may change
during execution of the application program. A variable may be associated
with a real-world input and output, but can also be an internal memory storage.
All variables are declared with a unique name and a corresponding data type.
This is normally done before the program code is written. A variable must also
have an attribute, either retain, constant or a blank field. Retain means that the
variable will retain its value when the system restarts. A constant variable will
not be changed by the system. Variables with a blank attribute will always be
calculated at system restart.
If a variable has to start at a specific value, that value has to be specified as
Initial value, otherwise it will start at a predefined value depending on its data
type (normally 0).
The table below shows examples of names and attributes of variables of
frequently used data types.
40 3BSE021358R4001
Chapter 4: Programming Languages 4.3 Ladder Diagrams
switch2
Normally closed Coil
contact
Normally open
contacts
Power rails
Fig. 14 Example of a simple ladder diagram with three contacts and a coil.
3BSE021358R4001 41
4.3 Ladder Diagrams Chapter 4: Programming Languages
using one of the relay’s physical switches as an input contact. A person with
experience in computing would probably call this a memory bit.
fan
Fig. 15 Feedback loop in an LD program. The fan starts with an impulse on contact
start and continues to run until the contact stop is opened.
Easy to Understand
Programming with LD can be learnt relatively quickly and the graphical pre-
sentation is easy to follow. The method is particularly easy to understand by
people who are familiar with simple electrical or electronic circuits.
42 3BSE021358R4001
Chapter 4: Programming Languages 4.3 Ladder Diagrams
LD programs are very popular among maintenance engineers since faults can
easily be traced. Most programming stations generally provide an animated
display showing the live state of transducers while the programmable control-
ler is running. This provides a very powerful online diagnostics facility for
locating incorrect logic paths or faulty equipment.
3BSE021358R4001 43
4.3 Ladder Diagrams Chapter 4: Programming Languages
state_1 state_2
state_2 state_3
state_3 state_1
state_1 output_a
state_2
state_3 output_b
44 3BSE021358R4001
Chapter 4: Programming Languages 4.3 Ladder Diagrams
From the above example it is obvious that ladder programs with sequences can
become very large and difficult to maintain. The most obvious problem is that
control of the memory-based sequence model is mixed with the application
logic so the behavior of the complete program is difficult to understand and
follow.
3BSE021358R4001 45
4.4 Instruction List Chapter 4: Programming Languages
IL Language Structure
IL is a language with a series of instructions, each on a new line. An instruction
consists of an operator followed by an operand. The operator tells the system
what to do, while the operand identifies which variable is to be processed.
Some operators can process more than one operand, in which case, the opera-
tors should be separated by commas.
IL programs are often written on a spreadsheet-like form with one column for
operators and another for operands. Labels, used to identifying entry points for
jump instructions, are placed in their own column to the left of the instruction.
All labels should end with a colon. The instructions only need to have labels if
the program contain jumps. Comments are placed in a fourth column to the
right of the operand. Comments are enclosed by asterisks (*comment*). It is
strongly advisable to add comments to all instructions during programming.
Large IL programs without comments are very difficult to follow.
46 3BSE021358R4001
Chapter 4: Programming Languages 4.4 Instruction List
IL Instruction Set
The IEC has developed a standardized instruction repertoire by examining the
many low-level languages offered by different vendors. The IL language, as
defined in IEC 61131-3, is a selection of the most commonly used instructions
in current programmable controllers. Each instruction is written as an abbrevi-
ation of the corresponding operation, sometimes referred to as a mnemonic.
Some IL operations can take operator modifiers after the mnemonic that
change the behavior of the corresponding operation. The modifier character
must complete the operator name with no blank characters in between. The
following three modifiers can be used:
• N, Boolean negation of the operand
• C, Conditional operation
• (, delayed operation
3BSE021358R4001 47
4.4 Instruction List Chapter 4: Programming Languages
The C modifier indicates that the corresponding instruction may only be exe-
cuted if the RR contains the Boolean value TRUE.
Parentheses are used to delay the operation of some parts in the program. This
is needed to change the execution order of the corresponding instructions,
since there is only one result register. The left-hand parenthesis indicates that
the evaluation of the following instructions must be delayed until the right-
hand parenthesis is encountered.
48 3BSE021358R4001
Chapter 4: Programming Languages 4.4 Instruction List
Machine-dependent Behavior
Of all the five IEC languages, IL has been found to be the most controversial.
Unfortunately, the semantics, i.e. the way in which the instructions operate, are
not fully defined in the standard. For example, it is unclear how the result reg-
ister stores values of different data types. Normally, the RR is not intended for
storing structured data, which means that it is very difficult to obtain consistent
behavior when working with arrays or strings.
Another problem is that the control system behavior for error conditions is not
defined. This means that different system types may respond differently if the
programmer uses inappropriate data types. Errors can normally only be de-
tected when the system is running the application.
3BSE021358R4001 49
4.5 Structured Text Chapter 4: Programming Languages
Statements
All ST programs contain a list of statements, each ending with a semicolon
separator. Statements contain expressions which, when evaluated, result in a
value of a variable having any kind of data type. Expressions are composed of
operators and operands. The ST language supports five different types of
statements:
• assignment statement, variable := expression;
• selection statements, IF, THEN, ELSE, CASE
• iteration statements, FOR, WHILE, REPEAT
• function and function block control statements
• control statements, RETURN, EXIT
The language statements can be written in a fairly free style with spaces, tabs,
line feeds and comments inserted anywhere between operators and operands,
i.e. where a space is needed for separation.
An expression can be short, for example a literal constant, or very complex
involving many other nested operations. The assigned variable can be either
simple or structured containing any number of elementary data types.
motor := (start or motor) and not stop;
speed3 := temp1*temp2 - 5*value7;
IF speed3 < 0 THEN
tank_level := 25.8;
ELSE
tank_level := 30.6;
END_IF;
Fig. 21 Example of a simple ST program.
Statement text should be written in a structured way. The computer will accept
any number of spaces in a statement but it is good practice to place statements
at a fixed position according to their role in the hierarchy.
50 3BSE021358R4001
Chapter 4: Programming Languages 4.5 Structured Text
Operators in Expressions
The table below summarizes the arithmetic and Boolean operators in the IEC
standard. The operators are listed in execution order with the highest prece-
dence first:
Conditional Statements
Often there is a need to execute certain statements repeatedly, a specified num-
ber of times, or only when a certain condition is fulfilled. The IEC standard
provides a collection of conditional statements for this purpose.
FOR Statement
The statement FOR is used when the number of executions is known.
count := 0;
FOR i:=1 TO 10 DO
count := count + i;
END_FOR;
The variable count starts with the value 0 and increases by 1 for each time the
addition is repeated until the final value 10 is reached.
3BSE021358R4001 51
4.5 Structured Text Chapter 4: Programming Languages
WHILE Statement
The statement WHILE is used when other statements are to be repeated an
unknown number of times until the condition no longer is fulfilled.
WHILE switch1 OR switch3 DO
pump := FALSE;
alarm := TRUE;
END_WHILE;
REPEAT Statement
The REPEAT statement is very similar to WHILE but the difference is that the
statement will always be executed once since the condition is written
after the statement.
REPEAT
B := B + 1;
UNTIL B>10
END_REPEAT;
IF Statement
An IF statement is used when one or more other statements are to be executed
conditionally.
IF A>B THEN
B := A;
ELSEIF A<B THEN
A := B;
ELSE
A := 0;
B := 0;
END_IF;
If A and B have different values the highest value will be given to both, else
both of the variables will be set to zero.
When using conditional statements it is very important to avoid infinite loops.
All statements must therefore include a condition that can be fulfilled.
52 3BSE021358R4001
Chapter 4: Programming Languages 4.5 Structured Text
3BSE021358R4001 53
4.6 Function Block Diagram Chapter 4: Programming Languages
In1
In2 1 TON
& IN Q Out1
In3
Time1 PT ET Out2
Fig. 22 Example of an FBD program with two logical function blocks and a timer block.
54 3BSE021358R4001
Chapter 4: Programming Languages 4.6 Function Block Diagram
TON
AND IN Q
Negation symbol PT ET
3BSE021358R4001 55
4.6 Function Block Diagram Chapter 4: Programming Languages
SR bistable RS bistable
SR RS
S1 Q1 S Q1
R R1
S1 R1
Q1 Q1
R S
Edge Detectors
There are two edge-detecting function blocks, Rising edge trigger (R_TRIG)
and Falling edge trigger (F_TRIG), which are used to detect the changing state
of a Boolean input. The output of the blocks produces a single pulse when a
transition edge is detected.
When the input changes state, according to the type of edge detector, the out-
put is true during one function block execution. After that the output remains
false until a new edge is detected.
R_TRIG F_TRIG
CLK Q1 CLK Q1
CLK CLK
Q Q
Fig. 25 Edge detectors create a single pulse with the same duration as the execution
time of the function block.
56 3BSE021358R4001
Chapter 4: Programming Languages 4.6 Function Block Diagram
Timers
Timers are among the most used function blocks in a control application.
Whenever there is a need for a time delay between a change of state and the
corresponding action a timer can be used. In most programmable control sys-
tems the timing is based on the CPU system clock, which means that the speci-
fied time intervals are very precise.
There are three different types of timer function blocks, pulse timers (TP),
on-delay timers (TON) and off-delay timers (TOF). All of them have a Bool-
ean input called IN, a Boolean output called Q, an input of type time called PT
and an output of type time called ET.
The required delay (or pulse width) is specified on input PT (Preset Time)
while the actual elapsed time is shown on output ET (Elapsed Time).
A pulse timer is normally used to generate output pulses of a specified dura-
tion. When input IN changes to the true state the output Q follows and
remains true for a duration specified by input PT. The elapsed time ET is in-
creased linearly as long as the pulse output is true. When the pulse terminates,
the elapsed time is held until the input changes to false. Note that the output Q
will remain true until the pulse time has elapsed, even if the input changes to
false.
Both delay timers are used to delay an output action by the specified time PT
when a certain condition becomes true.
The on-delay timer delays the activation of an output. When the input IN be-
comes true the elapsed time at output ET starts to increase. If the elapsed time
reaches the value specified in PT, the output Q becomes true and the elapsed
time is held. The output Q remains true until input IN becomes false. If input
IN is not true longer than the specified delay in PT, the output remains false.
The off-delay timer delays the deactivation of an output. When the input IN
becomes false, the elapsed time starts to increase and continues until it reaches
the specified delay given by PT. The output Q is then set to false and the
elapsed time is frozen. When input IN becomes true the output Q follows and
the elapsed time is reset to zero.
3BSE021358R4001 57
4.6 Function Block Diagram Chapter 4: Programming Languages
IN IN IN
PT PT PT PT PT PT
Q Q Q
ET ET ET
Fig. 26 Timing diagrams for the three different types of timer function blocks.
Counters
Counters are another commonly used type of function block. These are de-
signed to be used in a wide range of applications, for example counting pulses,
revolutions, completed production batches, etc.
There are three types of counter blocks, up-counters (CTUs), down-counters
(CTDs) and up-down counters (CTUDs). CTUs are used to indicate when the
counter has reached a specified maximum value. CTDs indicate when the
counter reaches zero, on counting down from a specified value. CTUDs can be
used to both count up and count down and have two outputs indicating both
maximum value and zero.
A CTU has three inputs and two outputs. A CTU block counts the number of
pulses (rising edges) detected at the Boolean input CU. The input PV (Preset
Value) of data type integer defines the maximum value of the counter. Each
time a new rising edge occurs on CU the output CV (Counter Value) of type
integer is incremented by one. When the counter reaches the value specified in
PV, the Boolean output Q becomes true and counting stops.
If necessary, the Boolean input R (reset) can be used to set the output Q to false
and to clear CV to zero.
58 3BSE021358R4001
Chapter 4: Programming Languages 4.6 Function Block Diagram
Up counter
CU
CTU
bool CU Q bool Q
bool R R
int PV CV int CV=PV
CV=0
CV
Fig. 27 Example of a CTU counter block with preset value PV=5.
The CTD is very similar to CTU with three inputs and two outputs. A CTD
counts down the number of pulses detected at the Boolean input CD. The input
PV is used to specify the starting (integer) value of the counter. Each time a
new rising edge occurs on CD the output CV is incremented by one. When the
counter reaches zero, the output Q becomes true and counting stops.
If necessary, the Boolean input LD (load) can be used to clear the output Q to
false and to load the output CV with the value specified in PV.
Down counter
CD
CTD
bool CD Q bool Q
bool LD LD
PV CV=PV
int CV int
CV CV=0
The CTUD is a combination of the other two counter blocks. It has two Bool-
ean inputs, CU and CD, used for counting up and counting down the value in
output CV. Similarly to the two other counters, the integer input PV defines the
counter’s maximum value. When the counter reaches the value specified in PV
the output QU is set to true and counting stops. In a similar way, the output QD
is set to true and counting stops when the counter reaches zero.
If necessary, the input LD can be used to load the value from PV to the output
CV while the input R can be used to clear the output CV to zero.
3BSE021358R4001 59
4.6 Function Block Diagram Chapter 4: Programming Languages
Up-down counter
CU
CTUD
bool CU QU bool CD
bool CD QD bool QU
bool R
QD
bool LD CV int
int PV LD
R
CV=PV CV=PV
CV CV=0
The CTUD is often used in applications where there is a need to monitor the
actual number of items in a process. It could, for example, be used to count the
number of products placed on and taken off a store shelf.
60 3BSE021358R4001
Chapter 4: Programming Languages 4.6 Function Block Diagram
3BSE021358R4001 61
4.7 Sequential Function Chart Chapter 4: Programming Languages
Chart Structure
SFC is a method of dividing the control function into a series of steps repre-
sented by rectangular boxes and connected by vertical lines. Each step repre-
sents a physical state of the system being controlled. On each connecting line
there is a horizontal bar representing a transition. The transition is associated
with a transition condition which, when true, deactivates the step before the
transition and activates the step after the transition. The execution flow is nor-
mally down the page, but SFC can also branch backwards in the chart.
Each step is normally associated with one or more actions. These actions
describe the actual physical behavior in the plant, e.g. open valve, start motor,
and so on. An action can, in some editors, be described directly in the associ-
ated step rectangle. However, in most editors the actions are described as sepa-
rate program statements (normally in ST language) in other code blocks or in
an separate editor window associated with the step. An important consider-
ation in SFC programs is that only the code in active steps is executed.
62 3BSE021358R4001
Chapter 4: Programming Languages 4.7 Sequential Function Chart
All SFC sequences must have an initial step identifying where program
execution starts after system initialization. This step is drawn as a rectangular
box with double border lines. The initial step remains active until the following
transition enables flow to the next step.
Some editors allow the programmer to describe short transition conditions
directly on the SFC, close to the corresponding bar. However with more com-
plex conditions it is better to put the code in a separate window. The program
is often written in ST language but many editors also allow the use of LD, IL,
or FBD languages.
When the sequence has finished, the flow can be terminated by a step with no
associated action. If necessary, the sequence can also repeat the same behavior
cyclically. Cyclic execution is enabled by a conditional branch backwards to
the first step in the flow. To avoid cluttering the SFC with crossing lines,
branches are drawn with a starting arrow where the branch begins and a con-
cluding arrow at the step where the branch ends up. In order to clarify the flow
the transition name is written at both places.
Initial step
Start Transition
Tr1 Transition conditions with code
in other windows
Pusch
Drill
Tr3
Wait
Tr4
Label
Tr5
Stop
Tr6
Fig. 30 Example of an SFC program for an automatic drilling machine. Note the cyclic
execution being enabled by the Tr6 transition condition.
3BSE021358R4001 63
4.7 Sequential Function Chart Chapter 4: Programming Languages
Action Descriptions
Steps in an SFC are used to describe the states of a controlled plant or machine.
When the programmable controller executes an SFC program the state model
only works as an internal memory representation of the control function. In
order to get real-world actions each state has one or more action descriptions
containing program code controlling the physical objects. Any of the four IEC
languages can be used to describe the behavior of an action.
Action descriptions are normally placed in rectangular boxes that are attached
to the step with a connection line. To avoid overloading the SFC with too much
detailed information the boxes can be folded in or out. Most editors use a sep-
arate window or another code block for specifying the actions.
Fig. 31 Example of a step with the associated actions folded out and one of them
described in a separate editor window.
Each action can have one or more action qualifiers that determine when and
how the action is executed. Most editors support the following three action
qualifiers.
• The N action qualifier (Non-stored) causes the action code to be executed
continuously as long as the step is active.
64 3BSE021358R4001
Chapter 4: Programming Languages 4.7 Sequential Function Chart
• The P1 (Pulse rising edge) action qualifier causes the action code to be
executed once when the step becomes active.
• The P0 (Pulse falling edge) action qualifier causes the action code to be
executed once when the step becomes inactive.
To use one or more of the action qualifiers the programmer writes the code
statements in the associated editor window. It is not necessary to use all three
action qualifiers. Most sequences use the N action qualifier, but it is possible
to leave all three qualifiers empty resulting in a step without any actions.
S1
Tr1
S2
Tr2 Tr3
S3 S4
Tr4 Tr5
S5
Tr6
3BSE021358R4001 65
4.7 Sequential Function Chart Chapter 4: Programming Languages
We have earlier seen how divergent paths can be used to execute alternative
paths in sequences. An important characteristic of such parallel branches is
however, that only one step in one of the branches may be active at any time.
However, in many batch process applications there is a need for simultaneous
sequence structure with several branches. The main sequence is used for pri-
mary process control, while secondary parallel sequences are used to monitor
that the process is running normally. Such parallel sequences can e.g. check
that plant temperatures and pressures are within required limits, otherwise the
control system may shut down the process.
In the example below, all three divergent branches start with a common tran-
sition condition. Execution then continues in parallel and independently along
all three paths until convergence is reached. Both the divergent and the conver-
gent flow in simultaneous sequences are drawn with a pair of lines to distin-
guish the construct from a sequence selection.
The transition condition that succeeds the simultaneous sequence structure
will not be tested until all the branches have finished execution, i.e. when the
last step of each branch is active.
Start
Tr1
Acid
Tr2
Tr3 Tr4
Heat Temp
Tr5
Wait
Tr6
66 3BSE021358R4001
Chapter 4: Programming Languages 4.7 Sequential Function Chart
Subsequences
One of the main uses of SFC is as a tool for developing the top down design of
the control function in a complex plant. Most processes can be described by a
relatively small number of main states, each representing a subprocess with a
number of minor states.
Some editors provide a method for dividing large SFC programs into a number
of subsequences, each represented by a general symbol. A subsequence may
in turn contain other subsequences which provides a powerful tool for struc-
turing the overall control function into any number of hierarchical levels. This
allows attention to be focused on either the overall behavior of the entire plant
or on the detailed operation of the controlled process objects.
A subsequence usually contains sequence parts that perform a set of logically
related actions. Steps and actions from different hierarchical levels are never
visible at the same time. To study the inside of a subsequence the programmer
has to step into the subsequence which changes the SFC view, so that only the
contents of the selected subsequence are displayed.
3BSE021358R4001 67
4.7 Sequential Function Chart Chapter 4: Programming Languages
68 3BSE021358R4001
Chapter 4: Programming Languages 4.8 Function Blocks
Application
Program Program
Function
Function block
Fig. 34 The abbreviation POU is a common name for all these program parts.
Function blocks may be regarded as basic building blocks for control systems.
The IEC standard ensures that function blocks can be realized using any of the
five programming languages. Each function block is a well-packaged software
module that can easily be reused in other parts of the control application.
A function block can be compared to an integrated circuit (IC) which is used
in almost all electronic equipment. The use of ICs has simplified the design of
electronic hardware enormously. Function blocks can provide a similar off-
the-shelf solution to common control problems.
3BSE021358R4001 69
4.8 Function Blocks Chapter 4: Programming Languages
The ability of a function block to store both data and algorithms means that it
is possible to develop truly encapsulated control functions. A function block
describes both the behavior of data and the data structure.
The use of function blocks encourages well-structured design which in
return will speed up program development considerably. This is especially true
in large plants containing a lot of similar control functions which means that
function blocks can be reused many times.
It may also be interesting to compare function blocks with objects used in
object-oriented programming. Function blocks contain truly encapsulated data
and also have methods (the algorithm of the control function) for processing
the data. However, other features from object-oriented languages, like
inheritance, are not fully supported by function blocks.
Do not mix up function blocks with the programming language FBD, which
uses a number of predefined function blocks. A function block may be defined
using any one of the five programming languages. Function blocks may also
be called from all the five programming languages.
70 3BSE021358R4001
Chapter 4: Programming Languages 4.8 Function Blocks
Converter2
Function blocks
Converter3
Algorithm
Fig. 36 Function block type and function blocks. The same algorithm is used several
times to calculate the unique sets of data in each function block.
3BSE021358R4001 71
4.8 Function Blocks Chapter 4: Programming Languages
On the other hand, care should be taken not to include so many features and
variations into the function block that it becomes cumbersome to use.
72 3BSE021358R4001
Chapter 4: Programming Languages 4.8 Function Blocks
3BSE021358R4001 73
4.8 Function Blocks Chapter 4: Programming Languages
With the IL programming language you have to call a function block by using
the instruction CAL followed by the function block unique name. The local
variables are specified in a similar way as with ST, as described above.
When a function block type is used with the FBD language the editor presents
the function block instance as a graphical symbol. The programmer only has
to connect the input and output parameters to local variables.
74 3BSE021358R4001
Chapter 5: Object-oriented Programs 5.1 New Life for an Old Method
Chapter 5
Object-oriented Programs
The IEC 61131-3 standard for programmable controllers is not the only effort
towards better program quality, standardization and the reuse of existing pro-
grams in new projects. During the past decade, many program projects have
been realized with a technique called object-oriented programming. In this
chapter, that technique will be compared with the IEC standard for program-
mable controllers.
Examples of object-oriented programming languages include Simula, Small-
talk and C++, the latter being a development of the language C. Other success-
ful examples using object-oriented techniques are the operating systems for
the Macintosh and Windows, both of which have an extensive degree of stan-
dardization of man/machine communication.
Compared with programs that have been produced using more conventional
tools, object-oriented programs require both more memory and better perfor-
mance from the computer. The increased demands on the hardware, however,
can be balanced by great savings in time and improvements in the quality of
the software.
3BSE021358R4001 75
5.1 New Life for an Old Method Chapter 5: Object-oriented Programs
Object
Methods
Variables
Message
Fig. 39 A living cell is object-oriented in the way it works and interacts with other cells.
76 3BSE021358R4001
Chapter 5: Object-oriented Programs 5.2 Objects in the Plant
Fig. 40 Object distribution on the right is more efficient as it needs less communication.
3BSE021358R4001 77
5.3 Data Flow in Real-time Systems Chapter 5: Object-oriented Programs
78 3BSE021358R4001
Chapter 5: Object-oriented Programs 5.4 Program Sorting
output signal is calculated as the sum of the control error, its integral and its
derivative. The integral part is changed automatically with time, which means
that the output signal has to be updated at regular intervals. Similarly, the out-
put signal from a timer has to be updated when the set time delay expires.
3BSE021358R4001 79
5.4 Program Sorting Chapter 5: Object-oriented Programs
soon as the output data have been calculated they immediately become avail-
able to other POUs. This leads to a new execution, etc., in cyclical succession.
During compilation, an analysis is first carried out of the data flow between
objects. The total function of the network of objects is then translated into a
program list divided into blocks, which are then sorted into a suitable order.
Sorting of the object’s program blocks is a complex operation, the aim of
which is to achieve the best ordering for their messages.
80 3BSE021358R4001
Chapter 5: Object-oriented Programs 5.5 Reuse of Code
5.6 Libraries
Nowadays, hardly any companies manufacture their own screws, nuts or sim-
ilar components. The production of standard components is carried out by a
few large companies who have long experience of the business and who can
produce goods of high quality at a low price. When it comes to program devel-
opment using traditional methods, on the other hand, there are still many who
are rediscovering the wheel over and over again.
One of the greatest advantages of object-oriented programming is that it is
easy to reuse objects with standard functions. The software for commonly
occurring objects is then produced by people with long experience which re-
sults in high quality. Examples of objects of this type are PID controllers,
alarm functions, communication units, etc. It is important to document the in-
teraction of the objects with their surroundings accurately, so that it is possible
to use them without knowing anything about their internal function.
Most IEC compliant programmable controllers today are delivered with a
large number of ready-made functions and function blocks stored in standard
libraries, for example, common functions such as timers, counters, pulse gen-
erators, PID controllers, limiters, etc.
3BSE021358R4001 81
5.6 Libraries Chapter 5: Object-oriented Programs
The standard modules are produced by people with many years’ experience of
applications in the process industry. This guarantees high quality in terms of
the modules’ function
.
82 3BSE021358R4001
Chapter 6: Control Modules 6.1 Control Module Concept
Chapter 6
Control Modules
The IEC 61131-3 standard does not fully support all requirements for object-
oriented programs. Some vendors of programmable controllers have therefore
extended their systems with extra functionality. The engineering tool Control
Builder Professional from ABB provides an extension called control modules.
Application
Material A
Material A Conveyor 1
Submodules
Conveyor 2
3BSE021358R4001 83
6.2 Graphical Programming Chapter 6: Control Modules
A control module may have an application program inside the module. Appli-
cation programs can be written in any one of the five IEC programming lan-
guages described in Chapter 4.
Control modules also provide basic supervision capabilities. Current process
status may be presented graphically and the user can feed in parameters
through command buttons and input fields.
Control modules have a great deal in common with IEC function blocks, but
they also expand the functionality with new features such as graphical pro-
gramming and automatic code sorting.
Fig. 45 The project explorer shows the hierarchy of all control modules which are
edited in the Control Module Diagram Editor. Compare this program with Fig. 44.
84 3BSE021358R4001
Chapter 6: Control Modules 6.3 Automatic Code Sorting
The graphical toolbar also has ready-to-use interaction objects, such as com-
mand buttons, option buttons, check boxes, input fields, windows buttons and
non-graphical interaction objects. Such objects make it possible for the user to
change process variables and open or close windows while the programmable
controller is executing the control application. The non-graphical interaction
button is invisible in online mode and is therefore normally placed on top of
another graphical object.
Finally, there are four composite objects: image selectors, string selectors, bar-
graphs and trend-graphs, which may be used for more advanced functions. The
image selector is used for displaying one of several pictures or control modules
in a specified position. The string selector is used in a similar way to display
one of several text strings. The bar-graph tool is used to produce a graphical
presentation of one or more real variables in bar form. The trend-graph is used
for presenting trend curves, that is, several values of variables over a given
time period.
The visibility of objects may be controlled by Boolean variables which offer a
powerful way of showing only the main functionality and temporarily hiding
unnecessary details.
3BSE021358R4001 85
6.4 Applications for Control Modules Chapter 6: Control Modules
The technique is called code sorting and means that the optimal execution
order will be based on data flow instead of program flow (as is the case for
function blocks).
V1
V1 := 10 + P1; P1 := 2; P1 R1 := V1 - 10;
V2 := 20 * P2; P2 := 3 * P1; P2 R2 := P1 + P2;
P1
P2
Fig. 46 Automatic code sorting detects that the control module 2 must be executed first,
followed by module 1 and finally module 3.
Since the execution order of the code blocks in the control modules is deter-
mined automatically, it is possible for one module to make a request to another
module and to react to the answer within the same scan (cycle).
However, when more than one control module uses the same variable for both
reading and writing, the compiler gives a warning message that a program loop
exists, meaning that the execution order cannot be resolved automatically.
Such a problem can be solved by introducing a new intermediate code block
with an extra variable storing the result from the previous scan.
86 3BSE021358R4001
Chapter 6: Control Modules 6.4 Applications for Control Modules
industry and in the food industry. Such program objects can easily be reused
in similar subprocesses. If all the code for process objects is concentrated into
modules, it will also be much easier to manage the maintenance of the plant.
Compared with function blocks, the control module strategy entails a system-
atic and time-consuming design process. Many engineers find this frustrating
since they are eager to produce code. However, the time spent on design is
repaid during the later phases of implementation, i.e. reuse and testing of the
control application.
Control Module
Function Block
Most application programs with control modules also contain function blocks.
The reason for this is that object orientation is not normally cost-effective at
the lowest complexity level in a plant. For simple Boolean logic, traditional
programming with function blocks is a more cost-effective strategy.
3BSE021358R4001 87
6.4 Applications for Control Modules Chapter 6: Control Modules
88 3BSE021358R4001
Chapter 7: Project Management 7.1 Stages of a Project
Chapter 7
Project Management
Analysis
Design
Coding
Testing
Documentation
Commissioning
Maintenance
3BSE021358R4001 89
7.2 Analysis Chapter 7: Project Management
7.2 Analysis
The initial stage of analyzing the control problem is, without doubt, the most
difficult stage in a project. This work has to be done by people with a good
knowledge of both the plant that is to be controlled and of the actual control
system being used. Often, the supplier/programmer of the control system
meets with the other contractors and the operators in the plant to determine
what controls are needed and how the control actions are to be carried out. At
this stage, it is also important to establish what operator controls are needed.
Another important consideration is to provide some form of manual mainte-
nance control that can be used for testing or rescuing an automated plant which
has failed to function as expected.
Experience shows that inadequate analysis will be very difficult and costly to
correct in the later stages of a project. Although programmable controllers are
easy to reprogram such work will be very time consuming if it has to be carried
out during the commissioning stage.
The result of the analysis stage is a description of how the plant will work,
what operator stations and control are needed and how these will be imple-
mented, what maintenance aids are to be included and a complete list of the
I/O signals, together with electrical specifications and physical location in the
plant. At this stage, the final testing requirements should also be defined.
7.3 Design
In large control applications, the programmer should not write a single, long
application program, but instead break it down into many small program parts,
if possible in an object-oriented structure. Ideally, each program part should
contain no more than about ten logical conditions, since this is the maximum
most human minds can hold at any time.
Over the years many methods have been developed which make the work sim-
pler and also result in better software quality. By working from the top down,
and breaking down the function of the installation into a hierarchical structure
of programs, the whole problem can be divided up into manageable parts.
In the IEC 61131-3 standard these parts are called POUs. A hierarchical struc-
ture is used with POUs at different levels, where every POU represents its own
particular part of the plant. The highest level in the hierarchy gives an over-
view, while the subordinate levels contain more and more detailed informa-
tion, the lower down one goes. In large industrial plants this method results in
considerable improvements in software quality.
90 3BSE021358R4001
Chapter 7: Project Management 7.3 Design
POUs at the higher levels in the hierarchy are constructed of a number of other
POUs which, in turn, can contain further POUs, and so on. The hierarchy can
therefore also be written as a block diagram, in which every POU contains sub-
ordinate POUs.
Fig. 49 Comparison between block diagram and POU hierarchy for an installation.
Assuming that the collaboration between POUs has been accurately specified,
it will be easy for several people to work together on building up the applica-
tion program. It is normally not necessary to know exactly how a complete
POU is constructed or how it works inside in order to be able to use it; we only
need to know how it interacts with other POUs.
One limitation of the top down method is that it can be difficult to draw bound-
aries between program POUs at the beginning of a project. Such problems are
often not discovered until much later, and it can then take a very long time to
correct finished program modules. The need for restructuring grows with the
total size of the program project.
An alternate method is to work from the bottom up, where complete POUs are
produced at a lower level without having to take account of the structure above
them. Each such POU can be tested and optimized individually, and can then
be used in different plant application programs. The disadvantage of this meth-
od is that the POUs have to be very generalized, which produces less effective
program code than with the top down method.
The object-oriented approach is the newest method for structuring large con-
trol applications. Physical plant objects are programmed as self-contained
modules communicating with other modules in a data flow-driven model.
When working with object-oriented programming, the top down method is
often used at the beginning of a project, while the bottom up method is best for
handling the internal object behavior. Object-oriented programming is
described in Chapter 5.
3BSE021358R4001 91
7.4 Coding Chapter 7: Project Management
7.4 Coding
Based on the structure laid down at the design stage, the coding can now be
done with any of the five IEC programming languages. If the initial two stages
of analysis and design have been carried out carefully the coding need not
involve more than 10% of the total time spent on a project.
An effective design with well-defined behavior and carefully defined interac-
tions between different subprocesses makes it possible to divide the work of
coding between several programmers. However, it should be noted that such
project groups must be managed by an experienced project leader with a good
overview of the entire control function.
During the work on coding it will sometimes be necessary to further specify
the control function in some of the plant subprocesses. There may also be a
need to divide some subprocesses into further subprocesses.
7.5 Testing
All control systems must be tested carefully before they are allowed to interact
with the real-world plant process. A very important advantage of software-
based control systems is that testing can be carried out with the system running
offline, without communicating with the process. Most computer-based engi-
neering stations have a useful simulation feature providing graphical display
of selected control functions. The programmer manually provides input sig-
nals via the engineering station, thereby simulating the real transducers. The
resulting actions of actuators are calculated by software in the engineering
station and presented graphically on the screen.
Fig. 50 Simulation of
SFCs is a very powerful
method for testing the
control function in a
subprocess.
92 3BSE021358R4001
Chapter 7: Project Management 7.5 Testing
With all but the simplest systems, it can be very time consuming to check all
the controls and actions that have been specified in the analysis. In many
projects there is spoken or unspoken pressure to hand over the plant control as
soon as all the basic operations have been tested, but with more rarely used
options untried. Too often, such tests are omitted and faults are not discovered
until years after the plant has commissioned. It is therefore very important to
establish what testing must be carried out before the plant can be started and
what can be tested later, online when the plant is in operation.
However, safety-related testing must never be omitted. Finding out that an
emergency stop sequence does not work when it is used for the first time in a
real emergency will definitely create a disaster.
3BSE021358R4001 93
7.6 Documentation Chapter 7: Project Management
7.6 Documentation
At every stage in a project new documents are added describing the plant from
several different aspects. After successful testing, all these documents have to
be gathered together to provide total documentation of the plant control sys-
tem. It is therefore very important that all documents are updated with changes
made to the control function during the project. Since it is very easy to alter
the control function in programmable controllers there always is a risk of
losing grip on the plant after program changes.
The purpose of the documentation is both to help the operators during normal
use and to serve the maintenance personnel when something goes wrong. It is
therefore very important that the documents are well structured and adapted to
the needs of both these categories.
When a new control system is introduced in a plant all personnel involved must
be informed about the system. Well structured documentation is one of the best
tools for this purpose.
7.7 Commissioning
If the application has been tested thoroughly offline, the online test together
with the process should not result in any unpleasant surprises. In many plants,
commissioning is an undramatic experience. However, if there are some pro-
cess conditions that could not be simulated effectively offline, the online test-
ing may be very difficult, time consuming and therefore also very expensive.
The cost of online testing together with the process may sometimes be more
than ten times higher than testing offline.
7.8 Maintenance
The final maintenance stage seems to be very far away during the earlier stages
of a project. However, once a plant control system is handed over it must be
maintained, which includes fault finding and minor changes in the specified
control function. Such changes are often a response to market needs or to new
technologies being developed.
Experience shows that the maintenance stage accounts for almost 50% of the
total time spent on a project during its life-time. Therefore, it is of vital impor-
tance that control programs be developed and documented so they can be
easily changed, also by people who were not involved in the previous stages.
94 3BSE021358R4001
Chapter 8: Industrial Application Example 8.1 Control Problem
Chapter 8
Industrial Application Example
In this final chapter we are going to apply the earlier described structuring
methods and programming techniques to a real-world plant. To keep complex-
ity at a reasonable level we will concentrate our efforts on one of many sub-
processes in the manufacturing line of an automobile factory.
Conveyor
ES
LSL
Forward/Back
Open/Close
Machine
LSR
Fig. 52 The industrial robot moves car parts between a conveyor and a machine.
3BSE021358R4001 95
8.2 Analysis Chapter 8: Industrial Application Example
8.2 Analysis
The robot has three different electrical engines which move the manipulator.
The entire arm can rotate left or right, the foremost part of the arm can also
move forwards or backwards and the gripper, finally, can open or close. The
reason for moving the arm forwards and backwards is that there is limited
space when the arm rotates between the conveyor and the machine.
All the movements are to be controlled by six digital output signals from the
programmable controller. The robot system uses four limit switches to collect
information about the current position of the arm. The gripper has a mechani-
cal device that stops it from pressing too hard on closing and opening. This
makes it possible to hold the output signal from the control system for a short
while after the gripper has reached its final position, thereby eliminating the
need for two limit switches. All the inputs and outputs are summarized in the
table below.
In its initial state the robot is placed at the conveyor with the arm in its back-
ward position and with the gripper fully open. If the machine has completed
the previous operation a command from the conveyor control program starts
the robot arm moving forward. When the arm reaches its forward position
(indicated by LSF) the gripper begins to close around the car part. The total
time needed for the gripper to close completely is 2 s. With the gripper closed
around the car part the arm is now moved backwards and when LSB is active
the arm begins to rotate right towards the machine. When LSR at the machine
96 3BSE021358R4001
Chapter 8: Industrial Application Example 8.2 Analysis
indicates that the arm is in the correct position it begins to move forwards
again, which continues until LSF is active. The gripper now opens and releases
the car part to the machine. The total time needed for the gripper to open com-
pletely is 1 s. After this, the arm is moved backwards until LSB is active fol-
lowed by a turn to the left until LSL indicates that the arm is back in its initial
state.
In order to minimize energy consumption and reduce the risk of damaging the
equipment and the car parts, all robot movements should start and stop
smoothly. This is accomplished through a ramp signal with a duration adapted
to the needs of the different movements and for start and stop.
The conveyor and the machine are both controlled by other control programs.
The robot control program has to communicate with these via the following
four Boolean parameters:
If something goes wrong in the plant the operator stops the control system via
an emergency switch. All motors must then stop immediately. After an emer-
gency situation the operator puts the system into its initial state by controlling
the motors manually in a normal sequence.
All the transducer signals from the limit switches and the emergency switch
are of digital type. Since the robot motors should be started and stopped
smoothly, all the actuator signals have to be of analog type. This means that
our programmable controller must have an I/O unit with five free digital inputs
and six free analog outputs.
3BSE021358R4001 97
8.3 Design Chapter 8: Industrial Application Example
8.3 Design
The analysis has shown that our robot is a self-contained system with relatively
limited communication with the surrounding subprocesses in the plant. Since
the plant contains several similar robots the control problem should preferably
be solved via an object-oriented robot control module. Such a module may be
reused several times in the plant, thereby standardizing the operator interface
and reducing the programming work.
Conveyor_Request Machine_Ready
Conveyor Robot Machine
Robot_Home Robot_Ready
The robot control module should have a graphical symbol with color shifts
indicating its state. Gray may be used to signify inactive, green for active
(moving car parts) and red for emergency state.
According to the top down strategy the robot control module should contain
an SFC sequence program, which together with a control program (interlock-
ing with emergency switch), handles the movement of the robot arm. The con-
trol program uses the internal states of the SFC sequence interlocked with the
emergency signal to control the motors. All motor controls will pass through
a ramp function block generating a smoothly increasing or decreasing output
signal.
98 3BSE021358R4001
Chapter 8: Industrial Application Example 8.3 Design
Technicians who are not familiar with SFC often use flow charts to describe
sequential behavior. Such flow charts are easy to follow, even for those with
no engineering background. But unfortunately they often become very large
and therefore will be difficult to manage in large plants. The sequential control
function for our robot arm is shown in such a flow chart below. The sequence
uses eight different working states plus the initial waiting state
.
Init 1
CR N AF
and
MR
Y N
LSF
AF
Y
N GO
LSF
Y
Delay N
GC 1s
Y
Delay N
AB
2s
Y
N
AB LSB
Y
N
LSB AL
Y
N
AR LSL
Y
N
LSR
Y
1
Fig. 55 Flow chart describing the control function for our robot sequence.
3BSE021358R4001 99
8.4 Coding Chapter 8: Industrial Application Example
The ramp function block type should generate a smooth increase or decrease
in the analog output as soon as the digital input is turned on or off. It must be
possible to change the ramp up and ramp down times depending on which
movements are to be controlled. An example of such a ramp timing diagram is
shown below.
Input
100%
Output
0% 1s 0.5 s
The ramp function block should be programmed via cyclical addition and sub-
traction. In order to produce a smooth output, the function block must have a
shorter interval time than the rest of the application, e.g. 100 ms compared
with the normal 250 ms.
8.4 Coding
Our robot control project will now be implemented with the engineering tool
Control Builder Professional from ABB. The control project will be developed
for downloading to an AC 800M programmable controller, equipped with a
digital input I/O module and an analog output I/O module.
Project Libraries
All project-specific control modules types, function blocks types, functions
and data types that are to be used several times are normally placed in one or
several project-specific libraries. Such control functions can easily be reused
in a similar manner as the objects in SystemLib. In large projects with several
programmers involved, it is advisable to appoint one programmer to be respon-
sible for the project-specific libraries and to allow the others to use them as
read-only files. In our example, we will create a library called MyLib for that
purpose.
Since the robot control module and the ramp function block will both be used
several times in our application, they should both be placed in MyLib. All the
100 3BSE021358R4001
Chapter 8: Industrial Application Example 8.4 Coding
underlying control modules used in the robot control module will automatical-
ly be available as control module types in MyLib.
Following the rules of object-orientation we will use a structured variable for
communication between the robot module and its surrounding modules. The
data type of this variable, called Robot_Communication, should also be placed
in MyLib.
3BSE021358R4001 101
8.4 Coding Chapter 8: Industrial Application Example
Global variables are available at all module levels in an application which sim-
plifies the programming. Unfortunately, this also increases the risk of data cor-
ruption, since all modules may write to such variables.
Using local variables gives better encapsulation of data but also has a small
disadvantage in that modules cannot be moved in the hierarchy once the con-
nection to the I/O unit is established. In our project we will choose this last
method.
Fig. 58 Local variables used in our robot control module. RealIO and BoolIO are both
composite data types containing the current value plus a number of components used
for manual signal forcing.
The only parameter needed in the robot control module is the project declared
Robot_Communication used for signal exchange with other modules.
102 3BSE021358R4001
Chapter 8: Industrial Application Example 8.4 Coding
Fig. 59 The ramp function block type uses conditional cyclic addition or subtraction of
a step value that is calculated from the time demands on the ramp signal.
The ramp will be used six times for the different robot motor outputs and the
ramp function block type must therefore be created six times. In order to create
almost linear output signal these function blocks should be executed with a
shorter interval time than the SFC sequence and the control program.
A shorter interval time is accomplished by connecting the six function blocks
to the Task Fast and setting its interval time to 100 ms in the Tasks window.
3BSE021358R4001 103
8.4 Coding Chapter 8: Industrial Application Example
Fig. 60 The robot sequence as an SFC code block with the selected transition condition
Tr4 in a separate window.
Our sequence uses two timer function blocks to create delays in the states
Close and Open. The required timer statements are placed in the code windows
for continuous action at the two corresponding steps.
104 3BSE021358R4001
Chapter 8: Industrial Application Example 8.4 Coding
Control Program
Normally, the binary status from an SFC step (Stepname.X) is not used direct-
ly for controlling the outputs in a process. The reason for this is that there is
often a need to interlock the step status with other variables such as emergency
signals. Additionally, many systems do not have a one to one relation between
the steps and corresponding process actions. In our robot sequence either the
step Forward1 or the step Forward2 should result in the same action. This is
also the case for the steps Backward1 and Backward2.
From the above mentioned it is evident that there is a need for an extra control
program block containing the interlocking logic and the “summing up” of the
different conditions for activation.
This program block is also a suitable place in which to call the ramp function
block that are to create smooth robot arm movements.
Finally we must not forget to create the two Boolean signals that are used to
tell other control modules that the robot has moved a car part to the machine
and that it is back in it’s initial position at the conveyor.
Fig. 61 The robot control program is used to connect the Boolean step states with the
analog motor outputs via six function blocks of the ramp function block type.
3BSE021358R4001 105
8.4 Coding Chapter 8: Industrial Application Example
106 3BSE021358R4001
Chapter 8: Industrial Application Example 8.5 Testing
8.5 Testing
When large applications are to be tested it is of vital importance to reduce the
complexity by first testing smaller program parts, like function blocks, and
control modules, separately. Once the smaller parts have been debugged the
entire application can be tested more effectively. All testing normally follows
such a bottom-up procedure.
Most engineering stations have a simulation feature where an entire program
project can be tested without compiling and downloading it to the programma-
ble controller. Real-world input signals are then fed in manually either by typ-
ing on the keyboard or by the pointing device.
In our robot project the testing starts with the ramp function block. If a func-
tion block is connected to surrounding local variables it is possible to simulate
and observe the function. The sequence function is very easy to test via simu-
lation since the status is displayed directly on the screen.
3BSE021358R4001 107
8.5 Testing Chapter 8: Industrial Application Example
When function block types and control module types are to be tested it is nor-
mally best to work with a funbction block and control module and connect it
to other modules providing the necessary parameter communication. It may
sometimes be necessary to create variables or control modules that are used for
testing only and deleted afterwards.
108 3BSE021358R4001
Chapter 9: Glossary 8.5 Testing
Chapter 9
Glossary
A
adaptive control
Control system where the controller parameters are automatically adjusted
to the properties of the process.
algorithm
A collection of rules which describe, step by step, how a problem is to be
solved.
analog signal
A continuously variable signal which represents a physical quantity, e.g.
temperature, flow or pressure.
application
The application contains a number of instructions that are compiled and
downloaded for execution in the controller.
ASCII
An abbreviation for American Standard Code for Information Interchange.
ASCII is the most commonly used code for character representation in data
processing systems.
assembler instructions
A low-level programming language using letter codes to represent the
machine code instructions.
3BSE021358R4001 109
8.5 Testing Chapter 9: Glossary
B
baud
A unit used to specify the data transmission rate between two devices.
One baud is equal to one bit per second.
Boolean
A variable that can only hold logical values such as True and False or
1 and 0.
bottom up
A method for structuring application programs where the individual
program objects are developed without consideration of the program
structure above them.
bus
A system of parallel circuit wires for connecting the different units in a
computer system or a programmable controller.
C
compiler
An application program that translates the control application to low-level
machine language that can be executed in a computer or programmable con-
troller.
CPU
The Central Processing Unit in a computer or programmable controller is
the “brain” that coordinates all activities and carries out all operations speci-
fied in the application program. In PLCs the name Central Unit is
often used instead of CPU.
cycle time
All application programs in programmable controllers are executed
repeatedly at a specified time interval.
110 3BSE021358R4001
Chapter 9: Glossary 8.5 Testing
D
digital signal
A signal with only two possible states, called high and low, on and off
or 1 and 0.
distributed systems
A control system with several computers or programmable controllers
communicating with each other via a local network.
download
A common name for the transfer of a compiled application program from
the engineering tool to the programmable controller.
E
editor
Application program that is used for writing and editing text or instructions.
execution
When a computer is running the instructions are executed one at a time.
F
falling edge
The change from 1 to 0 of a Boolean variable.
feedback
A signal from the controlled process may be fed back to the controller
where it is used in the control algorithm.
fieldbus
A communication bus used for digital information interchange between
sensors, actuators and programmable controllers.
full duplex
A transmission method where data can be both transmitted and received
simultaneously.
3BSE021358R4001 111
8.5 Testing Chapter 9: Glossary
G
gateway
A communication unit for connecting different types of networks.
It translates between different communication protocols.
global variable
A variable that can be accessed by all programs.
H
half duplex
A transmission method where data can only be transmitted in one direction
at a time.
hardware
A common name for all the equipment in a computer system.
hexadecimal
A system of numbers to the base 16. The numbers 0 – 9 are not changed
while 10 – 15 are represented by the letters A – F.
high-level language
A programming language similar to ordinary written text where each
instruction or statement results in several machine code instructions.
Pascal, C and Java are common high-level languages.
112 3BSE021358R4001
Chapter 9: Glossary 8.5 Testing
I
I/O module
Many programmable controllers use expandable I/O units making it
possible to add more input or output signals via extra modules.
I/O signal
The physical inputs or outputs of the I/O module.
identifier
A combination of letters, numbers and other characters used to give names
to variables, parameters, modules and other language objects.
initialization
Establishing basic conditions when a system starts up.
instruction
A programming language element that specifies an operation and the values
or location of its operands.
integrated circuit
Electronic functional unit containing a large number of semiconductors
which have been compressed to a small silicon chip.
L
LAN
Abbreviation for Local Area Network. A LAN is used to enable high-speed
communication between several computers and programmable controllers
in a plant.
local variable
A variable that can only be accessed in the program where it is defined.
low-level language
A programming language with letter codes where each instruction results in
one machine code instruction. Assembler is a typical low-level language.
LSB
An abbreviation for Least Significant Bit, i.e. the bit in a binary number with
the lowest value.
3BSE021358R4001 113
8.5 Testing Chapter 9: Glossary
M
machine code
When a computer executes a program it must be available in machine code
language which is a low-level language with binary or hexadecimal codes.
MMS
An abbreviation for Manufacturing Message Specification, which specifies
the messages used for industrial communication (manufacturing, process
robotics etc.). This is the application layer used within MAP (Manufactur-
ing Automation Protocol), a specification for open communication based on
the OSI model.
MSB
An abbreviation for Most Significant Bit, i.e. the bit in a binary number with
the highest value.
O
object code
Common name for the resulting code produced when the compiler has
translated an application program to executable machine language.
octal
A system of numbers to the base 8. The decimal digits 8 and 9 are not used
in this system.
offline
A computer (with editor and compiler) that is not connected to the controller
is considered to be offline. This is the normal situation for editing the source
code.
online
A computer (with editor and compiler) is considered to be online when it is
connected to the controller where the program is being executed. This is the
normal situation with the plant application executing and the process status
being displayed in the editor.
114 3BSE021358R4001
Chapter 9: Glossary 8.5 Testing
P
PLC
An abbreviation for Programmable Logic Controller which is the most
common type of control system in today’s industry.
POU
An abbreviation for Program Organisation Unit. The IEC standard
describes programs, function blocks and functions as POUs.
protocol
A set of rules which determines the procedure for communication between
different I/O units, computers or controllers.
R
RAS
Abbreviation for Remote Access Service. With RAS a remote client can dial
up a gateway machine resident on a LAN and establish a connection over
the telephone network.
real-time system
A system where changes in the input signals will result in immediate actions
on the corresponding output signals. Almost all control systems are of this
type.
rising edge
The change from 0 to 1 of a Boolean variable.
RS-232C
International standard for serial data transmission with the signal levels
-12V and +12V. Mainly used over relatively short distances.
3BSE021358R4001 115
8.5 Testing Chapter 9: Glossary
S
sampling
Computer-based control systems cannot communicate continuously with
the surrounding transducers and actuators. Instead, the control system
samples the environment (collects and transmits values) periodically with
a specified sample time.
SattBus
A fairly fast (62.5 kbit/s) fieldbus with token bus protocol. It is intended to
be used for short messages to field devices such as transducers, actuators,
etc.
simulation
Many computer-based engineering tools provide a function for simulating
the control function in the computer without downloading it to the program-
mable controller.
source code
Programs written in high-level languages are often called source code
before they are compiled to object code.
T
TCP/IP
An abbreviation for Transmission Control Protocol/Internet Protocol.
TCP/IP is used both on the Internet and on many Local Area Networks.
top down
A method of breaking down the entire control function into a hierarchical
structure of subprocesses.
W
workstation
A common name for a computer with associated software used for editing
and compiling control programs.
116 3BSE021358R4001
Index
Numerics control modules 83 I
controller 9
3964R 23 I/O unit 19, 20
cross-assembler 16
IC 10, 69
identifier 37
A
D IL register 47
abstract classes 81
data flow 79 inheritance 70, 81
access variable 40 initial step 63
accumulator 47 data structure 31
DCS 28 initial value 40
action 62
debugging program 16 instance 53, 70, 76, 81
action description 64 instruction 16, 46
action qualifier 64 definition/type 76
distributed system 23 instruction list 21
actuator 10
divergent path 65 integrated circuit 60
analyze 90 interaction object 85
assembler 16 download 21
Duration 39 internal state 78
assembly language 46
interpreter 17
interval time 22, 31, 80, 103
B E
edge 56
Basic 18
editor 16, 21
L
batch process 65, 86 label 46
Boolean data 39 elementary data type 38
encapsulated data 43, 70 ladder diagram 20
bottom up 32, 91
engineering station 19, 21 LED indicator 93
event 31 libraries 12
C execute 16, 22 local area network 11
C 18, 50 expression 50 local variable 40, 101
C++ 75 loop 86
central unit 19 low-level language 17
F
class 76
feedback loop 41
closed loop control 13
flow chart 99
M
code sorting 86
function 54, 72 machine code 16, 21
COMLI 23
function block 32, 54, 69, 72 Macintosh 75
comment 38, 46 main state 67
common elements 37 function block name 72
MAP 29
communication protocol 23
memory 12, 19
compatibility 27 G memory bit 42
compiler 17, 21 global variable 40, 101 message 76
compliance class 33 Grafcet 62 methods 70, 76
composite object 85 minor state 67
conditional statement 51
constant 39
H MIS 29
high-level language 17 mnemonic 47
contact 41 monitoring subsystem 12
Control Builder Professional 21,
83
3BSE021358R4001 117
Index
O state 44
statement 50
object 76
step 62
object code 18
object-oriented programming 75 Step active flag 64
structured data type 38
object-oriented systems 12
subclass 76
offline 21, 92
online 22, 93 subprocess 12
subroutine 43
operand 46, 50
subsequence 67
operator 46, 50
operator modifier 47 syntax 16
syntax checking 21
optical isolator 20
SystemLib 100
P
T
parameter 54, 70, 72, 76
task 23, 103
Pascal 18, 50
PID controller 13, 78 Time of day 39
timer 79
PLCopen 33
top down 32, 67, 90
plinth 14
POU 31, 40, 69, 77, 90 transducer 9
transition 62
power rails 41
transition condition 62
process computer 11
Process Value 13 type 70
Profibus 23
Programmable Controller 11, 19 V
Programmable Logic Controller variable 40, 76
11, 19
protocol 28
W
Windows 75
R
real-time system 22, 78
relay coil 13, 41
relay logic 13
remote I/O 23
result register 47
retain 40
S
SCADA 11, 28
semantics 49
sensor 43
sequence 12, 44
sequence selection 65
Set Point 13
shareware 26
Simula 75
simulation 21, 92
simultaneous sequence 66
Smalltalk 75
Soft PLC 23
source code 18
standard libraries 60, 81
118 3BSE021358R4001
3BSE021358R4001
October 2004