1、 IEC 61131-3 Edition 3.0 2013-02 INTERNATIONAL STANDARD NORME INTERNATIONALE Programmable controllers Part 3: Programming languages Automates programmables Partie 3: Langages de programmation IEC61131-3:2013 THIS PUBLICATION IS COPYRIGHT PROTECTED Copyright 2013 IEC, Geneva, Switzerland All rights r
2、eserved. Unless otherwise specified, no part of this publication may be reproduced or utilized in any form or by any means, electronic or mechanical, including photocopying and microfilm, without permission in writing from either IEC or IECs member National Committee in the country of the requester.
3、 If you have any questions about IEC copyright or have an enquiry about obtaining additional rights to this publication, please contact the address below or your local IEC member National Committee for further information. Droits de reproduction rservs. Sauf indication contraire, aucune partie de ce
4、tte publication ne peut tre reproduite ni utilise sous quelque forme que ce soit et par aucun procd, lectronique ou mcanique, y compris la photocopie et les microfilms, sans laccord crit de la CEI ou du Comit national de la CEI du pays du demandeur. Si vous avez des questions sur le copyright de la
5、CEI ou si vous dsirez obtenir des droits supplmentaires sur cette publication, utilisez les coordonnes ci-aprs ou contactez le Comit national de la CEI de votre pays de rsidence. IEC Central Office Tel.: +41 22 919 02 11 3, rue de Varemb Fax: +41 22 919 03 00 CH-1211 Geneva 20 infoiec.ch Switzerland
6、 www.iec.ch About the IEC The International Electrotechnical Commission (IEC) is the leading global organization that prepares and publishes International Standards for all electrical, electronic and related technologies. About IEC publications The technical content of IEC publications is kept under
7、 constant review by the IEC. Please make sure that you have the latest edition, a corrigenda or an amendment might have been published. Useful links: IEC publications search - www.iec.ch/searchpub The advanced search enables you to find IEC publications by a variety of criteria (reference number, te
8、xt, technical committee,). It also gives information on projects, replaced and withdrawn publications. IEC Just Published - webstore.iec.ch/justpublished Stay up to date on all new IEC publications. Just Published details all new publications released. Available on-line and also once a month by emai
9、l. Electropedia - www.electropedia.org The worlds leading online dictionary of electronic and electrical terms containing more than 30 000 terms and definitions in English and French, with equivalent terms in additional languages. Also known as the International Electrotechnical Vocabulary (IEV) on-
10、line. Customer Service Centre - webstore.iec.ch/csc If you wish to give us your feedback on this publication or need further assistance, please contact the Customer Service Centre: csciec.ch. A propos de la CEI La Commission Electrotechnique Internationale (CEI) est la premire organisation mondiale
11、qui labore et publie des Normes internationales pour tout ce qui a trait llectricit, llectronique et aux technologies apparentes. A propos des publications CEI Le contenu technique des publications de la CEI est constamment revu. Veuillez vous assurer que vous possdez ldition la plus rcente, un corr
12、igendum ou amendement peut avoir t publi. Liens utiles: Recherche de publications CEI - www.iec.ch/searchpub La recherche avance vous permet de trouver des publications CEI en utilisant diffrents critres (numro de rfrence, texte, comit dtudes,). Elle donne aussi des informations sur les projets et l
13、es publications remplaces ou retires. Just Published CEI - webstore.iec.ch/justpublished Restez inform sur les nouvelles publications de la CEI. Just Published dtaille les nouvelles publications parues. Disponible en ligne et aussi une fois par mois par email. Electropedia - www.electropedia.org Le
14、premier dictionnaire en ligne au monde de termes lectroniques et lectriques. Il contient plus de 30 000 termes et dfinitions en anglais et en franais, ainsi que les termes quivalents dans les langues additionnelles. Egalement appel Vocabulaire Electrotechnique International (VEI) en ligne. Service C
15、lients - webstore.iec.ch/csc Si vous dsirez nous donner des commentaires sur cette publication ou si vous avez des questions contactez-nous: csciec.ch. IEC 61131-3 Edition 3.0 2013-02 INTERNATIONAL STANDARD NORME INTERNATIONALE Programmable controllers Part 3: Programming languages Automates program
16、mables Partie 3: Langages de programmation INTERNATIONAL ELECTROTECHNICAL COMMISSION COMMISSION ELECTROTECHNIQUE INTERNATIONALE XHICS 25.040; 35.240.50 PRICE CODE CODE PRIX ISBN 978-2-83220-661-4 Registered trademark of the International Electrotechnical Commission Marque dpose de la Commission Elec
17、trotechnique Internationale Warning! Make sure that you obtained this publication from an authorized distributor. Attention! Veuillez vous assurer que vous avez obtenu cette publication via un distributeur agr. 2 61131-3 IEC:2013 CONTENTS FOREWORD . 7 1 Scope . 9 2 Normative references . 9 3 Terms a
18、nd definitions . 9 4 Architectural models . 18 4.1 Software model . 18 4.2 Communication model . 19 4.3 Programming model 20 5 Compliance 22 5.1 General . 22 5.2 Feature tables . 22 5.3 Implementers compliance statement . 22 6 Common elements 24 6.1 Use of printed characters 24 6.1.1 Character set .
19、 24 6.1.2 Identifiers 24 6.1.3 Keywords 24 6.1.4 Use of white space 25 6.1.5 Comments . 25 6.2 Pragma . 26 6.3 Literals External representation of data 26 6.3.1 General . 26 6.3.2 Numeric literals and string literals 26 6.3.3 Character string literals . 28 6.3.4 Duration literal . 29 6.3.5 Date and
20、time of day literal 30 6.4 Data types . 30 6.4.1 General . 30 6.4.2 Elementary data types (BOOL, INT, REAL, STRING, etc.) . 30 6.4.3 Generic data types 33 6.4.4 User-defined data types . 34 6.5 Variables . 47 6.5.1 Declaration and initialization of variables . 47 6.5.2 Variable sections . 49 6.5.3 V
21、ariable length ARRAY variables 51 6.5.4 Constant variables . 53 6.5.5 Directly represented variables ( % ) . 54 6.5.6 Retentive variables (RETAIN, NON_RETAIN) 56 6.6 Program organization units (POUs) . 58 6.6.1 Common features for POUs . 58 6.6.2 Functions. 70 6.6.3 Function blocks . 99 6.6.4 Progra
22、ms . 117 6.6.5 Classes . 118 61131-3 IEC:2013 3 6.6.6 Interface 137 6.6.7 Object oriented features for function blocks . 146 6.6.8 Polymorphism 152 6.7 Sequential Function Chart (SFC) elements 155 6.7.1 General . 155 6.7.2 Steps . 155 6.7.3 Transitions 157 6.7.4 Actions 160 6.7.5 Rules of evolution
23、168 6.8 Configuration elements 176 6.8.1 General . 176 6.8.2 Tasks 180 6.9 Namespaces . 186 6.9.1 General . 186 6.9.2 Declaration 186 6.9.3 Usage 192 6.9.4 Namespace directive USING 192 7 Textual languages 195 7.1 Common elements . 195 7.2 Instruction list (IL) . 195 7.2.1 General . 195 7.2.2 Instru
24、ctions 195 7.2.3 Operators, modifiers and operands 196 7.2.4 Functions and function blocks 198 7.3 Structured Text (ST) 201 7.3.1 General . 201 7.3.2 Expressions . 201 7.3.3 Statements 203 8 Graphic languages . 208 8.1 Common elements . 208 8.1.1 General . 208 8.1.2 Representation of variables and i
25、nstances . 209 8.1.3 Representation of lines and blocks 211 8.1.4 Direction of flow in networks 212 8.1.5 Evaluation of networks 213 8.1.6 Execution control elements 214 8.2 Ladder diagram (LD) . 215 8.2.1 General . 215 8.2.2 Power rails 216 8.2.3 Link elements and states . 216 8.2.4 Contacts 216 8.
26、2.5 Coils 218 8.2.6 Functions and function blocks 219 8.2.7 Order of network evaluation . 219 8.3 Function Block Diagram (FBD) 219 8.3.1 General . 219 8.3.2 Combination of elements . 219 8.3.3 Order of network evaluation . 220 Annex A (normative) Formal specification of the languages elements 221 4
27、61131-3 IEC:2013 Annex B (informative) List of major changes and extensions of the third edition . 228 Bibliography 229 Figure 1 Software model 18 Figure 2 Communication model 20 Figure 3 Combination of programmable controller language elements 21 Figure 4 Implementers compliance statement (Example)
28、 . 23 Figure 5 Hierarchy of the generic data types 34 Figure 6 Initialization by literals and constant expressions (Rules) . 35 Figure 7 Variable declaration keywords (Summary) 50 Figure 8 Usage of VAR_GLOBAL, VAR_EXTERNAL and CONSTANT (Rules) . 51 Figure 9 Conditions for the initial value of a vari
29、able (Rules) 57 Figure 10 Formal and non-formal representation of call (Examples) . 63 Figure 11 Data type conversion rules implicit and/or explicit (Summary) . 67 Figure 12 Supported implicit type conversions . 68 Figure 13 Usage of function block input and output parameters (Rules) . 108 Figure 14
30、 Usage of function block input and output parameters (Illustration of rules) 109 Figure 15 Standard timer function blocks timing diagrams (Rules) 116 Figure 16 Overview of inheritance and interface implementation 119 Figure 17 Inheritance of classes (Illustration) . 128 Figure 18 Interface with deri
31、ved classes (Illustration) . 138 Figure 19 Inheritance of interface and class (Illustration) . 143 Figure 20 Function block with optional body and methods (Illustration) 149 Figure 21 Inheritance of function block body with SUPER() (Example) . 151 Figure 22 ACTION_CONTROL function block External int
32、erface (Summary) 165 Figure 23 ACTION_CONTROL function block body (Summary). 166 Figure 24 Action control (Example) 168 Figure 25 SFC evolution (Rules) 174 Figure 26 SFC errors (Example) 175 Figure 27 Configuration (Example) . 177 Figure 28 CONFIGURATION and RESOURCE declaration (Example) 180 Figure
33、 29 Accessibility using namespaces (Rules) . 189 Figure 30 Common textual elements (Summary) 195 Table 1 Character set 24 Table 2 Identifiers 24 Table 3 Comments . 25 Table 4 Pragma . 26 Table 5 Numeric literals . 27 Table 6 Character string literals . 28 Table 7 Two-character combinations in charac
34、ter strings . 29 Table 8 Duration literals . 29 Table 9 Date and time of day literals 30 61131-3 IEC:2013 5 Table 10 Elementary data types . 31 Table 11 Declaration of user-defined data types and initialization 35 Table 12 Reference operations 46 Table 13 Declaration of variables . 48 Table 14 Initi
35、alization of variables 49 Table 15 Variable-length ARRAY variables 52 Table 16 Directly represented variables . 54 Table 17 Partial access of ANY_BIT variables . 60 Table 18 Execution control graphically using EN and ENO 65 Table 19 Function declaration 72 Table 20 Function call 74 Table 21 Typed an
36、d overloaded functions 76 Table 22 Data type conversion function . 78 Table 23 Data type conversion of numeric data types 80 Table 24 Data type conversion of bit data types . 82 Table 25 Data type conversion of bit and numeric types . 83 Table 26 Data type conversion of date and time types . 85 Tabl
37、e 27 Data type conversion of character types 86 Table 28 Numerical and arithmetic functions 87 Table 29 Arithmetic functions . 88 Table 30 Bit shift functions . 89 Table 31 Bitwise Boolean functions 89 Table 32 Selection functions d90 Table 33 Comparison functions 91 Table 34 Character string functi
38、ons 92 Table 35 Numerical functions of time and duration data types 93 Table 36 Additional functions of time data types CONCAT and SPLIT . 94 Table 37 Function for endianess conversion 98 Table 38 Functions of enumerated data types 98 Table 39 Validate functions 99 Table 40 Function block type decla
39、ration . 100 Table 41 Function block instance declaration . 104 Table 42 Function block call . 105 Table 43 Standard bistable function blocksa. 112 Table 44 Standard edge detection function blocks . 113 Table 45 Standard counter function blocks . 113 Table 46 Standard timer function blocks 115 Table
40、 47 Program declaration 117 Table 48 Class . 120 Table 49 Class instance declaration . 122 Table 50 Textual call of methods Formal and non-formal parameter list 125 Table 51 Interface 137 Table 52 Assignment attempt . 146 6 61131-3 IEC:2013 Table 53 Object oriented function block . 147 Table 54 SFC
41、step . 156 Table 55 SFC transition and transition condition 158 Table 56 SFC declaration of actions 160 Table 57 Step/action association . 162 Table 58 Action block . 163 Table 59 Action qualifiers . 163 Table 60 Action control features . 168 Table 61 Sequence evolution graphical . 169 Table 62 Conf
42、iguration and resource declaration . 178 Table 63 Task 182 Table 64 Namespace . 191 Table 65 Nested namespace declaration options . 192 Table 66 Namespace directive USING 194 Table 67 Parenthesized expression for IL language . 197 Table 68 Instruction list operators 197 Table 69 Calls for IL languag
43、e . 199 Table 70 Standard function block operators for IL language . 201 Table 71 Operators of the ST language 202 Table 72 ST language statements 203 Table 73 Graphic execution control elements . 215 Table 74 Power rails and link elements 216 Table 75 Contacts 217 Table 76 Coils 218 61131-3 IEC:201
44、3 7 INTERNATIONAL ELECTROTECHNICAL COMMISSION _ PROGRAMMABLE CONTROLLERS Part 3: Programming languages FOREWORD 1) The International Electrotechnical Commission (IEC) is a worldwide organization for standardization comprising all national electrotechnical committees (IEC National Committees). The ob
45、ject of IEC is to promote interna-tional co-operation on all questions concerning standardization in the electrical and electronic fields. To this end and in addition to other activities, IEC publishes International Standards, Technical Specifications, Tech-nical Reports, Publicly Available Specific
46、ations (PAS) and Guides (hereafter referred to as “IEC Publica-tion(s)”). Their preparation is entrusted to technical committees; any IEC National Committee interested in the subject dealt with may participate in this preparatory work. International, governmental and non-governmental organizations l
47、iaising with the IEC also participate in this preparation. IEC collaborates closely with the Interna-tional Organization for Standardization (ISO) in accordance with conditions determined by agreement between the two organizations. 2) The formal decisions or agreements of IEC on technical matters ex
48、press, as nearly as possible, an international consensus of opinion on the relevant subjects since each technical committee has representation from all inter-ested IEC National Committees. 3) IEC Publications have the form of recommendations for international use and are accepted by IEC National Committees in that sense. While all reasonable efforts are made to ensure that the technical content of IEC Publications is accurate, IEC cannot be held responsible for the way in which they are used or for any misinter-pretation by any end user