Eletrônica e Automação, Manual de Engenharia Elétrica. Universidade Federal do Acre (UFAC)
jhonnathas1
jhonnathas12 de Novembro de 2015

Eletrônica e Automação, Manual de Engenharia Elétrica. Universidade Federal do Acre (UFAC)

PDF (1 MB)
240 páginas
1Números de download
334Número de visitas
Descrição
Eletrônica e Automação
20pontos
Pontos de download necessários para baixar
este documento
baixar o documento
Pré-visualização3 páginas / 240
Esta é apenas uma pré-visualização
3 shown on 240 pages
baixar o documento
Esta é apenas uma pré-visualização
3 shown on 240 pages
baixar o documento
Esta é apenas uma pré-visualização
3 shown on 240 pages
baixar o documento
Esta é apenas uma pré-visualização
3 shown on 240 pages
baixar o documento

1

2

Contents

1 Introduction ........................................................................................................9 1.1 Subject of the Book .........................................................................................10 1.2 The IEC 61131 standard ..................................................................................12 1.2.1 Goals and benefits of the standard ................................................................12

Manufacturers (PLC hardware and software) ......................................................................... 13 Customers............................................................................................................................... 13

1.2.2 History and components ...............................................................................14 1.3 The OrganisationPLCopen ..............................................................................16 1.3.1 Aims..............................................................................................................16 1.3.2 Committees and fields of activity..................................................................17 1.3.3 Results ..........................................................................................................18

Certification ........................................................................................................................... 18 Exchange format for user programs........................................................................................ 19

2 Building Blocks of IEC 61131-3.......................................................................21 2.1 Introduction to the New Standard ....................................................................21 2.1.1 Structure of the building blocks ....................................................................22

Declaration of variables.......................................................................................................... 22 Code part of a POU ................................................................................................................ 23

2.1.2 Introductory example written in IL ...............................................................25 2.1.3 PLC assignment ............................................................................................27 2.2 The Program Organisation Unit (POU) ...........................................................30 2.3 Elements of a POU ..........................................................................................32 2.3.1 Example ........................................................................................................33 2.3.2 Declaration part ............................................................................................34

Types of variables in POUs. ................................................................................................... 35 Characteristics of the POU interface ...................................................................................... 36 The formal parameters and return values of a POU................................................................ 37 External and internal access to POU variables ....................................................................... 37

2.3.3 Code part ......................................................................................................39 2.4 The Function Block .........................................................................................41 2.4.1 Instances of function blocks..........................................................................41

What is an “instance”? ........................................................................................................... 41 Instance means “structure”. ................................................................................................... 43 Instance means “memory”. .................................................................................................... 45

2 Contents

Relationship between FB instances and data blocks............................................................... 46

2.4.2 Re-usable and object-oriented FBs .............................................................. 47 2.4.3 Types of variables in FBs............................................................................. 48 2.5 The Function ................................................................................................... 48 2.5.1 Types of variables in functions and the function value ................................ 49 2.5.2 Execution control with EN and ENO ........................................................... 50 2.6 The Program.................................................................................................... 52 2.7 Calling Functions and Function Blocks........................................................... 53 2.7.1 Mutual calls of POUs ................................................................................... 53 2.7.2 Recursive calls are forbidden ....................................................................... 54 2.7.3 Calling with formal parameters .................................................................... 56 2.7.4 Calls with input parameters omitted or in a different order.......................... 59 2.7.5 FB instances as actual FB parameters .......................................................... 60

Example of an indirect FB call. .............................................................................................. 62 FB instance names as actual parameters of functions............................................................. 63 Function values as actual parameters. .................................................................................... 63

2.8 Summary of POU Features.............................................................................. 64

3 Variables, Data Types and Common Elements.............................................. 65 3.1 Simple Language Elements ............................................................................. 65 3.1.1 Reserved keywords ..................................................................................... 67 3.2 Literals and Identifiers .................................................................................... 68 3.2.1 Literals ......................................................................................................... 68 3.2.2 Identifiers ..................................................................................................... 70 3.3 Meanings of Data Types and Variables........................................................... 71 3.3.1 From direct PLC addresses via symbols to variables ................................... 72 3.3.2 The data type determines the properties of variables ................................... 73 3.3.3 Type-specific use of variables...................................................................... 74 3.3.4 Automatic mapping of variables onto the PLC ............................................ 75 3.4 Data Types ...................................................................................................... 75 3.4.1 Elementary data types .................................................................................. 76 3.4.2 Derived data types (type definition) ............................................................. 77

Additional properties for elementary data types. .................................................................... 78 Arrays. .................................................................................................................................... 80 Data structures........................................................................................................................ 81 Initial values in type definitions. ............................................................................................ 83

3.4.3 Generic data types ........................................................................................ 84 3.5 Variables ......................................................................................................... 85 3.5.1 Inputs, outputs and flags as special variables ............................................... 86 3.5.2 Multi-element variables: arrays and structures............................................. 88 3.5.3 Assignment of initial values at the start of a program .................................. 90 3.5.4 Attributes of variable types .......................................................................... 91 3.5.5 Graphical representation of variable declarations ........................................ 93

Contents 3

