ebook img

Automating with STEP 7 in STL and SCL: SIMATIC S7-300/400 Programmable Controllers PDF

554 Pages·2012·13.934 MB·English
Save to my drive
Quick download
Download
Most books are stored in the elastic cloud where traffic is expensive. For this reason, we have a limit on daily download.

Preview Automating with STEP 7 in STL and SCL: SIMATIC S7-300/400 Programmable Controllers

Berger Automating with STEP7 in STL and SCL Automating with STEP7 in STL and SCL Programmable Controllers SIMATIC S7-300/400 by Hans Berger 6th revised and enlarged edition, 2012 Publicis Publishing Bibliographic information published by the Deutsche Nationalbibliothek The Deutsche Nationalbibliothek lists this publication in the Deutsche Nationalbibliografie; detailed bibliographic data are available in the Internet at http://dnb.d-nb.de. This book contains one Trial DVD. “SIMATIC STEP 7 Professional, Edition 2010 SR1, Trial License” encompasses: SIMATIC STEP 7 V5.5 SP1, S7-GRAPH V5.3 SP7, S7-SCL V5.3 SP6, S7-PLCSIM V5.4 SP5 and can be used for trial purposes for 14 days. This Software can only be used with the Microsoft Windows XP 32 Bit Professional Edition SP3 or Microsoft Windows 7 32/64 Bit Professional Edition SP1 or Microsoft Windows 7 32/64 Bit Ultimate Edition SP1 operating systems. Additional information can be found in the Internet at: http://www.siemens.com/sce/contact http://www.siemens.com/sce/modules http://www.siemens.com/sce/tp The programming examples concentrate on describing the STL and SCL functions and providing SIMATIC S7 users with programming tips for solving specific tasks with this controller. The programming examples given in the book do not pretend to be complete solutions or to be executable on future STEP 7 releases or S7-300/400 versions. Additional care must be taken in order to comply with the relevant safety regulations. The author and publisher have taken great care with all texts and illustrations in this book. Nevertheless, errors can never be completely avoided. The publisher and the author accept no liability, regardless of legal basis, for any damage resulting from the use of the programming examples. The author and publisher are always grateful to hear your responses to the contents of the book. Publicis Publishing P.O. Box 3240 91050 Erlangen E-mail: [email protected] Internet: www.publicis-books.de ISBN 978-3-89578-412-5 6th edition, 2012 Editor: Siemens Aktiengesellschaft, Berlin and Munich Publisher: Publicis Publishing, Erlangen © 2012 by Publicis Erlangen, Zweigniederlassung der PWW GmbH This publication and all parts thereof are protected by copyright. Any use of it outside the strictprovisions of the copyright law without the consent of the publisher is forbidden and will incur penalties. This applies particularly to reproduction, translation, microfilming or other processing‚ and to storage or processing in electronic systems. Italso applies to the use of individual illustrations or extracts from the text. Printed in Germany Preface Preface The SIMATIC automation system unites all the dling of STEP 7 when configuring, networking subsystems of an automation solution under a and programming SIMATIC PLCs. The uniform system architecture to form a homoge- description of the “Basic Functions” of a binary neous whole from the field level right up to pro- control, such as logic operations or latching/ cess control. This Totally Integrated Automa- unlatching functions, makes it particularly easy tion (TIA) enables integrated configuring and for first-time users or users changing from relay programming, data management and communi- contactor controls to become acquainted with cations throughout the complete automation STEP 7. The digital functions explain how dig- system. ital values are combined; for example, basic calculations, comparisons or data type conver- As the basic tool for SIMATIC, STEP 7 plays sion. an integrating role in Totally Integrated Auto- The book shows how you can control program mation. STEP 7 is used to configure and pro- processing (program flow) and design struc- gram the SIMATIC S7, SIMATIC C7 and tured programs. In addition to the cyclically SIMATIC WinAC automation systems. Micro- processed main program, you can also incorpo- soft Windows has been chosen as the operating rate event-driven program sections as well as system to take advantage of the familiar user influence the behavior of the controller at interface of standard PCs as also used in office startup and in the event of errors/faults. environments. One section of the book is dedicated to the For block programming STEP 7 provides pro- description of the SCL programming language. gramming languages that comply with DIN EN SCL is especially suitable for programming 6.1131-3: STL (statement list; an Assembler- complex algorithms or for tasks in the data like language), LAD (ladder logic; a represen- management area, and it supplements STL tation similar to relay logic diagrams), FBD towards higher-level programming languages. (function block diagram) and the S7-SCL The book concludes with the description of a optional package (Structured Control Lan- program for converting STEP 5 programs to guage, a Pascal-like high-level language). Sev- STEP 7 programs, and a general overview of eral optional packages supplement these lan- the system functions and the function set for guages: S7-GRAPH (sequential control), S7- STL and SCL. HiGraph (programming with state-transition The contents of this book describe Version 5.5 diagrams) and CFC (connecting blocks; similar of the STEP 7 programming software and Ver- to function block diagram). The various meth- sion 5.3 SP5 of the S7-SCL optional package. ods of representation allow every user to select the suitable control function description. This broad adaptability in representing the control Nuremberg, May 2012 task to be solved significantly simplifies work- ing with STEP 7. Hans Berger This book describes the STL and SCL program- ming languages for S7-300/400. As a valuable supplement to the description of the languages, and following an introduction to the S7-300/ 400 automation system, it provides valuable, practice-oriented information on the basic han- 5 The Contents of the Book at a Glance Overview of the S7- PLC functions compa- Numbers, manipulat- Program run control, 300/400 programma- rable to a contactor ing the contents of the block functions ble logic controller control system accumulators Introduction Basic Functions Digital Functions Program Flow Control 1 SIMATIC S7-300/ 4 Binary Logic 9 Comparison 15 Status Bits 400 Programmable Operations Functions Binary Flags, Controller AND, OR and Comparison Accord- Digital Flags; Structure of the Pro- Exclusive OR ing to Data Types INT, EN/ENO grammable Controller Functions; DINT and REAL Mechanism (Hardware Components Nesting Functions of S7-300/400); Memory Areas; 10 Arithmetic 16 Jump Distributed I/O 5 Memory Functions Functions (PROFIBUS DP); Functions Unconditional Jump; Four-function Math Communications Assign, Set and Reset; Jumps Conditional on (Subnets); Edge Evaluation; with INT, DINT and the RLO, BR and the Modules Addresses; REAL numbers; Example of a Digital Flags; Addresses Areas Adding Constants, Conveyor Belt Jump Distributor, Control System Decrementing and Loop Jump Incrementing 2 STEP 7 Program- ming Software 6 Move Functions 17 Master Control Editing Projects; Load Functions, 11 Math Functions Relay Configuring Stations; Transfer Functions; Trigonometric MCR Dependency, Configuring the Net- Accumulator Functions; MCR Area, work; Symbol Editor; STL Program Editor; Functions; Arc Functions; MCR Zone SCL Program Editor; System Functions for Powers, Logarithm Data Transfer Online Mode; 18 Block Functions Testing the Program 12 Converting Block Call, 7 Timer Functions Functions Block End; 3 SIMATIC S7 Start SIMATIC Timers Data Type Conversion; Temporary and Static Program with Five Different Complement Forma- Local Data; Program Processing; Types; tion Data Addresses IEC Timers Block Types; Programming STL and 13 Shift Functions 19 Block SCL Code Blocks; 8 Counter Functions Parameters Programming Data Shifting and Rotating Blocks; SIMATIC Counters; Formal Parameters, Addressing Variables, Count up, Count Actual Parameters; Constant Representa- down, Set, Reset and 14 Word Logic Declarations, tions, Data Types Scan Counters; AND, OR, Assignments and (Overview) IEC Counters Exclusive OR “Parameter Passing” 6 Processing the user Working with complex Description of the S5/S7 Converter, program variables, indirect Programming block libraries, addressing Language SCL overviews Program Variable Handling Structured Control Appendix Processing Language SCL 20 Main Program 24 Data Types 27 Introduction, 32 S5/S7 Program Structure; Structure of the Language Converter Elements Scan Cycle Control Data Types, Preparations for (Response Time, Start Declaration and Addressing, Conversion; Information, Back- Use of Elementary and Operators, Converting STEP 5 ground Scanning); Expressions, Complex Data Types; Programs; Program Functions; Value Assignments Programming of User Postprocessing Communications via Distributed I/O and Defined Data Types Global Data; UDT 28 Control 33 Block S7 andS7-Basic Statements Libraries Communications 25 Indirect IF, CASE, FOR, Organization Blocks; Addressing WHILE, REPEAT, System Function CONTINUE, EXIT, 21 Interrupt Area Pointer, GOTO, RETURN Blocks; Handling DB Pointer, IEC Function Blocks; Time-of-Day Inter- ANY Pointer; S5-S7 Converting rupts; Time-Delay In- Indirect Addressing 29 SCL Block Blocks; terrupts; Watchdog via Memory and Calls TI-S7 Converting Interrupts; Hardware Interrupts; DPV1 In- Register (Area-internal Function Value; OK Blocks; and Area-crossing); Variable, EN/ENO terrupts; Multiproces- PID Control Blocks; Working with Address Mechanism, Descrip- sor Interrupt; Handling DP Functions Interrupts Registers tion of Examples 34 STL Operation 22 Restart 26 Direct Variable 30 SCL Functions Overview Characteristics Access Timer Functions; Basic Functions; Cold Restart, Load Variable Counter Functions; Digital Functions; Hot Restart, Address Conversion and Math Program Flow Control; Warm Restart; Data Storage of Functions; STOP, HOLD, Variables in the Shifting and Rotating Indirect Addressing Memory Reset; Memory; Parameterizing Data Storage when 31 IEC Functions 35 SCL Statement Modules Transferring Parame- and Function Conversion and Com- Overview ters; “Variable” ANY parison Functions; 23 Error Handling Pointer; STRING Functions; Operators; Synchronous Errors; Brief Description of Date/Time-of-Day Control Statements; Asynchronous Errors; the “Message Frame Functions; Block Calls; System Diagnostics Example” Numerical Functions Standard Functions 7 The Programming Examples The present book provides many figures repre- The library STL_Book contains eight programs senting the use of the STL and SCL program- that are essentially illustrations of the STL method of representation. Two extensive exam- ming languages. All programming examples ples show the programming of functions, func- can be downloaded from the publisher’s web- tion blocks and local instances (Conveyor Ex- site www.publicis-books.de. There are two li- ample) and the handling of data (Message braries, one for STL examples (STL_Book) and Frame Example). All the examples exist as one for SCL examples (SCL_Book). When source files and contain symbols and com- dearchived with the Retrieve function, these li- ments. braries occupy approximately 2.9 or 1.7 MB The library SCL_Book contains five programs (dependent on the PG/PC file system used). with representations of the SCL statements and Library STL_Book Basic Functions Program Processing Examples of STL representation Examples of SFC Calls FB 104 Chapter 4: Binary Logic Operations FB 120 Chapter 20: Main Program FB 105 Chapter 5: Memory Functions FB 121 Chapter 21: Interrupt Handling FB 106 Chapter 6: Transfer Functions FB 122 Chapter 22: Restart Characteristics FB 107 Chapter 7: Timer Functions FB 123 Chapter 23: Error Handling FB 108 Chapter 8: Counter Functions Digital Functions Variable Handling Examples of STL representation Examples of Data Types and Variable Processing FB 109 Chapter 9: Comparison Functions FB 124 Chapter 24: Data Types FB 110 Chapter 10: Arithmetic Functions FB 125 Chapter 25: Indirect Addressing FB 111 Chapter 11: Math Functions FB 126 Chapter 26: Direct Variable Access FB 112 Chapter 12: Conversion Functions FB 101 Elementary Data Types FB 113 Chapter 13: Shift Functions FB 102 Complex Data Types FB 114 Chapter 14: Word Logic FB 103 Parameter Types Program Flow Control Conveyor Example Examples of STL representation Examples of Basic Functions and Local Instances FB 115 Chapter 15: Status Bits FC 11 Conveyor Belt Controller FB 116 Chapter 16: Jump Functions FC 12 Counter Control FB 117 Chapter 17: Master Control Relay FB 20 Feed FB 118 Chapter 18: Block Functions FB 21 Conveyor Belt FB 119 Chapter 19: Block Parameters FB 22 Parts Counter Source File Block Programming (Chapter 3) Message Frame Example General Examples Handling Data examples UDT 51 Data Structure Header FC 41 Range Monitor UDT 52 Data Structure Message Frame FC 42 Limit Value Detection FB 51 Generate Message Frame FC 43 Compound Interest Calculation FB 52 Save Message Frame FC 44 Double-Word-Wise Edge Evaluation FC 61 Clock Check FC 45 Converting S5 Floating-Point to S7 REAL FC 62 Generate Checksum FC 46 Converting S7 REAL to S5 Floating-Point FC 63 Convert Date FC 47 Copy Data Area (ANY Pointer) 8 the SCL functions. The programs “Conveyor mers – a statement for programming simple Example” The library SCL_Book contains five STL functions for SCL programs. programs with representations of the SCL state- To try the programs out, set up a project corre- ments and the SCL functions. The programs sponding to your hardware configuration and “Conveyor Example” and “Message Frame Ex- then copy the program, including the symbol ample” and “Message Frame Example” show table from the library to the project. Now you the same functions as the STL examples of the can call the example programs, adapt them for same name. The program “General Examples” your own purposes and test them online. contains SCL functions for processing complex data types, data storage and – for SCL program- Library SCL_Book 27 Language Elements 30 SCL Functions Examples of SCL Representation (Chapter 27) Examples of SCL Representation (Chapter 30) FC 271 Delimiter Example FB 301 Timer Functions OB 1 Main Program for the Delimiter Example FB 302 Counter Functions FB 271 Operators, Expressions, Assignments FB 303 Conversion Functions FB 272 Indirect Addressing FB 304 Math Functions FB 305 Shifting and Rotating 28 Control Statements 31 IEC Functions Examples of SCL Representation (Chapter 28) Examples of SCL Representation (Chapter 31) FB 281 IF Statement FB 311 Conversion Functions FB 282 CASE Statement FB 312 Comparison Functions FB 283 FOR Statement FB 313 String Functions FB 284 WHILE Statement FB 314 Date/Time-of-day Functions FB 285 REPEAT Statement FB 315 Numerical Functions 29 SCL Block Calls General Examples Examples of SCL Representation (Chapter 29) FC 291 FC Block with Function Value FC 61 DT_TO_STRING FC 292 FC Block without Function Value FC 62 DT_TO_DATE FB 291 FB Block FC 63 DT_TO_TOD FB 292 Example Calls for FC and FB Blocks FB 61 Variable Length FC 293 FC Block for EN/ENO Example FB 62 Checksum FB 293 FB Block for EN/ENO Example FB 63 Ring Buffer FB 294 Calls for EN/ENO Examples FB 64 FIFO Register STL Functions for SCL Programming Conveyor Example Message Frame Example Examples of Basic Functions and Local Instances Handling Data examples FC 11 Conveyor Belt Controller UDT 51 Data Structure Header FC 12 Counter Control UDT 52 Data Structure Message Frame FB 20 Feed FB 51 Generate Message Frame FB 21 Conveyor Belt FB 52 Save Message Frame FB 22 Parts Counter FC 61 Clock Check 9

See more

The list of books you might like

Most books are stored in the elastic cloud where traffic is expensive. For this reason, we have a limit on daily download.