92
TOMSK POLYTECHNIC UNIVERSITY S.V. Efimov COMPUTER-AIDED SYSTEM SOFTWARE Recommended for publishing as a study aid by the Editorial Board of Tomsk Polytechnic University Tomsk Polytechnic University Publishing House 2014

COMPUTER-AIDED SYSTEM SOFTWARE

  • Upload
    others

  • View
    1

  • Download
    0

Embed Size (px)

Citation preview

Page 1: COMPUTER-AIDED SYSTEM SOFTWARE

TOMSK POLYTECHNIC UNIVERSITY

S.V. Efimov

COMPUTER-AIDED SYSTEM SOFTWARE

Recommended for publishing as a study aid

by the Editorial Board of Tomsk Polytechnic University

Tomsk Polytechnic University Publishing House 2014

Page 2: COMPUTER-AIDED SYSTEM SOFTWARE

UDC 004.41(075.8) BBC 31.3я73

E91

Efimov S.V. E91 Computer-aided system software: study aid / S.V. Efimov;

Tomsk Polytechnic University. – Tomsk: TPU Publishing House, 2014. – 92 p.

The training manual provides basic information on automation systems,

approaches to their developing and stages of designing software. The training manual has been prepared on the basis of the original Russian

language materials and it is fully consistent with the course of «Computer-aided system software».

UDC 004.41(075.8) BBC 31.3я73

Reviewers

Candidate of Physical and Mathematical Sciences Senior Research Associate

Institute of Monitoring of Climatic and Ecological Systems of the Siberian Office of the Russian Academy of Sciences

A.I. Gribenyukov

Doctor of Technical Sciences, Professor The Head of Department of Automated Control Systems

A.M. Korikov

© FSAEI HE TPU, 2014 © Efimov S.V., 2014 © Design. Tomsk Polytechnic University

Publishing House, 2014

Page 3: COMPUTER-AIDED SYSTEM SOFTWARE

3

INTRODUCTION

The progress of technical, economic, social, and other spheres is hardly thinkable without automation of different processes at the present time. Automation of these processes is based on automation control systems which combine different sensors, tools, actuating mechanisms, microprocessor-based units, etc.

Automatic control system (ACS) is the firmware complex that provides automated collecting, processing, transfer and storage of data, which aimed at control optimization in different fields of human activity according to accepted standards. ACS are applied in different spheres nowadays: in power engineering, transport, industrial sector, etc. The term «automatic system» means the involvement of human resource in this system, i.e. a part of control function in either process is imposed on an individual.

Experience gained from the design and implementation of ACS makes it plain that the process control is based on set of rules, criteria, laws and requirements for this kind of control systems.

This book is devoted to automatic control system design, including ACS classification and types, standard requirements to ACS, ACS architecture, programmable logic controllers (PLC) designed to process automation, software for PLC and operator control stations.

Page 4: COMPUTER-AIDED SYSTEM SOFTWARE

4

1. ACS CLASSIFICATION

ACS are divided into two groups-information systems and control systems-according to general classification which is presented in modern bibliography devoted to automatic system control. The individuals, PLC, operator control station (OCS) play their own roles in these systems.

1.1. Information Systems

Information systems provide collecting, processing and output of measured information signals about technological or production progress in legible form: tables, mnemonic diagrams, graphs, trends, etc. Operator or control system determine what controlling actions are necessary at achieving optimal and favorable environment for the process behavior based on data received and related calculations. Data received can also serve as recommendations on process progress for operator. It is the individual who plays a key role for this type of systems. He makes decisions on process control based on knowledge provided by information ACS.

The primary task of these systems is accurate acquisition of production process performance information by operator. It enables the operator to make decisions for effective process control.

Information systems provide the process performance information and the information about situation caused by process parameter deviations.

Information systems are divided into passive and active systems. The passive system task is the information gathering for operator about process progress by operator request. The active information systems provide operator with data at given intervals or periodically and can include process control recommendations.

1.2. Control Systems

Control systems maintain the generation of control actions on executive mechanisms, or command executors, along with information acquisition and processing. The generation of control actions on executive mechanisms is performed in a real-time mode, i.e., at the same rate as the production process. Computing facilities perform the key role on control action generation in control systems.

Page 5: COMPUTER-AIDED SYSTEM SOFTWARE

5

2. ACS TYPES

According to purpose and application ACS can be divided into several types: automatic process control system (APCS), automatic control system of production (CAM), integrated automatic control system (IACS).

Each of the automatic control systems solves specific class of problems and has a set of functions and properties.

2.1. APCS

APCS is a system which provides acquisition and processing of information about technological process and generates control action on the control object according to given control parameters.

The tasks of APCS are operational status control of automation object, technological process control, etc.

APCS includes the firmware complex that provides technological process automation of any production as a whole or each production area taken separately.

APCS may include automatic control systems, and also microprocessor-based devices, which perform the local tasks of any object control. All these automation devices, including PLC, are combined in a complex system. APCS is a layered-structured system. Usually, the high-level operating system deals with information acquisition and storage about the technological process progress. There are different forms of information representation: trend, tables, graphs, mnemonic diagrams, etc. Operator can realize the remote control of technological process via the operating system interface. The system may have several OS depending on feasible APCS complexity and structure, e.g. performing such a task as backup and maintenance of APCS from the individual engineering station, etc. The industrial interfaces are used for the data connection of all local nodes and subsystems (PLC, OS, microprocessor-based devices, etc.).

The industrial implementation of APCS helps solve a number of problems and gain some advantages:

1) to provide manufacturing process safety using safety instrumented systems eliminating in this way human factors, un-cooperation of operators or their response time;

2) to cut the control system cost reducing the number of local devices, recording units and regulators (but this condition is not always satisfied);

Page 6: COMPUTER-AIDED SYSTEM SOFTWARE

6

3) to cut prime cost, boost productivity and improve production quality introducing a number of automated production procedures and optimization of equipment operation used in manufacturing process.

4) to implement the complex algorithms with a large amount of manufacturing process parameters. It is only possible if a certain number of PLC tasks is accomplished.

2.2. CAM

Computer-aided manufacturing system is a system designed for solving control problems related to production and business activity of a company.

The CAM objective is solving following problems of industrial management: business tasks (supply, sales, financial resources), personnel management is also of great importance in ACS (documentation, salary accounting, employment and dismissal procedures). The company document control is provided by means of CAM. Control actions are ensured by different documents – work instruction, orders, reports, etc. – and execution of these documents are realized by personnel in this system.

The possible tasks of CAM may include production planning adjusted for organization capacities, product analysis, production process modeling, product distribution and sales. Implementation of CAM leads to productivity improvement of organization.

2.3. IACS

Both APCS and CAM can run separately. However, organizations may combine them in one general system – IACS – to increase the production process efficiency. Coordinated control both of product or raw material technologies and industrial management within the entire organization is carried out by IACS. IACS application enables to organize the coordinated control of technological and production processes, and optimize enterprise activity as a whole. It should be noticed there are not so many organizations in Russia that can afford to explore these IACS- this will entail extensive business process reengineering and high financial expenditure. Organizations like Gazprom, Rosneft, Norilsky Nikel can afford the implementation of such systems.

APCS hereinafter referred to as ACS.

Page 7: COMPUTER-AIDED SYSTEM SOFTWARE

7

3. ACS ARCHITECTURE

ACS architecture has layered structure. Field equipment is located at one level: detecting elements, sensors, actuating mechanisms. Cross equipment, control cabinets, including PLC are located at other level. OS used by operator for technological process control is at the third level. However, applying of particular control systems causes some of the finer points and complicated practical issues related to standardization, safety, commercial effectiveness, manufacturing equipment compatibility, etc. All these moments have eventually an impact on architecture of a designed ACS.

3.1. Architecture Requirements

ACS architecture is its abstract representation including idealized system components, and also interaction facilities between these components. Elements of architecture are interconnected and act as a one system, which provides problem solution of technological process automation at architecture level. Furthermore, architecture affords the opportunity to choose specific technological solutions due to project configured equipment, different data transfer interfaces, sensors and converters with different interfaces. So, properly designed system enables a variety of implementations by selecting architecture components and methods of their interaction.

Architecture elements are sensors, input-output devices, PLC, OS, interfaces, field bus networks, actuating mechanisms, drivers, etc.

The following characteristics should be provided by ACS architecture design: • loose coupling of architecture components; • testability; • diagnosability; • maintainability; • reliability; • safety; • easy service and operation; • security; • economical efficiency; • modifiability; • functional expandability; • extensibility; • openness.

Page 8: COMPUTER-AIDED SYSTEM SOFTWARE

8

3.2. Architecture Varieties

Different ACS structures are widely known at present: hierarchical, centralized, decentralized, etc. Each of them has its own advantages and disadvantages. A designed system structure is chosen depending on the tasks to be realized within manufacturing automation, technological algorithm complexity, system equipment.

Figures 1, 2, 3 present different layouts of ACS structure.

Figure 1. Centralized ACS Structure

A single central microprocessor-based device (SCC – supervisory computer complex) is used for acquisition and processing of information about all parameters and control instructions in centralized ACS structure.

The centralized structure is characterized by high control performance as SCC contains all the information about process status.

The disadvantage of this structure is low reliability because the SCC failure causes the failure of the entire system. It is possible to improve system reliability by SCC backup that leads to increase in the system cost.

Figure 2. Decentralized ACS Structure

PLC

Sensors Actuating Mechanisms

Technological Process

SCC

Sensors Actuating Mechanisms

Technological Process

Page 9: COMPUTER-AIDED SYSTEM SOFTWARE

9

Decentralized structure includes series of stand alone systems designed on the basis of separate PLCs. The control of PLC operation is performed by adjustment of initial setting or programs.

The advantage of the system with decentralized structure is high reliability (a PLC failure doesn’t cause failure of the entire system). A drawback of the structure is the lower quality of control compared to centralized structure, because there is no controller coordination in the process.

Figure 3. Hierarchical ACS Structure

An OS (operating system) is used for coordination of PC operation in hierarchical structure. Such a system provides high reliability and high quality of control. Most automatic control systems today are designed based on hierarchical structure.

3.3. Information Flows

A large number of sensor elements different in design and operation principle are applied nowadays (detectors and sensors of temperature, pressure, level, rate, acceleration, frequency, humidity). Sensors generally convert physical quantities to unified electric signals. Then, the signal is transmitted to PLC input module, where analog-to-digital converter (AD converter) and microprocessor are built in. The microprocessor allows to linearize sensor response, compensate errors, apply data filters. Input module is directly connected to PLC. It was previously mentioned that PLC are configured according to project, it means that all the components – microprocessor, interface, input-output modules are selected relying on system parameters, complexity of technological algorithms and tasks.

PLC Sensors

Sensors Actuating Mechanisms

Technological Process

OS

Page 10: COMPUTER-AIDED SYSTEM SOFTWARE

10

There are various input-output modules, which differ in number of processing signals, type of actions (analog, discrete, impulse-number actions, etc.) Also, analog input-output modules are divided into current-controlled (4–20 мА, 0–20 мА, 0–5 мА), voltage (0–10 В, 0–5 В, 0–100 мВ, etc.), thermal resistance converters (platinum, copper converters, etc.), thermocouples (chromel-alumel, chromel-copel, etc.)

In addition to analog input modules, discrete input modules are widely used. These modules don’t comprise ADC and handle signals that have two levels (limit switches, level detectors, pressure, temperature sensors, door sensors, etc.).

Impulse-number input modules have discrete input and calculate an amount of impulses or impulse frequency. These modules are applied, for instance, by shaft motor speed measurements.

To realize technological algorithms an OS is designed that supports PLC operations by means of software tools allowing PLC programming according to required algorithms. To connect PLC with OS the industrial networks Ethernet, Controlnet, RS-485, Profibus, etc. are explored. The software – SCADA system – is installed in OS to design ACS graphic interface. The graphic interface describes technological process (mnemonic schemes, graphs, trends, process diagrams, etc.) and automation and remote control tools on operator control station (key buttons, control boards, controllers, etc.).

The SCADA and PLC communication is provided in a variety of ways. But the most common way is using of OPC server. Information about programming PLC, SCADA, OPS servers and their communication is considered in the following sections.

Control signals sending from OS (from SCADA ACS) to PLC, and also control signals automatically generated from PLC (according to specified standards and technological algorithms) arrive at output modules.

Output modules can generate different signals: discrete, frequency, analog. Output module generally contains an embedded digital-to-analog converter (DA converter) in case it’s needed. Converted signals enter the control systems of technological equipment: valves, pumps, motors, gates, etc.

There is a visible tendency to the distinction elimination between PLC and computer. The PLC introduction was authorized by the high cost of computers at the time. More and more industrial computers are used nowadays, which have special configuration, designed for round-the-clock operation and meet all the specifications accepted for PLC.

Page 11: COMPUTER-AIDED SYSTEM SOFTWARE

11

4. ACS Functions

ACS function is a list of system activities aimed at a local control purpose. The following functions are distinguished:

• data – computing functions; • control functions.

Supplying the information to operator station about the process progress is the result of executing data-computing functions.

A purpose of control functions is providing the control actions on automation object.

Data – computing functions include: 1) acquisition, processing and storage of information; primary

information processing includes input signal filtering, rating the information reliability, analytical calibration of sensor, i.e. accessing the status information by data received from the sensor;

2) signaling the equipment and technological conditions; 3) indirect measurement of process and equipment parameters; 4) calculating the engineering and economical performance

characteristics of manufacturing process; 5) recording of required parameters, equipment condition and results

of estimations provided by the system or PLC; 6) recording of process and equipment deviations; 7) analyzing and detecting the initial cause of occurred lockouts and

technological protections; 8) forecasting the parameters of manufacturing process and

equipment; 9) diagnostics of ACS equipment; 10) displaying the progress information and providing guidelines for

technological process control; 11) performance of information exchange with other ACSs.

Control functions include different control types: 1) single-loop control (control by certain parameters of technological

process); 2) logic control (lockouts and protection); 3) cascade control;

Page 12: COMPUTER-AIDED SYSTEM SOFTWARE

12

4) multivariable control; 5) program control; 6) optimal control of steady-state process (optimal control in static

mode); 7) optimal control of unsteady process (optimal control in dynamics),

solution of this problem is the law of parameter variation from one static mode to another one;

8) optimal control of manufacturing process with adapting the control system.

Page 13: COMPUTER-AIDED SYSTEM SOFTWARE

13

5. BASIC FUNCTIONS OF PLC AND OCS

Basic functions of PLC: 1) acquisition and primary processing of information; 2) parameter control; 3) program control; 4) warning; 5) safety protection; 6) fault diagnosis; 7) data transmission to the operator control station; 8) command receipt and execution.

The controller programming is performed by means of special systems.

Basic functions of OCS: 1) displaying of information in form of mnemonic schemes, graphs

(trends), numerical values, tables, text messages, animation, etc; 2) information backup; 3) report generation; 4) variation of control parameters; 5) manual remote control.

Page 14: COMPUTER-AIDED SYSTEM SOFTWARE

14

6. ACS STRUCTURE

ACS includes technical, mathematical, information, and organizational support.

Technical support includes microprocessor controllers, PC-based operator control stations, data collection and data transmission devices, execution units, etc.

Mathematical support divided into algorithmic support and software.

Algorithmic support is a combination of interrelated algorithms for ACS operating.

