logo资料库

IEC61131-3标准.pdf

第1页 / 共226页
第2页 / 共226页
第3页 / 共226页
第4页 / 共226页
第5页 / 共226页
第6页 / 共226页
第7页 / 共226页
第8页 / 共226页
资料共226页,剩余部分请下载后查看
INTERNATIONAL STANDARD IEC 61131-3 Second edition 2003-01 Programmable controllers – Part 3: Programming languages Automates programmables – Partie 3: Langages de programmation Reference number IEC 61131-3:2003(E)
Publication numbering As from 1 January 1997 all IEC publications are issued with a designation in the 60000 series. For example, IEC 34-1 is now referred to as IEC 60034-1. Consolidated editions The IEC is now publishing consolidated versions of its publications. For example, edition numbers 1.0, 1.1 and 1.2 refer, respectively, to the base publication, the base publication incorporating amendment 1 and the base publication incorporating amendments 1 and 2. Further information on IEC publications The technical content of IEC publications is kept under constant review by the IEC, thus ensuring that the content reflects current technology. Information relating to this publication, including its validity, is available in the IEC Catalogue of publications (see below) in addition to new editions, amendments and corrigenda. Information on the subjects under consideration and work in progress undertaken by the technical committee which has prepared this publication, as well as the list of publications issued, is also available from the following: IEC Web Site (www.iec.ch) Catalogue of IEC publications The on-line catalogue on the IEC web site (http://www.iec.ch/searchpub/cur_fut.htm) enables you to search by a variety of criteria including text searches, technical committees and date of publication. On-line information is also available on recently issued publications, withdrawn and replaced publications, as well as corrigenda. IEC Just Published This summary of recently issued publications (http://www.iec.ch/online_news/ justpub/jp_entry.htm) is also available by email. Please contact the Customer Service Centre (see below) for further information. Customer Service Centre If you have any questions regarding this publication or need further assistance, please contact the Customer Service Centre: Email: custserv@iec.ch Tel: +41 22 919 02 11 Fax: +41 22 919 03 00 • • • •
INTERNATIONAL STANDARD IEC 61131-3 Second edition 2003-01 Programmable controllers – Part 3: Programming languages Automates programmables – Partie 3: Langages de programmation  IEC 2003  Copyright - all rights reserved 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 the publisher. International Electrotechnical Commission, 3, rue de Varembé, PO Box 131, CH-1211 Geneva 20, Switzerland Telephone: +41 22 919 02 11 Telefax: +41 22 919 03 00 E-mail: inmail@iec.ch Web: www.iec.ch Commission Electrotechnique Internationale International Electrotechnical Commission Международная Электротехническая Комиссия PRICE CODE For price, see current catalogue XE
– 2 – 61131-3  IEC:2003(E) CONTENTS FOREWORD ....................................................................................................................................8 1 General........................................................................................................................................9 1.1 Scope.........................................................................................................................................9 1.2 Normative references ................................................................................................................9 1.3 Definitions..................................................................................................................................9 1.4 Overview and general requirements .......................................................................................14 1.4.1 Software model.....................................................................................................................14 1.4.2 Communication model..........................................................................................................16 1.4.3 Programming model .............................................................................................................18 1.5 Compliance..............................................................................................................................19 1.5.1 System compliance ..............................................................................................................20 1.5.2 Program compliance.............................................................................................................22 2 Common elements .....................................................................................................................23 2.1 Use of printed characters ........................................................................................................23 2.1.1 Character set ........................................................................................................................23 2.1.2 Identifiers ..............................................................................................................................23 2.1.3 Keywords..............................................................................................................................24 2.1.4 Use of white space ................................................................................................................24 2.1.5 Comments ............................................................................................................................24 2.1.6 Pragmas ...............................................................................................................................25 2.2 External representation of data ...............................................................................................25 2.2.1 Numeric literals.....................................................................................................................25 2.2.2 Character string literals ........................................................................................................26 2.2.3 Time literals ..........................................................................................................................28 2.2.3.1 Duration .............................................................................................................................28 2.2.3.2 Time of day and date.........................................................................................................29 2.3 Data types ...............................................................................................................................29 2.3.1 Elementary data types..........................................................................................................30 2.3.2 Generic data types ...............................................................................................................31 2.3.3 Derived data types................................................................................................................32 2.3.3.1 Declaration ........................................................................................................................32 2.3.3.2 Initialization........................................................................................................................33 2.3.3.3 Usage .................................................................................................................................35 2.4 Variables..................................................................................................................................36 2.4.1 Representation .....................................................................................................................36 2.4.1.1 Single-element variables ...................................................................................................36 2.4.1.2 Multi-element variables .....................................................................................................38 2.4.2 Initialization...........................................................................................................................38 2.4.3 Declaration ...........................................................................................................................39 2.4.3.1 Type assignment ...............................................................................................................41 2.4.3.2 Initial value assignment .....................................................................................................42 2.5 Program organization units .....................................................................................................45 2.5.1 Functions ..............................................................................................................................45 2.5.1.1 Representation ..................................................................................................................46 2.5.1.2 Execution control...............................................................................................................49 2.5.1.3 Declaration ........................................................................................................................50 2.5.1.4 Typing, overloading, and type conversion.........................................................................52 2.5.1.5 Standard functions.............................................................................................................55 2.5.1.5.1 Type conversion functions..............................................................................................55 2.5.1.5.2 Numerical functions........................................................................................................56 2.5.1.5.3 Bit string functions ..........................................................................................................59 2.5.1.5.4 Selection and comparison functions...............................................................................59 2.5.1.5.5 Character string functions ..............................................................................................62 2.5.1.5.6 Functions of time data types ..........................................................................................64 2.5.1.5.7 Functions of enumerated data types..............................................................................66
61131-3  IEC:2003(E) – 3 – 2.5.2 Function blocks.....................................................................................................................66 2.5.2.1 Representation ..................................................................................................................67 2.5.2.1a) Use of EN and ENO in function blocks ............................................................................68 2.5.2.2 Declaration ........................................................................................................................69 2.5.2.3 Standard function blocks ...................................................................................................77 2.5.2.3.1 Bistable elements ...........................................................................................................77 2.5.2.3.2 Edge detection................................................................................................................78 2.5.2.3.3 Counters .........................................................................................................................78 2.5.2.3.4 Timers.............................................................................................................................81 2.5.2.3.5 Communication function blocks......................................................................................83 2.5.3 Programs ..............................................................................................................................83 2.6 Sequential Function Chart (SFC) elements.............................................................................84 2.6.1 General.................................................................................................................................84 2.6.2 Steps.....................................................................................................................................84 2.6.3 Transitions ............................................................................................................................86 2.6.4 Actions..................................................................................................................................89 2.6.4.1 Declaration ........................................................................................................................89 2.6.4.2 Association with steps .......................................................................................................91 2.6.4.3 Action blocks .....................................................................................................................92 2.6.4.4 Action qualifiers .................................................................................................................93 2.6.4.5 Action control.....................................................................................................................94 2.6.5 Rules of evolution.................................................................................................................99 2.6.6 Compatibility of SFC elements ...........................................................................................107 2.6.7 SFC Compliance requirements ..........................................................................................108 2.7 Configuration elements..........................................................................................................108 2.7.1 Configurations, resources, and access paths ....................................................................110 2.7.2 Tasks ..................................................................................................................................114 3 Textual languages ....................................................................................................................123 3.1 Common elements ................................................................................................................123 3.2 Instruction list (IL) ..................................................................................................................123 3.2.1 Instructions .........................................................................................................................123 3.2.2 Operators, modifiers and operands....................................................................................124 3.2.3 Functions and function blocks............................................................................................126 3.3 Structured Text (ST)..............................................................................................................129 3.3.1 Expressions ........................................................................................................................129 3.3.2 Statements .........................................................................................................................131 3.3.2.1 Assignment statements ...................................................................................................133 3.3.2.2 Function and function block control statements ..............................................................133 3.3.2.3 Selection statements .......................................................................................................133 3.3.2.4 Iteration statements.........................................................................................................134 4 Graphic languages ...................................................................................................................135 4.1 Common elements ................................................................................................................135 4.1.1 Representation of lines and blocks .....................................................................................135 4.1.2 Direction of flow in networks...............................................................................................135 4.1.3 Evaluation of networks .......................................................................................................136 4.1.4 Execution control elements ................................................................................................138 4.2 Ladder diagram (LD) .............................................................................................................139 4.2.1 Power rails..........................................................................................................................139 4.2.2 Link elements and states....................................................................................................139 4.2.3 Contacts .............................................................................................................................140 4.2.4 Coils....................................................................................................................................140 4.2.5 Functions and function blocks............................................................................................140 4.2.6 Order of network evaluation ...............................................................................................141 4.3 Function Block Diagram (FBD)..............................................................................................143 4.3.1 General...............................................................................................................................143 4.3.2 Combination of elements....................................................................................................143 4.3.3 Order of network evaluation ...............................................................................................143
– 4 – 61131-3  IEC:2003(E) ANNEX A (normative) Specification method for textual languages ............................................144 A.1 Syntax ...................................................................................................................................144 A.1.1 Terminal symbols.............................................................................................................144 A.1.2 Non-terminal symbols ......................................................................................................144 A.1.3 Production rules ................................................................................................................145 A.2 Semantics .............................................................................................................................145 ANNEX B (normative) Formal specifications of language elements...........................................146 B.0 Programming model..............................................................................................................146 B.1 Common elements................................................................................................................146 B.1.1 Letters, digits and identifiers ...............................................................................................146 B.1.2 Constants ...........................................................................................................................147 B.1.2.1 Numeric literals ..............................................................................................................147 B.1.2.2 Character strings.............................................................................................................147 B.1.2.3 Time literals......................................................................................................................148 B.1.2.3.1 Duration........................................................................................................................148 B.1.2.3.2 Time of day and date ...................................................................................................148 B.1.3 Data types .........................................................................................................................149 B.1.3.1 Elementary data types ....................................................................................................149 B.1.3.2 Generic data types..........................................................................................................149 B.1.3.3 Derived data types ..........................................................................................................149 B.1.4 Variables ............................................................................................................................151 B.1.4.1 Directly represented variables ........................................................................................151 B.1.4.2 Multi-element variables ...................................................................................................151 B.1.4.3 Declaration and initialization ...........................................................................................152 B.1.5 Program organization units ................................................................................................154 B.1.5.1 Functions.........................................................................................................................154 B.1.5.2 Function blocks ...............................................................................................................155 B.1.5.3 Programs.........................................................................................................................156 B.1.6 Sequential function chart elements....................................................................................156 B.1.7 Configuration elements ......................................................................................................157 B.2 Language IL (Instruction List) ...............................................................................................159 B.2.1 Instructions and operands..................................................................................................159 B.2.2 Operators ...........................................................................................................................159 B.3 Language ST (Structured Text) ............................................................................................160 B.3.1 Expressions........................................................................................................................160 B.3.2 Statements .........................................................................................................................160 B.3.2.1 Assignment statements...................................................................................................161 B.3.2.2 Subprogram control statements......................................................................................161 B.3.2.3 Selection statements.......................................................................................................161 B.3.2.4 Iteration statements.........................................................................................................161 ANNEX C (normative) Delimiters and keywords.........................................................................162 ANNEX D (normative) Implementation-dependent parameters..................................................165 ANNEX E (normative) Error conditions .......................................................................................167 ANNEX F (informative) Examples ...............................................................................................169 F.1 Function WEIGH ...................................................................................................................169 F.2 Function block CMD_MONITOR...........................................................................................170 F.3 Function block FWD_REV_MON ..........................................................................................173 F.4 Function block STACK_INT...................................................................................................178 F.5 Function block MIX_2_BRIX .................................................................................................183 F.6 Analog signal processing ......................................................................................................186 F.6.1 Function block LAG1 ..........................................................................................................187 F.6.2 Function block DELAY ........................................................................................................187
61131-3  IEC:2003(E) – 5 – F.6.3 Function block AVERAGE....................................................................................................188 F.6.4 Function block INTEGRAL..................................................................................................188 F.6.5 Function block DERIVATIVE .............................................................................................189 F.6.6 Function block HYSTERESIS .............................................................................................189 F.6.7 Function block LIMITS_ALARM .........................................................................................190 F.6.8 Structure ANALOG_LIMITS................................................................................................190 F.6.9 Function block ANALOG_MONITOR.....................................................................................191 F.6.10 Function block PID............................................................................................................192 F.6.11 Function block DIFFEQ .....................................................................................................193 F.6.12 Function block RAMP ........................................................................................................194 F.6.13 Function block TRANSFER................................................................................................195 F.7 Program GRAVEL...................................................................................................................195 F.8 Program AGV .........................................................................................................................203 F.9 Use of enumerated data types ..............................................................................................206 F.10 Function block RTC (Real Time Clock)................................................................................206 F.11 Function block ALRM_INT...................................................................................................206 ANNEX G (informative) Reference character set........................................................................208 Index ............................................................................................................................................210 Table 1 - Character set features.....................................................................................................23 Table 2 - Identifier features.............................................................................................................24 Table 3 - Comment feature.............................................................................................................25 Table 3a - Pragma feature..............................................................................................................25 Table 4 - Numeric literals................................................................................................................26 Table 5 - Character string literal features .......................................................................................27 Table 6 - Two-character combinations in character strings ...........................................................28 Table 7 - Duration literal features ...................................................................................................29 Table 8 - Date and time of day literals............................................................................................29 Table 9 - Examples of date and time of day literals .......................................................................29 Table 10 - Elementary data types ..................................................................................................30 Table 11 - Hierarchy of generic data types ....................................................................................32 Table 12 - Data type declaration features ......................................................................................33 Table 13 - Default initial values of elementary data types..............................................................34 Table 14 - Data type initial value declaration features ...................................................................35 Table 15 - Location and size prefix features for directly represented variables.............................37 Table 16a - Variable declaration keywords ....................................................................................39 Table 16b - Usages of VAR_GLOBAL, VAR_EXTERNAL and CONSTANT declarations ............41 Table 17 - Variable type assignment features................................................................................41 Table 18 - Variable initial value assignment features.....................................................................43 Table 19 - Graphical negation of Boolean signals .........................................................................47 Table 19a - Textual invocation of functions for formal and non-formal argument list ....................49 Table 20 - Use of EN input and ENO output ....................................................................................50 Table 20a - Function features........................................................................................................51 Table 21 - Typed and overloaded functions...................................................................................53 Table 22 - Type conversion function features ................................................................................55 Table 23 - Standard functions of one numeric variable..................................................................57 Table 24 - Standard arithmetic functions........................................................................................58
– 6 – 61131-3  IEC:2003(E) Table 25 - Standard bit shift functions............................................................................................59 Table 26 - Standard bitwise Boolean functions..............................................................................60 Table 27 - Standard selection functionsd........................................................................................61 Table 28 - Standard comparison functions.....................................................................................62 Table 29 - Standard character string functions ..............................................................................63 Table 30 - Functions of time data types .........................................................................................64 Table 31 - Functions of enumerated data types.............................................................................66 Table 32 - Examples of function block I/O variable usage .............................................................68 Table 33 - Function block declaration and usage features ............................................................71 Table 34 - Standard bistable function blocks a ...............................................................................77 Table 35 - Standard edge detection function blocks ......................................................................78 Table 36 - Standard counter function blocks..................................................................................79 Table 37 - Standard timer function blocks......................................................................................81 Table 38 - Standard timer function blocks - timing diagrams.........................................................82 Table 39 - Program declaration features........................................................................................83 Table 40 - Step features .................................................................................................................85 Table 41 - Transitions and transition conditions.............................................................................87 Table 42 - Declaration of actions a,b................................................................................................90 Table 43 - Step/action association .................................................................................................92 Table 44 - Action block features.....................................................................................................93 Table 45 - Action qualifiers.............................................................................................................94 Table 45a - Action control features ................................................................................................98 Table 46 - Sequence evolution.....................................................................................................101 Table 47 - Compatible SFC features............................................................................................108 Table 48 - SFC minimal compliance requirements ......................................................................108 Table 49 - Configuration and resource declaration features ........................................................112 Table 50 - Task features...............................................................................................................116 Table 51a - Examples of instruction fields....................................................................................124 Table 51b - Parenthesized expression features for IL language..................................................125 Table 52 - Instruction List operators.............................................................................................125 Table 53 - Function Block invocation and Function invocation features for IL language.............127 Table 54 - Standard Function Block input operators for IL language...........................................129 Table 55 - Operators of the ST language.....................................................................................131 Table 56 - ST language statements .............................................................................................132 Table 57 - Representation of lines and blocks .............................................................................136 Table 58 - Graphic execution control elements............................................................................138 Table 59 - Power rails...................................................................................................................139 Table 60 - Link elements ..............................................................................................................140 Table 61 - Contacts a ....................................................................................................................141 Table 62 - Coils ............................................................................................................................142 Table C.1 - Delimiters...................................................................................................................162 Table C.2 - Keywords ...................................................................................................................163 Table D.1 - Implementation-dependent parameters ....................................................................165 Table E.1 - Error conditions..........................................................................................................167
分享到:
收藏