4 The New Programming Languages of IEC 61131-3 ......................................95 4.1 Instruction List IL ............................................................................................96 4.1.1 Instruction in IL ............................................................................................96 4.1.2 The universal accumulator (Current Result) .................................................97 4.1.3 Operators ....................................................................................................100

Negation of the operand. ...................................................................................................... 100 Nesting levels by parenthesis................................................................................................ 100 Conditional execution of operators....................................................................................... 101

4.1.4 Using functions and function blocks...........................................................104 Calling a function. ................................................................................................................ 104 Calling a function block. ...................................................................................................... 106

4.1.5 IL example: Mountain railway....................................................................107 4.2 Structured Text ST.........................................................................................111 4.2.1 ST statements..............................................................................................111 4.2.2 Expression: Partial statement in ST ...........................................................113

Operands. ............................................................................................................................. 113 Operators. ............................................................................................................................. 113 Function as operator. ............................................................................................................ 115

4.2.3 Statement: Assignment................................................................................116 4.2.4 Statement: Call of function blocks..............................................................118 4.2.5 Statement: RETURN ..................................................................................118 4.2.6 Statement: Selection and Multi- selection...................................................119

Selection. .............................................................................................................................. 119 Multi- selection. ................................................................................................................... 120

4.2.7 Statement: Iteration.....................................................................................122 WHILE and REPEAT statements. ........................................................................................ 122 FOR statement...................................................................................................................... 123 EXIT statement..................................................................................................................... 125

4.2.8 Example: Stereo cassette recorder ..............................................................125 4.3 Function Block Diagram FBD .......................................................................128 4.3.1 Networks, graphical elements and connections of LD and FBD.................128

Network label. ...................................................................................................................... 128 Network comment. ............................................................................................................... 129 Network graphic. .................................................................................................................. 129

4.3.2 Network architecture in FBD......................................................................131 4.3.3 Graphical objects in FBD ...........................................................................133

Connections.......................................................................................................................... 134 Execution control (jumps). ................................................................................................... 134 Call of functions and function blocks................................................................................... 135

4.3.4 Programming methods in FBD ...................................................................136 Network evaluation. ............................................................................................................. 136 Feedback variable................................................................................................................. 137

4.3.5 Example: Stereo cassette recorder ..............................................................137 Comments on the networks of Example 4.24 and Example 4.31 ......................................... 140

4 Contents

4.4 Ladder Diagram LD ...................................................................................... 141 4.4.1 Networks, graphical elements and connections (LD) ................................. 141 4.4.2 Network architecture in LD........................................................................ 141 4.4.3 Graphical objects in LD ............................................................................. 142

Connections.......................................................................................................................... 142 Contacts and coils. ............................................................................................................... 143 Execution control. ................................................................................................................ 147 Call of functions and function blocks................................................................................... 148

4.4.4 Programming methods in LD ..................................................................... 149 Network evaluation. ............................................................................................................. 149 Feedback variable................................................................................................................. 151

4.4.5 Example in Ladder Diagram: Mountain railway ........................................ 153 Comments on the mountain railway networks...................................................................... 156

4.5 The American way of Ladder programming ................................................. 159 4.5.1 Network Layout.......................................................................................... 159 4.5.2 Module addresses and memory areas ......................................................... 161 4.5.3 Configuration ............................................................................................. 163 4.6 Sequential Function Chart SFC..................................................................... 164 4.6.1 Step / Transition combination .................................................................... 165 4.6.2 Step - transition sequence........................................................................... 167 4.6.3 Detailed description of steps and transitions .............................................. 172

Step....................................................................................................................................... 172 Transition. ............................................................................................................................ 174

4.6.4 Step execution using action blocks and actions.......................................... 179 4.6.5 Detailed description of actions and action blocks ...................................... 181

Actions. ................................................................................................................................ 181 Action block. ........................................................................................................................ 182

4.6.6 Relationship between step, transition, action and action block .................. 185 4.6.7 Action qualifiers and execution control ..................................................... 189

Qualifier. .............................................................................................................................. 189 Sequential control................................................................................................................. 195

4.6.8 Example: “Dino Park”................................................................................ 196 Comments on the network for the dinosaur park.................................................................. 200

5 Standardised PLC Functionality .................................................................. 201 5.1 Standard Functions........................................................................................ 202 5.1.1 Overloaded and extensible functions.......................................................... 206

Overloaded functions............................................................................................................ 206 Extensible functions ............................................................................................................. 208

Contents 5

5.1.1 Examples ....................................................................................................209 Type conversion functions.................................................................................................... 210 Numerical functions ............................................................................................................. 211 Arithmetic functions............................................................................................................. 211 Bit-shift functions ................................................................................................................ 212 Bitwise Boolean functions.................................................................................................... 212 Selection functions ............................................................................................................... 213 Comparison functions .......................................................................................................... 214 Character string functions .................................................................................................... 215 Functions for time data types. .............................................................................................. 215 Functions for enumerated data types .................................................................................... 216

5.2 Standard Function Blocks..............................................................................217 5.2.2 Examples ....................................................................................................218

Bistable element (flipflop).................................................................................................... 220 Edge detection ...................................................................................................................... 221 Counter................................................................................................................................. 223 Timer.................................................................................................................................... 224

