Baixe IEC 61131-3 e outras Notas de estudo em PDF para Cultura, somente na Docsity!
1
2
- 1 Introduction ........................................................................................................
- 1.1 Subject of the Book .........................................................................................
- 1.2 The IEC 61131 standard ..................................................................................
- 1.2.1 Goals and benefits of the standard ................................................................
- Manufacturers (PLC hardware and software).........................................................................
- Customers...............................................................................................................................
- 1.2.2 History and components ...............................................................................
- 1.3 The OrganisationPLCopen ..............................................................................
- 1.3.1 Aims..............................................................................................................
- 1.3.2 Committees and fields of activity..................................................................
- 1.3.3 Results ..........................................................................................................
- Certification
- Exchange format for user programs........................................................................................
- 2 Building Blocks of IEC 61131-3.......................................................................
- 2.1 Introduction to the New Standard ....................................................................
- 2.1.1 Structure of the building blocks ....................................................................
- Declaration of variables..........................................................................................................
- Code part of a POU
- 2.1.2 Introductory example written in IL ...............................................................
- 2.1.3 PLC assignment ............................................................................................
- 2.2 The Program Organisation Unit (POU) ...........................................................
- 2.3 Elements of a POU ..........................................................................................
- 2.3.1 Example ........................................................................................................
- 2.3.2 Declaration part ............................................................................................
- Types of variables in POUs.
- Characteristics of the POU interface
- The formal parameters and return values of a POU................................................................
- External and internal access to POU variables
- 2.3.3 Code part ......................................................................................................
- 2.4 The Function Block .........................................................................................
- 2.4.1 Instances of function blocks..........................................................................
- What is an “instance”?
- Instance means “structure”.
- Instance means “memory”.
- Relationship between FB instances and data blocks............................................................... 2 Contents
- 2.4.2 Re-usable and object-oriented FBs
- 2.4.3 Types of variables in FBs.............................................................................
- 2.5 The Function
- 2.5.1 Types of variables in functions and the function value
- 2.5.2 Execution control with EN and ENO
- 2.6 The Program....................................................................................................
- 2.7 Calling Functions and Function Blocks...........................................................
- 2.7.1 Mutual calls of POUs
- 2.7.2 Recursive calls are forbidden
- 2.7.3 Calling with formal parameters
- 2.7.4 Calls with input parameters omitted or in a different order..........................
- 2.7.5 FB instances as actual FB parameters
- Example of an indirect FB call.
- FB instance names as actual parameters of functions.............................................................
- Function values as actual parameters.
- 2.8 Summary of POU Features..............................................................................
- 3 Variables, Data Types and Common Elements..............................................
- 3.1 Simple Language Elements
- 3.1.1 Reserved keywords
- 3.2 Literals and Identifiers
- 3.2.1 Literals
- 3.2.2 Identifiers
- 3.3 Meanings of Data Types and Variables...........................................................
- 3.3.1 From direct PLC addresses via symbols to variables
- 3.3.2 The data type determines the properties of variables
- 3.3.3 Type-specific use of variables......................................................................
- 3.3.4 Automatic mapping of variables onto the PLC
- 3.4 Data Types
- 3.4.1 Elementary data types
- 3.4.2 Derived data types (type definition)
- Additional properties for elementary data types.
- Arrays.
- Data structures........................................................................................................................
- Initial values in type definitions.
- 3.4.3 Generic data types
- 3.5 Variables
- 3.5.1 Inputs, outputs and flags as special variables
- 3.5.2 Multi-element variables: arrays and structures.............................................
- 3.5.3 Assignment of initial values at the start of a program
- 3.5.4 Attributes of variable types
- 3.5.5 Graphical representation of variable declarations - Contents
- 4 The New Programming Languages of IEC 61131-3 ......................................
- 4.1 Instruction List IL ............................................................................................
- 4.1.1 Instruction in IL ............................................................................................
- 4.1.2 The universal accumulator (Current Result) .................................................
- 4.1.3 Operators ....................................................................................................
- Negation of the operand.
- Nesting levels by parenthesis................................................................................................
- Conditional execution of operators.......................................................................................
- 4.1.4 Using functions and function blocks...........................................................
- Calling a function.................................................................................................................
- Calling a function block.
- 4.1.5 IL example: Mountain railway....................................................................
- 4.2 Structured Text ST.........................................................................................
- 4.2.1 ST statements..............................................................................................
- 4.2.2 Expression: Partial statement in ST ...........................................................
- Operands.
- Operators.
- Function as operator.
- 4.2.3 Statement: Assignment................................................................................
- 4.2.4 Statement: Call of function blocks..............................................................
- 4.2.5 Statement: RETURN ..................................................................................
- 4.2.6 Statement: Selection and Multi- selection...................................................
- Selection...............................................................................................................................
- Multi- selection.
- 4.2.7 Statement: Iteration.....................................................................................
- WHILE and REPEAT statements.
- FOR statement......................................................................................................................
- EXIT statement.....................................................................................................................
- 4.2.8 Example: Stereo cassette recorder ..............................................................
- 4.3 Function Block Diagram FBD .......................................................................
- 4.3.1 Networks, graphical elements and connections of LD and FBD.................
- Network label.
- Network comment.
- Network graphic.
- 4.3.2 Network architecture in FBD......................................................................
- 4.3.3 Graphical objects in FBD ...........................................................................
- Connections..........................................................................................................................
- Execution control (jumps).
- Call of functions and function blocks...................................................................................
- 4.3.4 Programming methods in FBD ...................................................................
- Network evaluation.
- Feedback variable.................................................................................................................
- 4.3.5 Example: Stereo cassette recorder ..............................................................
- Comments on the networks of Example 4.24 and Example 4.31
- 4.4 Ladder Diagram LD 4 Contents
- 4.4.1 Networks, graphical elements and connections (LD)
- 4.4.2 Network architecture in LD........................................................................
- 4.4.3 Graphical objects in LD
- Connections..........................................................................................................................
- Contacts and coils.
- Execution control.
- Call of functions and function blocks...................................................................................
- 4.4.4 Programming methods in LD
- Network evaluation.
- Feedback variable.................................................................................................................
- 4.4.5 Example in Ladder Diagram: Mountain railway
- Comments on the mountain railway networks......................................................................
- 4.5 The American way of Ladder programming
- 4.5.1 Network Layout..........................................................................................
- 4.5.2 Module addresses and memory areas
- 4.5.3 Configuration
- 4.6 Sequential Function Chart SFC
- 4.6.1 Step / Transition combination
- 4.6.2 Step - transition sequence...........................................................................
- 4.6.3 Detailed description of steps and transitions
- Step.......................................................................................................................................
- Transition.
- 4.6.4 Step execution using action blocks and actions..........................................
- 4.6.5 Detailed description of actions and action blocks
- 4.6.6 Relationship between step, transition, action and action block
- 4.6.7 Action qualifiers and execution control
- Qualifier.
- Sequential control.................................................................................................................
- 4.6.8 Example: “Dino Park”................................................................................
- Comments on the network for the dinosaur park..................................................................
- 5 Standardised PLC Functionality
- 5.1 Standard Functions........................................................................................
- 5.1.1 Overloaded and extensible functions..........................................................
- Overloaded functions............................................................................................................
- Extensible functions
- 5.1.1 Examples ....................................................................................................
- Type conversion functions....................................................................................................
- Numerical functions
- Arithmetic functions.............................................................................................................
- Bit-shift functions
- Bitwise Boolean functions....................................................................................................
- Selection functions
- Comparison functions
- Character string functions
- Functions for time data types.
- Functions for enumerated data types
- 5.2 Standard Function Blocks..............................................................................
- 5.2.2 Examples ....................................................................................................
- Bistable element (flipflop)....................................................................................................
- Edge detection
- Counter.................................................................................................................................
- Timer....................................................................................................................................
- 6 State-of-the-Art PLC Configuration.............................................................
- 6.1 Structuring Projects with Configuration Elements.........................................
- 6.2 Elements of a Real-World PLC Configuration ..............................................
- 6.3 Configuration Elements .................................................................................
- 6.3.1 Definitions ..................................................................................................
- 6.3.2 The CONFIGURATION ............................................................................
- 6.3.3 The RESOURCE ........................................................................................
- 6.3.4 The TASK with run-time program..............................................................
- 6.3.5 ACCESS declarations .................................................................................
- 6.4 Configuration Example..................................................................................
- 6.5 Communication between Configurations and POUs......................................
- 7 Innovative PLC Programming Systems........................................................
- 7.1 Requirements of Innovative Programming Tools ..........................................
- 7.2 Technological Change ...................................................................................
- 7.2.1 Processor performance................................................................................
- 7.2.2 Full-graphics display and printout ..............................................................
- 7.2.3 Operating systems.......................................................................................
- 7.2.4 Uniform user interfaces...............................................................................
- 7.3 Decompilation (Reverse Documentation)......................................................
- 7.3.1 No decompilation........................................................................................
- 7.3.2 Decompilation with symbols and comments...............................................
- 7.3.3 Decompilation including graphics ..............................................................
- 7.3.4 Sources stored in the PLC...........................................................................
- 7.4 Language Compatibility.................................................................................
- 7.4.1 Cross-compilation 6 Contents
- The motivation for cross-compilation...................................................................................
- Different approaches in graphical and textual languages.
- Differences in languages affect cross-compilation.
- Restrictions in LD/ FBD.......................................................................................................
- Restrictions in IL/ ST.
- Cross-compilation IL / ST.
- Full cross-compilation only with additional information......................................................
- Quality criteria for cross-compilation...................................................................................
- 7.4.2 Language independence
- 7.5 Documentation
- 7.5.1 Cross-reference list.....................................................................................
- 7.5.2 Allocation list (wiring list)
- 7.5.3 Comments
- 7.6 Project Manager
- 7.7 Test & Commissioning Functions
- 7.7.1 Program transfer.........................................................................................
- 7.7.2 Online modification of a program
- 7.7.3 Remote control: Starting and stopping the PLC
- 7.7.4 Variable and program status.......................................................................
- 7.7.5 Forcing
- 7.7.6 Program test
- 7.7.7 Testing Sequential Function Chart programs
- 7.8 Data Blocks and Recipes...............................................................................
- 7.9 FB Interconnection........................................................................................
- 7.9.1 Data exchange and co-ordination of blocks in distributed systems
- 7.9.2 Macro techniques in FB interconnection....................................................
- 7.10 Diagnostics, Error Detection and Error Handling
- Error concept of IEC 61131-3.
- Extended error handling model (beyond IEC).
- 7.11 Hardware-Dependence
- 7.12 Readiness for New Functionality
- 7.12.1 Exchange of programs and data
- 7.12.2 Extension with additional software packages...........................................
- 8 Main Advantages of IEC 61131-3.................................................................
- 8.1 Convenience and Security with Variables and Data Types
- 8.2 Blocks with Extended Capabilities................................................................
- 8.3 PLC Configuration with Run-Time Behaviour..............................................
- 8.4 Uniform Programming Languages
- 8.5 Structured PLC Programs..............................................................................
- 8.6 Trend towards Open PLC Programming Systems
- 8.7 Conclusion - Contents
- 9 Programming by Configuring with IEC 61499 ............................................
- 9.1 Programming by FB Interconnection with IEC 61131-3 ...............................
- 9.2 IEC 61499 – The Programming Standard for Distributed PLC Systems .......
- 9.2.1 System model..............................................................................................
- 9.2.2 Device model ..............................................................................................
- 9.2.3 Resource model ..........................................................................................
- 9.2.4 Application model ......................................................................................
- 9.2.5 Function block model .................................................................................
- Composite function blocks...................................................................................................
- 9.2.6 Creating an application ...............................................................................
- 9.3 Overview of the Parts of IEC 61499..............................................................
- 10 Contents of CD-ROM...................................................................................
- 10.1 IEC Programming Systems STEP 7 and OpenPCS .....................................
- Demo versions of STEP 7 (Siemens) and OpenPCS (infoteam)...........................................
- IL examples
- 10.2 Buyer's Guide for IEC 61131-3 PLC Programming Systems ......................
- A Standard Functions........................................................................................
- A.1 Type Conversion Functions .........................................................................
- A.2 Numerical Functions ....................................................................................
- A.3 Arithmetic Functions....................................................................................
- A.4 Bit-Shift Functions.......................................................................................
- A.5 Bitwise Boolean Functions ..........................................................................
- A.6 Selection Functions for Max., Min. and Limit .............................................
- A.7 Selection Functions for Binary Selection and Multiplexers .........................
- A.8 Comparison Functions ..................................................................................
- A.9 Character String Functions...........................................................................
- A.10 Functions for Time Data Types..................................................................
- A.11 Functions for Enumerated Data Types.......................................................
- B Standard Function Blocks .............................................................................
- B.1 Bistable Elements (Flip-Flops)......................................................................
- B.2 Edge Detection..............................................................................................
- B.3 Counters ........................................................................................................
- B.4 Timers ...........................................................................................................
- C IL Examples....................................................................................................
- C.1 Example of a FUNCTION ............................................................................
- C.2 Example of a FUNCTION_BLOCK.............................................................
- C.3 Example of a PROGRAM.............................................................................
- D Standard Data Types .....................................................................................
- E Causes of Error ..............................................................................................
- F Implementation-Dependent Parameters 8 Contents
- G IL Syntax Example........................................................................................
- G.1 Syntax Diagrams for IL
- G.2 IL Example from Syntax Diagrams
- H Reserved Keywords and Delimiters.............................................................
- H.1 Reserved Keywords......................................................................................
- H.2 Delimiters.....................................................................................................
- I Planned Amendments to the Standard
- J Glossary
- K Bibliography
- L Index
- Author Biographies...........................................................................................
- Karl-Heinz John
- Michael Tiegelkamp............................................................................................
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
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.
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 TF 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- 1994 DIN EN 661131 Parts 1 and 2 1995 International standard IEC 61131- 1996 Additional guide to DIN EN 661131 (user’s guide, IEC 61131-4) 1994 – 2001 Corrigendum to IEC 61131- 1995, 1996 Technical Reports type 2 and 3 1996 - 2001 Amendments
Table 1.1. Important precursors and milestones of IEC 61131-
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).
Technical Report 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.
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. 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- 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.
- 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.
- Portability level. The selection of compulsory features is extended so that it is possible to exchange real software components between certified programming systems.
- 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.