You are on page 1of 188
a | Automating with SIMATIC Integrated Automation with SIMATIC $7-300/400 Controllers, Software, Programming, Data Communication, Operator Control and Process Monitoring by Hans Berger 2nd revised edition, 2003 Publicis Corporate Publishing Bibliographic information pubished by Die Deutsche Bibliothek Die Deutsche Bibliothek lists this publication inthe Deutsche Nationalbibliogratie; ‘detailed bibliographic data is available in the Internet at http:/dnb.ddb. de This book was carefully produced. Nevertheless, author and publisher do not warrant the information contained therein to be free of errors. Neither the author nor the publisher ean assume any liability or legal responsibility for omissions or errors. Terms reproduced in thi ‘book may be registered trademarks, the use of which by tid parties for their own purposes ‘my violate the rights of the owners of those trademarks, ISBN 3-89578-223-8 Editor: Siemens Aktiongesellschaft, Berlin and Munich Publisher: Publicis Corporate Publishing, Eriangen ‘© 2003 by Publicis KommunikationsA gentur GmbH, GWA, Erlangen ‘This publication and al pats thereof are protected by copyright. A rights reserved. ‘Any use of it ouside the strict provisions of the copyright law without the consent of the publisher is forbidden and will incur penalties. This applies particulary to reproduction, ‘translation, microfilming or other processing, and to storage or processing in electronic systems, I also applies tothe use of extracts from the text Printed in Germany Content Content Lt 12 13 14 Ls Introduction Components of the SIMATIC Automation System .........22..2. : From the Automation Task to the Finished Program How Does a Programmable Logic Controller Work? ...... How a Binary Signal Finds its Way from a Sensor into the Program Structure of a SIMATIC Project .. seeeeeeenees SIMATIC Controllers — the Hardware Platform Components of a SIMATIC Station ‘The Micro PLC SIMATIC S7-200 ‘The Modular Mini Controller SIMATIC $7-300 0.2... cece SIMATIC S7-400 for Complex Control Tasks High Availability with SIMATIC . Failsafety on SIMATIC S7 . SIMATIC C7 Complete Systems Process Connection with Digital Modules Process Connection with Analog Modules Function Modules Take the Load of the CPU CP Modules Connect to Communication Networks SIMATIC-S7 Intelligence: CPU Modules . CPUs with technology functions STMATIC PC-based Automation . Distributed Process Connections SIMATIC DP Distributed VO. DP Slaves: Process Connection in the Vicinity ofthe Machine . ‘The SIMATIC Programming Devices STEP 7: Standard Tool for SIMATIC ..... 2.6.0.0. Data Management in the SIMATIC Programmable Logic Controller... STEP7 .....2.... SIMATIC Manager Projects and Libraries 49 30 52 3 36 35 36 37 38 39 3.10 3. 3.12 3.3 3.4 3.15 3.16 3.7 3.18 3.19 3.20 3.21 3.22 3.23 3.24 41 42 43 44 43 46 47 48 49 4.10 411 SA 52 53 34 35 56 57 Content Editing a Project ...... Configuring a SIMATIC-Station ‘Arranging Modules and Assigning Parameters. Addressing Modules... : Creating the User Program sees Symbol Editor... eee a Program Editor . Programming the Logie Block Incrementally Incrementally Programming a Data Block ‘Source-oriented Programming of Blocks Help on Program Creation . System Diagnostics. seve Downloading the User Program to the CPU . Diagnostics during Program Testing . Monitoring, Modifying and Forcing Variables ......... Program Status .. feet tetteeeeeee Testing User Programs Offine with S7-PLCSIM PID Control with SIMATIC Software Documentation in Wiring Manual Form with DOCPRO. ‘Telephone Network Connections with TeleService ... The Programming Languages ... The Basic Programming Languages LAD, FBD and STL .... 98 Binary Functions Digital Functions Program Flow Control Ladder Logic LAD .... Function Block Diagram FBD . Statement List STL .......... Structured Control Language SCL Continuous Function Chart CBC Sequential Control S7-GRAPH State Graph Control $7-HiGraph . ‘The User Program .... 122 Organization Blocks and Priority Classes... 123 ‘Types of User Program Processing .......... 124 Startup Program ...... ceeeeneees cevvees 126 Memory Reset, Retention .....2..6.2.c000ceccceeeesseeeeeseees 28 Main Program ..... wee 129 Start Information ....... --- 130 CPU Functions... 6.0.6... e cece cece eeeeeteteeeeeeee BI Content Process Images ........2..2. coves coves 132 Cycle Time, Reaction Time 2.2.0... we 14 Interrupt Processing (Overview) ............ .. D6 ‘Time-Delay Interrupts .. . . BB Time-of-Day Interrupts 139 Cyclic Interrupts ........ 140 Hardware Interrupts... 141 DPV1 interrupts ........ 142 Multiprocessor Interrupt .. 143 Isochrone interrupts 144 Error Handling .. . 146 Handling Interrupts... 148 User Blocks (Overview) 149 Structure of a Block ... sees 150 Block Call and Block Parameters . 152 ‘Temporary Local Data .... 134 Static Local Data ......... ISS Multi-Instances, Local Instances . 156 SIMATIC Timers... 158 ‘SIMATIC Counting Functions 160 Global Address Areas 162 Global Data Addresses... coven ees 1B Absolute and Symbolic Addressing ...... 164 Indirect Addressing .... 167 Data Types — Overview ....... 168 Elementary Data Types .. . 169 Combined Data Types. In Parameter Types wees 174 User-Defined Data Type (UDT) 175 6 — Communication : cesses 176 6.1 SIMATIC Subnets 178 62 Communication Utilities 180 6.3 Configuring the Network . 182 64 — Configuring Connections 184 65 Configuring Decentralized Peripherals ........... : 186 6.6 Addresses in the DP Master System. 188 67 Special DP Functions ............ ceeeees 190 68 Global Data Communication ........ ceveees 192 6.9 $7 Basic Communication ... ceeeee 194 6.10 $7 Communication ........ ceeteeeeeeee +. 196 6.11 PtP communication on the $7-300C - 198 10 7 72 73 14 15 16 71 18 79 7.10 TAL 712 TAB Content ‘Operator Control and Process Monitoring +200 Push Button Panels PP7 and PP17 eee 201 Text Display TD17 .........- +. 202 Text Based Displays OP3, OP7 and OPI7 «ss. ceceeee 203 Graphics Displays OP170B und OP270 . . wee 204 Touch Panels TP170 und TP270 . 205 MP270B and MP370 Multi Panels... SIMATIC Panel PCs . Connection with SIMATIC S7 Stations . 206 207 208 Configuring SIMATIC HMI Devices . 209 Configuring HMI Devices Using SIMATIC ProToo! . 210 Process Diagnostics Using SIMATIC ProAgent ....... 213 Visualization and Operator Control Using SIMATIC WinCC . 214 Process Diagnostics in the User Program Using S7-PDIAG 216 Index ts Abbreviations cee 2221 1_Ioteduetion 1 Introduction 1.1 Components of the SIMATIC Automation System The SIMATIC automation system is a range of coordinated components with uniform me- thods of configuring, data management and data transmission. ‘As programmable controllers (PLCs), the SIMATIC S7 controllers form the basis of the au- tomation system, SIMATIC $7-200 is the micro system for the low-end performance range stand-alone solution or in a linear-bus network, The system solution that concentrates con the manufacturing industry is the SIMATIC $7-300 with the compact CPUs and the in- novated standard CPUs. And as the top-level device with the highest performance power of the SIMATIC controllers, the SIMATIC $7-400 enables system solutions for the manufac turing and process industries. ‘The SIMATIC C7 controllers are designed as control systems for machine control and offer PLC performance power including visualization in the smallest possible space. Human ma- cchine interface functionality is carried out using a line-oriented or graphics-based operator ‘pane! in which the integral controller provides the PLC performance power on the basis of a SIMATIC 87-300. SIMATIC PC-based Automation supplements the SIMATIC controllers with PC-based con- trollers. SIMATIC WinAC is the integration platform for control, data processing, commu- nication, visualization, and technological functions. PC-based Control is available as a pure ly software solution (software PLC) and as a PC plug-in card (slot PLC). Embedded Control with a software PLC under Windows CE supplements the SIMATIC product range with a new class of devices for machine-level control and visualization. ‘The SIMATIC DP distributed 1/0 system allows you to install the /O modules connecting ‘the PLC to the machine or plant in the vicinity of the machine, at a distance from the PLC. ‘The distributed /s are linked to the central controller — with minimum wiring ~ by means of the PROFIBUS network. The user program treats distributed I/O modules in the same way as central VOs, SIMATIC HMI stands for Human-Machine Interface, From the humble text display to the ‘graphics-capable operator station, these products provide all the facilities you need for op- cating and monitoring a machine or plant. Powerful software indicates the state ofthe plant ‘with event and fault messages, manages recipes and measured value archives, and provides support with troubleshooting, servicing and maintenance. ‘SIMATIC NET links all the SIMATIC stations together and ensures trouble-free commu nication, One cable is all you need to network all the SIMATIC stations through their integral MPI interface. They can then exchange data or you can communicate with all the stations in the network from a central programming device. A range of bus systems with different per- formance specifications make it possible to include non-SIMATIC devices in networks, from field devices in the plant to computers at plant management level. programming. ‘Optional adaitional Distributed L/s extend the interface configuring and ‘between PLC and machine’plant fos runtime software Figure 1.1 Components ofthe SIMATIC automation system ‘The STEP 7 Standard Too! is the keystone of the Totally Integrated Automation concept, with its uniform configuration and programming, data management and data transmission. ‘You use STEP 7 to configure the SIMATIC components, assign parameters to them and pro- ‘gram them. SIMATIC Manager in STEP 7 Basic is the central tool for managing the auto- ‘mation data and the necessary software tools. It keeps all the data for an automation project ina project folder with a hierarchie structure and stores standard software and re-usable user software in libraries. ‘The main activities performed with STEP 7 are: > Configuring the hardware, that is arranging modules in racks, assigning addresses to them and setting the module properties > Configuring communication connections, that is defining the communication partners and connection properties > Writing the user program for the PLC in the programming languages Ladder Logic (LAD), Function Block Diagram (FBD) or Statement List (STL) and testing the program. online on the controller ‘Various optional packages are available to extend the functions of the STEP 7 Standard Tool. For example, the Engineering Tools provide additional programming languages and pro- ‘gramming methods, and there is also special configuring software for the human-machine interface, configuring software for communications processors and runtime software, such as closed-loop control functions for the user program. B 1 Introduction 1.2 From the Automation Task to the Finished Program ‘When you start to solve an automation problem, you have to ask yourself what type of PLC ‘you are going to use, If the machine to be controlled is a small one, will an $7-200 be big ‘enough or do you need an S7-300? Is it better to control the plant with an S7-400 or with a pair of S7-300s? Compact central /Os in the control cabinet or distributed 1/Os in the plant? ‘The following is a general outline of the steps that lead from the automation task to the fi- nished program. In individual cases with concrete requirements, some steps can be omitted ‘or others may need to be added. ‘Choosing the hardware ‘There are many criteria for selecting the type of controller. For “small” control applications the main criteria are the number of inputs and outputs and the size of the user program. For larger plants you nced to ask yourself whether the response time is short enough, and whe- ther the user memory is big enough for the volume of data to be managed (recipes, archives). ‘To be able to estimate the resources you need from the requirements alone, you need a lot of experience of previous automation solutions; there is no rule of thumb. A production machine will probably be controlled by a single PLC. In this case, the number of inputs/outputs, the size of the user memory and, possibly, the speed (response time) will enable you to decide between the $7-200, S7-300 or the $7-400. How is the machine to be ‘operated? (This will determine whether you should use separate operator control and moni- toring devices from the SIMATIC HMI range, or SIMATIC C7 complete systems). For plants spread over several locations, it is often more cost-effective to use distributed /Os rather than central I/Os. In many cases, this not only reduces the wiring overhead, but dele- ‘gating control tasks to their actual location can also cut the response time and the engineer- ing costs (decision in favor of SIMATIC DP distributed 1/0, possibly even “intelligent” DP. slaves with their own user program for preprocessing the signals). Distributed automation solutions have their advantages: the user programs for the different parts of the plant are shorter, have faster response times, and can often be started up inde- pendently of the rest of the plant. The necessary interchange of data with a central controller within the SIMATIC system is extremely easy using SIMATIC NET and the coordinated ‘communication functions. Whict programming language? The choice of programming language depends on the task. If it mainly consists of binary signal processing, the graphical programming languages LAD (Ladder Logic) and FBD (Function Block Diagram) are ideal, For more difficult tasks requiring complex variable handling and indirect addressing, you can use the STL (Statement List) programming lan- guage, which has an assembly language format. SCL (Structured Control Language) is the best choice for people who are familiar with a high-level programming language and who ‘mainly want to write programs for processing large quantities of data. 1 Introduction ‘There are different programming methods that make programs easier to write: S7-GRAPH for sequential control, state graph programming with S7-HiGraph, and $7-CFC (Continuous Function Chart) for linking together existing functions. Ready-made blocks are also avai- lable to help you write user programs, for example for programming control loops or con- figuring messages. Creating a project {All the data for your automation solution is collected together in a “project” You create a project using the STEP 7 basic software. A project isa (software) folder in which all the data is stored in a hierarchic structure. The next level down from the “project” are the “stations,” which contain one or more CPUs with a user program. All these objects are folders, which can contain other folders or objects that represent the automation data on the screen. You use ‘menu commands to insert new objects, open these objects and automatically start the neces- sary tool to work with them, Example: A station contains an object called Hardware. You double-click this object to start the Hardware Configuration tool, which is the tool you use for configuring the hardware of the station, that is you arrange the modules in a rack, and assign addresses and parameters to them, In SIMATIC you do all this with software: you define the properties of the modules in dialog boxes with support from the online Help. Writing, debugging and saving the user program ‘The user program contains all the instructions and arrangements programmed by the user for processing signals to control the machine or plant to perform the required task. Large, com- plex tasks are easier to solve if they are divided into small, manageable units, which can be programmed in “blocks” (subroutines). The division into blocks can be process-oriented or function-oriented. Inthe first case, each program unit corresponds to a part of the machine or plant (mixer, conveyor belt, drilling assembly). In the second case, the program is divided up according to control functions, for example signaling, communication, operating modes. In practice, a mixture of the two types of structure is generally used, The objects used for creating programs are the symbol table and the compiled blocks, and - depending on the programming language — the program source files. You double-click a pro- _gram source file or block object to start the program editor and then you can enter or modify the program for the block. You write the user program “offline” and save it on the hard disk of the programming device. To start up the system, you connect the programming device to the CPU, download the program to the user memory of the CPU and test it. You can monitor and modify the values of the variables and observe the program flow. Extensive diagnostics functions enable you to identify the location and cause of errors very quickly. You can test individual sections of ‘your program offline in advance with the PLCSIM optional software. When you have successfully started up the system, you copy the user program to a non-volatile flash EPROM memory card and generate the project documentation, for example in the form of 4 circuit manual with DOCPRO. With STEP 7 you can save an entire project as a com- pressed file. 1 Introduction 1.3 How Does a Programmable Logic Controller Work? In conventional control engineering, a control problem is solved by wiring up contactors and relays individually to perform the required task. Contactor and relay controllers and elec- tronic controllers assembled from separate components are referred to as hard-wired pro- ‘grammed controllers. The “program” is in the wiring. Programmable logic controllers, on the other hand, are made up of standard components. The desired control function is imple- ‘mented by a user program in the CPU. SIMATIC S7 automation systems are based on a central programmable logic controller. The solution to the automation task is stored in the user memory of the CPU in the form of pro- ‘gram instructions. The CPU reads the instructions one after the other, interprets their con- tents and ensures that they are executed. ‘The CPU processes instructions in MC7 machine code, either direct or by interpretation. Whichever programming language you use to write the user program, it is always converted into MC7 instructions. STL (Statement List) is the programming language that is the most similar to MC7 machine code. Logic operations using binary signals | | Here isan example: When the two inputs1s2\) and [ 4.7 both have the signal state “1”, output Input module Q855iisalso to be set to signal state “1”, other- wise it is to be set to “0”. The program in MC7 and STL is as follows: Example: “1 5.2" stands for input byte 8, bit 2 Status Check of address status| = Q8.4 Previous logic operation AT $.2 Check input 15.2 ("first check"). This signal state becomes the result Bitjogic operation of logic operation (RLO) A 14.7 Check input I 4.7, perform an AND operation with the stored RLO and store the result as the new RLO = Q8.5 Assign the stored RIO to output Q 8.5, A 15.3 Next logic operation Result of check ‘SetReset function ‘The CPU now processes this program one in- struction at a time. When the instruction A I 5.2 is processed, the relevant input module se- Ouput module lets the sensor atthe specified address, input o Example 15.2. The CPU checks the signal state (“sta- (08.” sands for tus”) of the selected sensor. If this is the first compat byte 8, bit check instruction after a control instruction, reyes 4.2 the CPU immediately stores the status of the fisw's programmable ogc controller address checked in the RLO (result of logic op- processes abit logic instruction 16 1_ Introduction ration) memory without performing a logic operation on it. When it processes the next check instruction, the CPU then performs the required logic operation on the result of the check and the result of the previous logic operation stored in the RLO memory. The result Of this logic operation is stored as the new result of logic operation. The CPU then processes the next instruction in the program. In the example, it processes the Output instruction by saving the result of logic operation at the specified address. ‘When the “old” result of logic operation has been saved, the next check instruction starts a new logic operation in which the result of the first check becomes the new result of logic operation. Cyclic program processing ‘The CPU of a programmable logic controller processes the user program continuously. The program continves to run even if no action is required from outside, for example if the ma- chine is at a standstill. This makes programming easier. For example, you can write your Ladder Logic program just as you would draw a relay ladder logic diagram or you can write ‘your Function Block Diagram program as though you were connecting electronic compo- nents, Broadly speaking, a PLC is like a contactor or relay controller: the many logic ope- rations in the program are all effective “in parallel” at the same time. How can this be so if the controller operates sequentially? When the power is switched on, the CPU pro- Power ON ‘cesses the operating system, and a startup pro- | ‘gram if there is one. Then it goes on to the main rogram. It processes the logic operations for ot STARTUP the first time. The CPU checks the input sig- ee mode nals, performs logic operations on them and sets oF resets the outputs. When the CPU has executed the main program , right to the end, it starts to process it again eee un from the beginning checks the inputs again, §—§ —"—T—— | ove performs the logic operations on them and sets ‘or resets the outputs again. In this way the Executing states of the outputs are adjusted to suit the main program changing states of the inputs at very short in- Cot tervals (the response time depends on the length of the main program to be processed). tL This type of eyctic program processing is typ- ical of programmable logic controllers. For special applications, cyclic program process- ing can also be interrupted by hardware inter- rupts of time-of-day interrupts (at fixed inter- Cele program processing in a pro- vals, for example). srammable logic controller 1 Introduction 1.4 How a Binary Signal Finds its Way from a Sensor into the Program In order to do its job, the CPU in the programmable logic controller needs to be linked to the machine or plant itis controlling. This link is provided by input/output modules, which are connected to the sensors and actuators in the machine or plant. Connection to the programmable logic controller, module address When you wire up the machine of plant, you decide where each signal is to be connected to the PLC. An input signal, for example the signal from momentary-contact switch +HPO1- $10, which means “Switch on motor,” is connected to a particular terminal on an input mo- dule. This terminal has an “address” (for example, byte 5, bit 2). The address of a module is either fixed by the slot in which the module is installed in the rack or you can set it with the STEP 7 Hardware Configuration tool. The module addresses are arranged in bytes (groups of 8 bits! binary signals). The module starting address is the lowest address of the module. If this is 4, for example, and the module has more than one byte, the address ofthe next byte of the mod- ule is automatically 5, and so on. The bit addresses in each byte are numbered from 0 t0 7. Absolute and symbolic addresses ‘The CPU executes the user program (main program) cyclically: when it comes to the end of the program, it starts processing it again from the beginning. Every time it processes the pro- ‘gram, the CPU first automatically copies the signals from the input modules to the process image input table, an area in the system memory of the CPU. The signal can then be located under its address in the process image, for example input I 5.2. The expression “I 5.2” is the absolute address. If there is power at the relevant input terminal, input I 5.2 has signal state “1s You can give this input a name, either right away when you are configuring the hardware or later on. You do this in the symbol table by entering alphanumeric symbols that convey the meaning of the input signal at the absolute address, for example “Switch on motor.” The expression “Switch on motor” is the symbolic address, You can assign names to all the sig- nals in the symbol table and use these names to address the signals more clearly in the user program. Outputs control the machine or plant ‘The outputs are treated in a similar way. They have addresses in a memory area of the CPU. called the “process image output table”, In the program, an output is set or reset ~ in the process image ~ depending on certain conditions. At the end of the program, the CPU copies the process image output table to the output modules and the relevant terminal controls the actuator connected to it, for example a contactor, a lamp or an electronic device 18 1 Introduction Addressing modules You can also address the input and output modules directly in the program. In this case, the smallest unit you can address is a byte. This makes it much more difficult to check or set a single signal, that is a single bit. For the user program it makes no difference whether you connect the sensors and actuators 10 modules installed in the central rack, or to distributed /O modules installed in the plant and connected to the central controller by a bus system. You address the input and output ‘modules in the same way in both cases, that is you check the sensors in the process image input table and control the actuators by setting or resetting the outputs in the process image output table. Sensor Input vo module area wise 0 }eyen “sto 7 0 Janene , =| Sot Mode address staring adores Configuration table Symbol table Slot] Type_] Adsress _][Symibot [hae [Data ype 5 pig 4 Switch on'moior (15% /BOOL ‘Symbolic addressing Absoluts addressing User program “Switeh, jor” 82 Ladder Logic (LAD) aca nf User program 7 Function Block Dlagram (FED) “Switehan meter") Tg 63a] See est) ‘A “Switch on motor aise Figure LA Module address, absolute address and symbolic address (How a signal from a sensor is checked inthe program) 1 Introduction 1.5. Structure of a SIMATIC Project ‘When you configure an automation system with STEP 7, you represent the “real” objects ‘with “logical” objects in a SIMATIC project. The object hierarchy is modeled on the real hardware configuration, that is a project contains one or more PLCs (Stations), each station ‘contains a CPU, and this contains a user program made up ofa symbol table, source files and ‘compiled code (Blocks). The screenshot shows the SIMATIC Manager project window. In the left pane you can see the structure of the project with its folders. These contain the folders ‘and objects that appear in the right pane. A station, for example, isa folder, which can con- tain other folders or objects. If you double-click an object in the right pane, the tool for ed- iting the object opens, For example, a double-click on a subnet starts the network configura- tion software, and a double-click on a block (in the Blocks folder) starts the Program Editor. ti MAMMA Figure 1.5 An automation system represented by “logical” objects in a SIMATIC project 2 SIMATIC Controllers - the Hardware Platform 2 SIMATIC Controllers — the Hardware Platform SIMATIC programmable logic controllers ~ the core of the automation systems ~ control production machines, manufacturing plants or industrial processes. We distinguish different controller “families” with regard to their range of performance and field of application: » SIMATIC S7 controllers are at the heart of the SIMATIC hardware. They are available in three versions: ~ SIMATIC $7-200, the compact micro PLC = SIMATIC $7-300, the modular PLC of the mid performance range = SIMATIC S7-400, the modular PLC of the upper performance range ‘The $7-200 station consists of a basic unit and can be expanded with additional modules. In $7-300/400 stations, the power supply unit, the CPU module and the UO modules are instalfed in the same mounting rack. This centralized configuration can be extended with ‘expansion racks for the installation of additional /O modules. The expansion rack may be a remote installation, that is it can be placed at a distance from the central rack. You ‘use the STEP 7 Micro programming language to program the SIMATIC S7-200 control- ler. STEP 7 with its different programming languages is provided for the controllers of the SIMATIC S7-300/400 series. SIMATIC C7 is a series of complete units combining an $7-300 controller and an oper- ator panel SIMATIC C7 stations have integrated inputs/outputs. They can be expanded in a central- ized arrangement by adding inpuv/output modules of the S7-300 range. You use the stan- dard STEP 7 programming tool to program SIMATIC C7 controllers. > SIMATIC WimAC is the generic term for the program packages of SIMATIC PC-based Automation. WinAC runs on a standard PC under a Windows operating system. PROFI- BUS-DP forms the link to the process. With SIMATIC PC-based Control, the controller can take the form of a purely software solution (Software PLC) or a plug-in card (SlotPLC), In SIMATIC Embedded Control, WinAC MP runs under Windows CE on an MP 370 Multi Panel, > SIMATIC DP are modules that are installed in the vicinity of the machine and connected to the master station of a PROFIBUS DP network. Many of the available SIMATIC CPUs provide an integrated DP interface which greatly facilitates the connection of distributed VO. You can also use this standard bus interface to connect third-party devices to a SI- MATIC controller. SIMATIC stations communicate with each other over subnets. The operator control and pro- ‘cess monitoring devices of the SIMATIC HMI series are also connected to these subnets. SIMATIC NET recognizes MPI, PROFIBUS and Industrial Ethernet as subnets. You can also connect a single device, such as a printer, through a serial point-to-point connection. 2 2. SIMATIC Controllers ~ the Hardware Platform 2.1 Components of a SIMATIC Station A complete programmable controller including all /O modules is called a “station.” An S7- 300/400 station consists of at least one module rack accommodating the power supply and the CPU module. /O modules establish the link to the machine or plant. The components of a SIMATIC station are described below: >» Mounting rack Accommodates and connects the individual modules. The $7-300 uses a simple DIN rail its length is determined by the number of modules. The S7-400 has an aluminum rack of fixed length with a backplane bus and bus connectors. > Power supply (PS) Provides the internal supply voltage; the input voltage is either 120V/230V AC or 24V. De. > Central Processing Unit (CPU) Stores and processes the user program; assigns parameters to the modules; handles the ‘communication with the programming device, the modules and additional stations over the MPI bus: can be equipped with an integrated DP interface for DP master or slave op- eration. > Interface module (IM); Connects the mounting racks with each other. > Signal module (SM) ‘Adapts the signals from the process to the internal signal level or controls contactors, ac~ tuators, tc.. Signal modules are available as inpuvvoutput modules for digital and analog signals and can also be used for the connection of sensors and actuators located in haz~ ardous areas of zone | and 2. > Function module (FM) Handles complex or time-critical processes independently of the CPU module, e.g, ‘counting, position control and closed-loop control. > Communications processor (CP) ‘Connects the SIMATIC station with the subnets, such as Industrial Ethernet, PROFIBUS FMS, actuator/sensor interface or serial point-to-point connection. ‘The rack-mounted backplane bus comprises two buses: the VO bus for the fast exchange of input/output signals, and the communication bus for the exchange of larger amounts of data. The connection between the communication bus and the CPU's MPI interface enables FM and CP modules with communication bus interface to communicate with the MPI bus sys- tem. It is thus possible to program these modules through the programming device interface of the CPU, The distributed /O modules connected to a SIMATIC station are also part of this station. A SIMATIC station can have several DP masters which communicate with the DP slaves, that is the field units, over one or several PROFIBUS DP subnets. The DP slaves are integrated in the address area of the centralized 1/O system and are principally treated just like the VO ‘modules installed locally, in the central and expansion racks. 2 2__SIMATIC Controllers ~ the Hardware Platform 2.2. The Micro PLC SIMATIC $7-200 ‘The SIMATIC $7-200 is a compact micro PLC replacing relay and contactor control arrangements. Also, SIMATIC $7-200 controllers increasingly replace specific electronic circuits in mechanical and system engineering applications, SIMATIC S7-200 can be used sa stand-alone system or in a network with other control systems. Various expansion mo- dules for the connection to the machine or plant are available. The programming language used is STEP 7 Micro, Compact-type basic modules and expansion modules Various basic modules with different functionality are available. The basic module contains the CPU, integrated inputs and outputs using 24V DC or 100V/120V to 230V AC and relay outputs. Number and type of the integrated inputs and outputs depend on the type of CPU used. Fast alarm and counter inputs enhance the module's real-time performance. Its inte- grated potentiometer allows you to set a digital value simply with a screw-driver — no pro- gramming device is needed. You can increase the number of inputs/outputs by connecting an expansion module. Such modules are available for both digital and analog inputs/outputs. The expansion modules are snapped onto the rail (e.g., standard DIN rail) next to the basic module and electrically con- nected by means of a bus connector. ‘Human machine interfacing on the S7-200 ‘The TD 200 Text Display and the TP 070 Touch Panel are available especially for the S7- 200. The TD 200 is linked to the CPU via the PPI connection, and the TP 070 is connected using MPI or PROFIBUS DP. The possible uses of these devices include displaying message texts, setting outputs, and controlling small machines or plants. ‘Communication capability just like a “large” station All S7-200 central processing units are equipped with a PPI interface (Point-to-Point Inter- face). This isthe interface through which the CPUs are programmed. The PPI interface also allows you to interconnect several S7-200 central processing units (up to 31 CPUs) and con- nect a programming device, operator panel or TD200 text display unit. Data exchange is based on the master-slave principle. The rate of transmission is 9.6/19.2/187.5 Kbis ‘The PPI interface can also use a bit-oriented communication protocol at up to 38.4 Kbits/s which you can create yourself making use of the user program's programmable communi- cation function. In this way it is possible to connect any terminal that has an RS 232 inter- face, for example, a bar-code reader using the ASCII protocol. Due to the integrated interface, some of the $7-200 central processing units can also be con- nected to an MPI subnet to serve as a slave device and thus exchange data with SIMATIC stations of other SIMATIC series. The AS Interface Master CP 242-2 allows you to connect up to 31 AS interface slaves to one ‘87-200 station and thus increase the number of available inputs/outputs. In addition to its AS interface master function, the CP 248-2 provides a PROFIBUS DP interface which allows you to use S7-200 stations as DP slaves. 4 2__ SIMATIC Controllers ~ the Hardware Platform 2.3. The Modular Mini Controller SIMATIC $7-300 Central rack The central rack of the $7-300 programmable controller accommodates the CPU and up to eight /O modules, The CPU requires a power supply of 24V DC. You can install this power supply on the standard DIN rail to the left of the CPU, for example. A serial backplane bus combining /O bus and communication bus functionality connects the modules with each other, Bus connectors link one module to the next. This means that the length of the bus al- ways depends on the number of modules plugged in and never extends beyond the last mo- dule, ‘The module slots in the mounting rack ate numbered in consecutive order: slot 1 for the power supply unit, even if not installed; slot 2 for the CPU; slot 3 for the interface module IM, even if not installed. Slots 4 to 11 are reserved for the /O modules which must be plugged in one next to the other without any gaps. Their is no connection between the mo- dule slot number and the module width. Expansion racks Ifa single-row configuration is not sufficient for your requirements, you can use (from CPU. 314 onwards) a two-row configuration (with IM 365) or a maximum configuration of four rows (with IM 360 and IM 361) with up to 32 1/0 modules. ‘The IM interface module is installed between the CPU and the first /O module. Like the cen- tral rack, the expansion rack, too, is a DIN rail with snap-on modules. The receiver IM, which establishes the connection with the central rack, is installed in module slot 2. A transmitter IM for the connection to another moxhule rack is installed in slot 3. Slots 4 to 11 are reserved for the /]0 modules which must be plugged in one next to the other without any gaps. Versatile use A wide range of standard $7-300 CPUs covers the low-end to mid performance ranges in the manufacturing industry. With a comprehensive range of modules and flexible networking facilities, the requirements for optimal adaptation to the controlled machine or plant are met. In addition to the standard CPUs, the S7-3xxC compact CPUs also contain technological functions (counting, measuring, closed-loop control, positioning) with integral inputs/out- puts, thus making compact design of mini controllers possible The failsafe SIMATIC S7-300F programmable controller is used in manufacturing industry {to meet increased safety demands. It complies with safety requirements to SIL. 3 in accor- dance with IEC 61508, AK6 in accordance with DIN V 19250 and Cat. 4 in accordance with EN 954-1. ‘The SIMATIC S7-300 outdoor has been developed for the use in hostile ambient condi- tions. These modules support an extended temperature range from -25°C to +60°C, and have higher vibration and shock resistance in accordance with IEC 68 Part 2-6. They are resistant to humidity, moisture condensation and icing in accordance with IEC 721-3-3, Class 3 KS. All other technical characteristics are identical to those of the standard modules. 25 2. SIMATIC Controllers the Handware Platform 2.4 SIMATIC $7-400 for Complex Control Tasks Central rack ‘The S7-400 mounting rack, an aluminum DIN rail ofa fixed length with backplane bus and bus connectors, can be used as a central rack (CR), an expansion rack (ER), or as a combi- nation of both (UR, universal rack). ‘The S7-400 central rack is available with 18, 9 or 4 module slots (UR1, UR2 or CR3) of fixed mounting widths. The power supply unit and the CPU module also occupy module slots, possibly even 2 slots per module. Normally, you start the module arrangement by in- stalling the power supply module at the far left of the mounting rack, followed by the CPU and the /)O modules. You may choose the slots as required. It is not necessary that the mod- ules are plugged in next to each other; gaps are allowed. Insert the interface modules for the ‘connection to expansion racks in the right-hand part of the mounting rack. The backplane ‘bus, comprising the parallel /O bus and the serial communication bus, interconnects the module slots. ‘The CR2 segmental rack allows you to use two CPUs on a common power supply. The CPUs ‘exchange data over the communication bus, but each uses its own I/O bus to communicate with its /O modules. The left segment provides 10 module slots, the right segment 8 module slots. ‘The UR2-H segmental rack consists of 2 segments with 9 module slots each. You can use it as a central rack or as an expansion rack in standard S7-400 stations or high-availability S7- 400H stations. Each segment requires its own power supply; 1/O bus and communication bus are separate, Universal rack URI All module slots are connected withthe communication ‘bus and the VO bus. The rack can have a standard or a redundant power supply unit. (Central rack CR ‘The rack’s 18 module slots are divided into two seg- ‘ments of 10 and 8 slots. The UO bus is restricted othe ‘elated segment. The segments have a common power ‘supply unit. Universal rack UR2-H The rack is divided into two segments of 9 module slots. The backplane bus is split. A second power sup- ply is therefore required. Figure 2.2. Backplane bus inthe SIMATIC $7-400 central racks, 2__ SIMATIC Controllers - the Hardware Platform Expansion racks f there is insufficient space for the /O modules in the central mounting rack, or if you want to install modules at a distance, you supplement the station with one or more expansion units. Universal racks and expansion racks can be used as expansion units, with up to 21 on ‘one central rack. The send and receive interfaces that are used in pairs transmit the signals over various distances. Iimerface pair IM 460.0 | IN460-1 [IM 460-3 ] IM 4604 i460 | incdet-t | IM 461-3. | IM 461-4 Max distance sm ism [102m | Sm ‘Max. number of connectable expansion racks 8 2 8 8 ‘Transferred buses yore | v0 voc | 10 ‘Supply voltage is wansferred o yes m0 7 ‘The ER! and ER2 expansion racks with 18 or 9 slots are intended for “simple” signal mo- dules which do not trigger process alarms, do not require a 24 V DC supply over the P bus nor a backup supply, and are not equipped with a communication bus interface. The URI and UR2 racks are equipped with a communication bus if they are used cither as central racks or expansion racks with the id. numbers 1 to 6. ‘Connection of SIMATIC $5 modules ‘The IM 463-2 interface module is used for connecting SIMATIC $5 expansion units (EG 183U, EG 185U, EG 186U, ER 701-2 and ER 701-3) to an $7-400 station. These expat ‘units can again be expanded in a centralized arrangement, An IM 314 interface module in the SS expansion unit establishes the connection. In such an arrangement you can use any of the digital and analog modules listed for the specified expansion units. Ina decentralized set- ‘up, you can connect up to 16 S5 expansion units to one S7- 400 station. If you want to use a single SS module in an S7-400 station, you have to make use of an ada- pter module. Enhanced performance with multiprocessing, ‘You can convert the $7-400 station into a multiprocessing controller by inserting several (CPUs (4 max.). Make sure to select CPUs that are specified for this type of operation which is also called “multicomputing.” As soon as you install more than one CPU, the programma- ble controller will automatically assume multiprocessing operation. All CPUs have the same ‘operating mode. This means they start together and also all of them go to STOP if one of the CPUs fails. Each CPU executes its own user program independently of the other CPUs. Each 1/0 module is assigned to one specific processor. This includes its address and alarms. All VO modules are located in the same VO bus segment, This means that you must give them different addresses although they refer to different CPUs. The same rule applies to distributed /]O modules. Although each CPU can operate one or several DP master systems independently from the other processors, each centralized and distributed module must have its unique address (V/O bus addresses) in the overall system, 27 2__ SIMATIC Controllers ~ the Hardware Platform 2.5 High Availability with SIMATIC For slow processes: software redundancy with standard components ‘The standard SIMATIC S7-300/400 components allow you to build a redundant system based on software redundancy. In such a redundant sctup, a standby station assumes control of the process if the master station breaks down. High-availability through software redun- Connection of V/24V incremental Fast count, FM 450-1: 2 channels sensor ‘up and down ‘Count up o $00 kite with +31 bits, | » Gate cont, also directly with digital FM 350-2: 8 channels ‘input on FM Count up o 20 kHz with +31 bits, | > Atzro-sossng or when comparison ‘can also be used for NAMUR sensor ‘value 1s reached: direct control of digi- ‘tal output or generanon of process in- terrupt M351, FM4S1 | Adjustment of 2 or 3 independent axes | > Setting (inching mode) Positioning mod- | with 4 digital outputs per axis for control-| > Incremental mode, absolute and rela- ‘ule for rapid and | ling contactors o frequency converters. | tive xeep sped drives | Incremental or synchronous-seil posi-_| > Search for reference ton detection Zero sift © Set reference point » Delete residual distance [FM 352, FM 482 | 32 cam tracks with 32/64/128 cams and | > Length measurement Electronic CAM | definable cam characteristic (eg, can be | > Set reference point ‘module defined as position or time cams) control | :- Set actual value on-the-fly. 13 or 16 digital outputs > Zero sift Incremental or synchronous-seril posi- | > Change cam edge ‘ton detection > Simulation mode FMI353, FMASS | Positioning of one (FM35I354) or upto | > Sewing inching mode) Positioning mod- | thee (FM 453) drives, © Incremental mode tule for stepping. | can be used for linear and rotary axes. | >» Automatic subsequent block! ‘motors © singe block control FM 384, FM 453 | For simple point-o-poat positioning as | > Length measurement Positionmng mod- | Wells complex traversing pattems. |» StarVstop through direct digital inputs aaaneae: > Rate-of-change limiting tor © Set actual valu on-the-fly FM355, FM485 | PID contol algorithm or selFoptimizing | — Prefabricated controller structure for CClosed-oop con- | temperature conto algorithm with. 16 | » Fixed setpoint control twolmodule for” | channels (actal valve sequsiton and | > Cascade contol pressure, tempera-| feed-forward contol), and 1 channel for |» Ratio contol Sean ow mi | test compenatncn ewes |» .congonent cna control step or pulse controller or cotinvows-2e- |" Sampling tine (depen onthe num tion controler also in backup mode inde-| per of controler for FM 385/FM 485) pendently ofthe CPU: ata resolution of > 12s: 20 ms to 100/180 ms 14 bits: 100 ms to $00/1700 ms 2. SIMATIC Controllers ~ the Hardware Platform. 2.11 CP Modules Connect to Communication Networks CP communication processors relieve the CPU of communication tasks. They represent the physical link to the network. Responsible for establishing the connection to and the data transfer over the network, they provide the necessary communication services for the CPU and the user program. CP modules for PROFIBUS and Industrial Ethernet are configured with the optinal software package NCM (which is part of the STEP7 package) offering parameter assignment screens and diagnostic screens for testing and commissioning. All other CP modules are supplied with the necessary screens which are automatically integrated in the “Hardware Configura- tion” during installation. ‘Table 2.2 CP modules with functions and characteristics {CP 340, CPI, | Sera point o-point connection with po] Transmission terfacee cr aat cific protocols; can also be used in sys- | > RS 232C (V.24) Pointiopoint | tems of other manufctres. > 20mAcTTY) connection (CP 441-1 with one interface > RS AZDIRS 485 (X27) (CP 41-2 with two interfaces Implemented protocols: Non-resident werspecifc drivers canbe | > ASCI drver ‘sed forthe interfaces ofthe CP 341 and |» Printer deer P44? modules. > 396448) © RK 512 (for CP 341 and CP 441-2) @xa2 "AS interface master forthe connection of | No specific parameters reuned ASimater | up 31 AS interface slaves craas, PROFIBUS DP maser, CP 3425 also ax | Commnication servicer Crags. | DPsive, > PROFIBUS DP PROFIBUS DP > $7 Communication faction > SENDIRECEIVE intrfice wes, Connection to PROFIBUS FMS ‘Commaniation series CP 443-5 Basie > PROFIBUS FMS PROFIBUS FMS > $7 Commoncation faction > SENDIRECEIVE interface xa Connscion wo Tndasal Eibemet Communication servies/ Connection: can > 87 Communication function Industrial Ethernet > SENDRECEIVE intrfice b- 150 Trrapotconsertion GPHG-1PN | Connection wo Industral Ethemet using | Communication eviee/Connestons Industral Ethernet | PROFInet > $7 Communication faction mit PROFInt > SENDIRECEIVE interface > 180 Transport connection with RFC GPRGAIT | Connection o ihe information sem of | Communication sevice/Connectons CP48-11T | acompany with tegrated Web Server, | > $7 Communication fonction Indastial here | HTM ies can be opened wih standard | SEND/RECEIVE itrace (formation "| trowser,cmailscan beset fiom within | » Progamming evictOP fnctions systems) the we program by means of FC calls, | » TCP Transport conection © with'without REC > UDP connection > email connection om ‘Connection to Industral Ethernet using | MMS services: Industrial Ethernet | MMS services ace. to MAP'3.0. © Environment Management ons) > VMD Suppor Services © Naiale Access Services 7 2.12 SIMATIC-S7 Intelligence: CPU Modules ‘The CPU modules of the SIMATIC S7 series contain the central control processor which ex- «ecutes the operating system and the user program, assigns module parameters and transmits user data. All CPU modules are equipped with an MPI interface for the connection to the programming device, operator interface systems or other SIMATIC stations. ‘The operating system controls the operating modes The operating system handles all CPU functions. It controls the startup sequence, initiates the execution of the main program, updates the process image tables, records alarms and fault messages and initiates processing of the associated priority class. It also monitors all actions and indicates errors by registering them in the diagnostic buffer and activating LEDs at the module’s front panel. The front panel also holds the key switch with which you start the execution of the user program. ‘The mode sclector switch has the positions STOP, RUN, and MRES. STOP halts processing of the user program; RUN starts processing. Ifthe mode selector switch is designed as a key- lock switch, the RUN position is for reading the program only, and in RUN-P it can also be modified. The MRES position is required for overall reset and cold restart, ‘The control processor executes the user program The control processor of the $7-300 CPU modules (except the CPU 318) is a micro-control- Jer which converts the MC7 code of the user program to its own machine language. On the innovated standard CPUs, the execution time for 1000 binary statements is between appro- ximately 0.1 and 0.2 ms. The CPU 318 modules and the CPU modules for the $7-400 can process the user program directly by means of a specific ASIC circuit. The processing time for 1000 binary instructions is approximately 0.2 milliseconds for CPU 412 modules and ap- proximately 0.08 milliseconds for CPU 416 modules. In $7-300 stations, the central control processor handles the communication with the pro- ‘gramming device or the data exchange with other stations in addition to its other tasks. S7- 400 stations have a communications processor for this purpose. After power-up @ the CPU isin the STOP mode. When the switch ‘startup —@-> is tured to the RUN or RUN-P position, start-up program @) is Power Sood wae eee S {ot fin er gn srs Tet S os xing he operating STOP + NN mode HOLD @ can be carried out <+@- 110 @ uring START-UP and RUN. If es rent creus drng ost awe cpsring won he CPU rts 1 the STOP mode ©. Figure 2.6 Operating modes of a SIMATIC $7 CPU 38 2 SIMATIC Controllers - the Hardware Platform ‘The user memory comprises the load memory and the work memory ‘The CPU stores the user program in two memory areas: in the load memory and in the work ‘memory. The load memory contains the complete user program including the configuration data and is either an integral part of the module or available in the form of a plug-in memory card. The work memory is a fast RAM memory containing the sequence-relevant program code and the user data, The programming device transfers the complete user program including the configuration data to the load memory. The operating system interprets the configuration data, assigns the CPU parameters and ~ at startup the parameters of the UO modules. The sequence-relevant program code and the user data are copied to the work memory. When the user program is uploaded to the programming device, the blocks are fetched from the load memory and up- dated with the current values of the data addresses from the work memory. A memory card extends the user memory ‘There are three types of memory card that are used depending on the CPU: RAM memory cards, flash EPROM memory cards, and micro memory cards. If, for example, you want to expand only the load memory on the S7-400 CPUs, you use a RAM memory card. With a RAM memory card, you can modify the entire user program online. RAM memory cards lose their contents when disconnected. ‘You can use a flash EPROM card to maintain the user program including the configuration data and module parameters in the event of a power failure, without the need of a backup battery. For this purpose, load the complete program offline to the flash EPROM memory card installed in the programming device. You can also load the program during online op- eration — with the memory card installed on the CPU module ~ if the CPU is equipped for this. ‘The innovated $7-300 CPUs use only a micro memory card as load memory. This is a non- volatile memory medium. However, as with RAM memory, the data can be read, written and, deleted. This allows data backup without the need for a battery Battery backup for retentive data management ‘The backup batteries are located on the CPU module (S7-300) oF on the power supply mod- ule (S7-400). The battery voltage is constantly monitored by the CPU; a low battery is indi- cated and can be evaluated in the user program. The backup battery has a maintenance inter- val of 1 year. ARAM load memory requires a backup battery for the retentive storage ofthe user program, EEPROMS or plug-in flash EPROM cards do not require backup batteries. In S7-300 controllers, current values of the work memory areas (data blocks) and system memory areas (memory bits, timers and counters) can be stored on nonvolatile media. In this ‘way the data is maintained without the use of a backup battery, even in the event of a power failure. 39 For the CPUs of the ‘new 7-400 controler. the sizeof these be specified by the user. All the project da the work memory can be ransferred sand the system tothe load memory ‘memory share the lof the CPU in thetr same pica memory ‘archived sate ‘rea, increasing the ‘Wrequired. they can system memory, for ‘he transferred back example, will decrease othe programming the work memory device onsite and (processed there. Figure 2.7 Memory areas for user program and addresses ‘The system memory contains the addresses ‘The system memory contains the addresses (variables) which are accessed by the user pro- ‘gram, The addresses are grouped into address areas with a specific number of addresses for ‘each CPU. The system memory of the CPU comprises the following address arcas: © Inputs (1) Image (process image) of the digital input modules > Outputs (0) Image (process image) of the digital output modules > Memory bits (M) Information memory areas that can be addressed from any location in the user program © Time functions (T) Timers for implementing delay and monitoring times > Count functions (C) Software counters for up and down counting. © Temporary local data (L) Dynamic intermediate buffers for block processing. The temporary local data are stored in the L stack which is dynamically occupied by the CPU during program execution, ‘The system memory also provides buffers for communication jobs and system messages (di- agnostic buffer). 2__ SIMATIC Controllers - the Hardware Platform 2.13 CPUs with technology functions ‘The $7-300C compact CPUs contain technology functions in the operating system that are used via integral system function blocks (SFBs) in the user program. The technology func- tions are permanently assigned to the digital and analog inputs/outputs on the CPU. These assignments overlap to some extent so that not all technology functions can be used together. In the case of open-loop positioning with analog output, the actual value is acquired with asymmetric 24 V incremental encoders. The drive (power section) is controlled using an an- alog output in the range +10 V (voltage signal) or +20 mA (current signal). SFB 44 ANA- LOG is called in the user program. This SFB allows jog mode, reference point approach, rel ative and absolute incremental mode, set reference point, delete distance to go, and linear ‘measurement In the case of open-loop positioning with digital output, the actual value is acquired with asymmetric 24 V incremental encoders. The drive (power section) is controlled using four digital outputs that switch the direction of travel and the velocity levels (rapid traverse or creep speed). SFB 46 DIGITAL is called in the user program. This SFB allows jog mode, reference point approach, relative and absolute incremental mode, set reference point, delete distance to go, and linear measurement. Depending on the CPU used, counting is performed at a frequency of up to 60 kHz using a permanently assigned 24 V digital input. SFB 47 COUNT is called in the user program. This SFB allows continuous counting, single-shot counting, and periodic counting. The gate function can start, stop, or interrupt counting. A comparator can force a digital output or trig- {get a process interrupt when a preset count value has been reached. In frequency measurement, the CPU counts the pulses within an adjustable time window. The time window can be set within the range 10 ms to 10,000 ms in steps of I ms. Depending. oon the CPU used, a frequency of up to 60 kHz can be measured, In the user program, you call SFB 48 FREQUENC. The gate function starts or stops the measurement. Ifthe frequen- cy reaches a lower or upper limit, a digital output can be forced or a process interrupt can be triggered. Pulse width modulation converts a numeric value into a pulse train with the relevant pulse/pause ratio and outputs this ata digital output. The output frequency is up to 2.5 kHz. and the minimum pulse duration is 200 us. Pulse width modulation is integrated into the user program with SFB 49 PULSE. The gate function starts or stops output of the pulse train. Depending on the CPU used, the protocols, ASCII, 3964(R), and RK512 are available for point-to-point connection. Up to 1024 bytes can be transferred at a data rate of 19.2 Kbit/s (fall duplex) of 38.4 Kbit/s (half duplex), SFBs 60 and 65 form the interface to the user pro- gram. The closed-loop control functions are software controllers implemented with SFB 41 CONT_C (PID controller with continuous manipulated variable output, suitable for two-step or three-step controls), SFB 42 CONT_S (PI controller with binary manipulated variable ‘output without position feedback), and SFB 43 PULSEGEN (PID two-step of three-step controller with pulse width modulation). 41 2__ SIMATIC Controllers the Hardware Platform 2.14 SIMATIC PC-based Automation SIMATIC PC-based Control ‘SIMATIC WinAC (Windows Automation Center) combines the functions open-loop control, technology, data processing, visualization, and communication on one standard PC, and it is the first choice when you have to handle PC applications in addition to the classic PLC tasks. You can operate WinAC strictly as a software solution or with a PC module as the controller. SIMATIC WinAC Software PLCs are available in three versions: WinAC Basis rans under Microsoft Windows NT 4.0 and 2000 and is the low-cost solution for non-deterministic pro- cesses in conjunction with extensive PC tasks. Win dC RTX provides a real-time expansion for Windows NT to guarantee deterministic characteristics for the controller. Finally, Win AC PNis the first software PLC for Component based Automation with PROFInet. Two Open Development Kits enable C/C++ code, software applications, and PC components such as seanners to be integrated into WinAC. ‘The SIMATIC WinAC Slot PLC is used ifthe application requires determinism, availabil- ity, and a high level of operational safety. It is a PCI plug-in card based on the CPU 412 or 416. The PS extension board enables controller operation even if the PC fails. The WinAC Slot T-Kit under Windows NT4.0 and 2000 forms a high-speed interface tothe PC applica- tions via a dual-port RAM with 4KB inputs and 4KB outputs. SIMATIC Embedded Control SIMATIC WinAC MP is the soft PLC under Windows CE that runs on the multifunctional platform SIMATIC MP 370. Thanks to hard-disk-free and fan-frec operation, WinAC MP is ideal for machine-level tasks where it provides a user-friendly interface and a large program and data memory. Standard interfaces with WinAC WinAC Computing establishes the connection between the PC software and the PLC soft- ware; HinAC Controlling handles contro! tasks, either as a software PLC (WinlC, Windows Logic Controller) or as a slot PLC (CPU 416-2 PCI, for example). Data exchange with WinAC is based on the Microsoft OLE technology (Object Linking and Embedding). You can use the SIMATIC controls supplied here or your own ActiveX. and OCX controls (OLE Custom Controls). WinAC Computing also contains an OPC server (OLE for Process Control) that guarantees other OPC client applications access to WinAC Controlling. The WinAC Tool Manager supports you in managing the standard applications that exchange data with WinAC Controlling, such as visual Basic or Microsoft Excel. WinAC supports distributed applications on several networked computers using DCOM (Distributed Component Object Model) from Microsoft. You can, for example, run WinAC ‘Computing on a different PC to the one operating WinAC Controlling, or you can connect a visualization system with SIMATIC HMI, o you can use STEP 7 to program WinAC Con- trolling from an engineering system. a2 2__SIMATIC Controllers the Hantware Platform SlotPLC (og. CPU 416 PCI PROFIBUS subnet ‘MPI subnet Ss UD Figure 2.8 Automating with SIMATIC WinAC Open-loop control with SIMATIC WinAC Controlling ‘You configure, parameterize, and program the WinAC Controllers with STEP 7. Using the ‘SIMATIC Manager, you create an object called SIMATIC PC Station within a project. This object in turn contains the object Configuration. Open this. Under “SIMATIC PC Station” in the Hardware Catalog you select “CPU 412-2 PCI”, for example, Connect the DP inter- face with a PROFIBUS subnet and parameterize the CPU (double-click on CPU and com- plete the object properties dialog). To configure the distributed VO, select the desired DP slaves from the Hardware Catalog under “PROFIBUS DP” and drag them to the station win- dow of the DP master system. Depending on the application, insert other components into the PC station represented. ‘These other components could be communications processors (CPs) for connecting to PROFIBUS or Industrial Ethernet, proxies for HMI components, or proxies for configuring. the connection, such as the OPC server under “User Application”. You can define the mem ‘ory location of the configuration file with STATION —> PROPERTIES. Following STATION + SAVE AND COMPILE, the SIMATIC Manager will have a container called $7-Program under Controller. You write the control program using the PLC program ‘ming languages as in SIMATIC S7. The free PC main memory can be fully utilized here as the work and load memory. 8 2__SIMATIC Controllers ~ the Hardware Platform 2.15 Distributed Process Connections PROFIBUS DP ‘The PROFIBUS DP (Distributed Peripherals) offers a standardized interface for the ex- change of mainly binary process data between an “interface module” installed in the (cen- tralized) programmable logic controller and the field devices. The interface module serves 4as the DP master and the field devices serve as the DP slaves. Distributed peripherals are modules which are connected to a DP master module through the PROFIBUS DP commu- nication network. PROFIBUS DP is a non-proprietary standardized communication network based on the European Standard EN $0170 for the connection of standard DP slaves. PROFIBUS PA The PROFIBUS PA (Process Automation) is a communication network for the process in- dustry and can be used both in intrinsically safe areas, such as hazardous areas of Zone 1, in ‘the chemical industry, and non-intrinsically safe areas, for example, in the food industry. ‘Two network components are available for linking PROFIBUS DP and PROFIBUS PA: > DP/PA coupler; is used if the PROFIBUS DP can be operated at a transmission rate of 45.45 KBit/s, > DPYPA link; converts the transmission rates of PROFIBUS DP to the transmission rate of PROFIBUS PA. SIMATIC PDM (Process Device Manager) is a manufacturer-independent tool for parame- ter assignment, commissioning and diagnostics for intelligent field devices with PROFIBUS PA or HART functionality. HART transducers (Highway Addressable Remote Transducer) can be configured using DDL (Device Description Language). Actuatorisensor interface ‘The actuator/sensor interface (AS interface) isa networking system for actuators and sensors at the lowest field level. An AS Interface Master can control up to 31 AS interface slaves through a two-wire AS interface cable. The cable transmits the control signals and the supply voltage. AS Interface Slaves can be bus-capable actuators or sensors, or AS interface mo- ules allowing the connection of up to 8 binary (“conventional”) actuators or sensors. An AS interface segment can have a maxinmum length of 100 meters. By using a repeater (AS inter- face slaves and power supply units on both sides) or extender (AS interface slaves and power supply unit only on the section leading away from the master) the cable can be extended by 2% 100 meters to a maximum length of 300 meters. Serial interface connection ‘The PROFIBUS DP/RS 232C link serves as a converter between an RS 232C (V.24) inter- face and PROFIBUS DP. Using the DP/RS 232C link, devices with an RS 232C interface ccan be directly connected to PROFIBUS DP. It supports the 3964 R procedure and the free ASCII protocol, 2__SIMATIC Controllers - the Hardware Platform 2.16 SIMATIC DP Distributed VO PROFIBUS DP master system ADP master and its connected DP slaves make up a DP master system. A network segment ‘can comprise a maximum of 32 stations, the entire network can interconnect a maximum of 127 stations, The maximum number of DP slaves in a DP master system is determined by the type of DP master used. A SIMATIC station can have several master systems, You can also connect programming devices as well as operator panels, SIMATIC SS-DP slaves or DP. standard slaves of other manufacturers to a PROFIBUS DP network. DP masters control the distributed /O. The DP master is the active station in the PROFIBUS network and communicates with its DP slaves by means of cyclic data transmission. The following modules can be used as DP masters: > CPU with integrated DP master interface or plug-in interface module (e.g., CPU 315- 2DP, CPU 417) > Interface module in conjunction with a CPU (e.g., IM 467) > CP module in conjunction with a CPU (e.g., CP 342-5, CP 443-5) DP masters can be Class 1 Masters for the data exchange in the online process mode, and Class 2 Masters for service and diagnostic tasks as carried out by a programming device. ee ==*=— iim ALT PROFIBUS DP Repeater persaszc | DP/AS link interface in 8 SmPtser) PROFIBUS PA PROFIBUS PA Serial connection AS interface Figure 2.9. Components in a PROFIBUS DP master system 4s 2__ SIMATIC Controllers - the Hardware Platform 2.17 DP Slaves: Process Connection in the Vicinity of the Machine DP slaves are the passive stations nodes in the PROFIBUS communication network. With SIMATIC S7 stations, we distinguish the following slaves: > Compact DP slaves ‘They respond to the master just » Modular DP staves They consist of several modules (submodules). > Intelligent DP slaves ‘They contain a user program that controls the modules of the slave station. The ET 200 series offers the distributed /O devices of SIMATIC DP for connecting sensors and actuators on site. Degree of protection is IP 20 or IP 65/67. a single module ET 200L: small and compact just like a posteard The ET 200L is a small, compact 1/0 station with IP 20 protection. Itis primarily used at the lower end of automation applications and where space is restricted. The maximum transmis- sion rate on the PROFIBUS network is 1.5 Mbit/s. The ET 2001. can be equipped with in- putvoutput modules and is available as non-expandable block /O or with a expandable ter- ‘minal block ET 200B: smi and compact, low mounting depth The ET 200B is a small, compact /O station with IP 20 protection and is primarily used in applications where only a small number of inputs/outputs is used or a device with a low mounting depth is required. The transmission rate on the PROFIBUS network is 12 Mbit/s. ‘The ET 200B can be equipped with digital and analog input/output blocks. ET 200eco: compact /O without a control cabinet ET 200eco is the low-cost solution in degree of protection IP 65/67 for processing digital signals at the machine level. There are modules with 8 or 16 digital inputs, 8 digital outputs, or 8 digital inputs and 8 digital outputs. Data transfer rates are up to 12 Mbit/s. ET 200R: rugged VO direct on-site ET 200R is available as a handling or welding module in a metal housing with degree of pro- tection IP 67 for environments subject to severe electromagnetic contamination. The in- puts/outputs can be parameterized channel-by-channel from 8DU/SDO up to 16 DI. Data transfer rates are up to 12 Mbit/s. ET 2008: bit-modular and innovative ET 2008 is a bit-modular 1/0 station with digital/analog inputs/outputs, technology mod- ules, and motor starters for three-phase loads in degree of protection IP 20 with a maximum data transfer rate of 12 Mbit/s. The modules can be replaced during operation. ET 200S can also be used as an intelligent DP slave with the IM 151 interface module/CPU. 2. SIMATIC Controllers ~the Hardware Platform ET 2004S: intrinsically-safe for use in the Ex area ET 200iS is an intrinsically-safe VO station in degree of protection IP 30 for use in the Ex area (Zones | and 2), where the sensors and actuators can also be located in Zone 0. PROFT- BUS DP is connected via an isolating transformer at up to 1.5 Mbit’. Bit-modular design with module replacement during operation is possible. ET 200M: expansion with $7-300 modules ‘The ET 200M is a modular 1/0 station with TP 20 protection. It accommodates up to eight '$7-300 modules. The maximum transmission rate is 12 Mbit/s. In connection with an S: 400 DP master, the station can be configured to hold active bus modules. This allows the re- placement of modules during running operation. Thanks to its large range of modules, the ET 200M can be used especially in individualized and complex automation systems (e.g. in ‘S7-400HF redundant and failsafe systems). ET 200X: decentralization at machine level, even with signal preprocessing ‘The ET 200X is a modular VO station with IP 6S/1P 67 protection and a maximum transmis- sion rate of 12 Mbit/s. It is particularly suitable for the use in the vicinity of the machine ‘without control cabinet. A basic module, available with integrated digital VO or with PLC functionality, establishes the connection to the PROFIBUS network. The following can be connected to the basic module: digital/analog input/output modules, motor starters for three- phase loads, ASi master module, pneumatic module with integral 4/2-way valve and pneu- matic interface for accommodating a CPV valve terminal from FESTO. It is possible to re- place individual modules without dismantling the entire station. ET 200X as a modular DP slave If equipped with a BM 141 or BM 142 basic module, the ET 200X station behaves like a modular DP slave: all expansion modules are addressed by the DP master as “modules” with ‘programmable addresses. In addition, the basic module BM 141 is equipped with eight di- gital 24V DC inputs, and the BM 142 with four digital 24V DC 2A outputs. ET 200X as an intelligent DP slave ‘An ET 200X station with the basic module BM 147/CPU can assume the role of an intelli- gent DP slave. The addresses of the expansion modules are determined by the mounting slot and can only be directly addressed by the slave CPU (in this case the BM 147/CPU). The transfer area (with adjustable structure and data consistency) to the DP master provides 32 bytes for inputs and 32 bytes for outputs. Due to its integrated PLC functionality, the BM 147/CPU is able to preprocess the signals in the ET 200X station on-site or control the station autonomously and thus reduce the load on the central SIMATIC station. The basic module is programmed in the STEP 7 programming. languages. ‘The BM 147/CPU has an integrated 12 KB RAM/flash EPROM load memory; a memory card is not available. It is programmed and configured through the PROFIBUS network, that is, with the programming device of the master station. a 2__SIMATIC Controllers ~ the Hardware Platform 2.18 The SIMATIC Programming Devices SIMATIC programming devices are the perfect tools for programming and configuring SI- MATIC programmable logic controllers. They can be considered as fully-functional com- ‘puters designed for industrial use, constantly adapted to the latest developments in computer technology (the described technical characteristics reflect the state of 2003). ‘The programming devices contain Windows NT 4.0 or Windows 2000 Professional with a selection of combinations of the five-language software packages STEP 7, STEP 7 Profes- sional, STEP 7 Micro/WIN and STEP 5/ST Basic Package. SIMATIC memory cards can be programmed with any programming device. In addition to the usual PC interfaces, the pro- gramming devices have an MPUDP interface for connecting to the MPI interface of the CPU ‘or to a PROFIBUS subnet at up to 12 Mbit’. A S-meter MPI cable is included. The Field PG is a portable PC in notebook format. The integral lithium-ion battery enables ‘mobile use. An external power section guarantees power supply in the office. Focal applica- tions are startup, maintenance and service, even in restricted spaces or on trips. The Power PG is a portable, powerful programming workstation. The main applications are in programming, configuring, and simulation in the office as a substitute for a desktop PC. ‘Table 2.3 Technical characteristics of SIMATIC programming devices Field PG Power PG ou ‘Mobile [nicl Celeron 900 Nit Thiel Pentium I 126 GHz, incl, 128 KB second level cache incl $12 KB second level cache ‘optionally Mobile Intel Pentium 11] | GHz incl. 256 KB second level cache ‘Main memory 128 Mbyte Te MB Expandable to 512 MB Expandable to $12 MB Hard disk 20 GB, optionally 40 GB; 2.5" 6B 3 Floppy disk drive | SuperDisk LS 240 ‘SuperDisk LS 240 240/120 MB SuperDisks or 240/120 MB SuperDisks or 144 MB; 3.5" 14 MB; 3.5" Optical dive ‘W24-speed DVD-ROMICD-ROM ‘W24-speed DVD-ROMICD-ROM ‘optionally ‘optional: 8/8/24-speed DCD-ROM/CD-RW. 81824-speed DCD-ROMICD-RW Display ‘36 em (14.1") TFT display, ‘38cm (15°) TFT display, ‘resolution 1024 % 768 pixels resolution 1024 x 768 pixels Graphics Internal Direct AGP Graphic with dy- | ATI Rage Mobility with ¥ MB video namic video memory, extemal monitor | memory. external monitor max. 1600 % ‘max. 1600 1200 pixels 1200 pixels Pointing device | Touch pad “Touch pad PC card (PEMCIA) | 1 Type ll or 2 Type Ht Te Type Ill or 2» Type Ht Free slows : TPCT ong, 1 PCI short 3._ STEP 7: Standard Tool for SIMATIC 3. STEP 7: Standard Tool for SIMATIC STEP 7 is the standard tool for SIMATIC and runs on a standard PC under the Microsoft ‘Windows operating systems. STEP 7 is available in different versions, STEP7 STEP 7 is the standard software for the SIMATIC $7-300/400, SIMATIC C7 and SIMATIC WinAC programmable logic controllers. As the central tool, SEMATIC Manager manages all transpiring automation data and all tools necessary for processing this data. With STEP 7, ‘you configure the hardware of the SIMATIC controller, you select the module addresses and ‘the module parameters, and you configure the network connections. Last but not least, STEP 7 makes available the programming languages ladder logic (LAD), function block diagram (FBD) and statement list (STL) with which you can write the user program for the controller. STEP 7 Lite STEP 7 Lite isan economical alternative for simple stand-alone applications with SIMATIC 7-300 and SIMATIC C7. With STEP 7 Lite, you configure the hardware for SIMATIC S7~ 300 and SIMATIC C7 including the distributed peripherals. The programming languages ladder logic (LAD), function block diagram (FBD) and statement list (STL) are completely supported, User programs created with STEP 7 Lite can be further processed under STEP 7. ‘Option packages and communication to other SIMATIC stations are not supported by STEP 7 Lit. STEP 7 Professional STEP 7 Professional consists of the standard tool STEP 7 and the optional packages $7- GRAPH, S7-SCL, and S7-PLCSIM. STEP 7 Professional thus also supports the remaining TEC languages “Sequential Function Chart” and “Structured Text” in addition to the PLC languages Ladder Diagram (LAD), Function Block Diagram (FBD), and Statement List (STL) familiar from STEP 7. Offline simulation of the user program is also possible. STEP 7 Micro/Win STEP 7 Micro/Win is the programming software for SIMATIC $7-200. With STEP 7 Micro, ‘you optimally create the user program for processing in an $7-200 CPU in the form of a statement list or graphically as ladder logic. The user program consists of one singular block that can contain subprograms. The functional scope of the S7-200 contains, among others, binary operations, time functions and count functions, integer arithmetic instructions, float- ing-point arithmetic instructions, comparison functions, number conversion, data transfer, 0 3. STEP 7: Standard Tool for SIMATIC 3.1 Data Management in the SIMATIC Programmable Logic Controller ‘A powerful tool in the form of the STEP 7 software package is available to you for solving control tasks. With STEP 7 you not only program your user program, that is, the program instructions and program functions that the controller is to execute later, but you also create and edit all automation data, In other words, also the configuration data forthe hardware, the parameter assignment data for the modules and the connection data for communication, for example, is defined and organized in STEP 7. This automation data is located in the programmable logic controller (PLC) in various mem- cory locations. First of all there is the PG programming device, generally known as the “Con- figuration Unit” or “Engineering Tool.” It can also be a Standard-PC, on which STEP 7 runs. All automation data is stored on its hard disk in a “project folder” The project folder is a software structure, that you cannot actually see, unless of course you look at the project di- rectory using Windows Explorer. You edit the data in the project folder with SIMATIC Man- ager, the user interface of STEP 7. SIMATIC Manager displays the automation data in Win- dows-typical windows. The automation data on the hard disk is also called the offine data. When STEP 7 has “com- piled” the automation data, it can be downloaded to a connected PLC. Usually the CPU, the central processing unit, accepts the data and distributes it as required to other modules, The data loaded into the user memory of the CPU is the online data. Offline and online data al- ‘ways has to be synchronized for a problem-free configuration. Let's take a look at a user program section, a “block,” at the path it takes through the data ‘management (Picture). SIMATIC Manager shows us, in the offline window, the blocks in the offline data management. In other words on the hard disk. You can now insert a new block and program it. When you start the program editor, the block is transferred to the main mem- ory of the PG programming device where it remains during editing. Only when you activate ‘the menuitem FILE —> SAVE is the block saved on the hard disk. You can program the block “offline,” that is, without being connected to a PLC. After you have completed the block, you have to transfer it into the CPU of the programma- ble logic controller — generally into “PLC” — where you will test it. There are two ways of transferring the block: you connect the MPI interface of the PG programming device and that of the CPU and are then “online” on the CPU. You then transfer the block into the user mem- ory of the CPU with SIMATIC Manager. The other possibility is that a block, or an entire program which is already tested, shall now “finally” be writen into the CPU memory: You transfer the program onto an Memory Card and then insert the Memory Card into the CPU. ‘You don’t need to switch the PG programming device to online for this. ‘When the CPU is connected, you see the contents of the CPU user memory in the online win- dow of SIMATIC Manager. You can now also edit a block from this CPU user memory in the online mode, The Program Editor or SIMATIC Manager transfers the selected block into the main memory of the PG programming device where you can modify it. Select PLC —> DOWNLOAD to write the edited block back into the CPU, without the block having been ac- cepted into the data management of the PG programming device. $0 3__ STEP 7: Standard Tool for SIMATIC This procedure is only recommended if you knowingly don't want to save the block offline, for example, because it was only programmed as atest auxiliary. In general, the offine data ‘management on the hard disk and the online data management in the CPU may not go se- pparate ways. Foron the one hand, the data stored in the project folder is also used to edit the ‘online data (symbols, comments, for example) and on the other hand, you want all the auto- mation data to be complete and consistent after program testing, Recommendation: If you are “online” in the CPU, you write every block that you are cu- rrently editing with the Program Editor onto the hard disk as well as tothe CPU, irrespective ‘of whether the block is an “offline block” or an “online block.” Accordingly, the other automation data is also handled in the same manner. the main memory of ———. see aes She promramming Renz foculaa roomed, sears Saale Fistsovtie pape fe in the CPU et with the compiled data which is necessary for monte ‘Figure 3.1. Data management in the SIMATIC programmable logic controller st 3. STEP 7: Standard Too! for SIMATIC 3.2. STEP7 STEP 7 is the central automation tool for SIMATIC, It contains the applications for config uring the hardware, for programming the network connections and for creating the user pro- gram. The data is organized in the form of a “project” with a common data management. The functional range of STEP 7 can be expanded with several option packages. STEP 7 is supplied in five languages (German, English, French, Italian, and Spanish), You require approximately 200 to 380 MB on the hard disk for one language, depending on the ‘operating system and the filesystem used. A swap file is also required with a size of appro- ximately 128 to 256 MB less main memory capacity. Approximately 10 to 20 MB must be reserved for each additional optional package STEP 7 is a 32-bit-application, that requires Microsoft Windows operating system, STEP 7 VS is “multi-user capable,” that is, you can edit a project that is located on a central server, from several workstations simultaneously. You make adjustments to the settings in Windows Control Panel with the “SIMATIC Workstation” program. Authorization For operating STEP 7, you require an authorization (user authorization). This is delivered on a diskette. After you have installed STEP 7, you will be requested to register, ifa registration is not already saved on the hard disk. You can also register later on. Should you lose your authorization through a hard disk error, for example, you can use the limited-time emergency authorization until you have obtained a new authorization. You will find the emergency authorization on the authorization diskette that you received. Online help, The SIMATIC Manager's Online Help supplies you with information during the program- ‘ming session without the need for looking up manuals. You need Microsoft Internet Explorer touse the Online Help. You select the help topics using the HELP menu, Under Fist STEPS, for example, the Online Help provides a brief overview of working with the SIMATIC Ma- ager. HELP — ConrENTS starts the central help to STEP 7 from every application. This help con- tains the fundamentals. HELP > CONTEXT-SENSITIVE HELP FI gives you help that is depen- dent on the context, that is, it contains information about an object that is selected with the ‘mouse of about the current error message, when you press the FI key. In the toolbar, there is a button with an arrow and a question mark. If you click on this button, the mouse pointer is also given a question mark. With this “Help” mouse pointer, you can ‘now click on an object on the screen, for example, an icon or a menu command, and receive the associated online help. 2 3__ STEP 7: Standard Tool for SIMATIC 3.3. SIMATIC Manager SIMATIC Manager is the central tool in STEP 7; after installation, you will find its icon on the Windows Desktop. A double-click on the icon starts SIMATIC Manager. An alternative way of starting it is through the toolbar: ‘START SIMATIC — SIMATIC MANAGER. With SIMATIC Manager, you work with objects in the STEP 7 world. These “logical” ob- jects represent the “real” objects in your plant system. A Project contains the entire plant sys- tem, a Station corresponds to a programmable logic controller. A project can contain several stations that are connected with one another by means of an MPI subnet, for example, One (CPUs inserted in a station. This CPU contains a Program, in our case an S7 program. This program, on the other hand is a “folder” for further objects, such as the Blocks object, that contains compiled blocks among other things. To start programming, you open an existing project or create a new one. The sample projects that are delivered with the software will help you to become familiar with the system. If you ‘open such a project with FILE —> OPEN , you will see the partitioned project window: the structure of the opened object is on the left (the object hierarchy), on the right is the contents of the selected object. A mouse click on the checkbox with the plus sign that is in the left pane opens further levels of the structure; by selecting an object in the left pane you display its contents in the right window. Opening objects on the lowest hierarchy, for example a dou- ble-click on the symbol OBI, starts the tool pertaining to the object, in the example, the Pro- gram Editor. Era 08 STEP? BB Seistic 20 Sater) Goune a ( See Fn Sons: Figure 3.2. Example ofa project window in SIMATIC Manager 33 3. STEP 7: Standard Tool for SIMATIC Automating with STEP 7 This double page illustrates the principal procedure for applying the STEP 7 pro- gramming software. You start SIMATIC Manager and create a new project or you open an existing one. All data for a planned automation is stored in a Project in the form of Objects. When you set up a project, you create Folders for the resulting data, by installing the required Sia- tions with at least the CPU; the folders for the user pro- grams are then also created. You can also create a Pro- gram folder directly in the Project In the next steps, you confi- gure the hardware and, if re- ‘quired, configure the commu- nication connections. After that you create and test the us- er program, ‘The sequence for generating the automation data is not fixed. There is only the gener al rule: If you want to process objects (data), they must ex- ist; if you want to insert ob- jects, the associated folders must exist. You can interrupt the editing ina project at any time and the next time you start SIMATIC Manager you can continue from anywhere you like. 3. STEP 7: Standard Too! for SIMATIC 35 3. STEP 7: Standard Tool for SIMATIC 3.4 Projects and Libraries At the top of the object hierarchy in STEP 7 is the project and the library as “main objects.” Projects are used for the orderly storage ofall data and programs, that are needed for solving an automation task. Essentially, these are > the configuration data about the hardware structure, > the parameter sets for the modules, > the configuration data for the communication using networks, > the programs (logic and data, symbols, sources). ‘The objects in a project are organized hierarchically. The opening of a project is your entry point for editing all objects that are contained in it. The description on the next pages shows ‘you the processing of these objects. Libraries store re-usable program components. Libraries are also organized hierarchically: they can contain S7-programs, which in tun contain a user program (a folder for compiled blocks), a folder for source programs and a symbol table. With the exception of online con- nections (no test opportunity), you have, in the creation of a program or a program section in a library, the same functionality available to you as in a project. STEP 7 contains the Stan- dard Library, which contains the following programs, among others: > Onganization Blocks Templates forthe startup information in the temporary local data > System Function Blocks all interfaces for the system functions (SFC) and system function blocks (SFB) > TBC Function Blocks Functions (FC) for processing DT variables and STRING variables > PID Control Blocks Function blocks FB for continuous controllers and step controllers > Communication Blocks Functions (FC) for the SEND/RECEIVE interface Projects are hierarchically structured ‘The STEP 7 objects are linked with one another through a tree structure. The picture shows the essential parts of the tree structure (the "main branch” so to speak), when you work in the offline view with the standard STEP 7 package for S7 applications. The objects displayed in bold are folders for further objects. All the objects contained in the picture are available to you in the offline view. These are the objects you will find on the hard disk of the PG pro- ‘gramming device. If your PG programming device is online to a CPU (generally: 1o a PLC), ‘you can switch to the online view by selecting VIEW —> ONLINE. Then you can sec the ob- jects that are located in the “target” device in an additional project window; the objects un- OPEN or create a new project with FILE —> NEW, 2 Insert a new Station in the project In SIMATIC Manager, select (highlight) the project and select INSERT ~> STATION ... to insert the folder for a new station. Ifthe project contains several stations, also insert the folders for the other stations as well as the objects for the subnets at this opportunity. 3. Configuring a Station ‘The station that is opened shows the Hardware object in the right window, open this. It starts HW Config and displays an empty station window and the Hardware Catalog. From the Hardware Catalog now move the rack and at least the CPU into the station window ‘using drag-and-drop (this is enough to create a user program, for more information see “Configuring a SIMATIC Station”). Compile the station, save and close; return to SIMATIC Manager. In addition to the Hardware object, the station that is opened now shows the CPU. With the CPU, SIMATIC Manager creates the Connections symbol and an $7 Program with ‘Symbol Table, Source Files folder and Blocks folder at the same time. The project struc ture fora station is now completely set up. 4 Looking at the contents of the $7 Program ‘Open the CPU by clicking the plus checkbox, open the S7 Program and Blocks folders as well; in the right pane, SIMATIC Manager shows the symbols for the compiled ‘configuration data (System Data) and an empty organization block for the main program. (OB 1). 38 3__ STEP 7: Standard Tool for SIMATIC 5 Editing the user program objects ‘You are now at the lowest level of the object hierarchy. The first time you open OB 1, a ‘window with the object properties appears and then opens the Program Editor for editing the program in the organization block. Every time you open an object, you simultancously start the associated tool. If, for ex- ample, you open a subnet or Connections, you start the network configuration tool Net- Pro; if you open Hardware, you start HW Config.; if you open Symbols, you start the ‘Symbol Editor and when you open a logic block you start the Program Editor. Creating a library ‘You can also create a program in a library if you want to reuse it several times. That way you always have the standard program available and can copy it completely or partially into your ‘current program. Please note that you cannot set up an online connection in a library; you ‘can therefore only test a program within a project. ‘Managing, Reorganizing and Archiving Projects SIMATIC Manager manages projects and libraries in project lists or ibrary lists. With FILE > MANAGE, SIMATIC Manager shows you all the projects that are known to it with name and path. You can now delete projects from the list that you don’t want to display any longer, (“hide”) or accept new projects into the project list (“display”). You manage the libraries in the same manner, When you select FILE > REARRANGE... , SIMATIC Manager removes the gaps created ‘when you delete objects and optimizes the data storage similar to a defragmenting program ‘optimizing the data storage on the hard disk. Rearranging can, depending on data movement, take some time. ‘You can also archive a project or a library with FILE —> ARCHIVE... . With this, SIMATIC Manager stores the chosen object in compressed form in an archive file (the project directory or library directory with all underlying directories and files). During archiving, stop editing the project or the library and make sure that all windows are closed. Projects and libraries cannot be processed in the archived (compressed) state. With FILE —> RETRIEVE you decompress an archived object and can then process it once more. The re- trieved objects are automatically accepted in the project or library management. Multi-projects make working with large projects easier Multi-projects combine projects and libraries into a single unit. In multi-projects, communi- cations links between projects, such as $7 connections, can be processed at a cross-project level. The individual projects can then be scaled dawn, made more manageable and pro- cessed in parallel. Multi projects are treated like single projects for administration, archiving and de-archiving, 9 3. STEP 7: Standard Tool for SIMATIC 3.6 Configuring a SIMATIC-Station ‘You plan the hardware configuration of your programmable logic controller with HW Con- fig. Configuration is made offline without connection to the CPU. You can also address and assign parameters to the modules with this tool. You can create the hardware configuration in the planning stage or later, when the hardware is already installed. ‘You begin hardware configuration with a selected station and Eprr > OPEN object, or by CUSTOMIZE. After con- figuration, you can check whether the inputs are error-free by selecting STATION —> CONSIS- TENCY CHECK. STATION ~> SAVE saves the configuration tables with all parameter data in ‘your project on the hard disk. With STATION > SAVE AND COMPILE, the configuration tables are compiled at the same time as they are saved and the compiled data is stored in the System ata object in the Blocks offline folder. After compiling you can transfer the configuration data to a connected CPU with PLC -> DOWNLOAD. The System Data object in the Blocks ‘online folder represents the current configuration data in the CPU. You can “return” them to the hard disk with PLC —> UrLoap. ‘You export the hardware configuration data with STATION —> EXPORT. STEP 7 then sets up file in ASCII format that contains the configuration data and the parameter data of the mo- dules. Figure 3.4 Example of a Hardware Configuration station window 3__ STEP 7: Standard Tool for SIMATIC ‘Configuring hardware in the station window ‘The Hardware Configuration tool HW Config. displays the station window and the Hard- ware Catalog after it has been opened. To make editing easier, enlarge or maximize the sta- tion window. In the upper section, the window shows the racks in the form of tables and the DP stations in the form of symbols. If there are several racks, you can see the connection between the interfice modules here and ‘when PROFIBUS is used you can see the configuration of the DP master system. If you have avery extensive project with many racks, you can have HW Config. automatically arrange the current view by VIEW —> ARRANGE RACKS. The lower section of the station window shows the detailed view of the rack or DP slave se- lected in the upper section. This detailed view is in the form of a configuration table. Detail view in the configuration table HW Config works with tables each of which represents a rack, a module or a DP station. A SET configuration table shows the slots with the SIMATIC 300 ‘modules allocated to them or the properties of the module, such as, the addresses and the or- der number. Double-clicking a module line in the configuration table opens the properties Gy CPU I2IFM window of the module and allows you to as- te cus sign parameters to the module. 3 pele Bouas G cru 520P All modules in the hardware catalog oan cote ‘You can display and hide the Hardware Cata- SES7 315.2401 0:80 log using View Catalog. It contains all avail- able racks, modules and interface modules that poslelsioslovbntd STEP 7 recognizes. Using Options Edit Cata- erean log Profiles, you can make up your own Hard @ Cy cru 716 ware Catalog which — in the structure of your Go PU 31620P choice — only displays the modules with which Gy crustez you want to work. = crus foes 2G cru m7 If you double-click the title bar, you can “at- 2 F090 tach” the Hardware Catalog to the right hand Smo edge of the station window in order to avoid Gl M7ExTENSION hiding the contents of the station window by & Ps00 the Hardware Catalog. A renewed double-click Gi RacK300 fon the title bar releases the attached catalog | _ ea fll SIMATIC PC Based Corot 6 3. STEP 7: Standard Tool for SIMATIC 3.7 Arranging Modules and Assigning Parameters Arranging Modules ‘You begin arranging the modules in the Hardware Catalog, for example, under “SIMATIC 300” and “RACK 300.” Here you select the (DIN) rail with the mouse and “holding down” the mouse you drag the ral into the upper section of the station window. You then “release” the rail anywhere you want (drag & drop). The empty configuration table for the central rack appears. Now you can take the required modules from the Hardware Catalog and, in the same manner, drag them to the planned slots. An icon for a no-stopping sign indicates that you cannot drag the module you just selected to the chosen slot. You generate the configura tion table for a further rack by moving the chosen rack from the catalog into the station win- dow. Assigning parameters to modules ‘You establish the properties of a module by assigning parameters o it, Assigning parameters is only necessary if you want to change the pre-assigned Prerequisite for assign- A dialog appears with module-specific tabs that show the adjustable parameters. Assigning Figure 3.6 Assigning parameters to a module, Example of a CPU 3__ STEP 7: Standard Tool for SIMATIC 3.8 Addressing Modules ‘When you arrange the modules, HW Config. automatically issues a module start address. ‘You can sce this address in the configuration table in the lower section of the station window of in the Object Properties dialog of the module in question. For S7-400-CPUs and for S7- 300-CPUs with integrated DP interface, you can change the module start address. The address ranges of the modules may not overlap each other. ‘There are modules that have inputs as well as outputs. Theoretically you can assign various start addresses to these modules. Please pay attention to the respective notes in the manuals. Most of the function modules and communication modules require the same start address for inputs and outputs. ‘When you assign the module start address you can, for $7-400, also make the assignment 10 « partial process image. If more than one CPU is installed in the central rack, the multicom- puting mode is automatically set and you have to assign the module to one of the CPUs. ‘When you click ViEW > ADDRESS OVERVIEW, a window pops up that shows you all the module addresses used for the selected CPU. Modules on the MPI bus or K-bus have an MPI address. You can change this address as well. Please note that the changes that directly affect the CPU, such as its own MPI address, take ‘effect immediately when you transfer the configuration data to the connected CPU. Figure 3.7 Assigning parameters a module, based on an example ofa digital put module with hardware sterrpt 8 3. STEP 7: Standard Tool for SIMATIC 3.9 Creating the User Program Procedure for creating the user program ‘After you have divided the automation task into smaller units, all the way down to the block size, you can begin to enter the program. You can choose between incremental and source- oriented programming. But first you have to define the global symbols. ‘The signal states or the values of addresses are processed in the program. An address is, for example, the input I 1.0 (absolute addressing). With the help of the Symbol Table in the ‘Symbols object, you can assign a symbol (an alphanumeric name, “Motor on,” for example) to an address and then refer to this address with this symbol (symbolic addressing). When you make a change in the symbol table to blocks that are already compiled, you can select in the Properties of the Blocks offline object folder whether the absolute address or the sym- bol is to prevail. This change takes effect the next time you save (address priority). ‘You can give every digital inpuoutput and every analog inpuvoutput a name already when ‘you arrange the signal modules with HW Config. For this, select Eprr —> SYMBOLS... . You use this name to address the inpuvoutput in the user program. The symbols assigned in HW Config are automatically taken into the symbol table. When you create the program inerementally, you input the program directly block by block. ‘The inputs are checked immediately for the correct format (syntax). At the same time that the block is saved, itis compiled and stored in the Blocks folder. With incremental program- ‘ming you can also edit blocks online in the CPU, even while in running operation. Incremen- tal program creation is possible for all basic languages. When you create a source-oriented program, you write one or more program sources and. store them in the Source Files folder. Program sources are ASCII text files that contain the program instructions for one or several blocks, possibly even for the entire program. You ‘compile these sources and the compiled blocks are then placed in the Blocks folder. Source oriented program creation is used with STL; you cannot program source-oriented with LAD and FBD, but you can save your programs created with LAD and FBD as sources. “The user program is created under the ‘87-Program object. You can assign this ‘object folder to a CPU inthe project hie rarchy or you can create it CPU indepen- dent. The 57 Program folder contains the ‘Spmbols object and the Source Files and Blocks folders Figure 3.8 ‘Arranging the user programs ‘within the project structure 3__ STEP 7: Standard Tool for SIMATIC 3.10 Symbol Editor In the control program, you work with addresses. These are inputs, outputs, counters blocks, for example. You can access these addresses absolutely (e.g. 1 1.0) or symbolically (e.g. start signal). Symbolic addressing uses names instead of the absolute address. You can make your program easier to read by using clearly descriptive names. In symbolic addressing we distinguish between local symbols and global symbols. A local symbol is only known in the block in which it was defined. You can use the same local sym- bols in various blocks for different purposes. A global symbol is known in the entire user program and has the same meaning in all blocks. You define global symbols in the symbol table (Symbols object in the $7 Program folder). A global symbol begins with a letter and can be up to 24 characters long. It can also contain blanks, special characters and country-specific characters such as vowel mutations, An ex- ception to this are the characters 0Oyex» FFpex and quotation marks ("). You have to place symbols with special characters in quotation marks when programming. In the compiled block, the Program Editor displays all global symbols in quotation marks. The symbol com- ‘ment can be up to 80 characters long. ‘When you create an S7 Program, SIMATIC Manager also creates an empty Symbols table, ‘You open this and can then establish the global symbols and assign the absolute addresses. ‘You can only have one symbol table in an S7 Program. When you establish a symbol you also need a data type. This data type defines specific properties of the data that is hidden be- hhind the symbol; essentially the representation of the data contents. For example, the data type BOOL characterizes a binary variable and the data type INT characterizes a digital vari- able whose contents represent a 16-bit integer. ata er conveyor bat 1 ‘ata for conveyor bet 2 Data er parte counter var bet cotter Ceunter contol and mentor anor be corter Stat connor ba ‘Acknawedymert that pars have beer remeved ‘Acknowadge fast Figure 3.9 Example ofa symbol table 6s 3. STEP 7: Standard Tool for SIMATIC 3.411 Program Editor The Program Editor of SIMATIC Manager provides you with the Ladder Logic (LAD), Function Block Diagram (FBD) and Statement List (STL. programming languages. You cre- ate the user program block by block and can choose the programming language of your choice for every block. For “incremental” programming, the inputs are immediately checked and compiled so that only error-free blocks can be saved. For source-oriented programming in STL, you write the program with the Program Editor as a “normal” text in ASC format and generate an executable program code with the compiler included in the Program Editor. Starting the Program Editor ‘A double-click on a block in the Blocks folder starts the Program Editor, so that you can im- ‘mediately edit the opened block. You also use this procedure for a source file in the Source Files folder. You can open further blocks and source files for editing in the Program Editor. Starting the Program Editor is also possible using the Windows menu bar with START —> SIMATIC - STEP 7 LAD, STL, FBD ~> PROGRAMMING S7 BLOCKS. Selecting the programming language individually for every block Where do you select the programming language? Since you ean freely choose the program- ming language for every block, the programming language belongs to the block properties ‘You can access the properties ofthe block that is currently open with Eprt > OBJECT PROP. [ERTIES and can change the language in the General ~ Part 1 tab. You can also change the language for blocks that are already programmed. If you choose LAD or FBD, the block pro- {gram is ~ if itis possible ~ graphically displayed; representation in STL is always possible. In the EDITOR — PROPERTIES you determine which programming language is preset for a newly created block. Using Options Customize in the “Editor” tab, you choose the language. You can also establish other properties here, such as, pre-selection for comments and sym- bals. Updating or generating source files Of the basic languages, only STL is possible for source-oriented programming. However, it must be said that even blocks that are created with LAD or FBD can be saved as program sources in the ASCII format, even automatically during input. If you select the option “AU- tomatically generate Source File,” in the “Source Files” tab in Editor Properties (OPTIONS > CUSTOMIZE), then a program source file is updated or newly created if it doesn’t already exist when a (incrementally edited) block is saved. ‘You generate a program source file from already compiled blocks that are found in the Blocks folder by clicking on the “Execute” button. Program source files can be “exported,” that is, the source file in ASCII format is copied into a directory of your choice. With “Im- port,” you fetch a program source file that was created with another text editor into the SIMATIC project. 3_ STEP 7: Standard Tool for SIMATIC ‘Symbois et 'mport external symbol table eit Symbol aymbals So j_CExpant ayer tate Import external source fle qari saathe te Source- programs Export source file ——_Export source fle, Generate source fle Blocks inPS Load PLC inp ‘Programming Load PLC Blocks (online) Blocks online >in the GPU Figure 3.10 Program creation with the LAD/FBDYSTL Editor Editing blocks offline and online ‘The Program Editor edits every block in the PG data management (offline) as well as in the uuset memory of the CPU (online). If the programming device is linked with a CPU and the user program is loaded, you can see all the blocks in the CPU in the “online view.” You ci tell the difference between the online window and the offline window by the color of the ttle bar. A double-click on a block in the online window opens a block in the CPU. In order to edit the block, you transfer it into the main memory of the programming device. Using FILE > SAVE you transfer a block found in the programming device to the hard disk, with PLC + DOWNLOAD into the CPU. If the CPU is in the RUN mode, the rewritten (and called) block is edited by the CPU in the next program cycle. or 3. STEP 7 Standard Too! for SIMATIC 3.12 Programming the Logic Block Incrementally Generating and opening a block ‘You begin programming a block by opening it, either with a double-click on the block in the project window of SIMATIC Manager or with FILE —> OPEN in the Editor. If the block doesn't already exist, generate it: > in SIMATIC Manager: you select the Blocks object in the left hand section of the project window and generate a new block with INSERT —> $7 BLOCK ... (more accurately: a new block object, that you then open for editing). > in the Program Editor: with FILE —> NEW, a dialog pops up in which you can enter the block under “Object name.” You establish the number of the block in the dialog that pops up; you can enter the other block properties later on. After you close the Properties dialog, you can immediately begin with the program input in the program window. In the upper section of the block window, the Program Editor shows the variable declaration table with the block parameters and the local data, and in the lower section it shows the pro- ‘gram with all symbols and comments, provided these have been selected. In addition, the de- il window and the overview window offer further support during editing, ‘Variable declaration table for the local block-specific variables ‘You define the local block-specific variables in the variable declaration table. These are vari- ables, which you work with in the block: the temporary and the static local data as well as, the block parameters, subdivided according to input, output and invout parameters. Not every type of variable can be programmed in every logic block. If you do not use a type of variable, the corresponding table remains empty. ‘The declaration of a variable consists of the name, the data type, possibly a pre-assignment ‘and a variable comment (optional). Not all variables can be pre-assigned (for example, itis not possible to have a default setting for temporary local data). The sequence of individual declarations for logic blocks is fixed, the sequence within a type of variable is of choice. You ccan save memory by grouping binary variables into blocks of 8 or 16 and by combining BYTE variables pair-wise. The Editor stores a (new) BOOL or BYTE variable at a byte boundary, a variable with another data type at a word boundary (beginning at a byte with an ‘even address). Table 3.1 Types of variables in the declaration part ‘Type of Variable Declaration Valid in Blocks of Type Input parameter N zi Fe B ‘Ourput parameter our oi FC Invout parameter 1N_OUT zi FC ‘Static local data STAT ‘Temporary local data TEMP oB Fe B Function value RETURN ¥e : 3__STEP 7: Standard Tool for SIMATIC mH ‘Figure 3.11 Example of the program window with an opened LAD block Program window In the program window, you can see ~ depending on the default setting of the Editor — the fields for the block title and the block comment as well as the fields for the network title, the ‘network comment and the field for the program input for the first network. In the program section of a logic block, you control the display of comments and symbols with the menu options View —> DisPLay... . With VIEW > ZOOM IN, VIEW —> ZOOM OUT and VIEW —> ‘ZOOM FACTOR you change the size of the display. ‘You define the size of the graphics in the Editor Properties. Networks. An LAD/EBD program is subdivided into networks that each represent a rung or a link. The subdivision into networks is optional in an STL program, even the network length and the contents is of choice. The Editor automatically numbers the networks from | on. You can give each network a network name and a network comment. You can directly choose each ‘network with EDIT > Go 10 ... for editing. ‘You program a new network with INSERT —> NETWORK. The Editor then inserts an empty network after the currently selected network. 3. STEP 7: Standard Tool for SIMATIC Program Input To input a program code, click once beneath the network ttle or, if you have selected “Dis- play with Comments,” once beneath the gray frame for the network comment. An empty frame appears in which you can begin with the program input anywhere you like. Input of the program depends on the programming language. In the graphic languages LAD and FBD, you select program elements, such as contacts or boxes, from the Program Ele- ‘ments catalog and place them in the window, either in a rung (LAD) or atthe input or output, of a box (FBD), For STL, you enter the program line by line, instruction by instruction. You don’t need to close a block with a special instruction; you simply end the block input. ‘You can however program one last (empty) network with the title “Block End,” for example. ‘You then immediately sce the end of the block which is of particular advantage for very long, blocks. Programming with absolute addressing Absolute addressing reads and writes addresses (operands) and block parameters with the address type and the byte or bit address, If there are three red question marks in the network. instead of addresses and parameters, then you have to replace these question marks with val- id addresses. Replacement is optional for three black dots, The Program Editor checks the LAD/FBD program clements to make sure thatthe data types of the addresses and parameters coincide. You can switch off some of these type checks (in the Program Editor with OPTIONS > CUSTOMIZE, “~LAD/FBD” tab, “Type check for ad- dresses”). Programming with symbolic addressing If you would like to use symbolic names for global addresses in incremental program input, they must already be given an absolute address in the symbol table. During program input with the Program Editor, you can call the symbol table for editing with OPTIONS — SYMBOL. TABLE, in order to change symbols or enter new symbols. ‘You activate the symbol address display with View > DisPLAY > SYMBOLIC REPRESEN- ‘TATION. The menu option VIEW ~> DISPLAY ~> SYMBOL INFORMATION causes the assign- ‘ment to the absolute address to be displayed in a list for every symbol used in a network, per network. ‘During symbol input you can display a list of all symbols that exist in the symbol table with INSERT ~> SYMBOL (or use the right mouse button and INSERT -> SYMBOL) and with a ‘mouse click you can use one from the list. The list is automatically displayed if you have selected ViEW —> DisPLAY —> SYMBOL SELECTION, If the symbol table does not yet contain a symbol, you can select Ett —» SyMBOL, make the assignment to the absolute address and possibly enter a symbol comment. This new sym- bol is then accepted into the symbol table when you click on OK. 3__ STEP 7: Standard Tool for SIMATIC Program Elements catalog Ifthe Program Elements catalog is not visible, you can drag it into the screen with ViEw > OVER- VIEWS. The Program Elements catalog is found in its own window which you can “attach” to the right edge of the Editor window and also release again (each time with a double-click on the title bar of the ea- talog window). The Program Elements catalog supports you in programming in the LAD and FBD languages by offering the graphic elements which are available. In all programming languages, it displays the blocks which are already placed in the Blocks of- fine folder, as well as the already programmed ‘multiple instances and the available libraries. Network templates Just as you save blocks in a library in order to re- ‘use them in other programs, you save network ‘templates in order to copy them several times into ‘other blocks. You create a library for saving the network templates. This library contains at least Qi) Integer function ‘one S7 Program and the Source Files folder. GB Floating point fet ‘You program the networks that you want to use as 2 Move ‘a template just as “usual” in a block (of your a choice). Then you replace the addresses that are to Gl Shit/Rotate ‘change with the wild card characters %00 to %99. Gl Status bts ‘You can also design the network title and the net- @ Timers work comment variably in the same manner. Gat Word logic (Gi FB blocks BFC blocks (Ga SFB blocks ‘When you want to use the network templates, you @ SFC blocks ‘open the associated library in the Program Ele- ‘ments catalog and then select the required network template (double-click or drag it into the Editor ‘window). In the dialog that automatically appears, ‘you replace the wildcards with valid entries. The network template is then inserted in the selected network. Several networks can be combined into one tem- plate, Figure 3.12 Program Elements catalog forthe LAD programming language n 3. STEP 7: Sundard Tool for SIMATIC 3.13 Incrementally Programming a Data Block Generating a data block ‘You begin programming a block by opening it, either with a double-click on the block in the SIMATIC Manager project window or with FILE —» OPEN in the Editor. If the block does not already exist, generate it > in SIMATIC Manager: You select the Blocks object in the left pane of the project window and generate a new data block with INSERT —> S7 BLOCK —> DATA BLOCK (more exactly: block object that you then open for editing). > in the Program Editor: You get a dialog with FILE —> New in which you enter the desired block under “Object name.” ‘You can enter the block's properties right away when you generate the block or you can do itat a later stage. After you close the Properties dialog, you can begin immediately with data input. ‘Types of data blocks ‘The first time you open a new data block with the program editor, the window “New Data Block” appears; you now have to decide what type the data block is to be. There are three possibilities to choose from and you do so by clicking one of the following options: > “Data block” Create as global data block; with this you declare the data addresses when programming, the data block > “Data block referencing a user-defined data type” Create as data block with user-defined data type; with this you declare the data structure ‘as user-defined data type UDT > “Data block referencing a function block” Create as instance data block; with this, the data structure is used that you declared when ‘you programmed the associated fimction block Data block window ‘The Program Editor displays the contents of a data block in two views: © In the Declaration View (VIEW > DECLARATION VIEW), you define the data addresses ‘and you see the variables just as you have defined them, for example, an array or a user- defined data type as one single variable. > In the Data View (VIEW —> DATA VIEW), the Editor displays every variable and every ‘component of an array or a structure individually. Now you can see an additional column, Actual Value. The actual value is the value that a data address has or will have in the work ‘memory of the CPU, By default, the Editor takes over the initial value as the actual value. 3__ STEP 7: Standard Tool for SIMATIC Figure 3.13 Example of an opened data block inthe declaration view and in the data view Initial values of data addresses ‘When you program a global data block, you can give each data address an initial value. By default, the variables are, depending on data type, pre-set with zero, with the smallest value or with a blank. An instance data block generated from a function block takes over the pre- set value from the declaration section of the function block as its initial value. Ifyou generate aa data block from a user-defined data type UDT, the initial value inthe data block is the ini- tialization value from the UDT. Actual values of data addresses ‘You can individually change the actual value for every data address. For example: You ge- nerate several instance data blocks from one function block, however you want a slightly di- ‘ferent pre-setting of particular instance data for every function block call (for every FB/DB pair). You can now edit every data block with View —> DATA VIEW and enter the values valid for this data block in the Actual Value column. With EDIT — INITIALIZE DATA BLOCK, you ‘cause the Editor to once again replace the actual values with the initial values. 3. STEP 7: Standard Tool for SIMATIC 14 Source-oriented Programming of Blocks ‘You edit an STL source file in the Source Files object folder with source-oriented program- ming. An STL source file is a pure ASCII text file. It can contain the source program for one or several logic blocks or data blocks or a complete program as well as the definition of the user-defined data types. You select the Source Files folder in SIMATIC Manager and create a new source file with INSERT — S7 SOFTWARE —> STL SOURCE FILE. You can open this new file with a double- click and edit it with the Program Editor, for example. In the Editor, you can sclect INSERT —> BLOCK TEMPLATE —... to simplify the creation of new blocks. With INSERT — OBJECT ~> BLOCK, the Program Editor inserts, after the cursor, aan already compiled block as an ASCII source file into the source file. ‘You also have the opportunity to generate a new STL source file from one or several com- piled blocks using the Program Editor and the FILE —> GENERATE SOURCE FILE menu option, If you have created an STL source file with another text editor, you can fetch it with INSERT —> EXTERNAL SOURCE FILE under SIMATIC Manager into the Source Files folder. With EDIT > EXPORT SOURCE FILE, you copy the selected source file into a folder (in a directory) of your choice. In source-oriented programming, you have to observe certain rules and use certain keywords that are intended for the compiler (see tables). Compiling the STL. souree file ‘You can save the program source file any time during processing even if the program is not yet complete. Only when the source file is compiled, does the Program Editor generate exe- ‘cutable blocks which it stores in the Blocks folder. If you have used global symbols in the STL source file, then the completed symbol table must also be available during compiling. ‘You set the properties of the compiler in the “Source Files” tab in the menu option OPTIONS. > CUSTOMIZE, These properties are, for example, whether existing blocks are to be over- written or if blocks are only then to be created when the entire program source file is error- free. In the “Create Block” tab, you can set the automatic updating of the reference data dur- ing the compiling of a block. ‘You can check the syntax of the program source file with FILE —> CONSISTENCY CHECK, without compiling the blocks. You start compilation with the program source file open, using the menu option FILE —> COMPILE. All error-free blocks that are found in the program source file are compiled. A block with errors is not compiled. If warnings occur, the block is still compiled; execution in the CPU can however be faulty Called blocks must already exist as compiled blocks or must be programmed in the program source file before the call “ 3. STEP 7: Standard Tool for SIMATIC ‘Table 3.2 Keywords forthe source-oriented programming of STL logic blocks Block ype | Organization block Function lock Function urgot | ORGANIZATION. BLOCK | FUNCTION. BLOCK | FUNCTION Fincon we Header | TITLE Blok tile TITLE= Block sile ‘Block comment Block comment CODE_VERSION! KNow_How_pRotEcT | KNOW How_prorecT | KNOW_HOW_PROTECT NAME NAME. NAME Block name Block name Block name FAMILY FAMILY FAMILY Block family Block family Block family AUTHOR : AUTHOR AUTHOR : Creator Creator Creator VERSION VERSION : VERSION Version Fersion Fersion Deva VARINPUT VaR_INFUT von Input parameter Input parameter END_VAR END_VAR VAR_OUTPOT VAR_OUTPUT ua parameter Ou parameter END_VAR END_VAR VAR_IN_OUT VAR_IN_OUT Inout parameter Inout parameter END_VAR END_VAR VAR state lca dana END_VAR VARTEMP VAR_TEMP temporary loca data temporary local data END_VAR ‘BEGIN NETWORK TITLE = Nerwork ide | -Neowork comment _ STL instructions (Mine comment NETWORK wt, Block end END_ORGANIZATION_ BLOCK TEND FUNCTION. BLOCK END_FUNCTION 15 3__ STEP 7: Standard Tool for SIMATIC ‘Table 3.3 Keywords forthe source-oriented programming of data blocks Block type | Global data block ‘Global data block from UDT | Instance data block Typeet | MATAR DATA BLOCK DATA_BLOCK Header | TITLE= Block ie TITLE = Block te TITLE = Block tte PBlock comment hock comment ‘Block comment KNOW_HOW PROTECT | KNOW_HOW_PROTECT | KNOW HOW PROTECT NAME NAME: NAME Block name Block name Block name FAMILY FAMILY : FAMILY : Block family Block family ‘Block family AUTHOR AUTHOR : AUTHOR : Creator (Creator Creator VERSION. ‘VERSION ‘VERSION Version Version Version READ_ONLY READ_ONLY UNLINKED UNLINKED Declar- | STRUCT a VARname : Type °= default; | UDTwame FBname END_STRUCT inital | BEGIN BEGIN BEGIN zation” | VARname = default: KOMPname := default KOMPname °= default: te. ete. wt. Block end_[ END_DATA_ BLOCK END_DATA BLOCK END_DATA BLOCK Block sequence for souree-oriented programming ‘When you call a block and assign parameters to it during programming, the Program Editor checks whether the defined addresses also match with the block parameter, for example, with regards to data type. For that reason, the properties of the block parameter of the called block have to be known to the Program Editor. That means that you have to program the functions and the function blocks before you call them, or that you begin programming with the blocks ‘on the “lowest level” (correspondingly in the source file, place them at the beginning). The following sequence is recommended: > User-defined data types UDT, © Global data blocks, > Functions and function blocks, beginning with the blocks in the “lowest” cal level, © Instance data blocks (can also be located directly after the associated function block) © and finally, the organization blocks. 6 3._ STEP 7; Standard Tool for SIMATIC 7 fPecept with positive eage® 7f4m REM, daca. formar, //3n REAL, data format (fraction) (/ffixet stored HEL value +/eeeond value (/thixd valve FEAL y= ou on //tourth value yeieeery Bie: BOO c= mata, /faige wen bit fox ecceptainoe A Rooopt; [Moen acceptance switches to "1" FP Rage menory.bit; ‘7 )ebe Wo = *2" ater PP Jat Bnd; //3ump “hen 20 positive edge /fTeenster of the values beginning with the Last valoe “Lo Walued T ~~ Sunpatvalues //Oucput of the last value Values, Values; L Valuea) T Values, Value; ‘T ~ Value2; % — ‘TaputValue; {/receptance of the input “value Valued; Afnstange for the FB "W_Menory* (fAndiccidual detaait /feolested values. Figure 3.14 Example ofthe programming ofa function block and the associated instance data block 3. STEP 7: Standard Tool for SIMATIC 3.15 Help on Program Creation Rewiring The Rewiring function allows you to exchange addresses in individual compiled blocks or in the entire user program. For example, you can replace the input bits 10.0 to [0.7 with the input bits I 16.0 to I 16.7. Permitted operands are inputs, outputs, bit memories, timers and ‘counters as well as functions FC and function blocks FB. In SIMATIC Manager you select the objects in which you want to make the rewiring, either ‘one singular block, a group of blocks with depressed Ctrl key and mouse click or the entire user program Blocks. With OPTIONS —> REWIRE a table appears in which you can enter the old, to be replaced addresses and the new addresses. When you click OK, SIMATIC Ma- nager exchanges the addresses. Following that, an info file shows you how many changes were made in which block. Address priority In the properties window of the Blocks offline object folder, in the “Blocks” tab, you can de- cide whether the absolute address or the symbol is to have priority when you make a change in the symbol table or in the declaration or assignment of global data blocks for already saved blocks, the next time you display and save. Default is “Absolute address has priority.” This default means that when you make a change in the symbol table, the absolute address is preserved in the program and changes according to the symbol. For the setting “Symbol has priority.” the absolute address changes and the symbol remains. For example: > In the symbol table is: I 1 0 "Limit switch above" 1 "limit switch below" Limit ewitch aboves > The input I 1.0 is scanned in the program of an already compiled block: © If the assignment for the inputs I 1.0 and 11.1 is now changed in the symbol table in- to: 11.0 "Limit switch below T 1.1 "Limit switch above and the already compiled block is read out, then the following is found in the program fr the setting © “Symbol has priority” T 1.1 "Limit mitch above > “Absolute address has priority” 11,0 "Limit ewitch below" lease note that this “rewiring” does not happen automatically, because the already compiled blocks contain the executable MC7 code of the instructions with the absolute address. Only after opening and resaving — after a corresponding message — does the change take place in the affected blocks. 3. STEP 7: Standard Too! for SIMATIC Reference dat Supplemental to the program, SIMATIC Manager shows you reference data that you can use as a basis for corrections and tests. You can have SIMATIC Manager generate the reference data for the entire program all at once or you can set the creation to be made when the block is compiled. You do so in the Program Editor with OPTIONS —> CusToMIZe in the “Create Block” tab and the option “Generate Reference Data” © Cross References: The cross reference list shows the use of the addresses and blocks in the user program. You see the absolute address, the symbol (in so far as it exists), the block in which the address is used, the type of utilization (reading or writing) and lan- ‘guage-dependent information. For STL there is the network, the line and the operation, ‘where and how the address is used. A mouse click on a column title sorts the table accord- ing to the column contents. The cross reference list shows you those addresses that you selected using VIEW —> FILTER (e-g. the bit memories). When you double-click an ad- dress, the Editor opens the block shown in the line at the location where the address is found, STEP 7 then uses the filter saved “as standard” every time it opens the cross ref= erences. > Assignment: The /Q/M assignment shows which bits of the inputs, outputs, bit memory address ranges are assigned in the program. One bit is given per line. The byte’s indivi- Unused Symbols: This list shows all addresses with the associated symbols that are in the symbol table, that were not used in the program. It shows the symbol, the address, the data type and the comment from the symbol table. > Addresses Without Symbols: This list shows all addresses used in the program that were not assigned a symbol. You see the addresses and how often they were used. Please note that the reference data only exists in the offline data management; even if the function is called in an online opened block, the offline reference data are shown. ” 3. STEP 7: Standard Tool for SIMATIC 3.16 System Diagnostics Diagnostic events ‘The system diagnostics functions cover the detection, evaluation and reporting of errors and faults that occur within an automation system. For example, errors in the user program, mo- ule malfunctions, or even signal module wire breaks. Diagnostic events can be: © Diagnostic interrupts from diagnostis-capable modules © System errors and CPU mode changes > User messages from system functions. Diagnostics-capable modules make a distinction between parameter-assignable diagnostic events and non-parameter-assignable diagnostic events. Parameter-assignable diagnostic ‘events are only reported if you have set the parameters to enable diagnostics. Non-parame- ‘er-assignable diagnostic events are always reported, without the need for enabling diagnos- tics, The following happens when a diagnostic event occurs that has to be reported: > The error LED on the CPU lights up > The diagnostic event is passed to the operating system in the CPU > A diagnostic interrupt is triggered, if you have made the parameter settings to enable it (diagnostic interrupts are disabled as the default setting). Diagnostic buffer All the diagnostic events reported to the operating system in the CPU are entered in the order in which they occur, together with the date and time, in a diagnostic buffer. The diagnostic buffer is a retentive area of memory in the CPU, which retains its contents even after a mem- ory reset. The diagnostic buffer is a FIFO buffer. ts size depends on the CPU. When the di- agnostic buffer is ful, the next new diagnostic event overwrites the oldest entry. ‘You can read out the diagnostic buffer at any time on a programming device. If you open the Object Properties dialog for the CPU and choose the Diagnostics/Clock tab page, you can seleet the “Extended Functional Scope” option in the System Diagnostics parameter block to display extended diagnostic buffer entries (with all the OB calls). You can also choose whether the last diagnostics entry before the CPU goes into STOP mode is to be sent to a specially selected station on the MPI bus. ‘Writing a user entry in the diagnostic buffer ‘You can use the system function SEC 52 WR_USMSG to write a user entry in the diagnostic buffer and send it as a message to all the stations that are logged in on the MPI network. The centry in the diagnostic buffer has the same structure as a system event, like the start informa- tion for an organization block. The permitted event IDs for a user entry are event classes 8 (diagnostic entries for signal modules), 9 (standard user events), A and B (freely assignable user events). Additional Information 1 is stored in bytes 7 and 8 of the buffer entry (one ‘word) and Additional Information 2 in bytes 9 to 12 (one double word). The contents of both variables are freely selectable. 3 STEP 7: Standard Too! for SIMATIC {3} Module Infomation - CPUGAT-0 ONLINE zc} x Patt: [RccessbleNodenMPl= 2 [SmulahonGlocs CPU operaingmode STOP Statue: OK 07.10.0546 pm 11/13/93 _ STOP caused by roganeing er (08 nat loaded o 4 71005451 pm 11/13/33. Mode tansken fiom STARTUP to RUN 5 7T06.270 pm 11/13/93 Requeet for marwal warm restart 8 —GP.70.06.203pm 11/13/93 Mode tension am STOP to STARTUP. 7 GP 1005175 5m 11/13/89 New startup formation in STOP made 8 06:1315142pm 11/13/33 New startup information in STOP mode a Detads onevert 3. 17 Eventi: 1682522 Figure 3.15 Example of eniries in the diagnostic buffer of the CPU Diagnostic interrupt Modules with diagnostics capabilities can trigger a diagnostic interrupt — if the appropriate parameter settings have been made. The CPU then interrupts execution of the main program and calls the diagnostic interrupt organization block OB 82. The start information of this OB contains the module that triggered the interrupt and the diagnostic information from the ‘module itself'in 4 bytes. You can use this data to generate a message, for example. Inthe case of modules that can supply more diagnostic information, for example distributed I/O slave stations, you can use a system function (SFC) to read out the additional diagnostic informa- tion. Reading the system status list ‘The system status list (SSL) describes the current status of a PLC. You can read the contents of the SSL with information functions, but you cannot change it. You use the system function ‘SFC 51 RDSYSST to read the different parts of the SSL. The SSL contains information about the system data (CPU configuration, status ofthe pri- ority classes, communication), information about the current status of the diagnostic data in the CPU and on the modules, and information about the diagnostic buffer. 3 STEP 7: Standard Tool for SIMATIC 17 Downloading the User Program to the CPU Online mode You use the programming device to create the hardware configuration and write the user pro- ‘gram, When you do this, the S7 program is stored “offline” on the hard disk, even in its com- piled form. In order to download the program to the CPU and rum it, you have to connect the programming device to the CPU, that is you establish an “online” connection. You can also use this connection to find out the current operating status of the CPU and its associated modules with the aid of diagnostics functions. Connecting the PLC ‘There must be a mechanical connection between the MPI interfaces of the programming de- vice and CPU before you can establish an online connection. The connection is unambigu- cous if the CPU is the only programmable module connected. Ifthere are several CPUs in the MPI subnet, you must give each CPU a unique station number (MPI address). You set the MPI address in the CPU parameter assignment dialog, Before you connect all the CPUs to form a network, connect the programming device to one CPU at a time and download the ‘System Data object from the offline folder Blocks or select the menu commands PLC -> DowNLoab in the Hardware Configuration editor. The CPU is then supplied with its MPI address together with its other properties. Protecting the user program ‘On certain CPUs access to the user program can be protected with a password. Those who know the password have unrestricted access to the user program. For those who do not know the password you can define three levels of protection. You set the protection levels with the hardware configuration tool HW Config. on the “Protection” tab of the CPU parameter as- signment dialog. Downloading the user program ‘When you dawnload the complete user program (compiled blocks and configuration data) to the CPU, itis written to the CPU load memory. The load memory can be either a RAM or a flash EPROM, either integrated in the CPU or on a memory card. A micro memory card ‘can be written to in the same way as a RAM memory but it is non-volatile like a flash EPROM. If the memory card is a flash EPROM, you can record the information on it from the pro- gramming device and use it as a portable data medium. You insert the memory card in the CPU when it is switched off. When you switch on the CPU, the data on the memory card that is relevant to the running of the program is copied to the work memory of the CPU after ‘ memory reset. On certain CPUs you can also write data to a flash EPROM card inserted in the CPU. In this case, you always have to record the whole program. Ifthe load memory is a RAM, you download a complete user program by switching the CPU to STOP mode, performing a memory resct and then downloading the user program. The configuration data is also downloaded. The program in the RAM is lost aftera memory reset or if you switch off a CPU that has no backup battery (not when using a micro memory card), 2 3. STEP 7: Standard Tool for SIMATIC Downloading blocks Ifthe load memory is a RAM, you can not only download a complete program, but also mo- dify, delete or download separate blocks. To download single blocks, you select them in the offline window and choose the menu commands PLC -> DowNLOAD. Alternatively you can have the offine and online windows open at the same time and drag the blocks from one win- dow to the other with the mouse, ‘You must be extremely careful if you want to download single blocks when the system is in ‘operation. Ifa block contains calls to other blocks (which are not in the CPU memory), you must download the called blocks first. The same applies to data blocks containing the ad- ‘dresses that are used in the block you want to download. You always download the “top” block last. It is then executed in the next program cycle if it i called in the program, Just as you can download individual blocks, you can also download only the configuration data to the CPU, for example after making change with the hardware configuration tool HW Config, (System Data object in the Blocks folder). Note that the parameters for the CPU are adopted immediately, whereas the parameters for the other modules do not apply until after the next startup. Modifying blocks online ‘You can edit blocks incrementally in the online user program (in the CPU) just as you can in the offline program. However, if there are differences in the online and offline data, the editor may not be able to display the additional information stored offline, and it may be lost (for example symbolic names or jump labels). {If you modify blocks online, you are advised to save them offline on the hard disk, o prevent data inconsistency (for instance a “timestamp conflict” ifthe interface of the called block is ‘more recent than the program in the calling block). Data blocks offfine/online You can enter an initial value and an actual value for the data addresses in a data block. ‘When a data block is downloaded to the CPU, the initial values are stored in the load memory and the actual values in the work memory. Every change made to the value of a data address in the program changes the actual value. If you upload a data block from the CPU, its values are taken from the work memory, be- cause the current data is only stored in the work memory. You can view the values current at the time of reading by clicking View —» DATA VIEW. If you change an actual value in the data block and download it to the CPU again, the new value is stored in the work memory. Ifyou use a flash EPROM memory card as the load memory, the blocks on the memory card are copied to the work memory after a CPU memory reset. The data blocks then have the initial values originally programmed. The same thing happens when you switch on a CPU without a backup battery. On the S7-300 you can prevent this from happening to a data area by defining it as retentive 3 3. STEP 7: Standard Too! for SIMATIC 3.18 Diagnostics during Program Testing ‘When you have established a connection to a CPU and downloaded the user program, you ‘can test the whole program or parts of it, such as single blocks. You supply the variables with signals and values, using simulator modules, for example, and evaluate the information re- ‘tumed by your program. If the CPU goes into STOP mode as a result of an error, the CPU information functions will help you to find the cause. You test long programs in sections. For example, if you only want to test one block, you download the block to the CPU and then write a call for it in OB 1. IT OB 1 is structured so that you can test the program one section at a time starting from the beginning, you can select, the blocks or program sections to be tested by using a jump function, for example, to jump ‘over the calls or programs you don’t want to process. ‘The $7-PLCSIM optional software enables you to simulate a CPU on the programming de- vice and test your program without any additional hardware. CPU information funetions ‘The following CPU information functions are available to you in online mode. You can ac- tivate the menu commands by selecting the module (in online mode without a project) or by selecting the $7 program (in the online project window). > PLC ~» DIAGNOSTIC/SETTING > DIAGNOSE HARDWARE Overview of failed modules © PLC — DIAGNOSTIC/SETTING —+ MODULE INFORMATION General (e.g. version), Diagnostic Buffer, Memory (current occupation of work memory and load memory), Scan Cycle Time (length of the last, longest and shortest program cy- cles), Time System (properties of the CPU clock, clock synchronization, run-time meter), Performance Data (e.g. memory configuration, sizes of the address areas), Commuica- tion (baud rate and communication connections) and, in STOP mode, Stacks (B Stack, 1 Stack and L Stack) PLC = DIAGNOSTIC/SETTING — OPERATING MODE Here you can view the current operating mode (e.g. RUN, STOP) and change it, & PLC — DIAGNOSTIC/SETTING —> CLEAR/RESET CPU memory reset in STOP mode > PLC DIAGNOSTIC/SETTING — SET DATE AND TIME ‘Settings for the internal CPU clock > PLC > CPU MESSAGES Messages about asynchronous system errors and user-defined messages generated in the program with SFC 2 WR_USMSG, SFC 18 ALARM_$ and SFC 17 ALARM_SQ. > PLC DISPLAY FORCE VALUES, PLC > MONITOR/MODIFY VARIABLES Monitoring, modifying and forcing variables. 3_ STEP 7: Standard Tool for SIMATIC Diagnosing hardware Ifa fault occurs, you can use the “Diagnosing Hardware” function to obtain diagnostics in- formation about the faulty module. Connect the programming device to the MPI network and start the SIMATIC Manager. Click PLC —> DIAGNOSE HARDWARE to display a quick ‘view of the faulty modules (this is the default setting). If you want the Hardware Configura- tion tool to display full diagnostic information about the modules in online view, you can select this option in the SIMATIC Manager by clicking the menu commands OPTIONS —> ‘Customize and choosing the “View” tab. Information about the status and operating mode of the modules that are accessible online is MODULE INFORMATION and choose the “Diagnos- tic Buffer” tab. The last message displayed (number 1) is the reason for the STOP, for exam- ple “STOP caused by programming error (OB not loaded...)” The error that caused it can be found in the earlier messages, for example, “FC not loaded.” You can click the message number to display more details about the message in the lower display panel. If the message refers to a programming error in a block, you can open the block for editing by clicking the “Open Block” button. Figure 3.16 The CPU information functions “Set Date and Time” and “Module Information” 3. STEP 7: Standard Tool for SIMATIC 3.19 Monitoring, Modifying and Forcing Variables An excellent method of testing the user program is to monitor and modify variables using variable tables. You can display the signal states or values of variables with elementary data types. If you have access to the user program, you can also modify variables, that is you can change their signal states or assign them new values. Creating a variable table ‘You use a variable table (VAT) to make alist of all the variables whose values you want to ‘monitor and modify. To create a new variable table, selector open the block folder and click the menu commands INSERT —> 87 BLOCK —> VARIABLE TABLE. Double-click the VAT sym- bol to open the variable table and then you can enter the variables (addresses) whose values ‘you want to monitor anor modify. You also define the format in which you want to monitor and modify the value of the variable. This display format doesn't have to be the same as the ‘data type the variable has in the user program. ‘You can give headings to certain sections of the table using comment lines. You can also specify which columns you want to display. You can change variables or the display format and insert or delete lines at any time. You save the variable table in the Blocks folder with the ‘menu commands TABLE —> SAVE. ‘Switching a variable table online and setting trigger conditions To work with a variable table you have created offline, connect the programming device to a CPU and switch the variable table to online mode. You set trigger conditions ~ separate conditions for monitoring and for modifying ~ to specify the time when the CPU is to read the values from the system memory or write them into it. For example, if you specify Start of Cycle as the trigger point for modifying, the variables being modified will be given the specified value before cyclic processing of the program begins, and if you specify End of Cycle as the trigger point for monitoring, the values displayed for the variables will be the values at the end of cyclic processing. You can choose to perform the monitoring and mod- ifying functions once only or every cycle ‘Monitoring variables ‘Select VARIABLE > MONITOR to activate monitoring of variables. The variables in the VAT are then updated atthe time specified by the trigger conditions you have set. If you have cho- sen to monitor every eycle, you can watch the values changing on the screen. Modifying variables When you select VARIABLE —+ MoDtry, the specified values are downloaded to the CPU at the time specified by the trigger conditions. You enter the values you want to use in the “Modify Value” column beforehand, only for the variables whose value you want to change. You can turn values you have entered into comments by preceding them with a double slash and they will then be ignored when modifying. 3._ STEP 7: Standard Too! for SIMATIC 1@VATIT0~ 57 Book\G7 Staion 314 Wastes CACPU 314 (ION) ONLINE zit Figure 3.17 Example of a variable table Foreing variables ‘On CPUs with the necessary capability you can specify fixed values for certain variables, ‘which cannot then be changed by the user program (“forcing”). Forcing is permissible in any operating mode of the CPU and is executed immediately. The first thing you need for forcing is a variable table. You create a variable table, enter the addresses you want to force and es- tablish a connection to the CPU. You can now copy some or all of the addresses from the variable table to the forcing window or enter new addresses. To stop forcing you have to de~ [ete the relevant force job. You cannot quit the Force function by closing the forcing window or breaking the online connection. Enabling peripheral outputs In STOP mode the output modules are usually disabled. The Enable Peripheral Output func~ tion allows you to cancel the output disable, so that you can change the states of the output modules even when the CPU is in STOP mode. You modify the outputs using a variable ta- ble. You can only modify the peripheral outputs assigned to a CPU. Application example: checking the wiring of the outputs in STOP mode without a user program. CCreate a variable table and enter the peripheral outputs (PQ) you want to modify init. Switch the variable table to online mode and switch the CPU to STOP mode if it isnot in this mode already. Select VARIABLE ~> ENABLE PQ to deactivate the output disable, The outputs now have signal status “O” or the replace or force value. Select VARIABLE —> ACTIVATE MODIFY ‘VALUES to modify the peripheral outputs. You can change the modify values and change the states of the outputs again. ‘You deactivate the function by pressing the ESC key. The output disable is reactivated and the module outputs are again set to “O”, the replace value or the force value. 87 3__ STEP 7: Standard Tool for SIMATIC 3.20 Program Status ‘You can test the user program direct by monitoring the program status. The Program Editor then shows you the following: © InLAD and FBD: the binary program flow and the digital values within a network © In STL: line by line the result of logic operation, the status of the binary statements and the contents of the registers, ‘The block containing the program you want to testis in the user memory of the CPU and is called and processed there. You open this block by double-clicking the symbol for the block in the online window of the SIMATIC Manager, for example. The editor is started and dis- plays the program in the block. You select the part of the block you want to test and start ‘monitoring the program status by clicking the menu commands DEBUG > MONITOR In LAD and FBD the binary signal flow will now be displayed in the block window and you can observe the changes. You can make settings for the display by clicking OPTIONS —> Cus- ‘TOMIZE and choosing the LAD/FBD tab page. In STL you will see the signal states of the addresses, the result of logic operation and the register contents, which you can select by clicking the menu commands OPTIONS — Cus- ‘ToMizé and choosing the “STL” tab page. You can also modify variables when monitoring the program status. Select the address you ‘want to modify and click DEBUG —> MODIFY ADDRESS. ‘Monitoring the program status extends the cyclic processing time of the program. You have a choice of two modes of operation for the test. In Test Operation you can use all the debug- ‘ging function without restrictions, and in Process Operation the extension of the scan cycle time is Kept to a minimum, which may result in restrictions. ‘Testing statement-by-statement in single-step mode {In STL you can test the program statement-by-statement in single-step mode if the CPU sup- ports this function. In this case, the CPU is in HOLD mode, and the peripheral outputs are switched off for safety reasons. You can use breakpoints to stop the program anywhere you like and test it step-by-step. You can only use single-step mode if you have selected Test Op- eration To set a breakpoint, position the cursor in the relevant statement line and select DEBUG —> ‘SET BREAKPOINT. To start the test, select DEBUG —> BREAKFOINTS ACTIVE. The breakpoints are then downloaded to the CPU and activated. If the CPU is not already running, it starts up and goes into HOLD mode when it comes to a breakpoint. Then the current register contents at the statement are displayed in a separate window. You can now nun the program one line at a time by selecting DEBUG —> EXECUTE NEXT STATEMENT. The CPU stops executing the program at each statement and displays the reg- ister contents. When you come to a block call, you can continue processing in the block called by selecting DEBUG — EXECUTE CALL. If you select DEBUG —> RESUME, the program runs at the normal speed until the next breakpoint is reached. 88 3__ STEP 7; Standard Tool for SIMATIC Metwenk 5: control belt motor “toed” stop" */tmalei® "Bede wot" 3. STEP 7: Standard Tool for SIMATIC 3.21 Testing User Programs Offline with S7-PLCSIM The S7-PLCSIM optional software enables you (o test the user program offline without ad- ditional hardware. $7-PLCSIM simulates a PLC (that is a CPU with modules) on the pro- ‘gramming device. The CPU is not specified. You can run user programs for any CPU with S7-PLCSIM. It also makes no difference which programming language the blocks are writ- ten in ‘When you have installed S7-PLCSIM, itis integrated into the SIMATIC Manager. When you have finished writing the user program, or even only the block you want to test, you start S7- PLCSIM by selecting the menu commands OPTIONS —> SIMULATE MODULES or elicking the corresponding icon. ‘The $7-PLCSIM user interface ‘The S7-PLCSIM user interface appears in a separate window. In the standard setting, this window contains a CPU subwindow, which shows the controls and LEDs of a CPU. You just click with the mouse to switch the simulated CPU to the RUN and RUN-P modes and back to STOP or perform a memory reset on the CPU. Ifthe simulated CPU goes into STOP mode as.a result of a programming error, for example, this is indicated by the group error LED and the STOP LED. ‘The plant to be controlled can be represented in the subwindows for inputs and outputs. Each subwindow can represent a bit, byte, word or double word address in different data formats. ‘You can use these subwindows, for example, to simulate the signal states of inputs (by click- ing them with the mouse) and observe how the outputs are set and reset You specify digital values in the correct format for the data type. A slider enables you to ‘ulate values that are constantly changing, such as analog values. You can change the position of the sliders using either the mouse or the arrow keys. You can also monitor and modify internal CPU addresses in separate subwindows. There are subwindows for bit memories, timers, counters and general variables. In a variable subwin- dow (inputs, outputs, bit memories or general variables) you can enter any shared addresses, including specific data addresses (for example DB62.DBB15) ‘You can select OPTIONS —> ATTACH SYMBOLS to assign a symbol table to S7-PLCSIM, to enable you to display symbolic names for the variables (by selecting the menu commands Ormions — SHOW SYMBOLS). You can also edit the assigned symbol table from $7- PLCSIM. Downloading and running a program ‘When you start $7-PLCSIM, the programming device is online to an imaginary CPU. You can now download the user program to the user memory of the CPU by clicking the menu commands PLC - DOWNLOAD ~ as you would with a real CPU. If you switch to online view in SIMATIC Manager, you will sce the blocks that have been downloaded to the CPU in the online window. Then you click RUN or RUN-P in the CPU pane, S7-PLCSIM pro- cesses the downloaded user program like a real CPU. 3__ STEP 7: Standard Tool for SIMATIC ‘Srulsin Et font BLC Execute Yew Optons edow Heb 2/2} Dislej ele} Beals) CPU window with LEDs and switches | Variable window | for binary signals Vaable window wale [Vaible window |r ig sana GI ‘Subwindow with | accumulators, address registers and status word Figure 3.20 Testing programs with PLCSIM If a programming error occurs, for example access to a non-existent address, S7-PLCSIM. responds by calling synchronous error organization block OB 122. If this block is not in the program, the CPU goes into STOP mode. You continue just as you would if you were testing, the program on a real CPU, for example by clicking PLC -> MODULE INFORMATION in. SIMATIC Manager to read out the diagnostic buffer and find out the cause of the stop. ‘You test the user program using the variable table and the program status monitoring func- tion, with the additional facility of single-step mode with breakpoints in STL. The CPU si- ‘mulated with S7-PLCSIM behaves like a real CPU here, too. Other functions 'S7-PLCSIM simulates a neutral CPU with a selection of system functions and system func- tion blocks. It supports most priority classes (organization blocks). Only one PLC can be simulated at a time. $7-PLCSIM can save the window arrangement and display it again the next time you want to work with it. ‘The S7-PLCSIM program $7ProSim is an ActiveX control for use in applications that sup- ort the Microsoft OLE/COM technology. This control enables you to simulate processes with S7-PLCSIM. a 3. STEP 7: Standard Tool for SIMATIC 3.22. PID Control with SIMATIC Software ‘There are a variety of ways of implementing PID controls with the SIMATIC automation system, For example, the FM 355 and FM 455 function modules perform pressure, temper ature and flow control functions independently of the user program in the CPU. The opera- ting system of some CPUs, such as the CPU 314C, includes PID controllers, which can be called in the user program as system function blocks (SFBs). They have the same function- ality as the function blocks in the Standard PID Control and Modular PID Control runtime software packages presented in this section. Standard PID Control ‘The Standard PID Control software package consists ofall the blocks you need for PID con- trol, together with the necessary tool for parameter assignment. With Standard PID Control ‘you can incorporate continuous-action PID controllers, step controllers and pulse controllers into your user program. The controllers have a predefined structure, and you can activate or deactivate individual functions, such as scaling, smoothing and limit value monitoring, with software switches. Each control loop stores its internal data in its own instance data block. Ready-to-use application examples, such as a fixed-setpoint controller with discontinuous- action output for integrating actuators, make this runtime software particularly easy to use, ‘You use the parameter assignment tool to assign parameters in graphical form in a block di- gram, to monitor the control loops (curve plotter with up to four variables, loop display of the relevant controlled variables), and to optimize and operate the controllers. Executable on $7-300 (CPU 313 and higher), $7-400 and C7, ‘Modular PID Control ‘The Modular PID Control software package consists ofall the blocks you need for PID con- trol, together with a startup tool. This package is designed for implementing complex control structures by interconnecting the blocks supplied. A number of application examples illus trate the use of modular PID control. You use the startup tool to monitor the control loops (curve plotter with up to four variables, Joop display of the relevant controlled variables), and also to optimize and operate them, Executable on $7-300 (CPU 313 and higher), S7-400 and C7. PID Self-Tuner The PID Self-Tumer software package adds an automatic tuning function to PID controllers in an installed system (initial tuning and continuous adjustment). This function is suitable for temperature, filing level and flow controls with a stable, asymptotic transient response, unipolar actuating signal, moderate delay times and moderate process gain. Executable on $7-300 (CPU 313 and higher), S7-400 and C7 in conjunction with integrated PID controllers, Standard PID Control, Modular PID Control, FM 355 and FM 455. 9 3_ STEP 7: Standard Too! for SIMATIC Fuzzy Control++ The Fuzzy Control++ software package consists of all the control blocks you need, together with a configuring tool. Fuzzy Control++ enables you to implement good-quality, fully au- tomatic control systems for processes that cannot easily be described in mathematical terms. In fuzzy control systems, the existing knowledge gained from experience with the behavior of the process is replaced by rules that qualitatively describe the process behavior. This is done in two steps: > The instantaneous values of the relevant input and output signals are characterized by “fuzzy” definitions and quantification of properties such as “a lot", “a little”, “warm”, “ice cold”, “fast”, “slow”, and so on. > The knowledge gained from experience with the process is formalized in “If-Then” rules. Processing is performed as follows: The instantaneous input values are translated into de- agrees of truth (“fuzzification”), logic operations are performed on the degrees of truth (“If” part of the rule), the degree of truth for the affected output is determined (the “Then” part of the rule, or the inference”), and the numerical output value is calculated by weighting the resulting membership functions and computing the centroid (“defuzzification”). ‘The configuring tool is menu-driven and enables you to assign parameters to the fuzzy con- trol system (draw up the “If-Then” rules and define the value ranges for the input and output signals), simulate the input signals using a curve generator, monitor controller activity in bar chart form, display the characteristics of the fuuzzy control system in three dimensions and ‘monitor up to four input and output signals (curve plotter, with facility for saving the data on the hard disk for further processing with standard applications). Executable on 7-300 (CPU 314 and higher) and $7-400 in conjunction with WinCC; also in combination with conventional PID controllers and neural networks. NeuroSystems ‘The NeuroSystems software package for neural networks consists of the standard blocks re- uired for control, together with a configuring tool. NeuroSystems is ideal for controlling or simulating processes when you know little or nothing about their behavior. From existing. ‘measured values NeuroSystems learns to recognize the typical process behavior or signifi- cant features of the measured values, for example by pattern recognition. The functions you can perform with the configuring tool are: assignment of parameters to neural networks (reading in the learning data and defining the value ranges), simulation of the input signals using a curve generator, three-dimensional display of the neural network. characteristics and monitoring of the response over time of up to four input and output sig- nals (curve plotter with facility for saving the data on the hard disk for further processing with standard applications). Executable on S7-300 (CPU 314 and higher) and S7-400 in conjunction with WinCC; also in combination with Fuzzy Control +. 93 3. STEP 7: Standard Tool for SIMATIC 3.23 Documentation in Wiring Manual Form with DOCPRO ‘The DOCPRO optional software simplifies the generation and management ofthe documen- tation for your system. DOCPRO enables you to: > Put the data to be printed together in any order to produce wiring manuals of uniform ap- pearance with uniform footers > Design the layout to DIN 6771 (standard for technical documentation) using the tem- plates provided or to suit your own individual requirements > Number drawings automatically or manually > Create document indexes automatically Examples of data you can document with DOCPRO are program code in the relevant pro- ‘gramming language, symbol tables, reference data, configuration tables, global data table ‘and connection table. Generating system documentation After installing DOCPRO, insert an object called Documentation in the project folder. When ‘you create a new project, this will then happen automatically. Double-click Documentation to start DOCPRO. In the left-hand side of the documentation window you will see the struc~ ture of the system documentation in the form of wiring manuals and job lists and on the right-hand side you will sce their contents. The DOCPRO Wizard helps you create new sy- stem documentation. You can change the layout and se- quence of the documentation at any time. You select the layout by clicking Ormions —> Customize .... You add ‘new items to the documentation by clicking INSERT —> WIRING MANUAL, INSERT — JoB LIST, INSERT —> PRINT De costo OBJECT and INSERT —> COVER SHEET. Bh Osiensas ‘The documentation can consist of sev- Syme 4 Sure? ral wiring manuals, which can each contain several job lists, in which the print objects (e.g. symbol table, com- piled blocks, eross reference list) are listed in the order in which they are to bbe printed, ‘When the printing process is complet- ed, a document index is printed. This is a table showing the objects that have been printed. You can specify a layout for the document index in the same —“#e*\ [wee J _- | way as for any other print object. Figure 3.21 Using the Wizard to select an object for printing 3__ STEP 7: Standard Tool for SIMATIC Se et oa aa Sige neoey Blt fo" gmerste Seavance’ guts Block for Te Si Figure 3.22 Example ofa wiring manual printout The illustration shows an example of a wiring manual printout for OB 1 with DIN A4 layout in portrait format with footer. You can also choose DIN A3 in portrait or landscape format or design your own layout. 3. STEP 7: Standard Tool for SIMATIC 3.24 Telephone Network Connections with TeleService ‘You use the TeleService optional package to connect a programming device or PC to a ‘SIMATIC PLC via the telephone network. This enables you to manage, control and monitor remote machines or plants from a central point. ‘TeleService runs under Microsoft Windows operating system on a programming device or standard PC. The connection can be made from either a physical or a virtual COM port. At the PLC end youneed a TS adapter, which establishes a connection to an MPI or PROFIBUS subnet. TeleService is modem-independent and works with all commercial Hayes-compati- ‘ble modems installed in the Windows Control Panel. Depending on the modem, you can use ‘an analog or digital telephone network or a radio network ‘You implement TeleService operation as follows: > Action at the PG/PC end Install TeleService, install a local modem in the Windows Control Panel, make the se- {tings for the PG/PC interface, select the TeleService and modem properties for optimum interaction. © Settings at the plant end Assign parameters to the TS adapter. > Using TeleService Create a “telephone book.” Establish a connection and perform the maintenance work at the plant using the functions provided by STEP 7, for example error analysis and correc tion, upgrading and updati ‘You assign the parameters to the TS adapter using the direct connection. You can also use the direct connection to the TS adapter to connect a PC to an MPI or PROFIBUS network using the COM port. ‘The SIMATIC PLC can also take the initiative in establishing a connection. At the PG/PC ‘end you need the PRODAVE MPI optional package, which exchanges data between a SIMATIC PLC and a standard PC program, like MS Excel. Wioing [pro suman pLe winster7 EJ ay Lahn vi oT kp poem — ScaeConpmrotm sana IT) ‘Sark or ROP swe Schge wi SIMATIC PLE. o I do this PRODAVE MPI must be installed = cn the PC. Depending on the mae, an analog or Modem ‘gjal telephone netwek of thera network.” Macom Figure 323. Controlling SIMATIC PLCs with TeleService 4 The Programming Languages 4 The Programming Languages ‘You use the SIMATIC programming languages to write your user program. You have a choice of several programming languages and programming methods to suit your particular needs or preference. Three of the programming languages (LAD, FBD and STL) are includ- ed in the basic STEP 7 package. The others are available as optional software. ‘The graphical programming languages are especially suitable for representing bit logic, in a form either modeled on a relay ladder logic diagram (Ladder Logic LAD) or resembling an electronic circuit diagram (Function Block Diagram FBD). The textual language Statement List STL also enables you to handle complex variables or use indirect addressing, S7-SCL is a textual programming language for programming complex algorithms and han- dling large quantities of structured data. You write separate user blocks in S7-SCL. just as you do in the basic programming languages LAD, FBD and STL. You can also write an en- tire user program in S7-SCL. ‘You use CFC to interconnect blocks, rather like drawing a flowchart. The blocks can be writ ten in any language (LAD, FBD, STL or SCL). CFC needs SCL for generating executable blocks. S7-GRAPH is a programming method for sequential control systems. You can write the con- ditions enabling transition from one step to the next in LAD or STL. Alternative or parallel ‘branching extend the scope of the linear execution of consecutive steps. Finally, $7-HiGraph allows you to express the control problem in the form of a state graph. ‘The emphasis here is not on linear execution, but on the varying sequences of states and tran- sitions typical of asynchronous processes. crc Optional Software Costinuans’” | CFC Funotion Chait} Sty ‘$7-SCL ‘'S7-GRAPH S7-HiGraph Siructured Sequential State Control Language | Control Graph sTL Lan FBO Statement List | Ladder Logie Function Block Diagram STEP? Platform with SIMATIC Manager Figure 4.1. The STEP 7 programming languages ” 4_The Programming Languages 4.1. The Basic Programming Languages LAD, FBD and STL ‘The STEP 7 Standard Too! includes a program editor for the programming languages Ladder Logic (LAD), Function Block Diagram (FBD) and Statement List (STL). These program- ming languages conform to standard IEC 1131-3 (DIN EN 6.1131-3). You use these pro- gramming languages to write your user program. LAD and FBD are graphics-oriented languages; in LAD you create control solutions by con- necting contacts in series and parallel arrangements and in FBD by interconnecting AND and OR boxes. STL is a text-oriented language; you describe the control task in the form of alist ‘These programming languages not only allow you to work with binary signal states. You can also easily process digital values in different number formats in any of the languages. For example, you can compare both whole numbers and fractions or perform the basic arithmetic ‘operations on them. Each language also provides functions that enable you to structure your program to suit your own requirements. This means that you can write an entire user pro- ‘gram in any one of the programming languages. Bit logic operations and Set/Reset functions enable you to program a PLC to perform the basic functions of contactor of relay controls or hard-wired electronic circuits. For more complex tasks you can process digital values with comparison functions, arithmetic and ‘mathematical functions, conversion and shift functions and word logic. Jump functions al- low you to adapt the program flow to suit your needs. ‘You write your user program in sections called “blocks.” Organization Blocks form the in- terface between the operating system and the user program. When certain events occur, the ‘CPU operating system calls these blocks, which mark the beginning of the program in a par ticular priority class, or level of execution. Blocks of the types Function Block and Function ‘can be called in the organization blocks and then executed. All the programming languages provide functions for calling blocks. The graphical pro- gramming languages use boxes with inputs and outputs for passing values to the block called and returning values from it, STL has the CALL instruction, which calls a block and uses a parameter list to pass the values to and from the block called. In addition to the other advantages of block programming, such as clear, self-contained and parameter-assignable program sections, this method also allows you to choose which pro- ‘gramming language you want to use for each block. This means that you don’t have to stick to the same programming language throughout your user program. For instanee, you can write the blocks for bt logic operations in LAD because you like the clear graphical arange- ‘ment of the contacts, and write the blocks for processing the data in STL because you can use address registers very effectively to address the data in the user program indirectly. Each block can call other blocks writen in a different language, ‘You can always convert blocks you have written in LAD or FBD into STL. Under certain conditions you can also view blocks written in LAD in FBD and vice versa; program sec- tions that cannot be represented in graphical form are then displayed in STL. The LAD, FBD_ ‘or STL program can be “decompiled.” This means that you can always generate a legible block from the machine code, for example if you want to read the user program in a CPU without offline data. 98 4. The Programming Languages a Ladi Lg LAD) wig eo pat et mpus Oot polaron pier patent ser Ls es trang ey aero dig. The ba bra Sl screencast Vt parallel arangement of eoniacts. Each oo Tagine co Coe ‘horace ve In Funetion Block Diagram (FBD) writ ‘ng the program for your control problem is like drawing an electronic circuit dia- ‘gram, You implement bit logic operations bby interconnecting AND and OR functions - and terminate them with simple boxes. npus: fat Qututt ‘Complex boxes are used for logic opera- nots Cl =] tions with digital variables. Anus neta Int In Statement Lis (STL) you write the input {OR tection program for your contol problem ithe ule ron form ofa list. Each line represents one Inputs staemeat consisting of an insrcton that defines the function te be performed, topu {AND tuncon and, if necessary, an address on which aie the function isto be performed. Input Output Oust sasignment "~gox>~ogor Figure 4.2 The basic programming languages Ladder Logic, Function Block Diagram and Statement List With the graphical programming languages you write your user program “incrementally” ‘This means thatthe program editor checks your entries as you make them. When you save a block, it is automatically compiled into machine code. You can only save blocks that do not contain errors. STL allows both source-oriented and incremental programming. You can create a program. source in STL. This is a text file with characters in ASCII format. You can save a program source at any time, even if it not finished or contains errors. You can also write @ program source using an external text editor and “import” it into your user program. To generate the machine code, you have to compile the program source. ‘You test your program in the programming language you used to write the block. In LAD you can observe the power flow in the rung and in FBD you can display logic operations that are true in a different color. STL allows you to test the instructions in the program line by line and observe the binary and digital values, 4 The Programming Languages 4.2. Binary Functions ‘The binary functions perform Boolean algebra operations on bit variables (signals). They process and store signals of data type BOOL. This is the format for a bit that can assume the two states “1” and “0”, of “ON” and “OFF”. A logic operation is performed on the input sig- nals, and the binary outputs (which are connected to contactors, valves or lamps, for exam- ple) are then set or reset. Logic operations ‘The diagram shows the results of the logic operations. Imagine that two momentary-contact switches are connected to the inputs with the names “Input!” and ‘“Input2”, and a lamp is connected to each output. In an AND operation or a series connection (“Output”) the lamp will be lit when both switches are operated. In the language of control engineering this is expressed as follows: If both inputs have signal state “1”, the signal state at the output is also “1", The logic operation is “true”. An OR operation or a parallel connection between con- tacts is always true if atleast one of the inputs has signal state “I”. An AND or OR function cean also have more than two inputs. All the inputs are then checked and the AND or OR op- eration is performed on all of them. ‘The third function in the diagram, the Exclusive OR function, is only available in FBD and STL. In LAD you can implement this function using a combination of series and parallel connections. If an Exclusive OR function has several inputs, it is true if an odd number of inputs have signal state ‘You can also combine binary functions. For example, you can OR the outputs of two AND. functions to program a complex circuit. In the graphical languages you program the required combination by means of the geometrical arrangement, in STL you use bracket nesting to determine the order in which the functions are processed. A rectangle means thatthe address tnputt STs signal state “1 (eg. the switch has been operated). No rectangle opt? — STL the adress has signal state “0 AND function, ‘An AND function is only tre if al Series circuit its inputs ave signal state “1 Output OR function, ‘An OR function is always true when Parallel eireuit at Teast one of its inputs has signal Cups ate”, Exclusive OR ‘An Exclusive OR function is only function te if both of its inputs have diffe- Outputs IL ent signa sates. Figure 4.3. Binary logic operationst 4. The Programming Languages Negation All inputs and outputs of a function can be “negated,” that is their signal state changes from “1” to “0” or from “0” to “1” when the fanction is processed. You need this, for example, ‘when you want to do something with a “zero-active” signal, e.g. when you want an output to have signal state “1” when two momentary-contact switches are not operated, that is they both have signal state “0”, ‘Output instruction The result of a logic operation is known as the RLO (Result of Logic Operation). Itis stored and processed in the CPU and can also, for example, be assigned to an output. Ifthe RLO = “1” —if the logic operation is true ~ this output also has signal state “1” (the output is “set”). If the RLO = “0”, the output also has signal state “0” (it is “reset”). An Output instruction {in LAD: coil, in FBD: simple box) always assigns the address that appears above it the same signal state as the RLO. Set/Reset function A Set/Reset function is executed if RLO =I” and retains the signal state of an address. With the Set function the address is set and remains set ifthe Set function is processed again with 0 = “0. The Reset function resets the address if RLO = “I” when itis processed. In the graphical languages the two functions can be combined in an SR flip-flop (Dominant Reset) and an RS flip-flop (Dominant Set). Dominant means that only the Set function or only the Reset function is performed if RLO ="1” at both function inputs. Edge evaluation Further scope is provided by edge evaluation functions, which indicate a change in the state ofa signal. This enables you to detect a transition from signal state “0” to “I” or from “I” to “0” (the moment when a signal is switched on or off) and use it in a logic operation. An edge is detected in the program by means of a comparison. The “old” RLO is stored in an “edge memory bit” (a static address) and this is compared with the “new” RLO. If the old RLO is “0” and the new RLO is “1”, this indicates a rising edge or “positive transition” (switching on). If the opposite is true, a falling edge or “negative transition” is detected (switching off). Sat ‘fl <___ Reset a Output iets dominant 3 = Otitput Rese dininent > — IL J Figure 4.4 The “Dominant Se” and “Dominant Reset” Functions 101 4 The Programming Languages 4.3 Digital Functions The digital functions operate on variables with digital values, such as speeds, current values, numbers of parts, etc., and extend the functionality of the programmable controller. The for- mats mainly used for storing and processing these values are the data types INT (Integer), DINT (Double Integer) and REAL (value with places after the decimal point). ‘Comparison The comparison functions compare two dial variables of daa types INT, DINT or REAL functions tofind out whether they are equal, not equal, greater than, greater than or equa oles tan, Jess than o equal to one another. The result ofthe comparison is a binary val (result of Jogi operation RLO) and can be saved o processed with binary functions Le), Repu vatilel L Input_ealued 1 tmput_vatuez —|IN2 Fo Resale 0) mewatt: ‘Arithmetic fune-The arithmetic fanctions perform the Basi arithmetic operations addition, subtraction, mal tons tiplication and division on two values. You can use the arithmetic functions on variables of data types INT, DINT and REAL, & Enpot_vaduet Input_valiuel — IN‘ ae Nes ee Input_value2—{IN2___ OUT b= Restiak -. Foo okeipane. ADD_| ‘Mathematical ‘These include the functions sine, cosine, tangent, ac sine, are cosine and are tangent, as functions well as square, square root, exponentiation and logarithms. 1B, Thput_valve: SIN ae a Yopat_vaive—{IN ouTpe meats FP Conversion The conversion functions change the data type ofa variable. For example, functions number with decimal places (REAL) to a whole number (INT) by rounding up or down. so 25 Anpot_vakudt Input_vatue—[IN OuTh=Resure. SOM Sain "The valucs of variables can Be sified to the right or left bit By bit The bits that are pushed functions out are citer lost or are inserted atthe other end of the variable (Rotate fumetions). %, Shite notber LW a rapee_vatue fin ois sie_eae mitemmbes—(N___outfthieas ° Seb agoase Digital variables with #, 16 or 32 bits can also be ANDed, ORd or XORed with one anoth- ‘operations cr 1 anges, vat Wan WT = repet_vatuet in 2 Snpst_vatues Inpet_valued —[IN2__OUT Ps das Figure 4.5 The digital functions shown graphically and in STL. 102 4 The Programming Languages 4.4 Program Flow Control All the programming languages include functions for controlling program flow. The most important are the block calls. These call blocks and cause them to be executed. You can use ‘block parameters to make the functions programmable, so that you can use the blocks several times with different values. You can also make the block calls dependent on certain condi- tions. In the graphical languages you use the EN (Enable Input) input to do this, and in STL. ‘you use a Jump function to jump over the CALL instruction and its parameter lst. In the ‘graphical languages the block called uses the ENO (Enable Output) output to report a group error. In STL the BR (Binary Result) bit serves the same purpose. This bit is set in the called. block and can be checked after the call. ‘You can control the flow of the program within a block using Jump functions. The Jump functions in the graphical languages are dependent on the RLO (Jump if™1” or Jump if“0”), ‘but you can check any status bit and thus make its signal state the RLO. STL has Jump func- tions that are always executed, Jump functions dependent on the RLO and Jump functions ‘that check status bits direct. The Jump function needs a label to mark the place where exe- ccution of the program is to continue after the jump. In the graphical languages this is always at the beginning of a network, in STL it can be before any instruction. he eet eet a Figure 4.6 Examples of Jump functions and block calls in LAD and STL. 103 4. The Prograinming Languages 4.5. Ladder Logic LAD LAD program elements In the Ladder Logic programming language (LAD) you write the program for your control application by arranging graphical program elements. These chiefty consist of contacts, coi and boxes, which you link together in a form resembling a relay ladder logic diagram. You start programming a “rung” in your diagram with the left-hand power rail. You select the point on the rung where you want to insert a program element and choose the element you want ~ by pressing the corresponding function key, clicking the relevant button in the ‘toolbar or selecting the element from the Program Elements catalog, whichever method suits ‘you best. You terminate each rung with a coil ot a box. You can also end a rung with a “T branch” leading to other coils and boxes, each with its own preceding logic operation. The LAD program editor creates a network based on a “main rung,” This is the top rung, which starts with the left-hand power rail and must be terminated with a coil or a box. You ‘can position any of the LAD program elements in this main rung. In parallel branches there are sometimes restrictions on the choice of program elements allowed. You must not “short- circuit” an LAD program element with an “empty” parallel branch and power must not flow through a program clement from right to left (a parallel branch must end in the same branch. in which it begins). Most of the program elements require you to enter addresses (variables). The best method is to arrange all the program elements first and label them afterwards. You can either use abso- tute addresses, for example I 1.0, or symbolic addresses, for example “Manval_mode™. Each “network” consists of one rung, that is a logic operation terminating in a coil or box. If you want to enter another rung, you generate another network after the network currently selected. You can give each network a title and enter a network comment to explain the func- tion of the network (rung) in detail Contacts You use contacts to check the signal states of binary addresses, such as inputs. By arranging the contacts in series or parallel you can perform logic operations on the signal states. There are two types of contact: Normally Open Contacts and Normally Closed Contacts. In a nor- ‘mally open contact the address entered above the contact is checked for signal state “I”; the contact “closes” if the address has signal state “1” (power flows when the contact is activat- ed). A normally closed contact checks the address for signal state “0”; the contact “closes” if the address has signal state “0” (power flows when the contact is not activated). Contacts are not only used for checking inputs. You can use them to check any bit address, including, for example, status bits. You can use the NOT contact to negate the result of logic ‘operation. If the RLO is “1” before the contact (“power” can “flow"), the NOT contact turns it into “0” (after the contact there is no “power flow”). 4. The Programming Languages Contacts Colts Bi address Bh edcress onal open cont Simpl co cy sesame Beare aml bt aaaress cal hosed co ‘ Col wit adi ir) function (eg Set, Reset, r (Contact with spectit fanction edge evaluation or jump Label ooueaed —nor}— any —(e)— Boxes Stundasd boxes without ENENO Standard bores with ENIENO Block boses eg tnew antes) (eg-ehnctc hection) (eg. Aetna bac cl) Times adress bam PULSE AOD 4s at EN ENO yo fins our ecof— Sine er Figure 4.7 Program elements for Ladder Logic LAD Coils. You use coils to set or reset bit addresses, such as outputs. Simple coils set the bit address when power flows to the coil (RLO =I”) and reset it again when the power stops flowing, There are coils with letters or symbols in them, which have special functions, such as Set and Reset coils. You can also use coils to control timer and counter functions, call blocks ‘without parameters, perform jumps to a different place in the program, and 50 on. Boxes Boxes are used for program elements with non-binary functions. LAD has two types of “standard boxes”: boxes without EN/ENO parameters (¢.g. SeUReset functions, timers, ‘counters and Compare boxes) and boxes with EN/ENO parameters (e.g, MOVE, arithmetic. and mathematical functions, and data type conversion). If you call a logic block, for example 1 function block, the LAD program editor also displays the call as a box with EN/ENO pa rameters. EN/ENO parameters ‘You use the EN input (enable input) to control execution of a box. The function is only exe- cuted if there is “power flow” to this input, There is “power” at the ENO output (enable out- put) ifthe box has been executed without error. You can connect boxes with EN and ENO in series to ensure that a box is only executed if the previous box has been executed correctly, ‘or to enable you to use one contact to switch on and off a “main sung” containing boxes con- nected in series. os 4. The Programming Languages Series and parallel circuits in LAD ‘A nung can consist of only one single contact or it can contain a large number of contacts ‘connected to one another. The example shows a series circuit with the normally open (NO) contact #Manual_ON and the normally closed (NC) contact #Automatic_mode. Power flows through the rung when #Manual_ON has the signal state “1” and #Automatic_mode"0". Par- allel to this is another series circuit with the NO contacts #Auto_ON and #Automatic_mode. ‘These two series circuits connected in parallel lead to the Set input of the Set/Reset box. ‘The Reset input is connected to two contacts arranged in parallel. The Reset function is per- formed if the address #Motor_OF has signal state “1” or the address #Fault has signal state “0” (“zero-active”).. Within a rung you can use a NOT contact to negate the result of logic operation (the “power flow”). This means that signal state “1” becomes “0”, and vice versa. A rung must always be terminated, usually with a coil. A coil with no letters or symbols in it assigns the RLO to a bit address. A rung can also terminate in a box. In the example, the output of the SeUReset box is connected to the NO contact #£nable. This is followed by a “T branch.” This allows you to control several outputs in one rung. Inthe ‘example these are the coils #M_start, which starts the motor, and #M_running for the dis play. Wetwork 1; Fepresentation of binary logical operations and memory functions wutonatic — #comand ‘Piamunl on pode i i eS ETT] Figure 48 Example of contacts connected in series and parallel in LAD 4 The Programming Languages Digital functions in LAD ‘The digital functions are represented by boxes. A digital box can process one or two input ‘values and store the result atthe output. ‘The EN input of a box determines whether it is executed or not: If the EN input has the signal state “I” (there is “power flow” to this input), the box is executed. I the function is executed without errors, the ENO output has the signal state “1”. If not, or if the function has not been executed because EN = "0", it has signal state “0”. ‘You.can interconnect ENO and EN so that the EN input of the first box controls the execution, of al the following boxes. The ENO output of the last box is then the group error indicator for all the boxes. ‘You select the boxes from the Program Elements catalog under the relevant headings. There is also a “neutral” box that you can label yourself for the function you want. Phd FS) es El Figure 4.9 Example of digital functions in LAD. 107 4. The Programming Languages 4.6 Function Block Diagram FBD FBD program elements In the Function Block Diagram programming language (FBD) you write the program for your control application by connecting boxes. FBD provides function boxes for performing logic operations on signal states, simple boxes for processing the results of logic operations and complex boxes for non-binary functions. You start programming a logic operation by selecting the program element on the left-hand side ~ by pressing the relevant function key, choosing the appropriate menu options, or se- Jecting the element from the Program Elements catalog, whichever method suits you best. In the simplest case you terminate a bit logic operation with an Output box, which uses the result of the logic operation to set or reset a bit address. ‘The FBD program editor creates networks from left to right and from top to bottom. The in- ‘puts to the functions are on the left and the outputs on the right. Every logic operation has a “termination function” (Output box), the simplest being the assignment of the RLO to a bit address. You can use a “T branch” to program more than one “termination function” for a logic operation (“multiple outputs”). There are sometimes restrictions on the choice of pro- gram elements permitted after a T branch. Most of the program elements require you to enter addresses (variables). The best method is to arrange all the program elements first and label them afterwards. You can cither use abso- lute addresses, for example I 1.0, or symbolic addresses, for example “Manual_mode”. Each network contains one logic operation; a logic operation consists of functions that are interconnected with one another. Before you start entering the next logic operation, you gen- erate another network after the network currently selected. You can give each network a ttle and enter a network comment to explain the function of the network in detail. Binary functions You use binary functions to check the signal states of bit addresses, such as inputs, and per- form logic operations on them. The functions available are AND, OR and Exclusive OR (XOR). All these functions can have more than two inputs. You can interconnect the function boxes to program complex logic operations in one network. If you insert a circle at an input to a function symbol, the check on the signal state of the address is negated. The result of check is then, for example, “I” ifthe signal state of the ad- dress is “0”. You can also place a “negation circle” at the input of an Output box to assign a negated result of logic operation to a bit address. ‘You can check the signal states not only of inputs but of all bit addresses, including the status bits. For example, the binary functions allow you to perform logic operations on the result of a calculation, like “Result = zero”, or on a range overflow bit, or use them to set or reset an output. 4. The Programming Languages Binary functions Simple boxes AND anetion Quip, Set Bitadsross “OR function f= Reh gonincenor, i, [Exssive OR function ST csi evaluation aaa qq CCoctot of timers ad ear Negation of check a ot J~ counters ou ener: fxr Jump fnetions, Castes 4 Master Contrl Rely, etc. “| IMP ‘Complex boxes Standard bones witout EN/ENO Standard bores with ENVENO Block boxes (e.g cman ou counters) (eo artdunetic Hunetons) (eg fonction Block calls) Timer adress bm 3 PULSE AOD Fen s eit en Sex oun ty sco) INI OUT Nt ourz R oe fine eno INQ ENO Figure 4.10 Program elements for Function Block Diagram FBD ‘Simple boxes ‘Simple boxes operate on bit addresses, like outputs. They usually only have one input and. ‘may contain additional letters or symbols. There are simple boxes for setting or resetting bit addresses, evaluating signal edges, setting or resetting timer or counter addresses, calling blocks without parameters, performing jumps in the program, and so on, Complex boxes ‘Complex boxes are used for program elements with non-binary functions. FBD has two types of “standard boxes”: boxes without EN/ENO parameters (e.g. SeReset functions, ‘timers, counters and Compare boxes) and boxes with EN/ENO parameters (c.g. MOVE, arithmetic and mathematical functions, and data type conversion). If you call a logic block, for example a function block, FBD also displays the call as a box with EN/ENO parameters. EN/ENO parameters ‘You use the EN input (enable input) to control execution of a box. The function is only exe cuted ifthe result of logic operation is “1” at this input. The ENO output (enable output) has signal state “I” if the box has been executed without error. You can connect boxes with EN and ENO in series to ensure that a box is only executed ifthe previous box has been executed correctly, or to enable you to use the RLO to activate and deactivate boxes connected in se- ties. 109 4. The Programming Languages Bit logic operations in FBD_ FBD provides the AND, OR and Exclusive OR functions for performing logic operations on binary signal states. At the inputs of these functions you enter the addresses whose signal states you want to check and use in the logic operation. In FBD you program one bit logic operation per network. A logic operation can consist of ‘only one function or it can be made up of a large number of functions connected to one an- ‘ther. In the example, an AND function with the direct input #Manual_ON and the negated input #4utomatic_mode is connected to an OR function, which has another AND function ‘connected to its second input. If #4utomatic_mode has signal state “O”, the signal #Manual_ (ON activates the Set input of the SeUReset function; if #Automatic_mode has signal state 1", the #4wto_ON signal activates the input. ‘You program negation of the result of a check or the result ofa logic operation by inserting ‘a negation circle atthe input or output ofa function. A logic operation must always be terminated. You normally terminate bit logic operations with an output assignment or a Set or Reset function. A T branch enables you to terminate a logic operation with several boxes (multiple outputs). You can also program different sub- sidiary logic operations before each termination function after the T branch. Figure 4.11 Example of binary functions in FBD 4. The Programming Languages Digital functions in FBD ‘The digital functions are represented by boxes. A digital box can process one or two input values and store the result at the output. ‘The EN input ofa box determines whether itis executed or not: Ifthe EN input has the signal state “I", the box is executed. Ifthe function is executed without errors, the ENO output has the signal state “I”. If not, or ifthe function has not been executed because EN ="0", it has signal state “0”. ‘You can interconnect ENO and EN so thatthe EN input of the frst box controls the execution of all the following boxes. The ENO output ofthe last box is then the group error indicator forall the boxes. ‘You select the boxes from the Program Elements catalog under the relevant headings; there isalso a “neutral” box that you can label yourself for the function you want. Network 2: Representation of digital operations reaives srvaive2: eateatoe Figure 4.12 Example of digital functions in FBD 4. The Programming Languages 4.7 Statement List STL Structure of an STL statement In Statement List (STL) you write the program for your control application in the form of a series of statements. Each statement contains an instruction that defines what is to be done, Depending on the type of instruction, this may be followed by an address that defines what the action is to be done to. Examples: In the statement “A I 1.0" the instruction “A” means that a check is to be made for the signal state “1” and the result of the check is to be ANDed with the existing RLO. ‘The A instruction is to be executed on the address “I 1,0", In the statement “= Motor_ON” the instruction “=” (assign statement) means that the current RLO is to be assigned to an ad- dress, and this address is Motor_ON. Bit logic operations in STL Bit logic operations are expressed in STL by signal state check instructions containing the logic operation and the type of check to be performed. Example: The “O” instruction means 1 check for signal state “I” and an OR operation; the ON instruction stands for a check for signal state “O” and an OR operation. When an address is checked for signal state “1” the signal state of the address is used in the logic operation. When a check is made for signal state “0”, the negated signal state of the address is used. The result of logic operation is as- signed to an address with the instructions = (Assignment), S (Set) or R (Reset). The next sig nal state check starts a new logic operation. You can program a number of logic operations in one network and separate them from one another optically with a blank line, for example. //ase operation with to anputs 1/onsng of M0 operations (Pet memory tenctson Hon operation [Trane mamocy fonction (/sean ovtput of memory function Heananct cenult to outputs Pa {05 te is Figure 4.13 Example of binary freon in STL m2 4. The Programming Languages Digital functions in STL Digital functions are processed in the accumulators. These are registers in the CPU for stor- ing values temporarily. A Load instruction loads a value into Accumulator 1. A second Load instruction loads another value into Accumulator | and shifts the previous contents into Ac- cumulator 2. Now an operation can be performed on the two values, for example, addition. ‘The CPU stores the result in Accumulator 1, from which it can be copied to another address with a Transfer instruction. In the example, the addresses #Value! and #Value2 are loaded into the accumulators with two Load instructions and added together with the +1 instruction. The statement T #_INT fetches the result from Accumulator 1 and stores it at the address ##_INT. ‘You can check the status of a digital function with check instructions or directly with Jump functions. For example, you can check for a range overflow with A OV or JO Label. You can also check for “Result = zero” or “Result = positive”, for example. Digital functions are al- ‘ways executed; but you can make the execution of a digital function dependent on conditions by using a conditional jump function to jump over it. (/Puoad Walvel and Waive? 1h the eo valves ‘/Pemporacsly store the reault Howetion /iesyide sntermedsate remult by 2 Hood, store sn Bresult /138 no overtiow oxcured, then 1am to Iabel 2 vas Hiomacsise negate the BLO W2: = pcaloul_or Wetwork 3: comparator in a logical operation 1b wspeed HTioad the variable speed & 1300 ‘(Pioad the constant 1500 3 /icompace for greater than = too high ‘73a #100 high Af #3peed greater than 1500 A tee high 1138 roo bag A arlashing ‘//a0 flashing are set, then : [itch on the #Indicator output {0859 Figure 4.14 Example of digital functions in STL U3 VARI GOT 3 easter | ARMYLO. LOHTT] OF tr ‘van_oorror ‘Salebutfer ARRAY(O LIMIT] OF ‘sTwocT ‘swap oor, Snden. help Ott, sslusr, retultno REAL: envi Bestn (e Part 1 Sorting : Scoording to sBubble Sort" procedure, syap pairs of values Geeil sessured value buffer’ ts sorted “=) epeat rove :* FALSE: FOR inden, <» LIMIT TO 3 BY 1 Do Te’ Sortbufter{index-i]"> sortbut{er{ inden help, oTaortbat fer{ der Sertvatterfinder) > Sortbuffer{ inden). Seeittcelindersy Seip othe UNTIL ¥oT seep ex EPEAT (e Part 2 Calculation | sssessssenssessesenssensassnssussssensnnssessneneensee St1Slstee'equare root usteg avanerd functice SORT and forme square usiea function SQUARE *) qo Lr By 1 rit Tor kzat sortbut fer( index) Set volver) Jo_I¥T(reeultn0) aartbut tert sndon)) rer is ‘Figere 4.15 Extract from the example supplied with the S7-SCL optional package ‘SCL functions Like the basic programming languages, SCL provides you with the following functions: ‘mathematical functions (c.g. sine, base 10 exponentiation, logarithms, square roots), shift and rotate, conversion functions (data type conversion) and the SIMATIC timers and counters. In SCL you can use any FC (function) that returns a function value in an expression just like 4 function in the accepted sense. Example: You can use the function FC 401 with three INT inputs and one INT function value in an SCL expression as follows: ‘Too_big:= FOUL (Input:= #Valuel, Input2:= #Value2, Input3:= #Value3) > 10_000; ‘The value returned by the function FC401 is compared with the value 10,000, If it is greater, the variable Too_big is set to TRUE. If not, itis set to FALSE. ns Eo comma. =} coment Sremce ” ies Figure 4.16 Extract from the example supplied with the CFC optional package (closed-loop conto!) Defining runtime properties for blocks The runtime property settings define the priority class or program execution level ofa block, that is the organization block in which the block is called. When you insert a block, itis au- tomatically given the runtime properties of the “Predecessor for Installation.” By selecting Ebrr—> RUN SEQUENCE you can view the execution sequence and move the block to the po- sition in which you want it to be called. To make things clearer, you can form runtime groups and position your blocks in them. Generating executable code from the CFC charts, When you have configured your charts, you can compile them. CFC first generates an SCL source in the Source Files folder and automatically starts the SCL compiler, which then gen- crates executable blocks in the Blocks folder. A complete program is usually generated from the charts. You can also generate a single block, which you can then call in a different pro- ‘gramming language, for example. “Decompilation,” that is generating charts from compiled blocks, is not possible. Downloading and testing CFC charts after compiling In the Debug mode of the CFC editor you can monitor the values ofall the block connections that have been assigned elementary data addresses as parameters. Before you can do this, ‘you must register the connections concemed for monitoring and set the time interval at ‘Which the values are to be updated. 7 4 ~ Caro [= [eta sae Flare 4.17 Estat fom he example supplied withthe S7-GRAPH optional package (ing) Programming steps and transitions "Now you enter actions for the individual steps of the sequencer. You enter these to the right of the step, under the step name. You specify the instruction and the address itis to be per- formed on, Examples of instructions are S for Set, R for Reset, N for Non Holding (the ad- dress only remains set as long as the step is active) and D for Delay (the address is not set ‘until the specified time has elapsed and is reset when the step is deactivated). ‘You can program the transitions in either Ladder Logic (LAD) or Function Block Diagram (BD). You can use the program elements AND and OR, or series and parallel connections, ‘and Compare. ‘Other functions that control the execution of the program are Interlocks, which affect indi- ‘vidual actions in a step, and Supervisions, which affect transition to the next step. Calling a sequencer for execution ‘When you save the sequencer function block, S7-GRAPH compiles it and generates the as- ‘sociated instance data block. You must now enter a call for the FB/DB pair in a block that is ‘executed cyclically eg. organization block OB 1, to enable the sequencer to be executed. 19 4. The Programming Languages 4.11 State Graph Control $7-HiGraph ‘The S7-HiGraph optional package is a graphical programming method for state graph con- tol systems, It needs the SIMATIC Manager (STEP 7) as basic software. ‘What is a state graph control system? A state graph control system describes the states of machines and processes and the possible transitions between these states. It is especially suitable for non-sequential, asynchronous processes. A whole set of states and transitions is represented by a state graph, Several state ‘graphs can be combined to form a graph group. A state graph starts with an initial state. Ifa condition for transition out of this state is ful- filled, the state associated with it becomes active. Several transitions can be assigned to one state. If they are all fulfilled at the same time, priority rules are applied. Only one state can bbe active at a time. An Any transition leads from any state to one target state; a Return tran- sition leads back from the current state to the previous state, First program the structure of the state graph You use source files to write a state graph program. It is made up of a function (FC) and a data block (DB). The function contains the control function of the state graph; the data block ‘contains the relevant data. In SIMATIC Manager, select the Source Files folder and generate a program source for S7- HiGraph by selecting the menu options INSERT —> S7 SOFTWARE — STATE GRAPH. You dou- ble-click the source file to start the S7-HiiGraph optional software. An empty state graph con- tains an initial state and a starting transition ‘You use INSERT —> STATE to position the state symbols in the drawing space. You then join up the states with transitions (INSERT —> TRANSITION). An Any transition leads from any point in the drawing space to the target state and a Return transition leads from a state to the ‘drawing space. Programming instructions for states and transitions Select VIEW > VARIABLES to display a window for declaring the block parameters and local variables of the function block. If you want to use the graph again, use these variables only (the use of instances with state graphs is similar to that for function blocks). The instructions for the states and transitions are like source-oriented STL statements. You ‘can program any instructions you like. You terminate each instruction with a semicolon. ecution of the instructions for a state o transition always begins with RLO = “1”. The structions you enter are displayed in the drawing space alongside the relevant state or tran- sition. You can position all the elements anywhere you like in the drawing space. Select a state and choose the menu options ViEW —> INSTRUCTIONS. A two-part window showing action types and instructions appears. The action types define how the actions are to be executed in the active state, Entry Actions are executed when the state is activated and Exit Actions when it is deactivated. Whilst the state is active Preceding Cyclic Actions are 120 fans) Figure 4.18 Extract from the example supplied with the $7-HiGraph optional package (drill motor) executed before the transitions are checked and Cyclic Actions after the transitions have been. checked. Selecta transition and choose the menu options VIEW —> INSTRUCTIONS. Program Condi- tions, which must be fulfilled before a transition can take place and enter Actions to be exe- cuted once when the transition is activated. ‘Compiling state graphs in a graph group To compile your state graph you create a graph group in the Source Files folder by selecting INSERT S7 —> SOFTWARE —> GRAPH GROUP. Double-click this to display the graph group ‘window, in which you can now insert an instance of the state graph with INSERT —> IN- STANCE. You select OPTIONS —> CUSTOMIZE and the Compile tab to specify the function (FC) and the data block (DB) to be generated. You then generate the blocks from the graph ‘group with FILE —» Comite. You can only compile graph groups and not single state graphs. Enter a call for execution of the HiGraph FC in a block that is executed cyclically, e.g. orga- nization block OB 1. 11 $_The User Program 5 The User Program On delivery, the SIMATIC controller with the inpuvourput modules is not yet able to control the machine or the plant. The CPU requires a program which it processes step by step, exe- ccuting the instructions stored in the program, and thereby solving the contro task. This pro- ‘gram is called the “user program” since itis created by you as. The programming languages of the STEP 7 programming software are used to write the program. ‘The user program is executed in various ways. Afier power-on, the CPU processes a startup program followed by cyclic (ic., repeated continuously) execution of the main program which can be interrupted by alarm or error events with assigned programs. Priority classes. contro! the mutual interruptbility The user program is usually divided into individual sections each representing a self-con- tained technological or functional unit. These program sections are called blocks. Before it can be processed, a block must be called. You can then call other blocks as so-called subpro- grams within one block, thereby structuring the user program. When skillfully organized, the call sequence in the main program (in the organization block OB 1) represents the techno- logical or functional structure of the machine or plant to be controlled. Inthe user program, you link the signal states or values of various addresses with each other and store the results or output them to the process (machine, plant). The memory areas which ‘you manipulate are called address areas (¢.g., inputs and outputs for the interface to the pro- ‘cess or bit memory for internal data storage). A distinction is made between global addresses ‘which are available throughout the entire user program and local block variables which only apply to the specific block (e.g., the temporary local data for the storage of dynamic inter- mediate results). To be read or write-accessed, an address needs a memory location. Absolute addressing uses the memory location for identification (ie., the relative address to the beginning of the ap- plicable address area). You can also assign a name to an absolute address and then use sym- bolic addressing. Some programming languages also permit indirect addressing for which the memory location is not calculated until run time). ‘The data types specify the value range and the internal structure (data storage) of the vari- ables. There are clementary data types which can be processed with the “normal” instruc- tions of a programming language, and there are combined data types which are composed of individual components to form a unit. User-defined data types (UDT) are defined by you, assigned a name and then used throughout the entire program. 12 5 The User Program 5.1 Organization Blocks and Priority Classes ‘The complete program of a central processing unit (CPU) consists of the operating system and the user program. ‘The operating system is the total of all instructions and declarations of internal device oper- ating functions (e.g., securing data against power failure, activation of the priority classes, and so on). Although the operating system is a fixed part of the CPU which cannot be changed by you, you can load it again from a memory card during a program update, for ex- ample, ‘The user program is the total of all your programmed instructions and declarations for the signal processing through which the system of process to be controlled is manipulated in ac- ‘cordance with the control task. ‘The organization blocks are the interfaces between operating system and user program. The “organization blocks are part of the user program and are called and processed by the operat- ing system when certain events occur. The organization blocks are divided into priority ‘classes which determine the sequence of program processing (mutual interruptibility) when several events occur. ‘The numbers of the organization blocks are fixed. You can specify the processing priority ‘yourself within the framework permitted by the particular CPU. Not every CPU can handle the processing of all events defined in STEP 7. The table below shows all organization bblocks. A specific CPU uses a selection of blocks from this overview. ‘Table 5.1 Organization blocks with SIMATIC S7 St [a ra iow Ra TTI | om = = a a 3 Seis oes oa See gi oe iE RT 73 ores earns Bee eae | Cl rte agar TO ia OB 40 w OB 47 = Pree | — Sean iain pee — ene aE] a omm ii 5 aT RT ae] saan ie om, | SR aT nimi | — EH SCoPE | Someemeaaea San Seema eeernce =| SE ae aby ae ae TT] am aaa irae | A 35%.on 1008 er 121, 08 122 ‘ess errors). = triggering OB 123 S_ The User Program 5.2. Types of User Program Processing Startup program After the power has been tured on or the mode selector switch on the front of the central processing unit has been activated, the CPU runs through a startup program. The startup pro ‘gram is located in organization block OB 100 (warm restart), OB 101 (hot restart) or OB 102 (cold restart) and bas priority 27. Asynchronous errors which occur during startup have pri- ority class 28. After concluding the startup organization block, the CPU begins processing ‘the main program (i¢.,it assumes the RUN state). Main program, background processing ‘The main program is located in organization block OB 1. OB | has the lowest processing. priority. Itcan be interrupted by all alarm events and error events. You cannot change the pro- cessing priority of OB 1 Afier concluding program processing in OB 1, the CPU immediately calls OB 1 again (ie, OB 1 iscyelically processed by the CPU). This cyclic processing is the “normal” type of pro- cessing used for programmable logic controllers. For many applications, the entire user pro ‘gram is located in OB 1 alone. You can set the processing time for the main program so that there is still time for back- ‘ground processing. The CPU calls organization block OB 90 which - depending on the time available — is processed “piece by piece” in altemation with a complete cycle of the main program. As with OB 1, OB 90 can also be interrupted by all alarm events and error events. Interrupt program, priority classes ‘The operating system of the CPU is able to react immediately to a certain signal (an inter- rupt) and call the assigned organization block. You write the interrupt program in this block {i.c., the reaction to the interrupt). If the program which is currently being processed has a Jower priority than the interrupt, itis interrupted at the next program instruction. The CPU “remembers” all relevant data so that it can continue processing the lower-priority program at the point at which it was interrupted, after the interrupt program has been processed. For example, interrupts are generated by the system to be controlled (hardware interrupts, DPV1 interrupts, isochrone interrupts), by the CPU (cyclic interrupts and time-of-day inter- rupts) or are triggered by the user program (time-delay interrupts and multiprocessor inter- rupt). The processing priorities of these interrupts can be set on most CPUs. If there are sev~ cral organization blocks for one type of interrupt, you can assign each OB its own priority class. When two events occur atthe same time, the event with the higher priority is processed first. When you define the CPU parameters, you specify which of the available priority class- you want to use. You can also assign the same priority to several organization blocks. As- sign priority 0 to unused organization blocks. 14 The User Program 5.3. Startup Program ‘The CPU performs a startup under the following conditions. © After the power is tumed on > After the mode selector switch is turned from STOP to RUN or RUN-P > When requested by a communication function (triggered by a programming device or by ‘communication function blocks of another CPU) AA startup can be triggered manually with the key-switch or a communication function, or ‘automatically by turning on the power supply. ‘There are no restrictions on the length of the startup program and no time restrictions on the execution of the startup program. No interrupts are processed while the startup program is being processed. Errors are handled as in RUN. During startup the CPU updates the time functions, the run-time meter and the real-time clock. The output modules are disabled dur- ing startup (ie., no output signals can be output during startup). Cold restart During a cold restart, the CPU puts itself and the modules into the configured basic state, deletes all data from system memory (the retentive also) and calls OB 102. The current pro- ‘gram and the current data in work memory are deleted. The program is reloaded from load ‘memory. (In contrast to the memory reset, a RAM load memory is not deleted.) After a cold restart, the CPU processes the main program in OB | from the beginning, Warm restart During a warm restart, the CPU puts itself and the modules into the configured basic state, deletes the non-retentive data from system memory and calls OB 100, The current program and the current data in work memory are retained. After a warm restart, the CPU processes ‘the main program in OB | from the beginning. Hot restart During STOP or a power failure, the CPU stores all interruption events and the internal CPU registers which apply to processing the user program. For this reason, during a restart. it can ‘continue at the point in the program at which it was interrupted. This can be the main pro- ‘gram or also an interrupt or error program. All “old” interruption events are stored and are processed. The so-called “remaining cycle” from the point in the program at which the CPU ‘continues afier a restart up to the end of the main program is still counted as startup. No new interrupts are processed. The output modules are disabled and are in the basic state. When setting the parameters for the CPU, you can specify the interruption duration after which the CPU may still perform a restart (100 msec to 1 hour). If the interruption takes longer, only ‘cold restart or a warmn restart is permitted. 126 5 The User Program 5.4 Memory Reset, Retention ‘Memory reset ‘The memory reset (also referred to as overall reset or clear/reset) puts the CPU into the “ba- sic state.” The memory reset can only be triggered with a programming device and when the CPU is in the STOP state, or by means of the CPU mode selector switch (hold switch in po- sition MRES at least 3 seconds, release, and then, after a maximum of 3 seconds, hold switch again in position MRES for at least 3 seconds). ‘The CPU deletes the entire user program located in work memory and in the RAM load ‘memory. System memory with the address areas is also deleted regardless of the setting of retentive behavior. The CPU resets the parameters of all modules — including its own —to the default setting. The MPI parameters are an exception. They are not changed so that a CPU ‘whose memory has been reset can still be addressed on the MPI bus. During a memory reset, the diagnostic buffer, the real-time clock and the run-time meter are also not reset. If a mem- ory card with flash EPROM or a micro memory card is installed, the CPU copies the user program from the memory card to work memory. If the memory card contains configuration data, this is also used by the CPU. Retentive behavior ‘A memory area is retentive when its contents are retained during a warm restart. Retentive ‘memory areas can include bit memory, times, counters, and, with the S7-300, also data areas. ‘The amount of retentive data depends on the particular CPU. When you define the parame- ters for the CPU, you specify which areas are to be retentive on the “Retentive Memory” tab of the “Object Properties” dialog. ‘The settings for retentive behavior are located in the system data blocks (SDBs) in load memory (ie., on the memory card). The data on a micro memory card are retained even wie thout a backup battery. Ifthe memory card is a RAM card, battery backup must be used with the programmable controller to ensure permanent storage of the retentive settings. If you use battery backup, the signal states of the bit memory, times and counters defined as retentive are retained. The user program and the user data are not changed. It makes no dif- ference whether the memory card is a RAM ora flash EPROM. Ifthe memory card isa flash EPROM and no battery backup is provided, the $7-300 and the S7-400 react differently. With the $7-300, the signal states of the bit memory, times and counters defined as retentive are retained. With the S7-400, they are not. The contents of the data blocks set as retentive are also retained with the S7-300. Remember that, with the S7-300, the contents of the re tentive data areas are stored on the CPU and not on the memory card. ‘The remaining data blocks (with S7-300) and all data blocks (with S7-400) are copied from the memory card to work memory. The code blocks are also copied. Only the data blocks from the memory card are retained. The data blocks generated with SFC 22 CREAT_DB are not retentive. After startup, the data blocks have the contents located on the memory card ie, the contents with which they were programmed). 128 5. The User Program 5.5 Main Program ‘The main program is the cyclically processed user program. Cyclic program processing is the “normal” program processing for programmable logic controllers. The majority of con- trollers use only this type of program processing. When event-controlled program process ing is used, this is usually only a supplement to the main program. ‘The CPU only processes the main program when itis in the RUN mode. The CPU is running, when the mode selector switch on the front of the CPU is set to RUN or RUN-P. A toggle switch as a mode selector switch only has the RUN position, a keylock switch also has RUN-P. In the RUN position, you can remove the keylock switch and thus make it impos- sible to change the operating mode and modify the user program using a programming device. Program organization The user program is usually divided into individual program sections (i.e., blocks). When a block is to be processed, it must be called. Only the organization blocks are not called by the user program. They are started by the operating system of the CPU instead. ‘The structure of the program specifies the event for which the CPU is to process the blocks and the sequence in which these blocks ate to be processed. For example, a rough program structure is created when you program the calls of the blocks for the main program in orga nization block OB 1. In these “higher-level” blocks, you can then call other blocks and struc ture the user program in more detail, and so on. In principle, there are two ways to divide the total automation task into smaller subtasks. A technological program structure is primarily based on the setup of the system to be con- trolled and is divided into system, subsystem and components. The individual parts of the system or the process to be controlled correspond to the individual program sections. Exam- ple: The subsystem “conveyor belt” may consist of different conveying elements, shunting vehicles and lifting station. These subsystems also consist of individual components such as motors, valves, and indicator elements. A functional program structure is based on the con- trol function to be performed. The lower-level blocks contain the program of the subfunc- tions. Example: The “message acquisition” function may consist of message conditioning, message storage and message output Nesting depth of the block calls During run time, the CPU makes an entry in the block stack (B stack) for every block which is called. With this information, the CPU is able to continue processing in the calling block, afier processing of the called block has been concluded. The next block which is called over- writes the data of the previous call in the B stack. Ifa “nested” block call is made within the called block, the CPU sets up a new element in the B stack. The number of B stack elements is limited to a CPU-specific maximum value. If too many “nested” block calls are made, the CPU assumes the STOP state with the error message “block stack overflow.” 129 5 The User Program 5.7 CPU Functions Real-time clock ‘The real-time clock provides the date and time. The time-of-day interrupts and impulses for the run-time meter are derived from the real-time clock. Ifthe backup battery is working, the real-time clock continues to run even when the power is off. Without buffering, the clock starts at power-on with the time at which the power was previously tured off. A memory reset of the CPU has no effect on the real-time clock. ‘The time is set either with STEP 7 by way of the CPU parameter set, or in the user program with system function SFC 0 SET_CLK and SFC 100 SET_CLKS. System function SFC 1 READ_CLK supplies the date and time in the format DATE_AND_TIME. When several CPUs are connected together in a subnet, declare the clock of one CPU as the “master clock”. When defining the parameters for the CPU, also specify the synchronization interval after which all clocks in the subnet are automatically synchronized to the master clock, Call SPC 48 SNC_RTCB on the CPU with the master clock. The call synchronizes all clocks in the subnet regardless of the automatic synchronization. If you provide a master clock with SFC 0 SET_CLK or SFC 100 SET_CLKS, all other clocks in the subnet will be automatically synchronized to this value ‘System time ‘The system time of a CPU starts when the CPU is tumed on. The system time continues run- ning as long as the CPU is in STARTUP or RUN. In STOP or HALT, the current value of the system time is frozen. During a restart, the system time starts running again at the stored val- tue, A cold restart or warm restart resets the system time, The system time is available in the data format TIME which contains only positive values. When an overflow occurs, the system time starts again at 0. System function SFC 64 TIME_TCK is used to read the current system time. You can use the system time to calculate the time between two SFC 64 calls, for example. Run-time meter A run-time meter on the CPU counts the hours during which it is running. ‘The run-time meter can be used to acquire the hours of operation of connected devices, for example, When the CPU is in STOP or HALT, the run-time meter stops too. When the CPU starts up again, the meter continues counting from the last value. When the maximum value is reached, the run-time meter stops and reports an overflow. A run-time meter can only be set to a new value ‘or to zero with an SFC call. A memory reset of the CPU has no effect on a run-time meter. ‘System function SFC 2 SET_RTM is used to set a run-time meter to a new value. SFC 3 CTRL_RTM starts or stops a run-time meter. A run-time meter must also be started again with SFC 3 after a warm restart or cold restart. SFC 4 READ_RTM supplies the current state ‘of a run-time meter as an INT value and the status “running” or “stopped.” The SFC 101 RTM system function processes operating hours counters with runtimes of up to 2°!-1 hours. 1B S__ The User Program Before the main program is processed, the process {mages or part process image 0 are updated Figure 3 Process image update during main program and interrupt programs Allocation to interrupt organization blocks Some CPUs allow you to assign part process images to the organization blocks for interrupt and asynchronous errors. You do this when you define the parameters for the CPU. We rec~ ‘ommend placing in these part process images the addresses of those modules that you ad~ dress in the interrupt program. When an alarm event occurs, the assigned part process images are updated. ‘System functions for part process images ‘The system functions SFC 26 UPDAT_PI and SFC 27 UPDAT_PO update the defined part process image of the inputs or the outputs. The system functions can be called at any point in the program to update a part process image. When you specify part process image 0, you ‘can also update the process image of the main program, provided you have disabled auto- matic updating. Ifan error occurs during the update, the error is reported with the return val- tue of the system function. 133 3._The User Program 5.9 Cycle Time, Reaction Time Cycle monitoring time Program processing in organization block OB 1 is time-monitored. This is handled by the so-called “cycle time monitoring” function. The standard monitoring time is 150 msec. You ‘can set this value in the range from I millisecond to 6 seconds when you define the pararm- ters of the CPU. If processing of the main program takes longer than the set cycle monitor- ing time, the CPU calls organization block OB 80 (“time error"), If this OB does not exist, the CPU goes into the STOP mode. The cycle monitoring time covers the total processing time of OB 1. Also included are the processing times for higher priority classes which interrupt the main program (during the ‘current cycle). Communication processes by the operating system (c.g., PG accesses to the CPU) also add to the run time of the main program. A PG programming device accessing the CPU is such a communication process. Minimum cycle time, background processing — OB 90 Some CPUs allow you to specify a minimum cycle duration. If main program processing, including interruptions, does not take as long as specified, the CPU waits until the set mini- ‘mum cycle time is reached. Not until this time is reached does the CPU start the next cycle by calling OB | again. The minimum cycle time is by default “disabled.” You can specify a minimum cycle time im the range from 1 millisecond to 6 seconds on the “Cycle/Clock Memory” tab in the “Object Properties” dialog of the CPU, ‘The CPU processes organization block OB 90 (“background processing”) in the time be- tween the actual end of the cycle and the expiration of the minimum cyele time. OB 90 is processed “piece by piece.” Processing of OB 90 is interrupted when OB 1 is called by the ‘operating system, and continued again at the point of interruption when OB 1 processing is ‘concluded. Interruption by OB 1 can occur after every instruction. The closer the processing time of OB 1 is to the minimum cycle time, the less time remains for processing OB 90, The program processing time is not monitored in OB 90. OB 90 is only processed when the CPU is in the RUN mode. It can also be interrupted by interrupts and error events just as it can be by 0B I | Minimum cycle duration and background processing Start current | Continuation of | Start next cyclic processing |peszeine ‘eyclc processing 0B 90 Current cycle time of OB 1 Fi wanpoyanoot [omoansooso| Pa] Acer ? oo ‘Minimum cycle duration Figure $4 Minimum cycle time and background processing 134 $__The User Program Reaction time ‘When the user program in OB 1 works with the signal states of the process images, a reaction time is obtained which depends on the program processing time (cycle time). The reaction time is between one and two cycle times as explained in the following example. For example, when a limit switch is approached, it changes its signal state from “0” to “1”. ‘The controller picks up this change next time the process image is updated and sets the input of the limit switch to “1”. The program evaluates this change and reacts to it, for example by resetting an output to turn off the motor concemed. The reset output is transferred at the end of program processing. Not until then is the associated bit canceled on the digital output module. In the best case scenario, the process image is updated immediately afte the limit switch sig- nal changes. The associated output only requires one cycle to react. In the worst case scenar- io, the process image has just been updated when the limit switch signal changes. Approxi- ‘mately one cycle passes before the controller notices the change and sets the input. One more cycle passes before the module output reacts ‘The reaction time to a change of the input signal may be between one and two cycle times. ‘The delay times for the input modules and the switching times of contactors and so on also ‘add to the reaction time. ‘The processing time of the user program contains all procedures in a program cycle, such as processing of interrupts, processing in the operating system such as updating the timers, con- ‘rolling the MPI interface and updating the process image. In individual cases, you can reduce reaction times by addressing the VO directly or using ‘event-controlled calls of specific program sections. Change in the encoder ‘signal without inclusion in the process image Figure $$ Reaction times on a programmable logic controller 13s 5 The User Program 5.11 Time-Delay Interrupts ‘You can use a time-delay interrupt to implement a time delay regardless of the timers. STEP 7 offers organization blocks OB 20 to OB 23 for the processing of a time-delay interrupt. Which of these four organization blocks are actually available depends on the CPU you are using. ‘Configuring time-delay interrupts on the CPU ‘You use the hardware configuration tool HW Config. to configure a time-delay interrupt on the CPU. The “Interrupts” tab of the CPU's “Object Properties” dialog lists the organization blocks available for this purpose. Here you set the processing priority. Make sure to reserve at least 20 bytes of temporary local data for each time-delay interrupt used or for its priority ‘lass. You do this on the “Memory” tab of the CPU's “Object Properties” dialog. Processing time-delay interrupts with system functions You can start a time-delay interrupt in the user program by calling system function SFC 32 SRT_DINT. The SFC call also transfers the delay duration and the number of the selected ‘organization block to the operating system. You can set the delay time in increments of 1 mil lisecond at a precision of I millisecond. The SFC call is also the starting point of the defined time period. The selected organization block is started when the delay time has run out. Note that the processing of a time-delay-interrupt organization block may be delayed if'a higher- priority organization block is being processed at the time the interrupt OB is called. ‘You can overwrite a running delay time with a new value by calling system function SFC 32 SRT_DINT again. The new delay time begins running at the moment the SFC is called. You can cancel a started time-delay interrupt by calling system function SFC 33 CAN_DINT a second time; the related organization block is then not called again. Use system function SFC 34 QRY_DINT to query the status of a time-delay interrupt. Make sure that the time- delay interrupt OB that has been started actually exists in the CPU and that it has been con- figured properly. Otherwise, the CPU calls error organization block OB 85 (“program exe- ution error”) oF goes into the STOP mode. ‘Time-delay interrupts are only executed when the CPU is in the RUN mode. A time-delay interrupt can be started in the startup program by calling SFC 32 SRT_DINT. In this case, the CPU must be in the RUN mode when the delay has run expired. If not, the CPU waits to call the organization block until the end of the startup program and calls the time-delay-in- terrupt OB during the transition to the RUN mode, before starting the main program. Disabling and delaying time-delay interrupts You can use the following system functions to affect the processing of time-delay interrupts: ‘SFC 39 DIS_IRT (disable interrupts), SFC 40 EN_IRT (enable disabled interrupts), SFC 41 DIS_AIRT(delay interrupts) and SFC 42 EN_AIRT (enable delayed interrupts). 138 5. The User Progam 5.13 Cyclic Interrupts (Cyclic interrupts are triggered at regular intervals. A cyclic interrupt (also referred to as watchdog interrupt) calls up a special organization block reserved for this type of interrupts. You can use a cyclic interrupt to have a certain program processed at a time interval which is not dependent on the processing time of the cyclic program. STEP 7 offers organization blocks OB 30 to OB 38 for the processing of cyclic interrupts. Which of these nine organi- zation blocks are actually available depends on the CPU you are using. Configuring cyclic interrupts on the CPU You define a cyclic interrupt in HW Config. when you define the parameters for the CPU. ‘You do this on the “Cyclic Interrupt” tab of the CPU's “Object Properties” dialog. A cyclic interrupt has three parameters: execution, phase offset and priority. You can set the parame- ters “Execution” and “Phase offset” to values in the range from | millisecond to 1 minute, in steps of | millisecond. Depending on the CPU you are using, you can select a priority from 2 to 24, or 0. Zero means that the particular cyclic interrupt is not activated for process- ing. Make sure to reserve at least 20 bytes of temporary local data for each cyclic interrupt OB used or for its priority class. You do this on the “Memory” tab of the CPU's “Object Properties” dialog. Phase offset ‘You can use the “Phase offset” parameter to time-stagger processing of those cyclic interrupt programs that have been set to the same time interval, or a multiple of this, in the “Execu- tion” parameter. This increases the accuracy of the processing period since the low-priority ‘organization block does not need to wait. Both parameters “Execution” and “Phase offset” —are started when the CPU is switched to RUN. Disabling and delaying cyclic interrupts ‘You can use the following system functions to affect the processing of cyclic interrupts: SFC 39 DIS_IRT (disable interrupts), SFC 40 EN_IRT (enable disabled interrupts), SFC 41 DIS_AIRT (delay interrupts) and SFC 42 EN_AIRT (enable delayed interrupts). OB | Execution | Phase offset | Priority 30 [Sse ‘Omsee a | 2s O msec 32 | tee Omsee 9 33 | S00 msec | Omsee 10 34 | 200msee | Omsee u 35 | 100msee | Omsee 2 36 | S0mscc | Omsee B 37 | 20mee | Omece “ 38 | 10 msec | Omsec 1s Figure $.6 Default setting and phase offset for eyelic interrupts 140 3. The User Program 5.15 DPV1 iterrupts ‘You use DPV1 interrupts in conjunction with PROFIBUS DPVI slaves. An appropriately ‘equipped slave can call one of the organization blocks OB 55 to OB 57 in the event of a DPV1 interrupt in the CPU (provided these organization blocks are available in the CPU). ‘Triggering a DPV! interrupt In addition to the interrupt types familiar in SIMATIC S7, PROFIBUS DPVI slaves can also trigger the following interrupts: > Status interrupt if, for example, the DPVI slave changes its operating state; interrupt oF ganization block OB 55 is called. > Update interrupt if, for example, the DPV slave has been re-parameterized via PRO! BUS or direct; interrupt organization block OB 56 is called. > Manufacturer interrupt if, for example, an event envisaged by the manufacturer occurs in the DPVI slave; interrupt organization block OB 57 is called. The interrupt-triggering events are defined by the manufacturer of the DPV1 slave, Ifa DPV! interrupt occurs, the assigned organization block must also be available. If this is not the case, the CPU enters a message in the diagnostics buffer and calls the asynchronous. error organization block OB 85 “Program execution error” or goes to the STOP state. DPV1 interrupts are only processed by the CPU in RUN. DPV1 interrupts occurring during restart are entered in the diagnostics buffer and in the module status data. ‘Scanning interrupt information ‘You can scan the interrupt organization block to find out which DP slave triggered the inter- rupt. The starting address of this module is located in bytes 5, 6, and 7 of the start informa- tion. Bytes 8 to 11 contain more information such as the interrupt type and the code that in dicates either a fault event or a back-to-normal event. You read the additional interrupt infor- ‘mation with system function block SFB 54 RALRM. Configuring DPV! interrupts in the CPU ‘The CPU is configured using Hardware Configuration. The “Interrupts” tab indicates which DPV! interrupt organization blocks are available in the CPU. Set the processing priority here. On the “Memory” tab, at least 20 bytes of temporary local data must be reserved for each DPV interrupt OB used or for its priority class. Disabling and delaying DPV1 interrupts ‘You can influence the processing of DPV! interrupts with the following system function: ‘SEC 39 DIS_IRT (disable interrupts), SFC 40 EN_IRT (enable disabled interrupts), SFC 41 DIS_AIRT (delay interrupts), and SFC 42 EN_AIRT (enable delayed interrupts) 142 She User Program Processing isochrone interrupts The isochrone interrupt is triggered by the global control (GC) command of the DP master. Isochrone interrupts are only processed in RUN mode. An isochrone interrupt in RESTART, STOP, or HOLD mode is rejected. The start information of the isochrone OB invoked first in RUN contains the number of unprocessed OB calls. You also receive the message “GC violation” from the start information if, for example, the global control command has failed or has been sent offset. The response time in the case of isochrone mode is the sum of the times Ti and To as well as the equidistance time (see figure). Ti is the time required for reading in the process values. It contains the processing time in the input modules or electronics modules and in the case of modular DP slaves, the transfer time on the backplane bus, When Ti has elapsed, the input information for transfer by the global control command is available. Equidistance time then begins. This is the period between two global control commands and encompasses transfer to the subnet as well as execution of the isochrone interrupt OP. From the time when execu- tion of the isochrone OB is completed until the next global control command, there should be sufficient time for executing the main program. To is the time required for outputting the process values. It begins with the global control command and comprises the transfer time on the subnet as well as the execution time in the output modules or electronics modules. In the case of DP slaves, the transfer time on the ‘backplane is also added to this. Disabling and delaying isochrone interrupts You can influence the processing of isochrone interrupts with the following system func- tions: SFC 39 DIS_IRT (disable interrupts), SFC 40 EN_IRT (cnable disabled interrupts), SFC 41 (DIS_AIRT) (delay interrupts), and SFC 42 EN_AIRT (enable delayed interrupts). Figure $8 Response time in the case of isochrone mode and equidistance 145 S._The User Program $5.18 Error Handling Errors that are detected by the CPU or the modules are reported by the CPU in different ways: > Errors in arithmetic operations (overflow, invalid REAL number) set the relevant status bits. For example, status bit OV is set in the event of a counting range overflow) > Error while processing the user program (synchronous error): Call organization blocks 0B 121 and OB 122. > Emror in the programmable controller not related to program processing (asynchronous error): Call organization blocks OB 80 to OB 88. ‘The CPU indicates an error and possibly the cause of the error by means of the LEDs on the PU front plate. When serious errors occur, such as an illegal operation code, the CPU switches directly to the STOP mode In the STOP mode, you can use a programming device to read the block stack, the interrupt stack and the local data stack using the CPU information functions, and then draw conclu- sions as to the cause of the error. The system diagnostics function can detect module faults and enter this fault information in a diagnostic buffer. The diagnostic buffer also contains in- formation on the mode transitions of the CPU, such as events that cause the CPU to go into STOP. The contents of the diagnostic buffer are retained when the CPU is in the STOP mode, during a memory reset and when a power failure occurs. After power recovery and CPU startup, you can read this information using a programming device. Synchronous erro ‘The operating system of the CPU generates a synchronous error event when an error occurs which is directly related to program processing. If you have not programmed a synchronous error OB, the CPU goes into the STOP mode when a synchronous error event occurs. There are two types of errors. > Programming errors; OB 121 is called > Access errors; OB 122 is called ‘A synchronous error OB has the same priority as the block that caused the error. Therefore, the registers of the interrupted block can be accessed by the synchronous error OB. Another cffect is that the program in the synchronous error OB can return the registers with modified contents to the interrupted block. Please note that, when a synchronous error OB is called, its 20 bytes of start information are stored in the L stack of the error-causing priority class, in addition to the remaining tempo- rary local data of the synchronous error OB and the temporary local data of all blocks called in this OB, Entering a substitute value ‘You can call SFC 44 REPL_VAL to write a substitute value into accumulator | from within ‘a synchronous error OB. Example: Values can no longer be read from an input module, OB 122 ("access error”) is called and a substitute value can be entered and processing can con- tinue with this value

You might also like