6 State-of-the-Art PLC Configuration.............................................................227 6.1 Structuring Projects with Configuration Elements.........................................227 6.2 Elements of a Real-World PLC Configuration ..............................................228 6.3 Configuration Elements .................................................................................230 6.3.1 Definitions ..................................................................................................230 6.3.2 The CONFIGURATION ............................................................................231 6.3.3 The RESOURCE ........................................................................................232 6.3.4 The TASK with run-time program..............................................................233 6.3.5 ACCESS declarations .................................................................................236 6.4 Configuration Example..................................................................................237 6.5 Communication between Configurations and POUs......................................240

7 Innovative PLC Programming Systems........................................................243 7.1 Requirements of Innovative Programming Tools ..........................................243 7.2 Technological Change ...................................................................................244 7.2.1 Processor performance................................................................................244 7.2.2 Full-graphics display and printout ..............................................................244 7.2.3 Operating systems.......................................................................................244 7.2.4 Uniform user interfaces...............................................................................245 7.3 Decompilation (Reverse Documentation)......................................................245 7.3.1 No decompilation........................................................................................246 7.3.2 Decompilation with symbols and comments...............................................246 7.3.3 Decompilation including graphics ..............................................................246 7.3.4 Sources stored in the PLC...........................................................................247 7.4 Language Compatibility.................................................................................247

6 Contents

7.4.1 Cross-compilation ...................................................................................... 248 The motivation for cross-compilation................................................................................... 248 Different approaches in graphical and textual languages. .................................................... 249 Differences in languages affect cross-compilation. .............................................................. 250 Restrictions in LD/ FBD....................................................................................................... 251 Restrictions in IL/ ST. .......................................................................................................... 251 Cross-compilation IL / ST. ................................................................................................... 251 Full cross-compilation only with additional information...................................................... 252 Quality criteria for cross-compilation................................................................................... 253

7.4.2 Language independence ............................................................................. 254 7.5 Documentation .............................................................................................. 255 7.5.1 Cross-reference list..................................................................................... 255 7.5.2 Allocation list (wiring list) ......................................................................... 256 7.5.3 Comments .................................................................................................. 257 7.6 Project Manager ............................................................................................ 257 7.7 Test & Commissioning Functions ................................................................. 261 7.7.1 Program transfer......................................................................................... 261 7.7.2 Online modification of a program .............................................................. 262 7.7.3 Remote control: Starting and stopping the PLC......................................... 263 7.7.4 Variable and program status....................................................................... 263 7.7.5 Forcing ....................................................................................................... 267 7.7.6 Program test ............................................................................................... 268 7.7.7 Testing Sequential Function Chart programs ............................................. 269 7.8 Data Blocks and Recipes............................................................................... 269 7.9 FB Interconnection........................................................................................ 273 7.9.1 Data exchange and co-ordination of blocks in distributed systems ............ 273 7.9.2 Macro techniques in FB interconnection.................................................... 275 7.10 Diagnostics, Error Detection and Error Handling ....................................... 276

Error concept of IEC 61131-3. ............................................................................................. 277 Extended error handling model (beyond IEC). ..................................................................... 277

7.11 Hardware-Dependence ................................................................................ 279 7.12 Readiness for New Functionality ................................................................ 279 7.12.1 Exchange of programs and data ............................................................... 280 7.12.2 Extension with additional software packages........................................... 281

8 Main Advantages of IEC 61131-3................................................................. 283 8.1 Convenience and Security with Variables and Data Types ........................... 283 8.2 Blocks with Extended Capabilities................................................................ 284 8.3 PLC Configuration with Run-Time Behaviour.............................................. 285 8.4 Uniform Programming Languages ................................................................ 286 8.5 Structured PLC Programs.............................................................................. 286 8.6 Trend towards Open PLC Programming Systems........................................ 286 8.7 Conclusion .................................................................................................... 288

Contents 7

9 Programming by Configuring with IEC 61499 ............................................289 9.1 Programming by FB Interconnection with IEC 61131-3 ...............................289 9.2 IEC 61499 – The Programming Standard for Distributed PLC Systems .......290 9.2.1 System model..............................................................................................291 9.2.2 Device model ..............................................................................................291 9.2.3 Resource model ..........................................................................................292 9.2.4 Application model ......................................................................................293 9.2.5 Function block model .................................................................................294

Composite function blocks................................................................................................... 296

9.2.6 Creating an application ...............................................................................298 9.3 Overview of the Parts of IEC 61499..............................................................298

10 Contents of CD-ROM...................................................................................299 10.1 IEC Programming Systems STEP 7 and OpenPCS .....................................299

Demo versions of STEP 7 (Siemens) and OpenPCS (infoteam)........................................... 299 IL examples .......................................................................................................................... 300

10.2 Buyer's Guide for IEC 61131-3 PLC Programming Systems ......................300

