Show/Hide Bookmarks L Manual Global Drive PLC Developer Studio Global Drive Drive PLC Developer Studio Introduction to IEC 61131-3 programming
Show/Hide Bookmarks Important note: The software is supplied to the user as described in this document. Any risks resulting from its quality or use remain the responsibility of the user. The user must provide all safety measures protecting against possible maloperation. We do not take any liability for direct or indirect damage, e.g. profit loss, order loss or any loss regarding business.
Show/Hide Bookmarks Introduction to IEC 61131-3 programming Contents 1 Preface and general information . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1.1 2 For further information on IEC 61131-3 programming . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 2 2 The software model . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 3 2.1 Resources within a configuration . . . . . . .
Show/Hide Bookmarks Introduction to IEC 61131-3 programming Preface and general information 1 Preface and general information This Manual informs about the standard IEC 61131-3. The IEC 61131-3 standard is the basis for uniform PLC programming that enables the user • to use already tested and standardized software components again. • to apply software engineering methods for the generation of these components. • to consider problem solutions from a complex point of view.
Show/Hide Bookmarks Introduction to IEC 61131-3 programming The software model 2 The software model The software model of IEC 61131-3 describes the concepts of configuration, resource, task, program, function block and function and their connection. For the definition of these terms, the standard is based on a maximum powerful PLC providing the following features: • • • • 2.
Show/Hide Bookmarks Introduction to IEC 61131-3 programming The software model • If several tasks fulfill the condition, the task with the highest priority will be executed. • It is not possible to assign the same priority to several tasks. (Exception: Priority 0 = Task inhibited) • If a task with a higher priority meets the condition while another task is being processed, the task with the lower prority will be interrupted and only be processed after the other task has been completed. 2.
Show/Hide Bookmarks Introduction to IEC 61131-3 programming The software model 2.2.2 Function blocks The IEC 61131-3 standard uses standard functions and function blocks to standardize typical PLC functions. This ”Standard library” is an important basis for uniform, manufacturer-independent programming of PLC systems. Function blocks (FBs) can be compared with integrated circuits, which include a certain control function. They are used to set inputs/outputs and internal variables.
Show/Hide Bookmarks Introduction to IEC 61131-3 programming The software model 2.2.3 Functions Unlike FBs, functions cannot buffer their internal values. Thus, they cannot use global variables, access function blocks and declare directly addressable variables. All functions have in common that they return the same output parameters if the input parameters are the same. Overview: IEC 61131-3 standard functions Type conversion functions ..._TO_...
Show/Hide Bookmarks Introduction to IEC 61131-3 programming The software model Overview: IEC 61131-3 standard operators Arithmetic operators ADD Addition MUL Multiplication SUB Subtraction DIV Division MOD Remainders EXP Exponentiation MOVE Assignment Bit-shift operators SHL Shift to LHS SHR Shift to RHS ROR CW rotation ROL CCW rotation Bit-string operators AND Bit-by-bit AND of bit operands OR Bit-by-bit OR of bit operands XOR Bit-by-bit XOR of bit operands NOT Bit-by-bit NOT
Show/Hide Bookmarks Introduction to IEC 61131-3 programming The communication model 3 The communication model The communication model of IEC 61131-3 describes the data exchange of configuration elements by means of • access paths • global variables • call parameters • communication organization units (IEC 61131-5) These unambiguously defined interfaces support the modularization and thus the reuseability of program parts. 3.
Show/Hide Bookmarks Introduction to IEC 61131-3 programming General language elements 4 General language elements General language elements of IEC 61131-3 are identifiers, keywords, comments, literals, data types and variables. They are described in detail in the following sub-sections: 4.1 Identifiers Identifiers are used to address variables, functions, programs, etc. They are elements and can support the readability of programs.
Show/Hide Bookmarks Introduction to IEC 61131-3 programming General language elements Integers can be defined with a basis, decimal numbers can also have a sign (+ or -). Reals can also be indicated with exponents. Identification Integers decimal Example 10 binary 2# 2#1010 octal 8# 8#12 hexadecimal 16# 16#A Reals without exponent with exponent -12.50 E 15.7E4 Times There are two different time literals: Duration and time of day/date. 4.
Show/Hide Bookmarks Introduction to IEC 61131-3 programming General language elements 4.6 Variables IEC 61131-3 defines five different variable classes: • Global variables • Local variables • Input variables • Output variables • Input and output variables Local variables do not have a connection to the outside, i.e. they can only be addressed from within a program part; global variables can be addressed from all POUs.
Show/Hide Bookmarks Introduction to IEC 61131-3 programming Programming languages 5 Programming languages IEC 61131-3 defines the following five programming languages: • IL: Instruction List (Instruction List, IL) • ST: Structured Text (Structured Text) • SFC: Sequential Function Chart (Sequential Function Chart, SFC) • FBD: Function Block Diagram (Function Block Diagram, FBD) • LD: Ladder Diagram (Ladder Diagram, LD) Each of these languages is used for special applications which are particularly suited
Show/Hide Bookmarks Introduction to IEC 61131-3 programming Programming languages 5.2 Structured Text (ST) (Structured Text) Structured Text consists of instructions which can be executed like in high languages with conditions (IF..THEN..ELSE) or in loops (WHILE..DO). Structured Text is an easily readable and understandable programming language that does not only offer powerful loop programming and the possibility of conditioned commands but also imaging mathematical functions.
Show/Hide Bookmarks Introduction to IEC 61131-3 programming Programming languages 5.3 Sequential Function Chart (SFC) (Sequential Function Chart, SFC) Sequential Function Chart is a graphically oriented language that enables the description of a time sequence of different actions within a program. An organization unit written in SFC consists of steps which are linked by means of directed connections (transitions). Fig.
Show/Hide Bookmarks Introduction to IEC 61131-3 programming Programming languages Transitions Transitions are between steps. A step that follows a transition is activated if the transition condition is TRUE.
Show/Hide Bookmarks Introduction to IEC 61131-3 programming Programming languages 5.4 Function Block Diagram (FBD) (Function Block Diagram, FBD) Function Block Diagram is a graphically oriented programming language. It works with a list of networks. Each network has a structure which represents a logic or arithmetics, a function block request, jump or a return instruction. Function block outputs are connected with inputs of following function blocks. Jumps facilitate programming.
Show/Hide Bookmarks Introduction to IEC 61131-3 programming Programming languages Contacts If a Boolean variable of a contact has the value TRUE, the status ”ON” is transmitted via the connection line from left to right. Otherwise, the right connection is set to ”OFF”. • Contacts can be switched in parallel. For this, one of the parallel branches must transmit the value ”ON”. • Contacts can also be switched in series. For this, all contacts must transmit the status ”ON”.
Show/Hide Bookmarks Introduction to IEC 61131-3 programming Appendix 6 Appendix 6.1 IEC keywords Keywords are unique character combinations used as individual syntax elements. • Keywords must not be used as identifiers. • Keywords under the Drive PLC Developer Studio also include the names of Lenze function blocks, that always start with ”L_” ( L_ABS , L_ADD , ...).
Show/Hide Bookmarks Introduction to IEC 61131-3 programming Appendix L Q Q1 QU QD R RELEASE RETC RS R1 REPEAT RETCN RTC R_TRIG REPLACE RETURN R_EDGE READ_ONLY RESOURCE RIGHT READ_WRITE RET ROL REAL RETAIN ROR S SHR SR SUB S1 SIN ST SD SINGLE STEP SEL SINT STN SEMA SL STRING SHL SQRT STRUCT TAN TOD TYPE TASK TOF THEN TON TIME TP TIME_OF_DAY TRANS TO TRUE UDINT UINT ULINT UNTIL VAR VAR_OUTPUT VAR_ACCESS VAR_EXTERNAL WHILE WITH WORD XOR XORN VAR_GLOBAL DDS-IEC61131 EN 2.
Show/Hide Bookmarks Introduction to IEC 61131-3 programming Appendix 6.2 Conventions for Lenze variable identifiers This chapter describes the conventions used for the variable identifiers of Lenze system blocks, function blocks and functions. The conventions ensure uniform and universal labelling and make reading the PLC program easier. Tip! The conventions used by Lenze are based on the ”Hungarian Notation”. This ensures that the most significant characteristics of a variable (e.g.
Show/Hide Bookmarks Introduction to IEC 61131-3 programming Appendix 6.2.2 Indication of the variable type The indication of the variable type is optional. It can be used to indicate the variable type in the identifier: 6.2.
Show/Hide Bookmarks Introduction to IEC 61131-3 programming Appendix 6.2.4 Identifier The identifier is the proper name of a variable and should indicate the application or function of the variable. • Identifiers always start with a capital letter. • If an identifier is assembled from several ”words”, then each ”word” must start with a capital letter. • All other letters are written in lower case. Examples of identifiers: JogValue NumberOfValues CurrentSelectedJogValue 6.2.
Show/Hide Bookmarks Introduction to IEC 61131-3 programming Appendix 6.3 L Glossary Sequential Function Chart Sequential Function Chart SFC (Sequential Function Chart - SFC) is a programming language to describe sequential and parallel control processes with time and event control. Action Boolean variable or instructions which can be controlled through an action block (in SFC). Action block Activation description of actions in SFC. Current event Intermediate result in IL of any data type.
Show/Hide Bookmarks Introduction to IEC 61131-3 programming Appendix 24 ST Abbreviation for Structured Text. Standard functions All functions predefined by IEC 61131-3 to implement PLC typical functionality. Standard organization units See Standard function blocks Standard function blocks All function blocks (Function Blocks) predefined by IEC 61131-3 to implement PLC typical functionality.