Software is a set of programs designed for control of operator stations and microprocessor controllers.

Organizational support represents documentation required for ACS maintenance: engineering manual, maintenance manual for operating staff, repair manual, etc.

Information support is a list of documents which contain information about set of input signals, their characteristics, set of output signals including presentation model of output information, and schemes of information acquisition, processing and using

The diagram of the certain support types interaction is presented in figure 4.

Figure 4. ACS Components Interaction Liaison

Technical Support

Organizational Support

Operating Staff

Input Information Information Support Output

Information

Computer Aids

Mathematical Support:

• algorithmic • software

Page 15: COMPUTER-AIDED SYSTEM SOFTWARE

15

7. IEC-61131 STANDARD

Industrial automation systems are rapidly developed in recent decades. PLC hold one of the central positions in ACS. Increasing in PLC production demands unification of programming tools which provides programming of PLC operation. To achieve this goal, the IEC – 1131 standard was designed later renamed as IEC 61131.

7.1. Standard Evolution

Development of PLC standards was initiated in 1979 when an ad hoc group was created with the participation of technical experts. In 1982 the first version of the standard was issued. However, it was decided to divide the standard into five directions to overcome difficulties in working with this paper.

Five divisions were organized to design the standard in the following directions:

1) background information; 2) equipment and testing requirements ; 3) programming languages; 4) user manuals; 5) message design.

Later the fifth direction was divided into two ones: • message specification design; • programmable controllers – communication.

The section «Programming Languages» is of particular interest as a part of the considered book. At first the standard was published under the name IEC 1131-3 in 1993, but in 1997 IEC changed the standard notifications by adding «6», so the standard was converted into IEC 61131-3

7.2. The IEC 61131-3 Characteristics

Programming systems based on IEC-61131-3 incorporates following characteristics:

• reliability of designed software. The reliability is maintained by the fact that the PLC programs are designed by means of dedicated development environment, which includes all necessary tools for program writing, testing and debugging using emulators and real PLCs as well as the number of completed code chunks;

Page 16: COMPUTER-AIDED SYSTEM SOFTWARE

16

• ability to easy program modification and program functionality increase;

• project portability from one PLC to another one; • ability to reuse of completed program segment; • programming language simplicity and limitation of language

elements.

7.3. Standard Languages

IEC-61131-3 provides PLC programming languages. Software is designed in such a way that certain parts of code can be developed in different standard languages, and then integrated to single executable software.

Structured programming, encapsulation, abstract types, etc were included into IEC-61131-3.

The implementation of IEC-61131-3 languages was based on analysis of various languages, which were already used. IEC-61131-3 defines five programming languages.

IEC-61131-3 includes graphic languages: Ladder Diagrams (LD) and Function Block Diagrams (FBD). These languages provide correspondence between graphics primitives describing solution of a particular problem and programs, which implement problem-solving algorithms. A certain primitive performs a particular task by setting input parameters.

The element base of LD includes a set of symbols for string programming. Ladder diagram programs are relay circuits including normally closed and normally open contacts, relay windings.

The element base of FBC looks like function blocks interconnected to electric circuit. This form of graphic representation makes the language easy to work with a lot of applications with inter-component data transfer. Function blocks, which form the language basis, are program objects that execute particular control and calculation algorithms. Output data of this block can be transmitted to other blocks by trace lines.

In addition to considered programming languages, IEC-61131-3 includes also Sequential Function Chart language (SFC). The element base of SFC is formed by steps and junctions which can be applied in algorithms described in any other standard languages.

IEC-61131-3 supports also text languages: Instruction List (IL) and Structured Text (ST). IL is a low level language, similar to assembler. ST is

Page 17: COMPUTER-AIDED SYSTEM SOFTWARE

17

a high level language used for structured programming. ST provides the work with arithmetic and Boolean operations and includes following programming structures: environment, cycles, multiple selection operator, etc.

7.4. Requirements to Standard’s Languages

IEC-61131-3 languages are based on following principles: • the program is divided into a number of functional elements –

Program Organization Units (POU). Each unit may consist of functions, functional blocks and programs; each unit can be hierarchically configured from simpler elements;

• IEC-61131-3 demands strong data typing, data type specification helps to detect most bugs before the program execution;

• there are tools to execute different program parts at different times, at different rates, and simultaneously;

• Sequential Function Charts (SFC) are used for certain operation sequence set by time intervals or events;

• IEC-61131-3 supports structure to define heterogeneous data, e.g. pump bearing temperature, pressure and on/off state can be defined by an integrated structure and then transferred as a single data unit within the program;

• the standard provides sharing of five languages, so the best suited language is chosen for each part of task;

• a program written for one type of controllers can be transferred to another type compatible with IEC-61131-3;

• any PLC operates in repetitive mode; a cycle starts from data collection from input modules followed by PLC program execution. Data output from output module completes the cycle, so the runtime of the cycle depends on input-output duration and processor module speed.

7.5. Standard’s Relevancy

There is no doubt that the implementation of IEC-61131-3 had its impact on users and PLC designers alike.

The standard language tools for PLC programming provides personnel training in this industry sector. Availability of the fixed language list enables the training of experts who are capable to program industrial PLCs from different manufacturers due to the fact that the basic software meets IEC-61131-3. On the one hand, engineers and system integrators should

Page 18: COMPUTER-AIDED SYSTEM SOFTWARE

18

study five languages for PLC programming, on the other hand, this training technique is standardized.

Usually, PLC manufacturers design both hardware and software, and deliver the PLC programming software in set with controller. Some companies such as Siemens, Emerson, Rockwell Automation also deliver software for SCADA OS design as well as software for SCADA and PLC communication. However, there are PLC manufacturers that use canned software for PLC programming. Wago and OVEN companies, which use in their controllers software from 3S Softaware Ltd., are good examples of such enterprises.

It should be pointed out that there are differences in SW element base, in syntax, etc. by different manufacturers despite the fact that the software is developed according to IEC-61131-3. However, all these differences are not serious and studied within a short time.

The next advantage of IEC-61131-3 implementation is a possibility to build integrated control systems, which include controllers from different manufacturers.

7.6. Development Trends of Standard

Issues of IEC-61131-3 development are discussed in different conferences, seminars, webinars and other events all over the world. However, the large majority of programming system manufacturers still concentrate all their efforts just on service development avoiding significant improvements in language development.

Programming is tool – limited in most cases. Although many of modern controller platforms support C#, a compiler provides just the aspects of programming. Function of system debugging and launching are nearly unsuitable for controller applications. E.g., the library calls should be written to monitor input – output values.

Based on the above stated, tendency to IEC – 61131-3 extension is to be noticed. This extension should meet following standard’s requirements:

• OOP of this extension should not be optional, not compulsory; • interoperability of OOP with not object oriented programming; • application support with possible transformation as required to OOP; • OOP implementation to all IEC – 61131-3 languages.

This standard extension is already developed by 3S-Smart Software Solutions. The main IEC – 61131-3 extension concerns the function block

Page 19: COMPUTER-AIDED SYSTEM SOFTWARE

19

transformation to a class. In the same way the C# structures were transformed into classes. This is achieved by method introduction. In fact, method is a function built in a function block. So, not only function parameters and local variables, but also instance data of function block are available by function implementation. As a result, method call includes both instance and method names.

The power increase due to OOP implementation enables interface creating. An interface is understood to be a set of methods using common parameters, but different realization ways for different function blocks. An interface can be transferred as a parameter, and the software component doesn’t actually bother what function block should be applied.

Page 20: COMPUTER-AIDED SYSTEM SOFTWARE

20

8. TOOLS OF PLC DESIGN

Currently, PCs are used for PLC programming. Software design, testing and debugging processes are developed by special-purpose software systems.

PLC manufacturers generally use their own programming tools for software development. These programming tools are already adapted to certain equipment. It is obvious that PLC manufacturers are not interested in versatile software production since they have incentives to promote just their own products in the market.

The IEC – 61131-3 openness and complexity of programming tool system implementation lead to establishing of specialized companies developing PLC programming tools.

A list of these programming tool systems based on IEC – 61131-3 includes more than twenty products. The most common software platforms are listed in the table 1.

Table 1 Software Platform List

Software platforms Manufacturer CoDeSys Smart Software Solutions, Germany OpenDK Infoteam Software, Germany ACCON-ProSys Deltalogic, Germany SUCOsoft S340 Klokner-Moeller, Germany PUMA KEBA, Austria PDS7 Philips, Netherlands NAIS CONTROL Matsushita AG, Germany Soft Control Softing, Germany SELECONTROL Selectron Lyss, Switzerland Concept Schneider Electric, France ISaGRAF CJ International, France

The IEC – 61131-3 as additional components is supported lately in some SCADA systems (FIX/Paradym-31, Factory Suite/InControl, WinCC/WinAC, TraceMode , etc.).