A Standard Functions........................................................................................301 A.1 Type Conversion Functions .........................................................................302 A.2 Numerical Functions ....................................................................................303 A.3 Arithmetic Functions....................................................................................304 A.4 Bit-Shift Functions.......................................................................................305 A.5 Bitwise Boolean Functions ..........................................................................306 A.6 Selection Functions for Max., Min. and Limit .............................................307 A.7 Selection Functions for Binary Selection and Multiplexers .........................308 A.8 Comparison Functions ..................................................................................310 A.9 Character String Functions...........................................................................311 A.10 Functions for Time Data Types..................................................................313 A.11 Functions for Enumerated Data Types.......................................................314

B Standard Function Blocks .............................................................................315 B.1 Bistable Elements (Flip-Flops)......................................................................316 B.2 Edge Detection..............................................................................................317 B.3 Counters ........................................................................................................318 B.4 Timers ...........................................................................................................320

C IL Examples....................................................................................................323 C.1 Example of a FUNCTION ............................................................................323 C.2 Example of a FUNCTION_BLOCK.............................................................325 C.3 Example of a PROGRAM.............................................................................327

D Standard Data Types .....................................................................................331

E Causes of Error ..............................................................................................333

8 Contents

F Implementation-Dependent Parameters ...................................................... 335

G IL Syntax Example........................................................................................ 339 G.1 Syntax Diagrams for IL ................................................................................ 340 G.2 IL Example from Syntax Diagrams .............................................................. 347

H Reserved Keywords and Delimiters............................................................. 349 H.1 Reserved Keywords...................................................................................... 349 H.2 Delimiters..................................................................................................... 353

I Planned Amendments to the Standard ......................................................... 357

J Glossary .......................................................................................................... 359

K Bibliography .................................................................................................. 365

L Index ............................................................................................................... 331

Author Biographies........................................................................................... 375 Karl-Heinz John .................................................................................................. 375 Michael Tiegelkamp............................................................................................ 375

1 Introduction

The rapid advances in performance and miniaturisation in microtechnology are constantly opening up new markets for the programmable logic controller (PLC). Specially designed controller hardware or PC-based controllers, extended by hardware and software with real-time capability, now control highly complex automation processes.

The different types of PLC cover a wide task spectrum - ranging from small network node computers and distributed compact units right up to modular, fault- tolerant, high-performance PLCs. They differ in performance characteristics such as processing speed, networking ability or the selection of I/O modules they support.

Throughout this book, the term PLC is used to refer to the technology as a whole, both hardware and software, and not merely to the hardware architecture.

The broad spectrum of capability of the hardware requires corresponding support from suitable programming tools, to allow low-cost, quality-conscious creation of both simple and complex software solutions. Desirable features of programming tools include:

- Simultaneous use of several PLC programming languages - "Online" modification of programs in the PLC - Reverse documentation of the programs from the PLC - Reusability of PLC program blocks - "Offline" testing and simulation of user programs - Integrated configuring and commissioning tools - Quality assurance, project documentation - Use of systems with open interfaces.

Modern PCs have enabled increasingly efficient PLC programming tools to be developed in the last 10 years.

The classical PLC programming methods, such as the instruction list, ladder logic or control system function chart, which have been employed until now, have reached their limits. Users want uniform, manufacturer-independent language

10 1 Introduction

concepts, high-level programming languages and development tools similar to those that have already been in existence in the PC world for many years.

With the introduction of the international standard IEC 61131 a basis has now been created for uniform PLC programming taking advantage of the modern concepts of software technology.

1.1 Subject of the Book

The aim of this book is to give the reader an understandable introduction to the concepts and languages of standard IEC 61131. Simple examples are given to explain the ideas and application of the new PLC programming languages. An extensive example program summarises the results of each section.

The book serves as a helpful guide and introduction for people in training and at work who want to become acquainted with the possibilities of the new standard.

Some experience with personal computers and basic knowledge in the field of PLC technology are required. Experienced PLC programmers will also find information here which will ease the changeover to the programming systems of the new generation. For this purpose, the concepts and terminology of previous systems are compared and contrasted with those used in the world of IEC programming and the advantages of programming according to the IEC standard are explained.

This book is a useful reference work for students and facilitates the systematic learning of the new programming standard.

Readers can also use the enclosed "Buyer's Guide" to evaluate individual PLC programming systems for themselves. See the enclosed CD-ROM.

The formal contents and structure of the IEC standard are presented in a practice- oriented way. Difficult topics are clearly explained within their context, and the interpretation scope as well as extension possibilities of the standard are demonstrated.

This book is intended to give the reader concrete answers to the following questions :

- How do you program in accordance with IEC 61131? What are the essential ideas of the standard and how can they be applied in practice?

- What are the advantages of the new international standard IEC 61131 compared with previous (national) PLC programming standards? What innovations and opportunities does the new standard offer?

1.1 Subject of the Book 11

- What do users have to be aware of if they want to change to a programming system of the new generation?

- What features must contemporary programming systems have in order to be consistent with IEC 61131 and to fulfil this new standard?

- What do users need to look for when selecting a PLC programming system: what criteria are decisive for the performance of programming systems?

Chapter 2 presents the three basic building blocks of the standard: program, function and function block. An introductory example which includes the most important language elements of the standard and provides an overview of its programming methods gives an initial introduction to the concepts of IEC 61131.

Chapter 3 describes the common language elements of the five programming languages as well as the possibilities of data description with the aid of declarations.

The five programming languages of IEC 61131 are explained at length and illustrated by an extensive example in Chapter 4.

The strength of IEC 61131 is partly due to the uniform description of frequently used elements, the standard functions and standard function blocks. Their definition and application are described in Chapter 5.

After programming, the programs and the data have to be assigned to the features and hardware of the relevant PLC by means of configuration. This is to be found in Chapter 6.

The PLC market is developing into a technology with very specific requirements. These special features of programming for a PLC as well as their implementation using the new facilities of IEC 61131 are the subject of Chapter 7.

Chapter 8 summarises the most important qualities of the standard from Chapters 2 to 7. The essential advantages of the standard and of consistent programming systems are outlined here for reference.

Chapter 9 introduces the future standard IEC 61499 for distributed automation processes. It is based on IEC 61131-3, but adopts a wider approach to cater for the demands for parallelism and decentralisation imposed by modern automation tasks.

Chapter 10 explains the use of the enclosed CD-ROM. It includes all the programming examples in this book, a buyer's guide in tabular form, and executable demo versions of two IEC programming systems.

The Appendices supply further detailed information. The glossary in Appendix J gives a brief explanation of the most important terms

used in this book in alphabetical order. Appendix K contains the bibliography, which gives references not only to books

but also to specialised papers on the subject of IEC 61131-3. Appendix L is a general index which can be very helpful for the location of

keywords.

12 1 Introduction

1.2 The IEC 61131 standard

The five parts of the standard IEC 61131 summarise the requirements of modern PLC systems. These requirements concern the PLC hardware and the programming system.

The standard includes both the common concepts already in use in PLC programming and additional new programming methods.

IEC 61131-3 sees itself as a guideline for PLC programming, not as a rigid set of rules. The enormous number of details defined means that programming systems can only be expected to implement part but not all of the standard. PLC manufacturers have to document this amount: if they want to conform to the standard, they have to prove in which parts they do or do not fulfil the standard.

For this purpose, the standard includes 62 feature tables with requirements, which the manufacturer has to fill in with comments (e.g. "fulfilled; not implemented; the following parts are fulfilled:...").

The standard provides a benchmark which allows both manufacturers and customers to assess how closely each programming system keeps to the standard, i.e. complies with IEC 61131-3.

For further proof of compliance, PLCopen (see Section 1.3) defines further tests for compliance levels which can be carried out by independent institutions.

The standard was established by working group SC65B WG7 (originally: SC65A WG6) of the international standardisation organisation IEC (International Electrotechnical Commission) which consists of representatives of different PLC manufacturers, software houses and users. This has the advantage that it is accepted as a guideline by most PLC manufacturers.

1.2.1 Goals and benefits of the standard

Because of the constantly increasing complexity of PLC systems there is a steady rise in costs for:

- Training of applications programmers - The creation of increasingly larger programs - The implementation of more and more complex programming systems.

1.2 The IEC 61131 standard 13

PLC programming systems are gradually following the mass software market trend of the PC world. Here too, the pressure of costs can above all be reduced by standardisation and synergy. Because the standard brings previously manufacturer- specific systems closer together, both manufacturers and customers stand to gain from IEC 61131-3.

Manufacturers (PLC hardware and software) Several manufacturers can invest together in the multi-million dollar software required to fulfil the functionality necessary in today's market.

The basic form of a programming system is determined to a large extent by the standard. Basic software such as editors, with the exception of particular parts like code generators or "online"-modules, can be shared. Market differentiation results from supplementary elements to the basic package which are required in specific market segments, as well as from the PLC hardware.

Through the introduction of the standard a lively exchange of experience and products is currently taking place between hardware and software manufacturers. Development costs can be substantially reduced by buying ready-made products. The error-proneness of newly developed software can be greatly reduced by the use of previously tested software.

The risk of an inappropriate development (the system does not satisfy the market needs) is smaller. The standard sets the rules which the customer already knows from other IEC 61131-3 products.

The development costs of contemporary programming tools have increased significantly as a result of the required functionality. By buying ready-made software components or complete systems the "time to market" can be significantly shortened, which is essential in order to keep pace with the rapid hardware evolution.

Customers Customers often work simultaneously with PLC systems from different manufacturers. Up to now this has meant that employees have needed to take several different training courses in programming, whereas with IEC 61131-3- compliant systems training is limited to the finer points of using the individual programming systems and additional special features of the PLCs. This cuts down on the need for system specialists and training personnel, and PLC programmers are more flexible.

The requirements of the standard ease the selection of suitable programming systems because systems that conform to the standard are easily comparable.

Though it is not expected that complete application programs will be able to be exchanged between different PLC systems in the foreseeable future, language elements and program structure are nevertheless similar among the different IEC systems. This facilitates porting onto other systems.

14 1 Introduction

1.2.2 History and components

The standard IEC 61131 represents a combination and continuation of different standards. It refers to 10 other international standards (IEC 50, IEC 559, IEC 617- 12, IEC 617-13, IEC 848, ISO/AFNOR, ISO/IEC 646, ISO 8601, ISO 7185, ISO 7498). These include rules about the employed character code, the definition of the nomenclature used or the structure of graphical representations.