The IEC – 61131-3 language programming will be considered through the example of CoDeSys designed by 3S – Smart Software Solutions (http://www.3s-software.com). CoDeSys is one of the most functional IEC – 61131 development systems.

Page 21: COMPUTER-AIDED SYSTEM SOFTWARE

21

8.1. PLC Programming System Tools

One of the main tasks of PLC programming environment is automation of software developer work flow. It helps reduce time of software development and deliver a developer from monotonous routines.

Today each of the companies are intend on increasing a number of service functions leading to more rapid and comfortable software development. Service functions have not been included into IEC – 61131-3 requirement list, but selection of development environment depends on its usability.

8.1.1. Embedded Editor

Compiler is usually called as embedded editor. A compiler task is to read programs written on IEC – 61131-3 languages and convert text or graphic code into machine code. A result of compiler operations is a final version of software which executed afterwards. A development environment supposes that embedded editor is provided. In case of software bugs compiler points out program ID, its line number and error type, otherwise, it points out absence of errors as illustrated in Fig. 5.

Figure 5. Compiler operation results

Page 22: COMPUTER-AIDED SYSTEM SOFTWARE

22

8.1.2. Text Editor

IEC – 61131-3 supports five programming languages, CoDeSys development systems includes six programming languages; the graphic language CFC is also on the list. There are text languages – IL and LD – on this list. Implementation of text languages in development system demands a number of certain characteristics:

• fast entry of text elements, keyboard combinations which provide insertion of orders, functions, functional blocks and other standard elements;

• automatic completion of input data, e.g., variables could be declared in short form in declaration part, but they are converted into required form upon completion;

• automatic declaration of variables; if a new identifier is used in program code, the declaration window pops up where a variable class, type, initial value, etc, can be defined. The window Declare Variable pops up by creation of output variable with the name valLevel (Fig. 6);

Figure 6. Automatic Declaration of Variable

• different presentation forms of variable declaration part (textual, table presentations;

• automatic formatting and syntax checking of input code: text editor highlights reserve words, commands, comments, etc. by different colors;

• automatic line numbering.

Page 23: COMPUTER-AIDED SYSTEM SOFTWARE

23

8.1.3. Graphic Editor

Similarly, there is a graphic editor for IEC – 61131-3 graphic languages. This editor has a number of characteristics aimed at speeding and developer environment improvement:

• automatic routing of block connecting lines; • automatic component layout, it is true for LD, FBD and SFC

programs, for CFC CoDeSys developer defines component layout by himself prioritizing the component execution;

• automatic numbering of algorithm chains; • copying, insertion and transferring of program graphic elements; • zooming of graphic code on display for its better presentation or

detailed view; • active circuits and variables are highlighted online in different line

weight and colors; in fig. 7 displays the variable VALVE_STATE highlighted by blue color, so this points to its True value;

• the input values are displayed in program blocks online which can be overwritten (if the input parameter is defined by a variable); Fig. 7 illustrates that the input values are displayed in PID controller block, double clicking on MAX_LEVEL variable called a pop-up window for overwriting its value.

Figure 7. Writing of Variable MAX_LEVEL New Value

8.2. Project Debugging

Software environment designed for PLCs includes the following functions of debugging:

• mechanism of connection to PLC or PLC emulator; the type and the way of connection make no difference, and can influence just any particular physical characteristics mostly related to physical implementation;

Page 24: COMPUTER-AIDED SYSTEM SOFTWARE

24

• providing the designed code loading of the control program into PLC RAM; automatic monitoring of loaded code; comparing the loaded code gained after the compilation with the code which is already contained in PLC memory [CoDeSys informs that no software is available on the controller in case of initial SW loading (Fig. 8), otherwise, that the loaded software has been changed in comparison with the PLC code version (Fig. 9)];

Figure 8. SW Loading into PLC

• control program operates in real-time mode; • the execution of the control program code is stopped under spare

fault condition, but other process stages are kept working (it is possible to monitor manually the parameter values at inputs and outputs а PLC);

Figure 9. SW Reload in PLC

• flush of data, which are stored in PLC, different types of data flush are possible: «hot» flush, «cold» flush, and factory flush (by the «hot» flush the control program is returned to initial state, and the variables take the initial values; by the «cold» flush the transition of the control program to initial state and initial value setting of the variables are also supplemented by initial value setting of the variables, which are located in volatile memory; and the factory flush provides for deleting the user control programs and restoring memory and controller settings aligned by manufacturer);

• input, altering, and monitoring of variable instantaneous values in project;

• input and output value simulation of the control system parameters;

Page 25: COMPUTER-AIDED SYSTEM SOFTWARE

25

• control program stepping (line by line, by one running cycle) with allowed breakpoints;

• keeping track of variable cross-references in control programs.

8.3. Project Management Tools

The source environment of bundled software designed for PLC programming includes project management tools. Problems of project management are solved by means of project manager, which enables:

• presenting the components and the structure of the designed project; • working with project components (create, rename, relocate, copy,

delete); • setting of project resources; • controlling the project libraries (connecting the available libraries and

adding any private libraries); • preparing the project documentary including:

♦ textual representation; ♦ description of project components and section of variable

declarations ♦ resources of designed project – PLC configuration, list and

description of global variables, list of project problems, list of the libraries available;

♦ cross – references list of the project variables.

8.4. Project Recovery

The need for source code updating arises anyway in operating of the introduced automatic control system. However, the potential source file loss of the introduced project should never be ruled out. This problem can be solved differently. The storage of all source codes in PLC memory is most common. Files are usually compressed, archived and stored on memory card. Another approach to solving the task is the code decompiling, conversion of the executable code to IEC programs. This approach, however, is more complicated by realization, so it is uncommon.

8.5. Security

The access to altering and modification of the source code is usually secured with the help of ACS administrator keyword. Limited access raises security level of ACS and eliminates the write access for outsiders.

The hardware key is used to limit the access to the system in some cases.

Page 26: COMPUTER-AIDED SYSTEM SOFTWARE

26

9. STRUCTURE BY PLC

Source environment for creating the PLC code has a clear structure. The project tree or project structure is displayed in project manager. The example of a project structure is presented in Figure 10.

Figure 10. Project Tree

This structure includes a program named PLC_PRG and LEVEL, SHIM, VALVE function blocks. The POU type is shown in brackets: a program, a function block, a function. However, there are more global elements in source environment such as tasks, source, configuration, which are considered in this section.

9.1. Tasks

The key task appointment is operation control of project programs which are performed by PLC processor. Each task has its unique identifier (program name). A separate task can control not only one, but a number of programs performed within every operating cycle of PLC. It is possible to create several tasks both of similar and also of different types within one project.

There are tasks of different types, e.g.. cyclic, independent (freewheeling), triggered by event (see Fig. 11). Triggered by event tasks are performed by an event defined by rising edge variable, which conforms to this event. Cyclic tasks are performed at the time intervals which are set by project designer. Freewheeling tasks are also performed in a cyclic way, however, there are not fixed time lags between task performances in freewheeling tasks, so they proceed to n+1 performance upon completion of the n-iteration.

Page 27: COMPUTER-AIDED SYSTEM SOFTWARE

27

Task description are performed through a variety of native means (text or graphics) in different source environments. In CoDeSys the Resources tab contains the task configuration folder where tasks are set and task attributes are defined (see Fig. 12).

Figure 11. Task Attributes

Figure 12. Task Manager

Page 28: COMPUTER-AIDED SYSTEM SOFTWARE

28

To perform the PLC programs at least one task should be set in any project. In CoDeSys there is one cyclic task on default, wherein the PLC_PRG program is included.

Tasks are controlled by the executive. Tasks should be prioritized to control the performance process. Task priority is defined by the assigned number in the range of 0-31 (see Fig. 11). The lower the number the higher the priority of the task performed. If several tasks to be performed, the task of higher priority is performed first. If there are two tasks with the same priority to perform, the task with longer waiting time is performed first. If two cyclic tasks of different priorities are delivered synchronized, the task with lower priority is not performed at all.

The nonpreemptive multitasking are generally realized in the PLC software executive. I.e., if the task of higher priority than the currently performed task appears in the waiting list, no performance interrupt will take place. The currently performed task will be executed till the end of the cycle.

Figure 13. Project Resources

The resources tab includes the following list of items: • global variables and direct addressable variables; • library manager; • PLC configuration;

Page 29: COMPUTER-AIDED SYSTEM SOFTWARE

29

• target settings of the executive: microprocessor type, memory allocation, network parameters, and other settings;

• task configuration. To simplify the work with source environment different PLC software manufacturers also include their original tools into resources such as network configuration, instruction control unit for PLC core, logs, etc.

9.3. Configuration

In relation to resource one more entity of a higher level is concerned in IEC. This is configuration. Configuration integrates a variety of resources working by a certain law. One system can include a number of resources each of which contains a processor, memory, a runtime system. Such resources can be both real modules, which are widely separated, and virtual ones, which are emulated by one process. All these modules have an access to certain hardware (PLC input-output modules), and their work and interconnection are synchronized by project global variables.

The configuration definition is generally used in distributed ACS to solve more challenging specific tasks.

Page 30: COMPUTER-AIDED SYSTEM SOFTWARE

30

10. PROGRAM ORGANISATION UNITS

10.1. POU Definition

Program organization units are basic elements, which are used in project code creating. Each POU has an individual interface, name and description in one of the IEC 61131-3 languages.

The POU definition was touched upon in section 9 and it was defined that function blocks, function and programs are related to the basis program organization units.

POUs are basic components for building the entire project code. Each unit has its individual identifier (its name), specific interface, and described in one of the IEC 61131 languages.

The POU call can be realized in different ways. Unit «program» is called to the executing by a specified task, and also by another POU, executing program. Units such as functions and function blocks are called to executing only by programs. The key feature of PLC software is recursion unfeasibility, because it is forbidden by IEC 61131.

The encapsulation characteristic is widely applied in PLC software, i.e., POUs are created on the «black box» principle: all details are hidden from users, and the information about inputs, outputs and current task of the POU suffices to work. It is unessential to have the information about POU internal arrangements. In graphic languages POU is represented as a rectangle with inputs at the left, outputs at the right, and with the name at the top (see Fig. 14). Local data are not available externally.

Figure 14. Type of Component in FBD Language

Applying the encapsulation characteristics in the project helps solve the problem of structural decomposition. Project is built from a bigger unit to a smaller one. A designer aligns the target settings in resources, sets the type of processor, configures PLC, sets up tasks, connects the required libraries, defines the set of global variables, etc. Then, in tasks created, designer calls programs, which are able to call in other programs, functions, and function

Page 31: COMPUTER-AIDED SYSTEM SOFTWARE

31

blocks. Thus, a certain group of tasks is solved at each design level of the project without going into details. To turn to details the unit of lower rank should be considered.

The next accompanying problem is solved by realizing the structural decomposition. This problem is the localization of variable identifiers. I.e., designing the certain blocks it is possible to use repeated names of variables for local variables, because the scope of variable names is the unit where they are used. It allows to simplify the project structure effectively, and reduce the global variable declaration list.

10.2. Formal and Current Parameters

The POU interface is provided by its name and its input and output variables as well. The POU input parameters are usual to name as formal parameters. The external variables of certain values are connected to the input variables (formal parameters) by using the POU. These parameters are called current parameters. Thus, by POU activation, its parameters gain current values entering the unit, and processed according to the algorithm realized within this unit, and after that the output values are recorded into current parameters.

10.3. POU Parameters and Variables

The variable declaration contains variables of several types: VAR_INPUT, VAR_OUTPUT, VAR, VAR_IN_OUT (see Fig. 15).

Figure 15. The POU Variable Declaration

Page 32: COMPUTER-AIDED SYSTEM SOFTWARE

32

Current values enter to the formal input parameters VAR_INPUT by copying. The parameter types should be coincided. A current parameter (an external value of the unit) enters the unit in each operating cycle of PLC.

The formal output parameters VAR_OUTPUT are formed out of the unit operating. Similarly, data are recorded into current parameters by copying.

The variables from VAR section are local and can be used just within this unit.

The VAR_IN_OUT variables can be inputs and outputs simultaneously. The variable values to the unit are passed by reference. I.e., the external variable outside the unit operates as an internal variable within this POU. By creating a POU with the variable from the VAR_IN_OUT section only the variable address is passed to the POU. There are series of restrictions for the variables from VAR_IN_OUT section:

• banned from use in functions; • giving the starting values is off-limits; • not used as element of data structure; • variable assignment is possible only by block calls.

10.4. Functions

Function is a program organization unit, which includes a variety of input values at the output. Function always returns only one value (which can consist of a number of elements in case of bit-mapped field or structure). The function name is a sort of output variables, where the calculating results are recorded. The type of returned value, the function name, and input parameters are provided in function declaration.

The function unit is realized without the internal memory available. Function may contain local variables, however, they are uploaded from memory when process is finished. The lack of memory means that function always returns the same value by similar values of input parameters.

The type of returned value is any one from the list of value types provided be environment and also from the user created types. Function body can be described in any of IEC languages except for SFC language, because there is no proper syntax in this language. It can just define the structure and the order of code priority. Calling other library and user functions is possible to realize in function body, but the call of function blocks and programs is impossible to perform therein.

Page 33: COMPUTER-AIDED SYSTEM SOFTWARE

33

10.5. Function Blocks

Function block is a program organization unit that can take, process and return arbitrary number of values. A function block unit is called in program code. In contrast with functions, function blocks can’t generate the returned values. All variable values are stored after the execution of a function block instance till the next call. Since the function blocks have internal memory and can store the variable values the called instances with similar input data can have different output data.

The external reference to the function block makes available just its inputs and outputs. The access to the function block instance variables is unavailable.

10.6. Programs

Program is a global POU which is able to generate don’t care values during the calculations. All variable values are stored after the program execution finished and stored till the next program call. In contrast with function blocks, programs have no instances, they are global POUs of entire project and set at the resource level of the project.

Page 34: COMPUTER-AIDED SYSTEM SOFTWARE

34

11. THE IEC 61131 LANGUAGES

Five PLC programming languages are included in IEC – 61131 as was mentioned earlier: IL, LD, FBD, ST and SFC. In addition to the mentioned above, one more language is incorporated in CoDeSys languages. This is CFC, a redesigned graphic language, where the execution priority of algorithmic blocks is set by their mutual arrangement. The IEC programming languages are considered next in the section.

11.1. The IL (Instruction List) Language

The IL language is an instruction list. This is a typical assembler with accumulator and label transitions. Set of instruction is standardized and doesn’t depend on a certain target platform.

Each instruction is written in a separate line. An instruction can include 4 fields separated by spaces and tabulation characters:

Label: Operator Operand Comments

The instruction label is not obligatory, it is used if required. Operator is an obligatory field. Operand is nearly always to be presented. Comment is not obligatory field, written at the end of the line. It’s forbidden to insert comments between instruction fields.

Text alignment is automatically performed by editor in addition to syntax checking and highlighting.

11.1.1. Result Register

Absolute majority of IL instructions perform an operation with the content of the result register. The IL result register is a general-purpose container able to save the variable values of any type.

Translator doesn’t report an error when the value of type BOOL, and then of type INT or REAL is put into result register. This flexibility doesn’t mean that the result register can contain several values of different types. It can be just one, moreover, the value type is registered in the result register. If operation demands another value type, translator will give an error message.

The term «result» is used for «result register» in the IEC standard.

Page 35: COMPUTER-AIDED SYSTEM SOFTWARE

35

11.1.2. Jump to Label

The IL language program is executed top-down. To change the order of execution and loop organization the jump to label is applied. A jump to a label can be unconditional – JMP- performed regardless of anything. A conditional jump JMPC is performed only if the result register value is TRUE. A jump is performed running up and down. Labels are local, i.e., a jump to another POU label is not allowed. E.g.:

LD 1 (*load a value into result register *) ST Counter (*set the current result value to variable *) loop1: LD Counter (*load Counter into result register *) ADD 1 (*add 1 to result register *) ST Counter (*set the result register value to Counter *) LE 5 (*result register value less than or equal <= 5*) JMPC loop1 (*jump to label*)

11.1.3. Parentheses

The execution order of IL instructions is possible to change by means of brackets. Left parenthesis is put in instruction after operation. Right parenthesis is put in a separate line. Instructions within parentheses are performed first. The result of calculating the instructions given in brackets is registered in additional result register, and then the program, which contains a left parenthesis, is executed. E.g.:

LD 5 MUL (2 SUB 1 ) ST y (*y=5*(2-1)=5*) LD 5 MUL 2 SUB 1 ST y (*y=5*2-1=9*)

Parentheses can be nested. Each nesting demands any temporary result register. This causes ambiguity by exiting the parentheses with instructions JMP, RET, CAL, and LD. It is prohibited to use these instructions in parenthesis.

Page 36: COMPUTER-AIDED SYSTEM SOFTWARE

36

11.1.4. Modifiers

The instruction content is modified by adding the C and N modifiers to the mnemonics of some operators.

The «N» modifier (negation) initiates a reverse operand value before the instruction performed. The operand types should be BOOL, BYTE, WORD, or DWORD.

The «С» modifier (condition) provides the condition evaluating of JMPC, CALC, RETC: these instructions are only performed if the result of preceding expression is TRUE. N with JMPC, CALC, RETC: the instruction is only then performed if the result of the preceding expression is FALSE. N without C makes no sense in these instructions.

11.1.5. Operators

The standard operators of IL languages are summarized in the table (see table 2).

Table 2 The IL Operators

Operator Modifier Meaning LD N Make current result equal to the operand

ST N Save current result at the position of the operand

S If the current result is TRUE, put the Boolean operand at TRUE

R If the current result is TRUE, put the Boolean operand at FALSE

AND N, ( Bitwise AND OR N, ( Bitwise OR XOR N, ( Bitwise exclusive OR NOT Bitwise result inversion ADD ( Addition SUB ( Subtraction MUL ( Multiplication DIV ( Division MOD ( Division modulo GT ( >

Page 37: COMPUTER-AIDED SYSTEM SOFTWARE

37

End of table 2

GE ( >= QE ( = NE ( < > LE ( <= LT ( < JMP CN Jump to label CAL CN Function block call RET CN Exit from POU and return into calling program

11.1.6. Calling Function Blocks and Programs

Calling a function block or program in IL is possible with simultaneous variable assignment. E.g.:

CAL CTD_1(CD:=TRUE, LOAD:=FALSE, PV:=10) LD CTD_1.CV ST y A similar call with preliminary variable assignment: LD TRUE ST CTD_1.CD LD FALSE ST CTD_1.LOAD LD 10 ST CTD_1.PV CAL CTD_1 LD CTD_1.CV ST y

11.1.7. Function Call

There is a significant feature by calling a function with parameter enumeration in IL. The result register is used as the first parameter:

LD TRUE SEL 3,4

11.1.8. Annotation

Annotation is performed by the symbols (*---*).

Page 38: COMPUTER-AIDED SYSTEM SOFTWARE

38

11.2. Structured Text (ST)

The ST language (Structured Text) is a high level language and resembles Pascal because it is based on it. Instead of Pascal procedures the program components of IEC 61131-3 are used in ST.

11.2.1. Expressions

Expressions provide the basis for a ST-program. The expression evaluation result is assigned to a variable with the operator «:=» as in Pascal. Each expression ends in «;» (simicolon)

ST operators are represented in symbolic expressions, e.g., mathematical operations +, –, *, /, comparison operations, etc .

Several expressions can be written in one line. Long expressions can be taken down to the next line. The line brake is equal to the passive distributor.

An expression can include another parenthesized expression. The parenthesized expression is calculated first

11.2.2. Order of Expression Evaluation

The expression evaluation is performed according to the rule of operator precedence. Operations of the highest priority are performed first.

In order of descending, operations are ranged in the following sequence: parenthesized expression; function call; EXPT degree; character replacement (–); negation NOT; multiplication, division, and division modulo MOD; addition and subtraction(+, –); comparison operations (<, >, <=, >=); equality(=); inequality(<>); logical operations AND, XOR and OR.

11.2.3. Empty Clause

An empty clause consists of a semicolon «;». Translator doesn’t generate any code for the semicolon. If an excessive semicolon is put occasionally, it will be a semicolon of language construct. E.g., a project should be translated which contains an unrealized POU. For the concise translation one empty clause should be written in POU body.

11.2.4. Selection Statement IF

Selection statement enables to perform different expressions depending on conditions of logical statements. The full syntax of the operator IF looks like this:

Page 39: COMPUTER-AIDED SYSTEM SOFTWARE

39

IF <Boolean statement IF> THEN <statements IF> ; [ ELSIF <Boolean statement ELSEIF 1> THEN

<of statement ELSEIF 1>; … ELSIF <Boolean statement ELSEIF n> v THEN

<of statement ELSEIF n>; ELSE <of statement ELSE>;

] END_IF

The part of code within the brackets [ ] is not obligatory.

11.2.5. Multiple Selector CASE

Multiple selector CASE enables to perform different statement groups depending on the value of one integer or one statement. Syntax:

CASE <integer> OF <value 1>: <of statement 1>; <value 2>: <of statement 2>; <value 3> : <of statement 3> ; … [ ELSE < of statement ELSE> ; ] END CASE

11.2.6. While and Repeat Loops

WHILE and REPEAT loops provide the statement iteration while the Boolean conditional statement is true. If the conditional statement is always true, the loop becomes infinite. The WHILE syntax:

WHILE < Boolean conditional statement> DO <Statements – loop body> END_WHILE

Page 40: COMPUTER-AIDED SYSTEM SOFTWARE

40

Condition in the WHILE loop is proved before the loop starts. If the Boolean statement initially has the FALSE value, the loop cycle will be performed not even once.

Syntax REPEAT:

REPEAT <statement – loop body > UNTIL < Boolean conditional statement > END_REPEAT

Condition in the REPEAT loop is proved after the loop body has been performed. If the logic statement initially has the FALSE value, the loop cycle will be performed just once.

A well-formed WHILE or REPEAT loop should definitely alter the variables, which make the terminating condition in the loop body, progressing towards the terminating condition. Otherwise, the loop will never end.

11.2.7. FOR Loop

The FOR loop provides the given number of statement block iterations. Syntax:

FOR <int counter> := <Starting value> ТО <Ending value> [BY <Step>] DO

<statements – loop body> END_FOR

Counter receives the starting value before the loop starts. The loop body is repeated as long as the counter value exceeds the ending value. The counter get increased in each loop. Starting and ending values and step can be both constants and statements.

11.2.8. Iteration Interrupting by EXIT and RETURN

The EXIT operator, put in iteration body WHILE, REPEAT and FOR, results in immediate loop terminating.

For internal loop EXIT terminates only «its own» loop, the external loop will continue working.

The RETURN operator realizes the immediate return from POU. This is the only way to interrupt the nested iterations without additional condition evaluating.

Page 41: COMPUTER-AIDED SYSTEM SOFTWARE

41

11.3. Ladder Diagrams

The ladder diagram language is a graphic language which realizes the electrical circuit structures.

Graphically, a ladder diagram is presented as two vertical power supply rails with the circuits in-between formed by contact connection. A relay is used for the circuit load. There are contacts to be applied in other circuits in each relay.

Boolean series connection (AND), and parallel contact connection (OR), and inverse (NOT) form the Boolean basis. As a result, LD is absolutely appropriate not only for on-off controllers but also for implementing the combinational logical networks. The implementation area of LD language is almost unrestricted due to the fact that function and function blocks written in other languages can be included into LD

Key elements are presented below, in the table 3.

Table 3 The Basic Elements of LD language

LD Unified System of Design Documentation

Meaning

Normally open contact

Normally closed contact

Relay coil winding

11.3.1. Latching Relay

Besides traditional relays the polarized relays are often applied in relay circuits. The relay of this type has two opposing coils switching the relay over two states. This is achieved by current impulses. When the current is switched off, the relay remains in its last state, and this realizes a low-level memory cell.

Page 42: COMPUTER-AIDED SYSTEM SOFTWARE

42

Latching relay is realized in LD by means of two coils SET and RESET. The coil of SET type is marked by parenthesized letter (S). The RESET coil are marked by letter (R), also in parentheses. If a variable, which corresponds to the (S) coil, takes the TRUE value, it keeps this value infinitely. To return the variable to the FALSE value is possible only by means of the (R) coil.

11.3.2. Execution Order and Feedback

The relay circuit method requires the parallel running of all circuits. The current is supplied simultaneously to all circuits.

The diagram solution in LD is performed top-down from left to right. All diagram circuits are one-shot performed in each cycle. This creates the effect of parallel circuit running. Any variable within one circuit always possesses the same value. Even if the relay alters the variable value, the new value will be transmitted to contacts only in the next cycle. Circuits of a lower level receive the new variable value immediately. Circuits of a higher level receive the new value just in the next cycle.

The diagram execution order can be changed in a forced way by means of labels and jumps.

A label can be set only at the circuit beginning. Label names should conform to the variable name instructions. It is possible to finish the label by a colon. The colon doesn’t generate a new label. Thus, M1: and M1 amount to the same thing. A circuit can contain just one label and one jump. The jump is equivalent to output relay and performed if the output variable has the TRUE value. If the jump is inversed, it will be performed by the FALSE value of the variable. A jump enables to ignore the execution of a diagram part. The ignored circuits are not removed, but just ignored – they are remained at the same state as before the jump. The upward jump is available and allows the cycle creation. Testing the conditions of the cycle termination is a task of a programmer.

Ideologically, jumps contradict the LD analogy with relay circuits, because they violate the electric circuit laws. But jumps are happen to be taken.

11.3.3. LD Enhancement

Functions and function blocks can be inserted into LD diagram. Each function block should have logic input and output.

To include functions in a diagram the extra Boolean input EN (Enable) is imposed into these functions. The Boolean value at the input EN enables

Page 43: COMPUTER-AIDED SYSTEM SOFTWARE

43

or disables the function performance. There are no internal changes of the function by adding the EN input.

11.4. Function Block Diagrams

Function Block Diagram (FBD) is a graphic programming language. A function block diagram is built from POUs, which are displayed as rectangles in the diagram. The POU inputs are displayed left from the rectangle, and output areon the right side of the rectangle. The POU type and names of inputs and outputs are represented within the rectangle. For the function block its name is displayed above the rectangle. In graphic programming systems the POU rectangle may contain the image which displays the POU type. The size of the rectangle depends on the number of inputs and outputs and set automatically by the graphic editor.

11.4.1. Bussing

The POU в FBD rectangles are connected by communication lines. Bussing is directed from left to right. The POU input can be connected to the output of the POU leftward. Moreover, the input is connected to a variable or a constant. Bussing should connect variables or inputs and outputs of the same type. As opposed to a POU, a variable is displayed without a rectangular frame in the diagram.

11.4.2. FBD Execution Order

The FDB circuits are executed top-down from left to right. The function blocks located left –of – other blocks are executed first. A function block is calculated only after calculating the values of all block inputs. The further calculation is performed after all output values have been calculated. In other words, all the output values are presented simultaneously. The circuit calculating is considered to be finished after the output value calculation of each POU.

In some programming environments a user can relocate the function blocks avoiding failure of connections. The FBD order in the program is to be considered in this case.

11.4.3. Boolean Signal Inversion

The Boolean signal inversion is displayed in FBD as a circle before the input or a variable. Inversion is not a characteristic of the function block, so it can be added or cancelled immediately within the diagram.

Page 44: COMPUTER-AIDED SYSTEM SOFTWARE

44

11.4.4. Connectors and Feedback

Connectors are the labeled connections, which can be broken and transferred to the next circuit. This method is reasonable by the limited window width of FBD editor.

The standard doesn’t prohibit connectors linking the block output to its own input or the input of the block which precedes it in the network. Feed back doesn’t form a loop similar to FOR, just any evaluated value will be used at the input by the next diagram call. In practice, this means the implicit creating the variable that keeps its value between the diagram calls.

The inverse connectors are prohibited in CoDeSys FBD editor. To create the inverse connection the explicitly declared internal variables are used.

If the connection transfer or fanout to another circuit are necessary, the intermediate local variables are used.

11.4.5. Labels, Jumps and Return

The order of execution of FBD circuits can be changed imperatively using labels and jumps exactly as in relay circuits.

A label is set at the beginning of any circuit and is per se the name of this circuit. A circuit can have just one label. The label names conform the common IEC rules for identifier names. The graphic editor numbers diagram circuits. This numeration is used for documentation only and can not replace the labels.

A jump is connected with the Boolean variable and performed if the variable has the TRUE value. The constant TRUE is used to realize the unconditional jump.

The RETURN operator is used in FBD as well as the jump to the label, i.e., connected with the Boolean variable. RETURN leads to immediate completion of POU and the return to high-level nesting. This is the start of the PLC running cycle for the main program.

11.5. Sequential Function Charts

Sequential Function Chart diagrams are ranked above the other four languages in IEC. The SFC diagrams are high-level graphic tools.

Page 45: COMPUTER-AIDED SYSTEM SOFTWARE

45

11.5.1. Steps

Each SFC is built from the units, which provide step and jump conditions. Steps in SFC programs are displayed as rectangles. The actual work of a step is described in a certain dialog and isn’t displayed in the diagram. The purpose of the SFC step is represented by its name and, if it is not sufficient, by a concise text description (a comment).

Steps can be empty, and it doesn’t cause errors by project compiling. The empty steps are considered to be a standard in top-down programming, which is common to SFC. It is possible to identify the action corresponding to the step at any time.

11.5.2. Transitions

There is a horizontal line below the step on the connector line. This line displays a transition.

A Boolean variable, a Boolean statement, a constant, or a direct address can be used as conditions for a transition. A transition is performed if both of the following conditions are met:

1) transitions is enabled (the step corresponding to this transition is active);

2) its condition has the TRUE value. Simple conditions are displayed at the diagram right from the line, which describes the transition.

The approach to complicated conditions is quite different. The transition identifier is written in the diagram instead of condition. The condition is written in the diagram directly in a separate dialog window using IL, ST, LD, or FBD languages.

Variables or direct addresses are used in a condition only for reading. The POU call or assignment operations are impermissible in a conditional statement.

The fact, that the transition identifier is an individually realized condition, and not a simple Boolean variable, is indicated in the diagram by means of a small triangle in the upper corner of the ractangle. A Boolean constant can be established as a condition for the transition. If the constant value is TRUE, the step will be performed just once within one running cycle. Then, the control is transferred to the subsequent step. If the constant value is FALSE, the step will be performed infinitely.

Page 46: COMPUTER-AIDED SYSTEM SOFTWARE

46

11.5.3. Initial Step

Each SFC begins with the step which box frame is graphically marked with a vertical double line or with a double line along the perimeter. This is the initial step. The initial step name is automatically generated (Init by default). The initial step is the obligatory element of SFC, although, it can be empty.

11.5.4. Parallel Branch

A sequential function chart can diverge, that is the processing line can be branched into two or several further lines («branches»). Parallel branches will be processed parallel (both at a time). Parallel branches within a chart are preceded by a horizontal double line (see Fig. 16). A parallel branch must begin and end with a step. I.e., the entry condition is common to all parallel branches, so as the output condition.

Figure 16. Parallel Branches

Theoretically, the parallel branches are executed simultaneously. Practically, they are executed in one running cycle from left to right.

The subsequent transition, which ends the parallel branches, is evaluated only if the last steps of all parallel branches are active.

Figure16: Step 2 will be processed just once. Steps 1 and 3 will be processed parallel to one another before the subsequent transition 4will be noticed.

11.5.6. Alternative Branch

Some of the SFC lines are alternative. The horizontal lines before and after the branched area are simple lines (see Fig. 17). An alternative branch must begin and end with a transition. If the step which precedes the alternative

Page 47: COMPUTER-AIDED SYSTEM SOFTWARE

47

beginning line is active, then the first transition of each alternative branch will be evaluated from left to right. The first transition from the left, whose transition condition has the TRUE value, will be opened and the following steps will be activated.

Figure 17. Alternative Branches

In this case, the а alternative is evaluated first. Steps 2 and 3 can be activated only if the а value is FALSE.

Page 48: COMPUTER-AIDED SYSTEM SOFTWARE

48

12. STANDARD COMPONENTS

12.1. Arithmetic Operators

Nearly all arithmetic operators have symbolic form to be written in ST language. In other IEC languages the operator call is performed in function form. Table 4 presents the list of the more common arithmetic operators.

Table 4 Arithmetic Operators

Operator Symbol Operation Type of Parameters

ADD + Addition ANY_NUM, TIME

SUB – Subtraction ANY_NUM, TIME

MUL * Multiplication ANY_NUM, TIME

DIV / Division ANY_NUM, TIME

MOD MOD Remainder of Division ANY_INT

ЕХРТ ЕХРТ Exponentiation IN1 ANY_NUM, IN2 ANY_INT

MOVE := Assignment ANY

Arithmetic operators are reloaded: the type of operation result is defined by operand type.

MUL and ADD can be extended in graphical languages, i.e., any random number can be added to these operations.

The variables of type TIME can be added and subtracted together. One variable of the type TIME multiplied and divided by a number. The result obtained is always of the TIME type.

The operation MOD is applied only for set of integers.

The operation MOVE has only one parameter of an appropriate type. MOVE is available as a box in graphic languages only. The value of one variable or the constant of another variable in IL are assigned by the instructions LD and ST.

Page 49: COMPUTER-AIDED SYSTEM SOFTWARE

49

12.2. Bitwise Shift Operators

Bitwise shift operators are applied for the types ANY_BIT. The list of bitwise shift operators is presented in table 5.

Table 5 Bitwise Shift Operators

Operator Operation

SHL Bitwise shift of the operand IN to the left over N bit, with addition of zeros right

SHR Bitwise shift of the operand IN to the right over N bit, with addition of zeros left

ROR Rotate right operation of the operand IN over N bits; high-order bits are replaced by low-order bits

ROL Rotate left operation of the operand IN over N bits; low-order bits are replaced by high-order bits

12.3. Bitwise Logical Operators

Shift operators are used for the ANY_BIT types. The list of bitwise logical operators is shown in Table 6.

Table 6 Bitwise Logical Operators

Operator Operation

AND Bitwise AND

OR Bitwise OR

XOR Bitwise XOR

NOT Bitwise NOT

NOT has just one parameter.

AND, OR and XOR can be enhanced in FBD, i.e., the arbitrary number of input parameters can be added.

12.4. Selection and Delimiter Statements

Selection and Delimiter Statements are displayed in table 7

Page 50: COMPUTER-AIDED SYSTEM SOFTWARE

50

Table 7 Selection and Delimiter Statements

Text Format Operation Parameter Types

OUT:= SEL(G, IN0, IN1) Binary choice: OUT = IN0 by G = FALSE OUT = IN1by G = TRUE

IN0, IN1: ANY, G: BOOL

OUT:= MAX(INO, INI) Maximum value ANY

OUT:= MIN(INO, INI) Minimum value ANY

OUT:= LIMIT(Min, IN, Max) Delimiter: OUT = MIN(MAX(IN,Min),Max) ANY

OUT:= MUX(K, IN0,..,IN(K-1)) Multiplexer: OUT = INK

IN: ANY K: ANY_INT

12.5. Comparison Operators

The operators, which are presented in the table 8 below, realize the comparison operations.

Table 8 Comparison Operators

Operator Symbol Operation GT > greater-than GE >= equal-to-or-greater-than EQ = equal-to LE <= Equal-to-or-less-than LT < less than NE <> not equal to

12.6. Mathematical Functions

Standard mathematical functions are presented in table 9 by following operators.

Table 9 Mathematical Functions

Operator Operation Parameter Types ABS Absolute value of a number ANY_NUM SQRT Square root ANYREAL

Page 51: COMPUTER-AIDED SYSTEM SOFTWARE

51

End of tabe 9

LN Natural logarithm ANYREAL LOG Common logarithm ANYREAL EXP Exponential ANYREAL SIN Sine ANYREAL COS Cosine ANYREAL TAN Tangent ANYREAL ASIN Inverse sine ANYREAL ACOS Inverse cosineс ANYREAL ATAN Inverse tangent с ANYREAL

12.7. String Functions

String functions are presented in table 10 by following instructions.

Table 10 String Functions

INT:= LEN(STR) returns the length of a string literal

STR:= LEFT(STRING STR, INT SIZE) returns the left part of a string STR in size SIZE

STR:= RIGHT(STRING STR, INT SIZE) returns the right part of a string STR in size SIZE

STR:= DELETE(STRING STR,INT LEN,INT POS) returns STR by deleting the symbol length LEN from the position POS

STR:= MID(STRING STR, INT LEN, INT POS) returns the part of STR of the length LEN from the position POS

STR:= CONCAT(STRING STR1, STRING STR2) returns the concatenation of a string STR:= STR1 + STR2

STR:= INSERT(STRING STR1, STRING STR2, INT POS) returns STR1 with inserted STR2 into position POS

STR:= REPLACE(STR1, STRING STR2, INT LEN, INT POS) returns STR1, replacing the symbol length LEN, from POS to STR2

INT:= FIND(STRING STR1, STRING STR2) returns the position STR2 in the string STR1. If STR2 is not found, it returns 0.

Page 52: COMPUTER-AIDED SYSTEM SOFTWARE

52

12.8. Timers

PLC timers are fundamentally different from timers applied in general purpose languages. Computer programming languages contain delay functions (delay, sleep), which result in program lay-off for the preset time. There is no timer that is able to delay the PLC operating in IEC standard. Let us think of the situation when some signal entries at one of the PLC inputs. The same signal entries the another PLC input, but through the hardware delay module. Such is indeed the standard timer work. The time delay affects just the output signal generation but doesn’t cause any delay in the program.

The hardware support is essential for correct timer operating. All instances of timer function blocks “keep” time by means of the common clock (in CoDeSys, in internal local variable StartTime ). Just one timer counter incrementing with constant frequency is sufficient to PLC designing. The hardware counter should have the certain bitness to eliminate a possibility of the counter overrun during a single running cycle of PLC.

12.8.1. Timed Pulse

The timer pulse interface, and the type description of the input and output variables are presented in the table 11.

The timer start is performed when the IN input makes a positive (False-to-True) transition. The PT input sets the time duration of the generated pulse. After the start timer provides no response to the altering the IN value. The ET output counts the elapsed time. The counter stops when ET reaches the PT value, and the Q output returns to False value. The TP operation diagram is presented in the figure 18.

Figure 18. The TP Operation Diagram

Table 11 The Timed Pulse Interface

TP

IN BOOL

BOOL Q PT TIME TIME ET

Page 53: COMPUTER-AIDED SYSTEM SOFTWARE

53

12.8.2. Timer Off Delay TOF

The TOF interface (the timer off delay), the type description of the input and output variables are presented in table 12.

The timer output Q turns TRUE if the IN input is TRUE. As soon as IN becomes FALSE, the time is counted in ET until its value is equal to PT. Q is FALSE when IN is FALSE, and ET is equal to PT. Otherwise it is TRUE. Thus, Q has a falling edge when time indicated in PT has run out.

The TOF operations is displayed in figure 19.

Figure 19. The TOF Operation Diagram

12.8.3. Timer On Delay TON

The interface of the function block TON (the timer on delay), and the type description of the input and output variables are presented in table 13.

The input variables IN and PT are the variables of the BOOL type and the TIME type respectively. Q and ET are output variables of the BOOL and TIME types respectively. If IN is FALSE, Q is FALSE and ET is equal to 0. As soon as IN becomes TRUE, the time is counted in ET until its value is equal to PT. Then, it remains constant. Q is TRUE when IN is TRUE and ET is equal to PT. Thus, Q has a rising edge when the time indicated in PT has run out. The TON operations are displayed in figure 20.

Table 12 The Timer Off Delay Interface

TOF IN BOOL

BOOL Q

PT TIME TIME ET

Table 13 The Timer On Delay Interface

TON IN BOOL

BOOL Q

PT TIME TIME ET

Page 54: COMPUTER-AIDED SYSTEM SOFTWARE

54

Figure 20. The TON operation diagram

12.8.4. Runtime Clock

The interface of the function block RTC (the runtime clock), and the type description of the input and output variables are presented in table 14.

Table 14 The Interface of the RTC Function Block

RTC EN BOOL BOOL Q

PDT D_A_T D_A_T CDT

Instantiating the function block the output Q is FALSE and the CDT output is DT#1970-01-01-00-00:00:00 while the EN input is FALSE. The PDT time set by a rising edge starts to be counted up. As long as the runtime clock is keeping the time, and the EN input is TRUE, the Q output is TRUE. If EN is reset to FALSE, CDT is reset to the initial value DT#1970-01-01-00-00:00:00.

The RTC realization described above cause a lot of difficulties. It is obvious that the clock should keep running when PLC power is off. The clock rate correction of the certain function block instances should be performed at the application layer. A number of PLCs have the hardware-realized runtime clock. To support the RTC block the access to hardware realized clock is easier to be arranged through the directly addressed memory cells.

12.9. Triggers

The operations of the SR and RS latches is to be explained easier by analogy with electrical appliances. Let’s use an electrical starter as an example. Just two buttons, START and STOP, are used to switch the starter on/off. These

Page 55: COMPUTER-AIDED SYSTEM SOFTWARE

55

are the self-return switch buttons, so the switching is performed by a short push. The starter fixes its eigenstate.

This is a way that the SR and RS triggers operate in. Their operations are different just by the simultaneous button action.

Triggers the SR and RS have different behavior only in case when pushing both buttons. The block SR has dominant «START», and RS has dominant «STOP».

12.9.1. SR Latch with Set Domination

The SR block interface, and the type description of input and output variables are displayed in table 15.

There is two constant states in a SR latch: Q is TRUE and Q is FALSE. The following statement is used to describe the SR operation in ST language:

Q = (NOT RESET AND Q) OR SET.

The input SET makes the output in, the RESET makes it off. If both inputs are run simultaneously, the SET input is the dominant one. The diagram of the SR latch operation is shown in figure 21.

Figure 21. The Diagram of the SR Latch Operation

12.9.2. RS Latch with Reset Domination

The RS block interface, and the type description of input and output variables are displayed in table 16.

Table 15 The SR Block Interface

SR SET BOOL BOOL Q

RESET BOOL

Page 56: COMPUTER-AIDED SYSTEM SOFTWARE

56

The RS latch has two constant state when Q is TRUE and Q is FALSE. The following statement is used to describe the RS operation in ST language:

Q = NOT RESET AND (Q OR SET).

The SET input makes the output in, the RESET makes it off. If both inputs are run simultaneously, the RESET input is the dominant one. The diagram of the RS latch operation is shown in figure 22.

Figure 22. The Diagram of the RS Latch Operation

12.10. Pulse Detector

Pulse detectors are intended for use when the response to change of the discrete signal is required, and not to the discrete signal state.

12.10.1. Rising Edge Detector R_TRIG

The interface of rising pulse detector is displayed in table 17.

The function block R-TRIG will generate the unit pulse if the rising-edge is detected at the input. The R_TRIG operation diagram is presented in figure 23.

Figure 23. The R_TRIG Operation Time Diagram

Table 16 The RS Latch Interface

RS SET BOOL BOOL Q

RESET BOOL

Table 17 The R_TRIG Interface

R_TRIG CLK BOOL BOOL Q

Page 57: COMPUTER-AIDED SYSTEM SOFTWARE

57

12.10.2. Falling Edge Detector F_TRIG

Table 18 presents the interface of the falling edge detector.

The function block F_TRIG will generate the unit pulse if the falling edge is detected at the input. The F_TRIG operation time diagram is presented in figure 24.

Figure 24. The F_TRIG Operation Time Diagram

12.11. Counters

There are several types of counters: incrementer, decrementer, incrementer/ decrementer counters.

12.11.1. Function Block Incrementer CTU

The CTU incrementer interface, which increases the value of the output variable, is displayed in table 19.

The counter value CV will be raised by 1 if CU input has a rising edge from TRUE to FALSE. The Q output will return to TRUE when CV is greater than or equal to the upper limit PV. When reset input is TRUE, the up count input CV is cleared (CV:= 0).

12.11.2. Function Block Decrementer CTD

The CTD decrementer interface, which decreases the value of the output variable, is displayed in table 20.

Table 18 The F_TRIG Interface

F_TRIG CLK BOOL BOOL Q

Table 19 The CTU Incrementer Interface

CTU CU BOOL

BOOL Q

RESET BOOL PV WORD WORD CV

Page 58: COMPUTER-AIDED SYSTEM SOFTWARE

58

When LOAD is TRUE, the counter variable CV will be initialized with the upper limit PV. If CD has a rising edge from FALSE to TRUE, the CV output will be lowered from 1 to 0 provided that CV is greater than 0 (i.e., it doesn’t cause the value to fall below 0). The Q output returns to TRUE when CV is less than or equal to 0.

Table 20 The CTD Decrementer Interface

CTD

CD BOOL

BOOL Q

LOAD BOOL

PV WORD WORD CV

12.11.3. Incrementer/ Decrementer CTUD

The CTUD incrementer/ decrementer interface is displayed in table 21.

Table 21 The CTUD function block interface

CTUD

CU BOOL

BOOL QU

CD BOOL BOOL QD

RESET BOOL

LOAD BOOL

PV WORD WORD CV

If RESET is TRUE, the counter variable will be reset to 0. If LOAD is TRUE, the counter variable CV will be initialized with the PV value.

The CTUD function block will increase CV by 1 when up counter input CU changes from 0 to 1, and CV is decreased by 1 when down counter input CD changes from 0 to 1.

The QU output will be TRUE if CV is greater than or equal to PV, otherwise it is FALSE. The QD will be TRUE if CV is equal to 0, otherwise it is FALSE.

Page 59: COMPUTER-AIDED SYSTEM SOFTWARE

59

12.12. Bit Serial Access to Integers

The following instruction used for bit serial access to integers: bit read, bit record, pack and unpack.

12.12.1. Bit Read

The EXTRACT function of type BOOL has two input parameters: DWORD X and BYTE N. The function returns TRUE if the bit number N of the X input is equal to 1, otherwise it is FALSE. The bit numeration is started from 0.

12.12.2. Bit Record

There are three input parameters in the function of type DWORD: DWORD X, BYTE N and BOOL В. The function will return back X with the Nth bit set in 1 while B is TRUE. Otherwise, the N bit is equal to 0.

12.12.3. Function Block PACK

Packing the eight Boolean variables as a byte. The PACK function gets eight input parameters В0, В1, В7 of type BOOL. The return value of type BYTE contains the value pack of the input parameters.

12.12.4. Function Block UNPACK

Unpacking the input of type BYTE into eight Boolean variables. The function block UNPACK has one input of type BYTE and eight outputs of type BOOL, and this is the opposite operation to the PACK function block.

12.13. Hysterisis

The hysterisis block interface is presented by the table 22.

Table 22 The Hysterisis Block Interface

HYSTERESIS

IN INT

BOOL OUT

HIGH INT

LOW INT

The function block HYSTERESIS realizes the comparator which provides the hysteresis effect.

Page 60: COMPUTER-AIDED SYSTEM SOFTWARE

60

If the IN value exceeds the HIGH threshold, the OUT will be FALSE. Ig the IN value is below the LOW threshold, the OUT will be TRUE. The output of the function block HESTERISIS is not varied within the range from LOW to HIGH. The hysteresis operation diagram is shown in figure 25.

Figure 25. The Hysterisis Block Operation Time Diagram

12.14. Threshold Signal Indicator LIMITALARM

The interface of threshold signal indicator is displayed in table 23.

Table 23 Interface of Threshold Signal

Indicator

LIMITALARM

IN INT

BOOL O

HIGH INT BOOL U

LOW INT BOOL IL

The LIMITALARM function block monitors the corresponding of the input value to the range given. The result is formed by the Boolean outputs LOW, HIGH, IN. The input signal value IN is compared to the upper (HIGH) and lower (LOW) thresholds. All the input variables are of integer type signed (INT). Three Boolean outputs provides the comparison result:

• the O output alarms the increased value (IN > HIGH); • the U output alarms the decreased value (IN < LOW); • the IL output reports the nominal value (LOW<= IN >= HIGH).

The LIMITALARM operation diagram is displayed in figure 26.

Page 61: COMPUTER-AIDED SYSTEM SOFTWARE

61

Figure 26. The LIMITALARM Operation Diagram

12.15. Limiting the Signal Changing Rate

Table 24 shows the interface of the function block which limits the signal changing rate.

Table 24 The RAMP Block Interface

RAMP

IN INT, REAL

INT, REAL OUT

ASCEND INT, REAL

DESCEND INT, REAL

TIMEBASE TIME

RESET BOOL

The function block RAMP limits the signal changing rate.

A signal is free passed to the input if the input current value is increased by more than ACSEND or decreased within the DESCEND limits compared to the preceding value. If the rate of signal growth or fall is high, the signal changing will be limited. TIMEBASE set the time interval to detect the changing. The momentary changing is calculated in such a way as to avoid the overrun of the assigned limits in the set time interval. If TIMEBASE is equal to t#0s, the fetch cycle of a function block instance will be used as the interval.

Page 62: COMPUTER-AIDED SYSTEM SOFTWARE

62

The reset (RESET:= TRUE) call the immediate assignment of the input value to the output. The monitoring of changes starts from the current value after the reset release.

12.16. Interpolation of Dependence

The Interface of the dependence interpolation block is presented in table 25.

The function block CHARCURVE performs the piecewise-linear interpolation of dependencies set by vector of the anchor points values. Interpolation means the calculating the values of dependence which is assigned by anchor points in gaps between these points.

Assume the input value x belongs to the interval 1 .i iX х X− < < Then, y is in the line segment connecting the corresponding anchor points (Xi-1, Yi-1) and (Xi, Yi). The у value is estimated by the straight line formula:

( )1

1

.i ii i

i i

Y Yy Y X xX X

−= + −−

The vector of anchor points CHARCURVE should be represented in еру form ARRAY P [0..10], where P is a structure of type POINT, which consists of two INT variables X and Y. The N input (BYTE) specifies the anchor point number which should not exceed 11, corresponding to ten interpolation segments. The data are transmitted to the IN input (INT) and after the conversion they occur at OUT (INT).

The anchor points should be sorted in ascending order of X values. The ERR output provides error diagnosis of applying the CHARCURVE function block (table 26).

Table 26 Error Codifier

ERR Interpretation 0 no error pending 1 the array of points is sorted incorrectly 2 the input value is out of allowed values: IN < Р[0].Х or IN > P[N-1].X 4 wrong value N: N < 2 or N > 11

By the error detection OUT gets the corresponding value Р[0].

Table 25 The CHARCURVE Interface

CHARCURVE IN INT

INT OUT

N BYTE BYTE ERR P ARRAY

Page 63: COMPUTER-AIDED SYSTEM SOFTWARE

63

12.17. Derivating

The function block DERIVATE provides numerical differentiation of the input signal. Table 27 represents the interface of the DERIVATIVE function block.

Table 27 The DERIVATIVE Block Interface

DERIVATIVE IN REAL

REAL OUT

TM DWORD

RESET BOOL

The signal derivative is calculated using two ordinates and time increment. Dividing the signal increment by time increment we’ll get the approximate derivative value. To get the precise value the infinitesimal increment should be used, which is practically impossible. The two-point calculation of a derivative produces good results by using the precise values of ordinates. A quantizing error as well as the different high-frequency noises generally occurs by processing the digitized measurement data. The slight ordinate deviation from one of two points affects the result essentially. That is why the function block DERIVATIVE applies the improved formula derived from the interpolation polynomial of four ordinate values.

The DERIVATIVE function block, which is included into the CoDeSys util.lib library, calculates the derivative value according to the following formula:

( )0 3 1 2

2 1 0

3Out .

3 4 3y y y yT T T

− + −=

+ +

The graph representing the differentiation formula of this function block is shown in figure 27.

The sampling time intervals are not obligatory to be regular.

The ordinates of four latest calls of the function block are stored. The values are shifted by each subsequent call of a function block instance.

The derivative value provides the only output OUT of type REAL. y0 is IN, and Т0 is ТМ in the reduced formula. At the moment of reset (when RESET is TRUE) and the first instance initialization (first call) the ordinates y3, y2 and y1 will take the value IN. The output OUT is equal to 0.

Page 64: COMPUTER-AIDED SYSTEM SOFTWARE

64

Figure 27. The Four Value Differentiation

The function block DERIVATIVE relies on central difference formula. Practically, it calculates the approximate derivative value for the point corresponding to the interval center Т1. As a result, the output is delayed for one and a half of the instance call cycle towards to the input. .

12.18. Integrating

The function block INTEGRAL approximately determines the certain integral of the function. The INTEGRAL block interface is represented in table 28.

Table 28 The INTEGRAL Function Block Interface

INTEGRAL IN REAL

REAL OUT

TM DWORD BOOL OVERFLOW RESET BOOL

The integral value provides the output OUT. The Overflow output of type BOOL alarms that the maximum value of the OUT variable of type REAL is overflowed.

Before starting the calculations the reset should be performed. Then, the specified integrating interval is divided into several small parts. The integral value is calculated by cyclic summation method. The function block gets the new input value IN and the corresponding time increment TM by each instance call. The integral is approximately calculated by the method of rectangles. The integral value is approximate to the sum of rectangle areas.

Page 65: COMPUTER-AIDED SYSTEM SOFTWARE

65

All values are cleared the overflow alarm is canceled when the RESET input is TRUE.

TM is described in milliseconds but this marks the most common application area. There is no reason to interfere the INTEGRAL block operation with indefinite time scale (seconds, hours, etc.)

12.19. PID Controller

12.19.1. Control Algorithm Description

Proportional integral-derivative controller is the most widely used type of automatic feedback controllers. The block interface is displayed in figure 28.

Figure 28. The PID Function Block Interface

Let us take a brief look at PID controller operation. Suppose a certain object has an input that allows to control this object and a sensor that estimates the object response (an output variable). Furthermore, various perturbing factors affect the object. This is how the output variable can be altered even by the constant reference input . The difference between the reference input and the output variable is the control error e ( t ) . The controller task is to change automatically the input action y ( t ) so that the perturbing effects will be minimized.

Controllers regulate any process which has a measurable output such as voltage, pressure, temperature, rate of travel, etc. A mathematical model of such an object involves the differential equation system. The optimal law of control can be derived from the object model. However, this is quite a difficult task. Practically, the all-purpose controller is applied for most industrial automation. The law of control is formed by tuning three constants, which are calculated from object model or fitted experimentally. The PID controller equation takes the form:

Page 66: COMPUTER-AIDED SYSTEM SOFTWARE

66

( ) ( ) ( ) ( )0

0

1 ,t

pn

de ty t Y K e t e t T

T dt

= + + + ∫ ν

where Y0 is zero error value (initial value), Kp is proportionality constant, Tn is integral time, Tυ is derivative action time.

The proportional controller term produces an output value that is proportional to the current error value. The low proportional gain results in a small output response to an infinitely long-lasting error.

Even the small constant error integration results in a constant increasing of proportional gain. Thus, the controlling accuracy is attained on the change of object characteristics. The derivative term of a PID controller improves the dynamic characteristics, compensating delay of the control signal phase.

The input variable descriptions of the PID controller are presented in tables 28 and 29.

Table 29 The Description of Block Inputs

Input Data Type Description ACTUAL REAL response signal SET_POINT REAL desired value, task КР REAL transmission coefficient TN DWORD integral time (msec) TV DWORD derivative action time (msec) Y_MANUAL REAL manual task Y_OFFSET REAL offset for the manipulated variable Y Y_MIN REAL lower limit for the manipulated variable Y Y_MAX REAL upper limit for the manipulated variable Y MANUAL BOOL manual mode RESET BOOL reset

Table 30 The Description of Block Outputs

Y REAL manipulated value

LIMITS_ACTIVE BOOL Indicator of achieving the prescribed limits

OVERFLOW BOOL indicator of overflow

Page 67: COMPUTER-AIDED SYSTEM SOFTWARE

67

12.19.2. PID Controller Setting

There are numbers of PID regulator setting, such as the Ziegler-Nichols method, the Kuhn method, the Schedel method, the Shubladze method.

The Ziegler-Nochols method was developed by American engineers John Ziegler and Nathaniel Nichols. Here are the main principles of this method:

• the integral and derivative gains are set to zero in the function system(ki = ∞, kd = 0), i.e., the system is transferred to P control;

• by gradually increasing kp and generating a jump signal the output generates sustained oscillations with the Tcr period. The system is put on the oscillation boundary. Thus, the critical gain Kcr and the corresponding period in the system Tcr are determined. By critical oscillations no variables can exceed the limiting level;

• the PID controller parameters are set according to the formula shown

below: cr crcr0,6 , , .

2 8p i dT Tk k k k= = =

This method have been widely used in process control systems when the plant dynamics are not known precisely. A majority of experts recognize the significant overshoot and putting the system on the stability limit as the main disadvantage of this method.

The general drawback of the existing methods is approximation of driving models, which contain neither zeroes nor lag units.

The considered engineering methods are easy to operate. However, let’s consider actual advantages and disadvantages.

The basic concept of the Ziegler-Nichols method is putting the control system on the stability limit. The sustained oscillations of the output signal are generated by increasing the proportionality coefficient. An obvious advantage is the simple realizing of this method because there is no need for opening the control system loop and further examining the object. However, not every object is allowed to exceed the stability limits according to the operating procedure. Oftentimes this condition is unrealizable. It should be noticed that the system with a PID controller that is set by this method can easier be overcontrolled.

According to the Shoubladze method of adjusting the PID controller the control object is approximated by a lag element of nth rank. The system gets the high level of stability, there is no possibility for overregulation, but the transient period is extended considerably. The Shoubladze method is

Page 68: COMPUTER-AIDED SYSTEM SOFTWARE

68

effective for inertial objects of low dynamics. A disadvantage of this method is the great number of calculations performed by determination of the controller coefficients.

The Kuhn method is based on the calculating the total time constant of the object. This method is effectively used by adjusting a controller for a low-order control object the first or the second-order object). Increasing the order demands the significant overshooting the synthesized system.

Using the Schedel method of a PID controller adjustment the system offers the shortest transient period as compared to other methods of PID controller adjustment. However, the increasing the overregulation of the control system also occurs by using the Schedel method. The analysis of the existing methods of the PID controller adjustment revealed that decision for one or another method should be based on control object characteristics and requirements of the synthesized system. If the higher system performance is required, the Ziegler – Nichols method and the Schedel method are preferable. If the opportunity of overcontrol is of crucial importance, PID controllers, which are adjusted by the Shoubladze and the Kuhn methods, provide more efficient system operation.

The general drawback of the existing methods is approximation of driving models, which contain neither zeroes nor lag units. The considered methods assure the stability of the synthesized control system. However, to execute the process successfully a controlled parameter should be altered in the certain time period with the deviation within a certain limit. In other words, a control system should have the certain quality indicators: these are overcontrol and control time, which should be provided by PID controllers. So it is necessary to design a method of setting the PID controllers which ensure the certain quality indicators.

Developing this method a designer will face the issue which concerns the approach alternatives. This paper offers to use the root approach, because it allows to evaluate the dynamics of the synthesized control system.

The problem of developing the methods of PID controller adjustment continues to be relevant so far. Scientists develop different frequency, algebraic, root methods, link the controller settings to different quality indicators, which should provide the required quality of running the control loops.

Page 69: COMPUTER-AIDED SYSTEM SOFTWARE

69

13. USER INTERFACE

Most automation systems are human – assisted. The interface between a person and a system is called the human-machine interface (HMI) or man-machinery interface (MMI). In particular, if the HMI is designed for the interaction of a person and an automatic technological process, it will be called the SCADA system – Supervisory Control And Data Acquisition. Modern SCADA packages include the wide range of features which exceeds just the data acquisition and supervisory control.

13.1. The SCADA Functions

The current SCADA packages perform the set of functions which could be divided into several groups:

• the SCADA task tailoring (i.e. developing the software component of automation system);

• supervisory control; • automatic control; • process data store; • performing the security functions; • performing the general-system functions.

In spite of set of functions performed by SCADA its main distinguishing characteristic is the user interface. Without that kind of interface the listed above functions match the functions of controller programming tools, and the control process is performed automatically as contrasted to the supervisory control.

Quality of the decisions made by a supervisor (operator) often impact not only the quality of products but also the human life. For this reason, the ergonomic work station, the interface readability, available prompting and delay of obvious errors are most significant SCADA characteristics, and their development is performed towards the human factor engineering and the expert subsystem design.

Sometimes SCADA is completed with controller programming tools, but this is due to commercial purposes and can hardly be related to the primary purpose of SCADA.

The SCADA packages include the alarm and event terms. Event is a change of some states in the system. E.g., powering on/off the equipment,

Page 70: COMPUTER-AIDED SYSTEM SOFTWARE

70

termination of the part process, the new operator registration, etc. Events don’t require the supervisor’s intervention, they just inform him about the system condition.

Alarm is a warning of a significant event, and the certain actions should be taken as a response to this warning. Coming to the critical value of pressure when a the cladding break is possible, actuation of sensors in a security system, gas contamination of a boiler room, etc are all the examples of alarm signals.

As the alarms require a decision- making they are divided into confirmed and unconfirmed. The confirmed alarm is supported with the supervisor’s confirmation as the response to this alarm. Up to this point the alarm is considered to be unconfirmed.

Alarms are divided into the discrete and the analog ones. Discrete alarms indicate the discrete variable change, the analog alarms monitor whether the analog variable y(t) exceeds the limit values which are given in advance. As an example, figure 28 displays the division of the y(t) variable into the following increments: NORMAL, ATTENTION (pre-emergency status) and «ALARM:

• ATTENTION occurs when у(а) < y(t) < у(b) by increasing the observable variable and when y(d) < y(t) < у(с) by its decreasing;

• ALARM occurs when у(b) < y(t).

Figure 29. The Alarm Signal Realizing

Page 71: COMPUTER-AIDED SYSTEM SOFTWARE

71

Each critical line in fig. 29 has a blind spot preventing the variable to be returned to the alarm value because of the random noise in the system. The blind spot limits can change with time.

The similar limits can be adjusted for the variable rate (for the derivative of the y(t) function) which is calculated as the а angle of the y(t) curve.

The alarm generating method should be reliable. In particular, the pop up windows with alarm messages should always be displayed on top and followed by sound and light signals. Since there is a large number of alarms in the system, they are prioritized and get different sound volume and tones, etc.

13.2. Design Of Human-Machine Interface

Designing the human-machine interface is one of the basic SCADA functions, i.e., SCADA is the HMI and also the development tool of HMI simultaneously. The development rate affects profitability of the company which provides the implementation of the automation system, so the development rate is the main indicator of SCADA quality from the viewpoint of system integrators. The development process includes the following operations:

• the graphic interface design (mnemonics, graphs, tables, pop-up windows, input elements for operator commands, etc.);

• programming and debugging the algorithms of automatic system operation. Many SCADA provide system debugging both by implementing the emulated equipment and by the connected hardware;

• setting the communication system (networks, modems, communication controllers, etc.), data base creation and their connecting to SCADA.

13.3. SCADA As A Supervisory Control System

As a system of supervisory control SCADA can provide following tasks: • operator interaction (exhibition of visual and auditory information,

the transfer of operator commands into the system); • operator assistance by decision-making (the expert system functions); • automatic alarm signaling; • issue of informative messages to the operator station; • system event logging; • acquisition of information from the data store and its operator-

friendly representation;

Page 72: COMPUTER-AIDED SYSTEM SOFTWARE

72

• report generation (e.g., printing the temperature table, operator schedule, operator function list);

• accounting the in-service time of the production equipment.

13.4. SCADA As A Part of Automatic Control System

The main part of automatic control tasks is usually performed using PLC, but a certain part of the tasks can be imposed on SCADA. Furthermore, there can be no PLC in many of small control systems at all, and this case a computer with the installed SCADA is the only control tool. SCADA usually performs the following automatic control:

• automatic regulation; • the operating sequence control in automation system; • adaptation to the operational changes; • automatic locking of operation units by meeting the certain

requirements which are specified in advance.

13.5. Workflow History Storage

Information about historical data of a controlled process makes it possible to improve the system operation in the future, analyze the problem cause or defective products, detect the operator errors. To create the workflow history the system performs following operations:

• data acquisition and processing (digital filtration, interpolation, reduction, scaling, etc.);

• data backup (operator actions, gathered and processed data, events, alarms, graphs, screen forms, configuration files, reports, etc.);

• data base management (online and archive data).

13.6. SCADA Security

The SCADA implementation in the remote access systems through the Internet increased suddenly the SCADA vulnerability to the hostility. Discounting this problem can result e.g. in failures of electrical networks, life-support systems, communications, see markers, traffic lights, in water contamination with sewage, etc. More serious consequences with human and economical losses are also considered to be possible. To improve the SCADA security following methods are used:

Page 73: COMPUTER-AIDED SYSTEM SOFTWARE

73

• system access security in different user levels (an operator, a process engineer, a programmer, and a director should have different access rights to information and modifying the system settings);

• data security (by data encryption and providing the communication protocol security);

• providing the operator security due to his remote workstation from the dangerous controlled process (remote control). Remote supervisory and control are the standard requirements of Rostechnadzor, Federal Service for Environmental, Technological and Nuclear Supervision, and performed via the wired network, radio channel (via the GSM or wireless modem), via the Internet, etc.;

• different methods of cyber attacks; • firewall implementation.

The general – system functions. As far as SCADA is usually the only program for the automation system control it can also provide any of general-system functions:

• providing the interactions between several SCADA, between SCADA and other programs (MS Office, database, MATLAB, etc.);

• diagnostics of hardware, communication links and software.

13.7. SCADA Characteristics

Analyzing the characteristics of different SCADA systems enables to choose the optimal system to complete the assigned task. A great number of SCADA characteristics can be divided into the groups as follows:

• tool properties; • performance properties; • degree of openness; • economical efficiency.

13.8. Tool Properties

The SCADA properties, which influence the integrator operating efficiency, are qualified as tool properties:

• rapidity of project development; • accessibility; • supported communication tools;

Page 74: COMPUTER-AIDED SYSTEM SOFTWARE

74

• functions for advanced data processing; • IEC – 61131 languages and the universal algorithmic language of the

Visual Basic type; • degree of openness for developer (COM and ActiveX support for

connection of user programming modules, and ОРС, ODBC, OLE DB as well);

• specification quality (completeness, полнота, clear presentation, , error frequency);

• emulation mode for debugging equipment; • internal graphic editors, which allow to avoid using the external

editor such as CorelDraw or Photoshop; • support of standard graphical file formats; • technical assistance quality (response time to user’s questions,

available hot-line).

SCADA systems use the IEC- 61131 languages oriented on process engineers and supplemented by the SCADA specific functions. Most SCADA include the embedded editor and the Visual Basic interpreter of the Microsoft company.

13.9. Performance Properties

The SCADA operation quality is estimated by end users and incorporates following characteristics:

• robustness (resistance to user’s errors, tampers, hostile elements, and source data errors);

• reliability; • information security; • data storage tools available in emergency situations, power

interruptions and system failure; • automatic system restart after the system hang or power interruption; • redundancy support (operator station, network servers, customer

working stations, data backup); • screen switch with different zoom properties; • support of several displays.

Page 75: COMPUTER-AIDED SYSTEM SOFTWARE

75

13.10. Degree of Openness

Openness has a significant effect on the economical efficiency of a system. However, this influence is of random nature because it depends on efficiency of openness properties in a certain project.

The SCADA openness provides the system connection with software units, which are developed by users or other manufacturers. This is due to the fact that SCADA is developed as a container for the COM objects and ActiveX elements. Compatibility with hardware and database of other manufacturers is achieved by OPC standard, use of the ODBC or OLE DB interface. The openness of SCADA is achieved by support of IEC 61131-3languages.

The web-interface provides the access to SCADA from any computer regardless of hardware platform, type of communication channel, operating system, and web-browser applied.

13.11. Economical Efficiency

The SCADA economical efficiency can be defined as a ratio of system implementing benefit to the total cost of the installation and system maintenance. Eventually, the economical efficiency is influenced by almost all SCADA characteristics, but the impact of the following features is to be specially emphasized:

• scalability (adaptability to large and small systems); • modularity. The modularity allows to make an appropriate system

version as required. The input – output unit, rendering husk, alarm unit, trend module, report module, accounting module of commercial electricity and heat, etc. can be applied as standard modules;

• maintenance cost; • update requirements; • supplier reliability, operational experience available; • training cost; • cost of technical assistance; • pricing methods.

The common drawback of the general – purpose SCADA systems is the low economical efficiency when the system is used for trivial task solving. In spite of the fact that the cost of SCADA packages is essentially decreased by reducing the number of user-available tags and modules the cost of technical assistance remains high. Adapting the general – purpose SCADA

Page 76: COMPUTER-AIDED SYSTEM SOFTWARE

76

for the specified objective also remains a time-consuming and expensive, respectively. So a number of companies offer more single-purpose micro-SCADA with a limited number of functions, which are easy to set, e.g. the RLDataView package (www.RealLab.ru).

13.12. MasterSCADA

The MasterSCADA system produced by InSAT company is designed for creating the fully specified automation systems in different industries. The key feature of the system is the object orientation used on the level of system description when the system is adjusted to a certain automation object. E.g., a workshop, a production area, a technological unit, and a physical device are considered as single objects by a project design where MasterSCADA is applied to. The technology language description is designed for each object. This description includes object characteristics and object documentation. Object characteristics can include a poll period, a sensor linearization method, an input range. The object image, the mnemonic diagram, the graph of variable behaviour etc. are related to the object documentation. Each system file is related to a certain object. This approach provides the multiplication of the objects which have been already designed so that the rate of SCADA adjustment to the user tasks is essentially increased.

The setting inheritance from the «parent» objects also belongs to the characteristics of object orientation. I.e., there is no need to adjust settings for each object type from scratch in MasterSCADA. The parent object settings can be inherited. You should just modify the settings which make the difference between the parent and descendant objects.

The designed object can be copied with the purpose of reusability. All the properties and files related to the object are saved during the object copying. The connection with external data sources and data receivers are restored process if there are appropriate data sources or vacant data receivers (physical devices) in the system after the copying. It allows to add newly designed objects to the object library and use the objects that have been designed by other developers.

Page 77: COMPUTER-AIDED SYSTEM SOFTWARE

77

14. OPC-SERVER

The OPC standard was designed by the international organization OPC Foundation, which currently includes more than 400 members. These are the companies in automation and measurement technologies. The organisation was founded by Fisher-Rosemount Inc., Rockwell Software Inc., Opto 22, Intellution and Intuitive Technology Inc. The first OPC standard version was released in 1998. The executives from Siemens AG, Emerson Process Management, Yokogawa, Honeywell, Rockwell Automation, ICONICS were members of OPS Foundation Board of Directors in 2008.

14.1. The ОРС Standard Review

The main purpose of OPC standard is providing the interoperability of automation facilities operating in different field networks which are based on different hardware platforms and produced by different manufacturers. Up to the OPC standard development the SCADA package should be individually adapted to each new equipment. There were long lists of «supported equipment», and the technical support was too complicated. The driver alterations should have been made by the equipment modifying. Each of the drivers supported the data communication protocol only with one client-side program. A number of such drivers amounted to several hundreds.

Almost all SCADA packages were redesigned as OPC client after the OPC standard had been developed. Each hardware manufacturer began to supply his controllers, input-output modules, smart sensors and operation units with the standard OPC server. Due to the standard interface the connection of any physical devise to any SCADA package is possible if they conform to the OPC standard. Developers finally had the opportunity to design only the single driver for all SCADA packages, and users got a choice of equipment and programs without earlier compatibility constraints.

The OPC standard refers just to the interfaces which are provided by OPC server for the client-side programs. The mean of communication between the server and the hardware (e.g., with input – output modules) is not provided by the standard and should be realized by the hardware developer. So the OPS standard can be used not only for SCADA and hardware interaction but also for data exchange with any data provider, e.g. with a database or a GPS receiver.

The OPC server as means of interaction with technical device can be applied by developing the custom programs in C++, Visual Basic, VBA, Delphi, etc.

Page 78: COMPUTER-AIDED SYSTEM SOFTWARE

78

For these purposes the OPC server is applied as a Microsoft DCOM object with difference in standard notations and specific terminology in the field of industrial control. Using the OPC standard by developing the custom programs enables the easier access to hardware through the COM interfaces.

The OPC standard includes the following parts: • ОРС DA (ОРС Data Access) specification designed for real time

data exchange between a client (e.g. SCADA) and the hardware (controllers, input – output units, etc.);

• ОРС Alarms & Events (А&Е) specification is intended to report the alarms and events in the system and make them available to the client applications. This server transmits alarm signals, operator actions, information messages, supervisory data of system conditions;

• ОРС HDA (Historical Data Access) specification provides the access to historical data (to the data store).The OPC server enables the uniform access by means of DCOM technology. It enables data reading, record and modification;

• ОРС Batch specification is designed for the specific physic–chemical not continuous batch processing. In such processes the a number of different raw materials is loaded according to prescribed parameters, the processing mode is set, and when the processing cycle is completed and the final product is delivered, the next batch is loaded. The OPC server provides the exchange of between the server and a client application of prescriptions, technical characteristics, processing conditions and results;

• ОРС Data exchange specification enables data interoperability between OPC DA servers over the Ethernet;

• ОРС Security specification is need to control client access to the server in order to protect the sensitive information and guard it against unauthorized modification of process parameters;

• OPC XML-DA specification is a set of flexible and rulesand presentation formats of initial data by means of XML-based language, web- technologies,and SOAP messages;

• ОРС Complex Data specification is the addition to ОРС DA and XML-DA which enables servers to work with complex data,such as binary structures and XML- based files;

• ОРС Commands specification is a set of program interfaces, which enables the OPC clients and servers the identifying, order and control

Page 79: COMPUTER-AIDED SYSTEM SOFTWARE

79

of commands executed in technical device (in a controller, in a input- output unit);

• ОРС Unified Architecture specification is a fundamentally new set of specifications which is not based on the DCOM technology.

Only two from the specifications listed above, OPC DA and OPC HAD, are commonly used in Russia.

14.2. ОРС DA Server

The OPC DA server is most in demand in industrial control. It provides the data exchange (record and reading) between a client application and physical devices. The data include three fields: a value, the quality and a timestamp. The value quality enables the information transfer from the device to a client application concerning the value exceeding the dynamic range, lack of data, communication errors, etc.

There are four data read modes from OPS server. 1) synchronous read mode: the OPC client sends the request and waits

for the response to resume its processing; 2) asynchronous read mode: the OPC client sends the server request

and immediately starts to perform the next task. The client is informed of new data values by the server whenever changes occur.

3) subscription mode: the OPC client reports the list of tags, which values should be sent back by the server only if they are changed. Not to mistake the data noise for the data value changing the “dead band” concept is introduced. The dead band easily exceeds the noise signal limits;

4) update mode: the OPC client calls the simultaneous reading of all active tags. A tag is active if it is not marked as a passive one. This tag division reduces the processor overload by updating the data received from the physical device.

In each of these modes the data can be read either from the OPC server cash or from the physical device. Reading from cash is performed much faster than directly from the physical device, but the data can become outdated to the moment of reading. That is why the server should refresh the data as frequently as possible. To reduce the processor overload the update rate is used, which is set to each tag group individually. Moreover, it is possible to mark some tags as the passive ones, so their values will not be updated from the physical device.

Page 80: COMPUTER-AIDED SYSTEM SOFTWARE

80

The data recording into the physical device can be performed in two ways: by synchronous and asynchronous methods. It is completed directly into the device without buffering. In synchronous mode the recording will be performed until the confirmation of the completed record is sent from the device. This is a time-consuming process, and the client has no opportunity to continue his work till the end of the function. In asynchronous mode the client sends data to the server and continues to work. When the record is completed the server sends the corresponding notification to the client.

The OPC server can have the user interface (but not compulsory), which enables any utility functions to ease the equipment control, e.g. to perform the following functions:

• searching the equipment connected to the field network; • adjusting the equipment settings (name, address, rate of data

exchange, watchdog timeout, hash total, etc.); • representing the tag names hierarchically; • supervising the tag values; • control over the access rights to the OPC server.

According to the standard the OPC server are automatically entered into Windows registry. The server is started like any other program, or automatically from the client-side program.

The C++ program (e.g. the SCADA package) and also the Visual Вasic, VBA or Delphi programs can act as the OPC client, so as any other program, which supports the COM embedding.

The OPC server and OPS clients are run only on the computers and controllers that support the DCOM technology (e.g. Windows ХР or Windows СЕ).

The OPC server is connected to the physical devices by any methods; these methods are not prescribed in the OC standard.

The client application and the OPC server can be installed either at the same computer or at different computers within the Ethernet. When there are several computers in the network each of them can have the OPC server installed and physical devices connected to. Any of the OPC clients may request any of OPC servers from any computer in this system, even if the server is installed at another computer within the network. It is provided by using the Remote Procedure Call in the DCOM technology.

Page 81: COMPUTER-AIDED SYSTEM SOFTWARE

81

A number of the OPC servers from different manufacturers can be installed at a computer (a controller). However, the OPC server exclusively occupies a COM-port of the computer (because it continuously performs the data updating), so the number of ports should be equal to the number of the OPC servers. To provide the additional number of COM-ports the USB interface can be converted into RS- 232, etc. Different field networks can be connected to different computer ports, and this case the OPC servers act for the gateways.

14.3. ОРС HDA Server

The purpose of the OPC HAD server (the historical data access server) is to identify interfaces used to pass historical data between the client applications and any of databanks. A nonstandard data file, a standard DBMS, the OPC DA server or other OPC HAD server can be used as databanks.

The OPC HDA specification sets a standard for COM interfaces and methods of their implementation. The server structure and the ways of interaction with client applications are identical to the common OPC standards including the OPC DA described above. E.g. the OPC client application can be connected to several OPC HAD servers of different manufacturers, and be installed on different computers within the Ethernet.

There are two types of the HDA servers: • the simple HDA server for graphing; • the HDA server intended to store the packed data with possible data

processing and analysis. The processing and analysis functions are the calculating the average, the maximum and the minimum values, etc. The data handling involves data reading, data recording and data changing.

14.4. ОРС UA Server

In spite of real success and general acceptance the following disadvantages of the OPC technology became apparent in actual practice:

• availability just on Microsoft Windows operating systems; • communication with the DCOM technology, which source codes are

closed. It doesn’t enable to decide the SW reliability issues, detect and eliminate the program failures;

• occasional problems in configuration related to DCOM; • inaccurate DCOM reports about communication failures;

Page 82: COMPUTER-AIDED SYSTEM SOFTWARE

82

• DCOM is not adapted to the data exchange via the Internet; • DCOM is not adapted to the information security.

Taking all of this into account, OPC Foundation developed the new specification in 2006 targeted for data exchange in industrial control systems. The specification was named OPC Unified Architecture and considered as the next generation OPC standard.

The OPC UA sets the mechanisms of data exchange between the OPC server and the client application independent of the hardware and software platform and the type of systems and networks. The OPC UA provides the reliable and secure communication, virus resistance and ensures the information identity.

The standard means by the object concept a physical or an abstract element of the system. Physical devices which include their systems and subsystems can be considered as the examples of objects. A temperature sensor can be considered as the object which includes the temperature value, a set of alarm parameters and alarm limits. The object is defined as a class instance, and the class is considered as a data type. Objects include variables, events and methods.

The OPC UA includes a number of data formats, main of which are the binary structures and the XML files. The data format can be defined by the OPC server supplier or by the standard. The client can request the server for description of any format. The automatic data format recognition is frequently used by the data transmission.

The OPC UA exhibits the high robustness of data and event notifications. The robustness is provided by the mechanism of communication errors detection and data restore.

The OPC servers can have the access both to current and to historical data, to alarms and events. The OPC UA can be enveloped in different communication protocols with optimal data coding.

14.4.1. Service-Oriented Architecture

The essential difference of the OPC UA from the OPC is the refuse of COM and DCOM technologies to the service-oriented architecture (SOA) in order to enhance security and provide multi-platform implementation.

The OPC UA service enables functionality of a certain software component, which can be transmitted between the client and the server and called remotely. The service invocation is similar to the method call in object-

Page 83: COMPUTER-AIDED SYSTEM SOFTWARE

83

oriented programming. The client –to – server interface is defined as a set of services. The main characteristic of the SOA is independence of a software technology, of a computing platform, of programming languages, of certain applications. Services are considered as loosely – coupled elements for system building. Services include the information security service based on new standards.

Due to the service-oriented architecture the server became scalable and compatible to platforms with different computing resources: the reduced service set is adaptable for embedded applications, and the enterprise network server can implement the complete service set.

The OPC UA services are divided into the following logical groups: • Secure Channel Service Set; • Session Service Set; • User – side Interaction Service Set • Node Management Service Set. It allows adding, modifying and

deleting nodes and references in the addressed space. • Accessible Node Service Set. It allows the individual node setting for

different client applications; • Attribute Service Set. It allows modifying the node attributes; • Method Service Set. It calls functions performed by system

components; • Monitored Item Service Set allows the client applications to check

periodically the variables, attributes and events and generate the reports under the specified conditions;

• Subscription Service Set. Independence of COM and DCOM. New mechanisms based on SOAP, XML, HTTP, and other services enable the refuse from DCOM as a means for inter-process communication. Due to these mechanisms the OPC UA provides the secure and reliable data transmission and assemble the functionality of the ОРС DA, ОРС HDA and ОРС А&Е servers in one server.

The OPC UA standard is not intended for the existing OPC specifications, it just enhances their opportunities.

Page 84: COMPUTER-AIDED SYSTEM SOFTWARE

84

14.4.2. Security

To provide the information security web-services like the WS – Security, WS – Trust or WS – SecureConversation are used in the OPC UA. The security capabilities are ranged from the trivial authentication and authorization to full encryption of transmitted messages.

The OPC messages in the UA standard are transmitted via the SOAP messages in the XML format. As the XML coding and decoding are a quite time- consuming process the alternative coding to a binary equivalent is provided by the standard.

14.4.3. Advantages of New Standard

The main advantages of the OPC UA are: • multiple platform implementation including portable ANSI C, .NET

and Java implementations (from the OPC Foundation); • service orientation instead of object orientation, what enables

implementing the OPC UA on any computers, embedded systems, in communicators, etc, used by web-services;

• scalability, i.e. changing the program size according to processor power and required functionality. It is possible to compile single – threaded or multi-threaded applications;

• support of the reliable and modern SOAP mechanism with the HTTP protocol implementation;

• high information security; • configurable time-out for each service; • implementation of open standards of the World Wide Web

Consortium (W3C) instead of the COM/DCOM standard.

14.4.4. OPC UA- based System Concept

The OPC UA – based system can include a variety of client applications and servers. Each client can work with several servers simultaneously, and each server can service multiple client request in parallel. A user application (e.g. SCADA) can combine the client and server groups to forward messages which it exchanges with other servers and client applications.

An application (e.g. SCADA) acts as the client in the interaction with the OPC server. The client application requests for the server services via the internal interface. The internal interface is considered as the insulating layer

Page 85: COMPUTER-AIDED SYSTEM SOFTWARE

85

between the application and the communication stack. Communication stack converts the client requests into the messages delivered to the server and returns the appropriate response messages to the client application.

The server application is considered as the software implementation of functions that should be performed by server. Interaction of the OPC server and the client application is executed via application interface by requesting and response messaging.

The address space of the OPC server involves a variety of nodes accessible by the client application via the OPC UA services. «Nodes» are used in address space to present real objects, the object definitions and cross- references. The subspace of nodes which are accessible by the client application is included into the address space. Accessible nodes are hierarchically structured for their convenient navigation.

The client – to – server data exchange can be performed both as the instant messaging and as the «editor - subscriber» scheme. In the second way the system subscribes to the certain data that should be returned from the server as soon as available. The server monitors nodes and corresponding objects to detect any data changes. The server reports the data, event or alarm changes to the client application via the subscription channel.

The OPC UA allows data exchange between to servers. This case one server acts as the client application and another one performs the server functions. So several servers can be concatenated in a chain and each server will operate as a client for one part and as a server for the other.

The OPC Foundation developed the strategy how to turn to the new technology applying the «UA- shell». It enables the data exchange between old and new standards. This shell provides, e.g., interaction between the DCOM OPC server and the OPC UA client application, and conversely.

Page 86: COMPUTER-AIDED SYSTEM SOFTWARE

86

REFERENCES

1. Christensen, James Ch. Znakomstvo so standartom na yazyki programmirovaniya PLC: IEC – 61131-3 [Introduction to PLC language standard: IEC 61131-3] [source online] // Mir computernoy avtomatizatsiyi. М., (1/1995) URL: http://www.mka.ru/?p=40772 (request date: 05.09.2013).

2. Zyubin, V.E. Programmirovaniye PLC: yasyki IEC – 61131-3 I vozmozhnyie alternativy [PLC Programming: the IEC 61131-3 Languages and Possible Alternatives] // Promyshlennyie ASU I controllery, №11, 2005. P.31-35.

3. Denisenko, V.V. Computernoye upravleniye technologitcheskim processom,experimentom, oborudovaniyem [Computer- aided Control of Process, Experiment, Equipment] – М.: Goryatchaya liniya – Telecom, 2009. – 608 p.

4. Petrov, I.V. Programmiruyemyie controllery. Standartnyje yazyki I instrumenty [Programmabe Controllers. Standard Languages and Tools]/ ed. Prof. V.P. Dyiakonov – M.: SOLON – Press, 2003 – 256 p.

5. Rukovodstvo polzovatelya po programmirovaniyu PLC v CoDeSys 2.3 [The PLC programming manual in CoDeSys 2.3] / PK Prolog – Smolensk: RU 2.5, for CoDeSys V2.3.6.x, 2006. – 455 p.

6. Standartnyje yazyki programmirovaniya dlya controllerov [Standard programming languages for controllers] // Systemy upravleniya URL: http://texproc.ru/index.php/ispiu/95-sjpispip?start=2 (request date: 05.09.2013).

7. Yeliseyeva, A.A., Malyshenko, A.M. Analis metodov nastroyki PID regulyatora [Adjustment analysis of PID Controller] // Molodyozh i sovremennyje informatsionnyje technologiyi: the sources of VII All-Russia Scientific Conference for students, postgraduates and young scientists – Tomsk – 2009. – P. 30-31.

8. Efimov, S.V. Analiz I sintez statsionatnykh i intervalnykh system uprevlenijana osnove zavisimosti raspolozheniya ikh polyusov i nuleiy ot pryamykh pokazeteleiy katchestva [Analysis and design of stationary and interval control systems based on relation of their pole – zero configuration to quality indicators] [online source]: author’s abstract of Ph. D. thesis in engineering science / S.V. Yefimov, TPU – Tomsk, 2011, eccess pattern http://www.lib.tpu.ru/fulltext/a/2011/16.pdf.

Page 87: COMPUTER-AIDED SYSTEM SOFTWARE

87

9. Lange J. Free choice of platform. The next OPC Generation. – Softing AG (www.softing.com). Nov. 2006. – 4 p.

10. OPC Foundation. OPC unified architecture. Release candidate specification. Part 1: Concepts. Version 1.20 June 1. 2006. – 25 p.

11. William Bolton Programmable logic controllers – Burlington: Elsevier Newnes, 2006. – 292 p.

12. Garry A. Dunning Introduction to Programmable Logic Controllers – California: Delmar Thomson Learning, 2003. – 516 p.

13. Katsuhiko Ogata Modern Control Engineering – USA: Prentice Hall, 2010. – 894 p.

14. Kevin Roebuck Scada: High-Impact Strategies – What You Need to Know: Definitions, Adoptions, Impact, Benefits, Maturity, Vendors – USA: Emereo Pty Limited, 2011 – 166 p.

15. Stuart A. Boyer SCADA: Texte Imprimé – Charlottesville: – ISA-The Instrumentation, Systems, and Automation Society, 2004. – 216 p.

Page 88: COMPUTER-AIDED SYSTEM SOFTWARE

88

AUTHORIZED ABBREVIATIONS

ACS – automatic control system; PLC – programmable logic controller; SW – software; OCS – operator control station; APCS – automatic process control system; CAM – computer-aided manufacturing system; IACS– integrated automatic control system; SCC – supervisory computer complex; ADC – analog-to-digital converter; DAC – digital-to-analog converter; IEC – International Electrotechnical Comission; OOP – object oriented programming;

Page 89: COMPUTER-AIDED SYSTEM SOFTWARE

89

CONTENTS

INTRODUCTION .............................................................................................................. 3 1. ACS CLASSIFICATION ............................................................................................... 4

1.1. Information Systems .................................................................................................. 4 1.2. Control Systems ......................................................................................................... 4

2. ACS TYPES .................................................................................................................... 5 2.1. APCS ......................................................................................................................... 5 2.2. CAM .......................................................................................................................... 6 2.3. IACS ......................................................................................................................... 6

3. ACS ARCHITECTURE ................................................................................................ 7 3.1. Architecture Requirements ........................................................................................ 7 3.2. Architecture Varieties ................................................................................................ 8 3.3. Information Flows ..................................................................................................... 9

4. ACS FUNCTIONS ....................................................................................................... 11 5. BASIC FUNCTIONS OF PLC AND OCS ................................................................. 13 6. ACS STRUCTURE ...................................................................................................... 14 7. IEC-61131 STANDARD .............................................................................................. 15

7.1. Standard Evolution .................................................................................................. 15 7.2. The IEC 61131-3 Characteristics ............................................................................. 15 7.3. Standard Languages ................................................................................................. 16 7.4. Requirements to Standard’s Languages ................................................................... 17 7.5. Standard’s Relevancy .............................................................................................. 17 7.6. Development Trends of Standard ............................................................................ 18

8. TOOLS OF PLC DESIGN .......................................................................................... 20 8.1. PLC Programming System Tools ............................................................................ 21

8.1.1. Embedded Editor ............................................................................................... 21 8.1.2. Text Editor ........................................................................................................ 22 8.1.3. Graphic Editor ................................................................................................... 23

8.2. Project Debugging ................................................................................................... 23 8.3. Project Management Tools ...................................................................................... 25 8.4. Project Recovery ...................................................................................................... 25 8.5. Security .................................................................................................................... 25

9. STRUCTURE BY PLC ............................................................................................... 26 9.1. Tasks ........................................................................................................................ 26 9.3. Configuration ........................................................................................................... 29

10. PROGRAM ORGANISATION UNITS ................................................................... 30 10.1. POU Definition ...................................................................................................... 30 10.2. Formal and Current Parameters ............................................................................. 31 10.3. POU Parameters and Variables ............................................................................. 31 10.4. Functions ................................................................................................................ 32 10.5. Function Blocks ..................................................................................................... 33 10.6. Programs ................................................................................................................ 33

11. THE IEC 61131 LANGUAGES ................................................................................ 34 11.1. The IL (Instruction List) Language ....................................................................... 34

Page 90: COMPUTER-AIDED SYSTEM SOFTWARE

90

11.1.1. Result Register ................................................................................................ 34 11.1.2. Jump to Label .................................................................................................. 35 11.1.3. Parentheses ...................................................................................................... 35 11.1.4. Modifiers ......................................................................................................... 36 11.1.5. Operators ......................................................................................................... 36 11.1.6. Calling Function Blocks and Programs .......................................................... 37 11.1.7. Function Call ................................................................................................... 37 11.1.8. Annotation ....................................................................................................... 37

11.2. Structured Text (ST) .............................................................................................. 38 11.2.1. Expressions ..................................................................................................... 38 11.2.2. Order of Expression Evaluation ...................................................................... 38 11.2.3. Empty Clause .................................................................................................. 38 11.2.4. Selection Statement IF .................................................................................... 38 11.2.5. Multiple Selector CASE .................................................................................. 39 11.2.6. While and Repeat Loops ................................................................................. 39 11.2.7. FOR Loop ....................................................................................................... 40 11.2.8. Iteration Interrupting by EXIT and RETURN ................................................ 40

11.3. Ladder Diagrams ................................................................................................... 41 11.3.1. Latching Relay ................................................................................................ 41 11.3.2. Execution Order and Feedback ....................................................................... 42 11.3.3. LD Enhancement ............................................................................................. 42

11.4. Function Block Diagrams ...................................................................................... 43 11.4.1. Bussing ............................................................................................................ 43 11.4.2. FBD Execution Order ..................................................................................... 43 11.4.3. Boolean Signal Inversion ................................................................................ 43 11.4.4. Connectors and Feedback ............................................................................... 44 11.4.5. Labels, Jumps and Return ............................................................................... 44

11.5. Sequential Function Charts .................................................................................... 44 11.5.1. Steps ................................................................................................................ 45 11.5.2. Transitions ....................................................................................................... 45 11.5.3. Initial Step ....................................................................................................... 46 11.5.4. Parallel Branch ................................................................................................ 46 11.5.6. Alternative Branch .......................................................................................... 46

12. STANDARD COMPONENTS .................................................................................. 48 12.1. Arithmetic Operators ............................................................................................. 48

12.2. Bitwise Shift Operators ...................................................................................... 49 12.3. Bitwise Logical Operators ................................................................................. 49

12.4. Selection and Delimiter Statements ....................................................................... 49 12.5. Comparison Operators ........................................................................................... 50 12.6. Mathematical Functions ......................................................................................... 50 12.7. String Functions ..................................................................................................... 51 12.8. Timers .................................................................................................................... 52

12.8.1. Timed Pulse ..................................................................................................... 52 12.8.2. Timer Off Delay TOF ..................................................................................... 53 12.8.3. Timer On Delay TON ..................................................................................... 53 12.8.4. Runtime Clock ................................................................................................ 54

12.9. Triggers .................................................................................................................. 54 12.9.1. SR Latch with Set Domination ....................................................................... 55

Page 91: COMPUTER-AIDED SYSTEM SOFTWARE

91

12.9.2. RS Latch with Reset Domination .................................................................... 55 12.10. Pulse Detector ...................................................................................................... 56

12.10.1. Rising Edge Detector R_TRIG ..................................................................... 56 12.10.2. Falling Edge Detector F_TRIG ..................................................................... 57

12.11. Counters ............................................................................................................... 57 12.11.1. Function Block Incrementer CTU ................................................................. 57 12.11.2. Function Block Decrementer CTD ............................................................... 57 12.11.3. Incrementer/ Decrementer CTUD ................................................................. 58

12.12. Bit Serial Access to Integers ................................................................................ 59 12.12.1. Bit Read ......................................................................................................... 59 12.12.2. Bit Record ..................................................................................................... 59 12.12.3. Function Block PACK .................................................................................. 59 12.12.4. Function Block UNPACK ............................................................................ 59

12.13. Hysterisis ............................................................................................................. 59 12.14. Threshold Signal Indicator LIMITALARM ........................................................ 60 12.15. Limiting the Signal Changing Rate ..................................................................... 61 12.16. Interpolation of Dependence ................................................................................ 62 12.17. Derivating ............................................................................................................ 63 12.18. Integrating ............................................................................................................ 64 12.19. PID Controller ..................................................................................................... 65

12.19.1. Control Algorithm Description ..................................................................... 65 12.19.2. PID Controller Setting .................................................................................. 67

13. USER INTERFACE ................................................................................................... 69 13.1. The SCADA Functions .......................................................................................... 69 13.2. Design Of Human-Machine Interface ................................................................... 71 13.3. SCADA As A Supervisory Control System .......................................................... 71 13.4. SCADA As A Part of Automatic Control System ................................................. 72 13.5. Workflow History Storage ..................................................................................... 72 13.6. SCADA Security ................................................................................................... 72 13.7. SCADA Characteristics ......................................................................................... 73 13.8. Tool Properties ....................................................................................................... 73 13.9. Performance Properties .......................................................................................... 74 13.10. Degree of Openness ............................................................................................. 75 13.11. Economical Efficiency ......................................................................................... 75 13.12. MasterSCADA ..................................................................................................... 76

14. OPC-SERVER ............................................................................................................ 77 14.1. The ОРС Standard Review .................................................................................... 77 14.2. ОРС DA Server ..................................................................................................... 79 14.3. ОРС HDA Server .................................................................................................. 81 14.4. ОРС UA Server ..................................................................................................... 81

14.4.1. Service-Oriented Architecture ........................................................................ 82 14.4.2. Security ........................................................................................................... 84 14.4.3. Advantages of New Standard .......................................................................... 84 14.4.4. OPC UA- based System Concept .................................................................... 84

REFERENCES ................................................................................................................. 86 AUTHORIZED ABBREVIATIONS .............................................................................. 88

Page 92: COMPUTER-AIDED SYSTEM SOFTWARE

Educational Edition

Национальный исследовательский

Томский политехнический университет

ЕФИМОВ Семён Викторович

ПРОГРАММНОЕ ОБЕСПЕЧЕНИЕ АВТОМАТИЗИРОВАННЫХ СИСТЕМ

Учебное пособие

Издательство Томского политехнического университета, 2014 На английском языке

Published in author’s version

Scienсe Editor Doctor of Technical Sciences, Professor

G.P. Tsapko

Linguistic Advisor N.V. Kurkan

Typesetting V.D. Pyatkova

Registered at TPU Publishing House

Available on a TPU Corporate Portal in full accordance with the quality of the given make up page

Tomsk Polytechnic University Quality management system

of Tomsk Polytechnic University Publishing House was certified in accordance with ISO 9001:2008 requirements

. 30, Lenina Ave, Tomsk, 634050, Russia Tel/fax: +7 (3822) 56-35-35, www.tpu.ru