Several efforts have been made in the past to establish a standard for PLC programming technology. Standard IEC 61131 is the first standard which has received the necessary international (and industrial) acceptance. The most important precursor documents to IEC 61131 are listed in Table 1.1.

Year German international 1977 DIN 40 719-6 (function block

diagrams) IEC 848

1979 Start of the working group for the first IEC 61131 draft

1982 VDI guideline 2880, sheet 4 PLC programming languages

Completion of the first IEC 61131 draft; Splitting into 5 sub-workgroups

1983 DIN 19239 PLC programming Christensen Report (Allen Bradley) PLC programming languages

1985 First results of the IEC 65 A WG6 TF3 1990 IEC 61131 Parts 1 and 2 are made

standard 1992 International standard IEC 61131-1, 2 1993 DIN EN 661131 Part 3 International standard IEC 61131-3 1994 DIN EN 661131 Parts 1 and 2 1995 International standard IEC 61131-4 1996 Additional guide to DIN EN

661131 (user’s guide, IEC 61131-4)

1994 – 2001 Corrigendum to IEC 61131-3 1995, 1996 Technical Reports type 2 and 3 1996 - 2001 Amendments

Table 1.1. Important precursors and milestones of IEC 61131-3

The standard contains six parts as well as a Corrigendum, which includes error corrections in the standard (as of August 1999). Two Technical Reports and an Amendment complete the documentation. These are not (yet) however a direct part of the standard:

Part 1: General information:

1.2 The IEC 61131 standard 15

Part 1 contains general definitions and typical functional features which distin- guish a PLC from other systems. These include standard PLC properties, for example, the cyclic processing of the application program with a stored image of the input and output values or the division of labour between programming device, PLC and human-machine interface.

Part 2: Equipment requirements and tests: This part defines the electrical, mechanical and functional demands on the devices as well as corresponding qualification tests. The environmental conditions (temperature, air humidity etc.) and stress classes of the controllers and of the programming devices are listed. A revision is at present under development.

Part 3: Programming languages: Here the PLC programming languages widely used throughout the world have been co-ordinated into a harmonised and future-oriented version.

The basic software model and programming languages are defined by means of formal definitions, lexical, syntactical and (partially) semantic descriptions, as well as examples.

Part 4:User guidelines The fourth part is intended as a guide to help the PLC customer in all project phases of automation. Practice-oriented information is given on topics ranging from systems analysis and the choice of equipment right through to maintenance.

Part 5:Messaging service specification: (in preparation) This last part is concerned with communication between PLCs from different manufacturers with each other and with other devices.

In co-operation with ISO 9506 (Manufacturing Message Specification; MMS) conformity classes will be defined to allow PLCs to communicate, for example, via networks. These cover the functions of device selection, data exchange, alarm processing, access control and network administration. Part 5 has not yet been released (Committee Draft CD).

TechnicalReport 2 "Proposed Extensions to IEC 61131-3": A list of proposals describes alternatives, extensions or changes to IEC 61131-3. This will be used for preparation of the next revision of the standard and exists at present in the form of a Committee Draft.

Technical Report 3 "Guidelines for the application and implementation of programming languages for programmable controllers": This report supplies interpretations of points left open by the standard. It contains guidelines for implementation as well as application tips for the end user and programming advice. It is currently at the voting stage (Committee Draft for Final Voting CDV) and will probably be published in IEC 61131-3.

16 1 Introduction

Corrigendum "Proposed Technical Corrigendum to IEC 61131-3": The Corrigendum corrects errors in the standard which were found after its publication.

Amendments "Proposed Amendments to IEC 61131-3": The Amendments present a collection of improvements and above all extensions to the standard which have not as yet been published. This document was introduced in order to be able to add important improvements without having to wait for a complete new revision of the standard.

Part 8:Fuzzy Control Language: The draft currently been debated at the voting stage extends the programming languages to include Fuzzy Logic.

The standard describes a modern technology and is therefore subject to strong innovation pressure. This explains why further development of the findings of the standard is being carried out at both national and international level.

This book is concerned with Part 3 "Programming Languages", in short IEC 61131-3. It also incorporates the findings and interpretations of the two Technical Reports ([IEC TR2-94] and [IEC TR3-94]) and the improvements described in the Corrigendum ([IEC CORR-94]).

IEC 61131-3 has been adopted in Germany as German standard "DIN EN 661131- 3" ([DIN EN 661131-3-94]). It thus replaces the standards DIN 19239, DIN 40719T6 as well as the VDI guideline VDI 2880 Sheet 4.

1.3 The Organisation PLCopen

PLCopen, founded in 1992, is a manufacturer- and product-independent inter- national organisation. Many PLC manufacturers, software houses and independent institutions in Europe and overseas are members of the organisation.

1.3.1 Aims

The aim of PLCopen is the promotion of the development and use of compatible software for PLCs ([PLCopen-99]).

The means for reaching this target are based on:

1.3 The Organisation PLCopen 17

- The application of the international standard IEC 61131-3, - The commitment of the members to produce or employ PLC products which

conform to IEC 61131-3, - Common marketing strategies such as fairs or workshops, - Support for the international standardisation committee IEC WG 65B, - Support for national standardisation committees like DIN-DKE UK 962.2

PLC, - Establishment of compliance classes to allow better evaluation of programming

systems, and commissioning of independent institutions to carry out the required checks.

PLCopen is not another standardisation committee, but rather a group with a com- mon interest wanting to help existing standards to gain international acceptance. Detailed information can be found on the Internet (http://www.plcopen.org).

1.3.2 Committees and fields of activity

PLCopen is divided up into several committees, each of which handles a specific field of interest, as shown in Figure 1.1.:

Board of Management

Technical Committees Promotional Committees

2: Functions

1: Standards

3: Certification

4: Communications

5: Safe Software

Promotion Activities

Common Training

Promotion North-America

General Meeting

Managing Director

Promotion Japan

Figure 1.1. Committees of PLCopen

The technical committees work out guidelines for common policy; the promotional committees are responsible for marketing measures.

18 1 Introduction

The work in the committees is carried out exclusively by representatives of individual companies and institutions. This ensures that the resulting papers will be accepted in industry.

1.3.3 Results As a result of the preparatory work of the promotional committees, PLCopen is represented at several fairs in Europe and the USA. Workshops and advanced training seminars have brought the desired international recognition for PLCopen.

As a discussion forum for customers, manufacturers and software houses some impressive technical results have been achieved:

- Certification for manufacturers of PLC programming systems, - Exchange format for user programs.

Certification Certification tests demonstrate the standard compliance of programming systems designed and implemented in accordance with IEC 61131-3.

For this purpose a list of requirements which a PLC programming system has to fulfil in order to receive the PLCopen certificate of compliance with IEC 61131-3 was drawn up. The test is carried out by independent institutions with the aid of test programs and inspections.

For every programming language of IEC 61131-3 a grading system consisting of three levels exists with each level imposing stricter requirements. The requirements of the standard (feature table) mentioned in Section 1.2 serve as the basis of the classification. The feature table is used to determine which of the requirements must be available at the respective level.

1) Base level. The basic structure of programs developed with the programming system must be compatible with IEC 61131-3. The essential language elements of a programming language must be available.

2) Portability level. The selection of compulsory features is extended so that it is possible to exchange real software components between certified programming systems.

3) Full level. Further extension of the Portability level: inclusion of configuration information in the exchange process.

This enables all PLC manufacturers to document the degree of conformity of each of their languages to other IEC 61131-3-compliant systems.

By specifying a defined functionality, PLCopen guarantees a minimum com- pliance. This makes it possible to compare systems with each other.

Several of these compliance classes have already been established (IL Base Level, ST Base Level, AS Base Level, IL Portability level, FBD Base Level). The first IL certifications for PLC programming systems were awarded in August 1994. The remaining compliance classes are still in preparation.

1.3 The Organisation PLCopen 19

While the Base Level test is purely offline, i.e. the certification test programs check the syntactical behaviour of the programming system, the Portability Level includes additional online tests, which test the semantic behaviour of the pro- gramming system in connection with a PLC. This ensures that the programming system interprets IEC 61131-3 in the correct manner.

To what extent portability can be implemented in actual systems is a constant subject of discussion and still remains to be seen. Limiting factors here are hardware features of the manufacturer-specific PLCs, which often shape the program architecture. Furthermore, the high functionality of IEC 61131-3 makes it extremely difficult for programming systems and PLC operating systems to implement all the functions. Small PLC manufacturers, on account of their target market or the capabilities of their PLC families, will hardly require all the properties of the standard — the implementation costs for parts of IEC 61131-3 are simply too great.

Thus the need to be able to exchange and/or port all IEC elements between all programming systems is not the highest priority. It is more important that a certain basic functionality should be available and that functionalities defined by the standard should be implemented correctly. In the final analysis the wishes and demands of the customers will give the ultimate answer to all questions.

Exchange format for user programs In order to be able to exchange user programs between two PLC programming systems, both must be able to understand the same file format, read it in and convert it into their own format.

This exchange can be done by reading an ASCII file into the target system (as long as an import/export interface is available) or by means of the copy/paste function. In this case, the type definitions, data declarations and the code section are read in.

For a secured exchange of a program source, information such as place of origin, version, date, programmer's name etc. is important. As there are no rules or regulations in the IEC 61131-3 standard concerning file format, PLCopen has defined an ASCII-based format for textual blocks (exchange format FxF).

Not only programs can be imported into other IEC 61131-3 systems. In large applications, it is desirable to exchange data while a program is running. A special data format is necessary here, too. Information such as place of origin and the expiration date must be supplied with the data. PLCopen proposes data structures which can, for example, be transmitted with the aid of the blocks described in IEC 61131-5.

2 Building Blocks of IEC 61131-3

This chapter explains the meaning and usage of the main language elements of the IEC 61131-3 standard. These are illustrated by several examples from real life, with each example building upon the previous one.

The reader is introduced to the terms and ways of thinking of IEC 61131-3. The basic ideas and concepts are explained clearly and comprehensively without dis- cussing the formal language definitions of the standard itself [IEC 61131-3-94].

The first section of this chapter gives a compact introduction to the conceptual range of the standard by means of an example containing the most important language elements and providing an overview of the methodology of PLC pro- gramming with IEC 61131-3.

The term “POU” (Program Organisation Unit) is explained in detail because it is fundamental for a complete understanding of the new language concepts.

As the programming language Instruction List (IL, see Chapter 4.1) is already well known to most PLC programmers, it has been chosen as the basis for the examples in this chapter .

2.1 Introduction to the New Standard

IEC 61131-3 not only describes the PLC programming languages themselves, but also offers comprehensive concepts and guidelines for creating PLC projects.

The purpose of this section is to give a short summary of the important terms of the standard without going into details. These terms are illustrated by a simple example. More detailed information will be found in the subsequent sections and chapters.

22 2 Building Blocks of IEC 61131-3

2.1.1 Structure of the building blocks

POUs correspond to the Blocks in previous (conventional) programming systems. POUs can call each other with or without parameters. As the name implies, POUs are the smallest independent software units of a user program.

There are three types of POUs: Function (FUN), Function block (FB) and Program (PROG), in ascending order of functionality. The main difference between functions and function blocks is that functions always produce the same result (function value) when called with the same input parameters, i.e. they have no “memory”. Function blocks have their own data record and can therefore “remember” status information (instantiation). Programs (PROG) represent the “top” of a PLC user program and have the ability to access the I/Os of the PLC and to make them accessible to other POUs.

IEC 61131-3 predefines the calling interface and the behaviour of frequently needed standard functions (std. FUN) such as arithmetic or comparison functions, as well as standard function blocks (std. FB), such as timers or counters.

Declaration of variables The IEC 61131-3 standard uses variables to store and process information. Variables correspond to (global) flags or bit memories in conventional PLC systems. However, their storage locations no longer need to be defined manually by the user (as absolute or global addresses), but they are managed automatically by the programming system and each possess a fixed data type.

IEC 61131-3 specifies several data types (Bool, Byte, Integer, ...). These differ, for example, in the number of bits or the use of signs. It is also possible for the user to define new data types: user-defined data types such as structures and arrays.

Variables can also be assigned to a certain I/O address and can be battery- backed against power failure.

Variables have different forms. They can be defined (declared) outside a POU and used program-wide, they can be declared as interface parameters of a POU, or they can have a local meaning for a POU. For declaration purposes they are therefore divided into different variable types. All variables used by a POU have to be declared in the declaration part of the POU.

The declaration part of a POU can be written in textual form independently of the programming language used. Parts of the declaration (input and output parameters of the POU) can also be represented graphically.

2.1 Introduction to the New Standard 23

VAR_INPUT (* Input variable *) ValidFlag : BOOL; (* Binary value *)

END_VAR VAR_OUTPUT (* Output variable *)

RevPM : REAL; (* Floating-point value *) END_VAR VAR RETAIN (* Local variable, battery-backed *)

MotorNr : INT; (* Signed integer *) MotorName : STRING [10]; (* String of length 10 *) EmStop AT %IX2.0 : BOOL; (* Input bit 2.0 of I/O *)

END_VAR

Example 2.1. Example of typical variable declarations of a POU

Example 2.1 shows the variable declaration part of a POU. A signed integer variable (16 bits incl. sign) with name MotorNr and a text of length 10 with name MotorName are declared. The binary variable EmStop (emergency stop) is assigned to the I/O signal input 2.0 (using the keyword “AT”). These three variables are known only within the corresponding POU, i.e. they are “local”. They can only be read and altered by this POU. During a power failure they retain their value, as is indicated by the qualifier “RETAIN”. The value for input variable ValidFlag will be set by the calling POU and have the Boolean values TRUE or FALSE. The output parameter returned by the POU in this example is the floating- point value RevPM.

The Boolean values TRUE and FALSE can be also be indicated by “1” and “0”.

Code part of a POU The code part, or instruction part, follows the declaration part and contains the instructions to be processed by the PLC.

A POU is programmed using either the textual programming languages Instruction List (IL) and Structured Text (ST) or the graphical languages Ladder Diagram (LD) and Function Block Diagram (FBD). IL is a programming language closer to machine code, whereas ST is a high-level language. LD is suitable for Boolean (binary) logic operations. FBD can be used for programming both Boolean (binary) and arithmetic operations in graphical representation.

24 2 Building Blocks of IEC 61131-3

%IX23.5 Motor

Button N

S1

R

SR

FlipFlop

Q1 VarOut

VarIn

EmStop

Ladder Diagram

>=%IW3

%MW3

Function Block Diagram

Instruction List Structured Text

LD ORN ANDN S

S

%IX23.5 Button EmStop Motor

FlipFlop ( R := VarIn ); S1 := (%IW3 >= %MW3),

VarOut := FlipFlop.Q1;

Figure 2.1. Simple examples of the programming languages LD, FBD, IL and ST. The examples in LD and IL are equivalent to one another, as are those in FBD and ST.

Additionally, the description language Sequential Function Chart (SFC) can be used to describe the structure of a PLC program by displaying its sequential and parallel execution. The various subdivisions of the SFC program (steps and transitions) can be programmed independently using any of the IEC 61131-3 programming languages.

comentários (0)
Até o momento nenhum comentário
Seja o primeiro a comentar!
Esta é apenas uma pré-visualização
3 shown on 240 pages
baixar o documento