Home

"user manual"

image

Contents

1. L Pea z Figure A 1 Defining Areas Within a Process Describing the Section 1 2 described how to divide the sample process into functional areas Parts of a Process and individual tasks The individual areas are described below The area for ingredients A and B e The pipes for each of the ingredients are equipped with an inlet and a feed valve and feed pump e The inlet pipes also have flow sensors e Turning on the feed pumps must be interlocked when the tank level sensor indicates that the tank is full System Software for S7 300 and S7 400 Program Design A 2 C79000 G7076 C506 01 Sample Program for an Industrial Blending Process e The activation of the feed pumps must be interlocked when the drain valve is open e The inlet and feed valves must be opened at the earliest 1 second after starting the feed pump e The valves must be closed immediately after the feed pumps stop signal from the flow sensor to prevent ingredients leaking from the pump e The activation of the feed pumps is combined with a time monitoring function in other words within 7 seconds after the pumps start the flow sensor must report a flow e The feed pumps must be turned off as quickly as possible if the flow sensor no longer signals a flow while the feed pumps are running e The number of times that the feed pumps are started must be counted maintenance interval Mixing ta
2. Figure 7 4 Addressing Parameters ID and R_ID Sample Program Appendix B contains a sample program illustrating data exchange using communication SFBs for configured connections System Software for S7 300 and S7 400 Program Design C79000 G7076 C506 01 7 7 Data Exchange Between Programmable Modules 7 5 Data Exchange with Communication SFCs for Non Configured Connections Requirements Using communication SFCs for non configured connections you can exchange data between an S7 CPU and another module that is capable of communication The following conditions must be satisfied e The communication partner must be attached to the same MPI subnet or belong to the same S7 station module capable of communication in the central rack in an expansion rack or in a DP station e The required SFCs must be called in the user program Communication The S7 300 and S7 400 CPUs provide communication SFCs for SFCs for non configured connections to allow data exchange between two Non Configured communication partners and to terminate existing connections Connections Table 7 3 SFCs for Communication between S7 Stations Block Description SFC65 X_SEND Data exchange between communication partners using a send SFC66 X RCV and a receive SFC SFC67 X_GET Reads a variable from a communication partner SFC68 X_PUT Writes a variable to a communication partner SFC69 X_ABORT
3. 2 e0eeseeee 7 1 7 4 Types of Communication 0 0 c eee eee eee eee 7 2 7 2 Data Exchange with SFBs for Configured Connections 7 3 7 3 Configuring a Communication Connection Between Partners 7 5 7 4 Working with Communication SFBs for Configured Connections 7 7 7 5 Data Exchange with Communication SFCs for Non Configured Connections 00 ccc cee eee ees 7 8 System Software for S7 300 and S7 400 Program Design C79000 G7076 C506 01 Contents 8 Setting System Parameters 000 cee e eee eee eens 8 1 Changing the Behavior and Properties of Modules 8 2 Using the Clock Functions 00sec eens 8 3 Specifying the Startup Behavior 00 cece eee eee eee 8 4 Settings for the Cycle 0 c cece nents 8 5 Specifying the MPI Parameters 000 c cece eee eee 8 6 Specifying Retentive Memory AreaS 20 cece eee eee eee 8 7 Using Clock Memory and Timers 0 00 cece neces 8 8 Changing the Priority Classes and Amount of Local Data 9 Operating Modes and Mode Changes eeeeeee cence eeneeeees 9 1 Operating Modes and Mode Changes 000 cece ee ee eens 9 2 STOP Modein Sends eatin we mde eats oobi e sable esuialesdtacens 9 3 STARTUP M006 w 560 ceben tesa dean ne sod ca a u aE a Baws nie 9 4 RUN Mode 0 0c cece eect ttt EE E AERE 9 5 HOLD MO 6 erein ineen P
4. Diagnostic Status Data on the CPU Diagnostic Data on Modules Diagnostic Buffer Diagnostic status data describe the current status of the components monitored by the system diagnostics Table 11 2 shows the topics about which information can be displayed partial system status lists Table 11 2 Diagnostic Status Data of the System Status List Topic Information Communication status data All the communication functions currently set in the system Diagnostic modules The modules with diagnostic capability logged on at the CPU Start information list of the Start information about the OBs of the CPU OB Start event list Start events and priority classes of the OBs Module status information Status information about all assigned modules that are plugged in faulty or generate hardware interrupts In addition to the CPU there are also other modules with diagnostic capabilities SMs CPs FMs whose data are entered in the system status list Table 11 3 shows the topics about which information can be displayed partial system status lists Table 11 3 Module Diagnostic Data of the System Status List Module diagnostic Module start address internal external faults channel information faults parameter errors 4 bytes Module diagnostic data All the diagnostic data of a particular module The diagnostic buffer of the CPU contains diagnostic messages in the order in which they occur For more information
5. Diagnostic data on modules 11 6 Diagnostic event Diagnostic functions Diagnostic interrupt OB Diagnostic message sending to a station writing your own Diagnostic status data Diagnostics Distributed peripheral I Os Dividing a process into tasks for the example of an industrial blending process 1 3 DMSK_FLT DP Glossary 4 DP standard slaves DPNRM_DG DPRD_DAT 6 7 DPWR_DAT 6 7 DWORD range E Elementary data types description Eliminating errors sample programs 11 11 EN_AIRT EN_IRT Error detection OB types OB 81 11 12 sample programs replacement values 11 14 11 16 Error ID using error OBs to react to errors System Software for S7 300 and S7 400 Program Design C79000 G7076 C506 01 Error OB OB types OB121 and OB122 3 11 OB80 to OB87 3 11 using error OBs to react to events 3 10 B 19 Errors in the multicomputing mode F FB Glossary 5 FC 2 11 Glossary 4 at parameter 2 Function FC Ta application creating a oar FC for the blending pro cess example A 11 Function block FB 2 3 actual parameters application 2 12 assigning memory creating a sample FB for the blending pro cess example A 7 4 10 G GET GRAPH 2 8 H Hardware interrupt MiGraph HOLD 9 CPU N I stack used by system memory 3 12 writing to I O access error OB I Os distributed 6 6 In out parameters order f
6. SFC72 I_GET SFC73 I_PUT 7 8 SFC74 I_ABORT 7 8 Situations in which data is overwritten 2 21 SRT_DINT SY System Software for S7 300 and S7 400 Program Design C79000 G7076 C506 01 Index START Start address 6 3 Start event for error OBs Start events delaying 3 11 for time of day interrupts masking STARTUP 9 6 aborting CPU activities 9 9 CPU mode 9 2 9 4 Startup behavior Startup comparison Startup OB Startup program 3 4 Startup type check Statement List STL absolute addressing situ al ations in which data is overwritten STATUS STEP 7 configuring retentive memory areas error OBs reactions to errors 3 10 function programming languages test options STL STOP CPU mode 9 2 p 4 Storing data in the L stack 2 19 STRING STRUCT STRUCT data type description C 10 number of nested levels Structured data types C 4 array CT nesting structures and arrays structure C 10 nesting structures and arrays Structured program advantages 2 3 designing A 4 Structured programming 2 9 Symbolic addressing 5 5 in the sample program Synchronization Multicomputing using message points using wait points Synchronization points of the CPU 10 8 System Software for S7 300 and S7 400 Program Design C79000 G7076 C506 01 Synchronous error using OBs to react to errors 3 10 B 12 System architecture
7. e You can evaluate and optimize the dynamic system response You can read out the diagnostic buffer with STEP 7 or using SFC51 RDSYSST You can specify that the last diagnostic buffer entry before the transition from RUN to STOP is signaled automatically to a logged on display device for example programming device OP TD This helps to locate and remedy the cause of the change to STOP more quickly see also Section 11 4 System Software for S7 300 and S7 400 Program Design C79000 G7076 C506 01 Diagnostics and Troubleshooting 11 4 Sending Your Own Diagnostic Messages Introduction User Defined Diagnostic Events Sending Diagnostic Messages to Stations Generating a Message with Acknowledgment 11 8 You can also extend the standard system diagnostic functions of SIMATIC S7 using the system function SFC52 WR_USMSG as follows e To enter your own diagnostic information in the diagnostic buffer for example information about the execution of the user program e To send user defined diagnostic messages to logged on stations monitoring devices such as a PG OP or TD For more information about assigning parameters to SFC52 refer to the reference manuals 235 The diagnostic events are divided into event classes 1 to F The user defined diagnostic events belong to event classes 8 to B These can be divided into two groups as follows e Event classes 8 and 9 include messages with a fixed number and predef
8. Aborts an existing connection to a communication partner This releases connection resources at both ends of the connection Table 7 4 SFCs for Communication within an S7 Station SFC72 I_GET Reads a variable from a communication partner for example FM SFC73 I_PUT Writes a variable to a communication partner for example FM SFC74 I_ABORT Aborts an existing connection to a communication partner This releases connection resources at both ends of the connection System Software for S7 300 and S7 400 Program Design 7 8 C79000 G7076 C506 01 Data Exchange Between Programmable Modules Connection to Communication Partner Addressing the Communication Partner To allow data to be exchanged between communication partners the partners must be networked K bus or PROFIBUS DP for SFCs I_GET I_PUT and I_ABORT MPI for SFCs X_SEND X_RCV X_GET X_PUT and X_ABORT A communication connection is established by the operating system of the CPU while the SFC is being executed You decide whether or not the connection is terminated after the data transfer using an input parameter for more detailed information refer to the Reference Manual 235 If a connection cannot be established at the present time you must call the SFC again later A connection is established by the CPU on which a communication SFC is called exception the SFC66 X_RCV call does not establish a connection A m
9. Agitator motor Figure A 2 Specifying the Program Structure System Software for S7 300 and S7 400 Program Design C79000 G7076 C506 01 A 5 Sample Program for an Industrial Blending Process A 3 Assigning Symbolic Names Defining Symbolic Symbols are used in the example program and they must be defined in the Names symbol table using STEP 7 Table A 1 shows the symbolic names and the absolute addresses used to control the feed pumps the agitator motor and the inlet valves Table A 1 Symbolic Addresses of the Feed Pumps the Agitator Motor and the Inlet Valves Symbolic Name Address Data Type Description Feed_pump_A_ stop 10 1 BOOL Stop button of the feed pump for ingredient A Flow_A Ingredient A flowing Feed_valve_A Q4 1 BOOL Activates the feed valve for ingredient A Feed_pump_A_on Lamp for feed pump ingredient A running Feed_pump_A_fault Lamp for feed pump A fault Feed_pump_B_ start BOOL Start button of the feed pump for ingredient B Feed_pump_B_stop BOOL Stop button of the feed pump for ingredient B Flow_B 10 5 BOOL Ingredient B flowing Inlet_valve_B Q5 0 BOOL Activates the inlet valve for ingredient B Feed_pump_B_on Q5 2 BOOL Lamp for feed pump ingredient B running Feed_pump_B_off Lamp for feed pump ingredient B not running Feed_pump_B Q5 4 BOOL Activates the feed pump for ingredient B Feed_pump_B_fault Q5 5 BOOL Lamp for
10. STEP 7 assigns the actual parameters to the formal parameters of an FB as follows When you specify actual parameters in the call statement the instructions of the FB use the actual parameters provided e When you do not specify actual parameters in the call statement the instructions of the FB use the value saved in the instance DB Table 2 4 shows which variables must be assigned actual parameters Table 2 4 Assigning Actual Parameters to the Formal Parameters of an FB Data Type Variable Elementary Data Complex Data Type Parameter Type Type Input No parameter required No parameter required Actual parameter required Output No parameter required No parameter required Actual parameter required In out No parameter required Actual parameter required System Software for S7 300 and S7 400 Program Design C79000 G7076 C506 01 2 13 Structuring the User Program Assigning Initial Values to Formal Parameters 2 14 You can assign initial values to the formal parameters in the declaration section of the FB These values are written into the instance DB assigned to the FB If you do not assign actual parameters to the formal parameters in the call statement STEP 7 uses the values saved in the instance DB These values can also be the initial values that were entered in the variable declaration table of an FB Table 2 5 shows which variables can be assigned an initial value Since the temporary data are
11. operating time are saved in different data blocks The DB assigned to the FB when it is called determines which motor is controlled With this technique only one function block is necessary for several motors see Figure 2 5 Call FB22 DB201 uses DB201 Motor_1 data for motor 1 Call FB22 DB202 uses FB22 Motors DB202 Motor_2 data for motor 2 Call FB22 DB203 uses Pecos Melis data for motor 3 Figure 2 5 Using an Instance DB for Each Separate Instance One Instance DB You can also transfer the instance data for several motors at the same time in for Several one instance DB To do this you must program the calls for the motor Instances of an FB controllers in a further FB and declare static variables with the data type FB for the individual instances multiple instances in the declaration section of the calling FB If you use one instance DB for several instances of an FB you save memory and optimize the use of data blocks System Software for S7 300 and S7 400 Program Design C79000 G7076 C506 01 2 15 Structuring the User Program In Figure 2 6 the calling FB is FB21 Motor processing the variables are of data type FB22 and the instances are identified by Motor_1 Motor_2 and Motor_3 In this example FB22 does not need its own instance data block since its instance data are saved in the instance data block of the calling FB DB100 Call FB21 from a
12. 4 The valves are deactivated if the following condition is satisfied The flow sensor signals no flow Table 1 4 Description of the Agitator Motor Agitator Motor 1 The agitator motor mixes ingredient A with ingredient B in the mixing tank Rating 100 kW 134 hp at 1200 rpm 2 The agitator motor is controlled start stop from an operator station located near the mixing tank The number of starts is counted for maintenance purposes Both the counter and the display can be reset with one button 3 To operate the agitator motor the following conditions must be satisfied The tank level sensor is not signaling Tank Below Minimum The drain valve of the mixing tank is closed The emergency stop is not active 4 The agitator motor is switched off if the following condition is satisfied The tachometer does not indicate that the rated speed has been reached within 10 seconds of starting the motor Table 1 5 Description of the Drain Valve Drain Valve 1 The drain valve allows the mixture to drain using gravity feed to the next stage in the process The valve has a solenoid with a spring return Ifthe solenoid is activated the outlet valve is opened Ifthe solenoid is deactivated the outlet valve is closed 2 The outlet valve is controlled open close from an operator station 3 The drain valve can be opened under the following conditions The agitator motor is
13. CPU mode 9 2 p 4 cycle System data System data block System diagnostics extending 11 8 System error Glossary 9 System function blocks types System functions types System memory 5 2 System parameters System status list 11 content reading out SZL Glossary 9 R T Temporary variable TEMP order for declaring parameters 2 6 TIME range Time reading 8 4 setting 8 4 Time error OB Time format 8 4 TIME OF DAY range Time of day changing Time delay interrupts Time of day interrupt TIMER parameter type Timer T memory area retentive 5 8 Transferring parameters designing parameters for a structured pro gram A 8 parameter types Sample FB for the blending process exam ple A 7 saving the transferred values 2 12 situations in which data is overwritten 2 21 U UDT C 4 Glossary 4 Unmasking start events 3 11 Index 7 Index Unsynchronized operation in segmented racks o z 0 2 UPDAT PI 8 7 UPDAT_PO 8 7 7 3 User program debugging 9 14 elements in the CPU memory loading 5 6 tasks User defined data types description USTATUS V Variable declaration table FB for the blending process example A 9 FC for the blending process example for OB 81 11 12 OB for the blending process example Act 6 order for declaring parameters 2 Index 8 VAT Glossary 10 WwW Wait point WP 10 8 Warning L st
14. Communication on non configured connections e Generating block related messages For more detailed information about SFBs and SFCs refer to the reference manual 235 The CPU descriptions 70 and 101 explain which SFBs and SFCs are available System Software for S7 300 and S7 400 Program Design C79000 G7076 C506 01 Structuring the User Program 2 8 Functions FC Definition Functions FCs belong to the blocks that you program yourself A function is a logic block without memory Temporary variables belonging to the FC are saved in the local data stack This data is then lost when the FC has been executed To save data permanently functions can also use shared data blocks Since an FC does not have any memory of its own you must always specify actual parameters for it You cannot assign initial values for the local data of an FC Application An FC contains a program section that is always executed when the FC is called by a different logic block You can use functions for the following purposes e To return a function value to the calling block example math functions e To execute a technological function example single control function with a bit logic operation Assigning Actual You must always assign actual parameters to the formal parameters of an FC Parameters to The input output and in out parameters used by the FC are saved as pointers to Formal Parameters the actual parameters of the logic block tha
15. If you do not program OB84 the CPU changes to the STOP mode when a CPU hardware fault is detected System Software for S7 300 and S7 400 Program Design C79000 G7076 C506 01 11 21 Diagnostics and Troubleshooting 11 13 Priority Class Error OB OB85 Description The operating system of the CPU calls OB85 in the following situations e When a start event for an interrupt OB exists but the OB cannot be executed because it has not been loaded on the CPU e When an error occurs accessing the instance data block of a system function block e When an error occurs updating the process image table module does not exist or defective Programming You must generate the priority class error OB OB85 as an object in your S7 OB85 program using STEP 7 Write the program to be executed in OB85 in the generated block and download it to the CPU as part of your user program You can use OB85 for example for the following purposes e To evaluate the start information of OB85 and determine which module is defective or not plugged in the module start address is specified e By including SFC49 LGC_GADR to find out the slot of the module involved If you do not program OB85 the CPU changes to the STOP mode when a priority class error is detected System Software for S7 300 and S7 400 Program Design 11 22 C79000 G7076 C506 01 Diagnostics and Troubleshooting 11 14 Rack Failure OB OB86 Description Programming OB86 Th
16. Table 8 1 lists several SDBs that are available on every CPU and shows which parameters they contain Table 8 1 Parameters in SDBs SDB Parameter Record 0 CPU operating system parameters 1 Peripheral I O assignment list 2 CPU default parameter record 3 Integrated DP interface 22 Distributed I O assignment list internal interface 26 Distributed I O assignment list external interface 100 to 103 Parameters for modules in the central configuration of an S7 300 100 to 121 Parameters for modules in the central configuration of an S7 400 122 Parameters for modules in the distributed configuration internal interface of an S7 300 and S7 400 126 to 129 Parameters for modules in the distributed configuration external interface of an S7 300 and S7 400 1000 to 32767 Parameters for K bus modules System Software for S7 300 and S7 400 Program Design C79000 G7076 C506 01 Setting System Parameters Which Seitings can be Made Parameter Assignment with SFCs The module parameters are divided into parameter fields Which parameter fields are available on which CPU is explained in the CPU descriptions 70 and 101 Parameter fields exist for the following topics e Startup behavior e Cycle e MPI e Diagnostics e Retentive data e Clock memory e Interrupt handling e On board I Os only for the S7 300 e Protection level e Local data e Real time clock e Asynchronous errors In addition to as
17. WORD Binary number 2 0 to L 2 0001_0000_0000_0000 2 1111_1111_1111_1111 Hexadecimal W 16 0 to W 16 FFFF L W 16 1000 number L word16 1000 C 0 to C 999 L C 998 B 0 0 to BH 255 255 L B 10 20 Decimal number L byte 10 20 unsigned DWORD Binary number 2 0 to 2 1000_0001_0001_1000 Double word 2 1111_1111_1111_1111_ 1011_1011_0111_1111 1111_1111_1111_1111 Hexadecimal DW 16 0000_0000 to L DW 16 00A2_ 1234 number DW 16 FFFF_FFFF L dword 16 00A2_ 1234 B 0 0 0 0 to L B 1 14 100 120 Decimal number B 255 255 255 255 L byte 1 14 100 120 unsigned INT Decimal number 32768 to 32767 L1 Integer DINT L 2147483648 to L L 1 Integer 32 bits L 2147483647 System Software for S7 300 and S7 400 Program Design C79000 G7076 C506 01 Data and Parameter Types Table C 1 Description of the Elementary Data Types continued Type and Size Format Options Range and Numeric Example Description in Representation lowest to Bits highest value REAL floating point TEEE floating point number Upper limit 3 402823e 38 Lower limit 1 175 495e 38 L 1 234567e 13 SSTIME SIMATIC time TIME IEC time DATE IEC date S7 time in steps of 10 ms default IEC time in steps of 1 ms integer signed IEC date in steps of 1 day S5T 0H_OM_0OS_10MS to SST 2H_46M_30S_0OMS and S5T 0H_OM_OS_OMS T 24D_20H_31M_23S_648MS to T 24D_20H_31M_23S_647MS D 1990 1 1 to D 2168 12 31 L SST 0H_1M_OS_OMS
18. e After an FB has addressed an in out parameter with a complex data type for example STRING DATE_AND_TIME ARRAY STRUCT or UDT STEP 7 uses the address register AR1 and the DB register to access data This overwrites the contents of both registers e After an FC has addressed a parameter input output or in out with a complex data type for example STRING DATE_AND_TIME ARRAY STRUCT or UDT STEP 7 uses the address register AR1 and the DB register to access data This overwrites the contents of both registers When using function blocks remember the following points e When calling an FB and a multiple instance the address register AR2 is written e If the address register AR2 is overwritten while an FB is being executed the correct execution of this FB can no longer be guaranteed Note There are also other situations in addition to those listed above in which data are overwritten System Software for S7 300 and S7 400 Program Design C79000 G7076 C506 01 2 21 System Software for S7 300 and S7 400 Program Design C79000 G7076 C506 01 Organization Blocks and Executing the Program What Does This This chapter provides an overview of the following topics ibe Chapter DECID e Types of organization block e Cyclic program execution e Interrupt driven program execution Where to Find You will find more detailed information about interrupt driven program More Information execution in Chapterl4 Error OBs are d
19. e You can store your program in the FEPROM either memory card or integrated on the CPU refer to the CPU descriptions 70 e You can store a certain amount of data depending on the CPU in an area of the non volatile NVRAM Your S7 300 CPU provides an area in the NVRAM non volatile RAM see Figure 5 3 If you have stored your program in the FEPROM of the load memory you can save certain data if there is a power outage or when the CPU changes from STOP to RUN by configuring your CPU accordingly To do this set the CPU so that the following data are saved in the non volatile RAM e Data contained in a DB This is only useful if you have also stored your program in an FEPROM of the load memory e Values of timers and counters e Data saved in bit memory On every CPU you can save a certain number of timers counters and memory bits A specific number of bytes is also available in which the data contained in DBs can be saved For more detailed information refer to the CPU descriptions 70 The MPI address of your CPU is stored in the NVRAM This makes sure that your CPU is capable of communication following a power outage or memory reset Dynamic load Configurable memory RAM Work memory System memory NVRAM memory Static load memory CPU FEPROM Plug in FEPROM cartridge optional Figure 5 3 Non Volatile Memory Area on S7 300 CPUs System Sof
20. manual When working with the software you can also use the online help system with the exception of HiGraph that provides you with detailed information about using the editors and compilers Optional package for system software for S7 300 S7 400 Other Manuals vi The various S7 300 and S7 400 CPUs the S7 300 and S7 400 modules and the instructions of the CPU are described in the following manuals e For the S7 300 programmable logic controller refer to the manuals Hardware and Installation CPU Data Module Data and the Instruction List e For the S7 400 programmable logic controller refer to the manuals Hardware and Installation CPU Data Module Data and the Instruction List System Software for S7 300 and S7 400 Program Design C79000 G7076 C506 01 Preface How to Use this Manual Conventions Additional Assistance Since this manual provides you with a basic overview of the operating system of the S7 300 400 we recommend that you first have a look at the general contents of the chapters and then select the topics that you will require when designing your program for more intensive reading e Chapter describes the basic tasks involved in planning an automation project e Chapter 2 shows you how to select the block structure for your S7 program Chapterd 3 and describe the role of the organization blocks when the CPU executes your program Chapters 5 and 6ldescribe the memory are
21. modules belonging to it You can only read the data of the system status list but not modify it It is a virtual list that is only created on request The information that you can display using the system status list can be divided into four areas Figure 11 2 shows the structure of the system status list System Status List System data ee Diagnostic data nm l in the CPU STE Diagnostic buffer Figure 11 2 System Status List There are two ways of reading out the information in partial system status lists as follows e Implicitly using the STEP 7 menu option on the programming device for example memory configuration static CPU data diagnostic buffer status bits e Explicitly using the System function SFC51 RDSYSST in the user program by specifying the required partial list number SFCs are described in detail in the reference manual 235 System Software for S7 300 and S7 400 Program Design C79000 G7076 C506 01 Diagnostics and Troubleshooting System Data System data are intrinsic or assigned characteristic data of a CPU Table 11 1 shows the topics about which information can be displayed partial system status list Table 11 1 System Data of the System Status List Topic Information List of all SZL IDs Partial lists available for a module Module identification Order number type ID and version of the module CPU characteristics Time system sy
22. 1 and the sixth is Op_temp 2 3 F 1 1 Integer lt 1 2 Integer Op_temp ARRAY 1 2 1 3 CiS Integer INTEGER 2 1 Integer gt lt s 22 Integer U 2 3 Integer Figure C 3 Multi dimensional Array You can define up to a maximum of 6 dimensions 6 indexes for a field You could for example define the variable Op_temp as follows as a six dimensional field ARRAY 1 3 1 2 1 3 1 4 1 3 1 4 The index of the first element in this array is Op_temp 1 1 1 1 1 1 The index of the last element Op_temp 3 2 3 4 3 4 You define arrays when you declare the data in a DB or in the variable declaration When you declare the array you specify the keyword ARRAY followed by the size in square brackets as follows lower limit value upper limit value In a multi dimensional array you also specify the upper and lower limit values and separate the individual dimensions by a comma Figure C 4 illustrates the declaration for creating a field in the format 2 x 3 like the array illustrated in Figure C 3 0 0 STRUCT TORO Heat_2x3 ARRAY 1 2 1 3 eZ INT END STRUCT Figure C 4 Creating an Array System Software for S7 300 and S7 400 Program Design C79000 G7076 C506 01 Data and Parameter Types Specifying Initial Values for an Array Accessing Data in an Array Using Arrays as Parameters
23. 1 Changing the Behavior and Properties of Modules Default Settings Which Modules Can You Assign Parameters to Setting and Loading Parameters System Data Blocks 8 2 When supplied all the configurable modules of the S7 programmable controller have default settings suitable for standard applications With these defaults you can use the modules immediately without making any settings The defaults are explained in the module descriptions 70 71 and 101 You can however modify the behavior and the characteristics of the modules to adapt them to your requirements and the situation in your plant Configurable modules are CPUs FMs CPs and some of the analog input output modules and digital input modules There are configurable modules with and without backup batteries Modules without backup batteries must be supplied with data again following any power down The parameters of these modules are stored in the retentive memory area of the CPU indirect parameter assignment by the CPU You set module parameters using STEP 7 When you save the parameters STEP 7 creates the object System Data Blocks that is loaded on the CPU with the user program and transferred to the modules when the CPU starts up System data blocks SDBs can only be evaluated by the operating system and cannot be edited with STEP 7 Not all the existing system data blocks are available on all CPUs refer to the CPU descriptions 70 and 101
24. 3 gt CPU 5 only with homogeneous PUT GET START STOP STATUS CPU 1 system from other vendor heterogeneous Note Distributed FMs on the P bus cannot currently take part in data exchange using communication SFBs for configured connections To allow data to be exchanged between communication partners the partners must be networked MPI PROFIBUS Industrial Ethernet and there must be a connection between the partners In STEP 7 you configure this connection by creating a connection table and loading it on the corresponding module with the user program The table contains the following information e The connection IDs for both communication partners e The remote communication partner e The type of communication Just as there is unilateral and bilateral communication there are also unilateral and bilateral connections e Unilateral connection there is only one communication SFB on the local communication partner e Bilateral connection there is a pair of blocks on the local and remote communication partners You must also specify the type of connection when you create the connection table The number of possible connections per configurable module depends on the CPU Each configured connection is identified by a connection ID This represents the local reference between the block and the connection The local and the remote communication partners of a configured connection can have different connection IDs
25. 300 and S7 400 Program Design C79000 G7076 C506 01 Setting System Parameters Updating the During cyclic program execution by the CPU the process image is updated Process Image automatically On S7 400 CPUs you can prevent updating of the process image in one of the two following situations e Ifyou want to access the I Os directly or e You want to update one or more process image input or output sections at a different point in the program using system functions SFC26 UPDAT_PI and SFC27 UPDAT_PO Communication To prevent communication functions extending the time required for program Load execution too much you can specify the maximum amount by which the cycle can be extended by communication When you decide on the load added to the cycle by communication remember that the operating system execution time further extends the run time If you set a communication load of 50 this does not double the original run time but more than doubles it the further increase depending on the CPU being used This is illustrated by an example based on a worst case situation Situation e The operating system execution time is 250 ms per second cycle time e The user program has a run time of 750 ms e The load on the cycle caused by communication is 0 A cycle can be represented in simplified form as follows 0 1 2 3 t t Opsy Upr Opsy Upr Opsy Upr 250 ms 750 ms 250 ms 750 ms 250 ms 750 ms Total cycle tim
26. CFC Users who want to work Description of oriented on the continuous technological functions processes Optional package without extensive programming or PLC experience 1 But with syntax check when editing 2 8 For a detailed description of these programming languages refer to the manuals 232 233 236 250 251 252 and 254 System Software for S7 300 and S7 400 Program Design C79000 G7076 C506 01 Structuring the User Program 2 6 Organization Blocks OB and Program Structure Definition Cyclic Program Execution Interrupt Driven Program Execution Linear Versus Structured Programming Organization blocks OBs are the interface between the operating system and the user program They are called by the operating system and control cyclic and interrupt driven program execution and how the programmable logic controller starts up They also handle the response to errors By programming the organization blocks you specify the reaction of the CPU In most situations the predominant type of program execution on programmable logic controllers is cyclic execution This means that the operating system runs in a program loop the cycle and calls the organization block OB1 once each time the loop is executed The user program in OB1 is therefore executed cyclically Cyclic program execution can be interrupted by certain events interrupts If such an event occurs the block currently being
27. Changes 9 1 Operating Modes and Mode Changes Operating Modes 9 2 Operating modes describe the behavior of the CPU at any particular point in time Knowing the operating modes of CPUs is useful when programming the startup debugging the control program and for troubleshooting Figure 9 1 shows the operating modes of the S7 300 and S7 400 CPUs STOP START UP RUN and HOLD 6 HOLD 10 9 2 al pee g 7 3 STARTUP g 1 STOP e _ 3 RUN a Figure 9 1 How the Operating Modes Change In the STOP mode the CPU checks whether all the configured modules or modules set by the default addressing actually exists and sets the I Os to a predefined initial status The user program is not executed in the STOP mode In the STARTUP mode a distinction is made between the startup types Complete Restart and Restart e JInacomplete restart the program starts at the beginning with initial settings for the system data and user address areas the non retentive timers counters and bit memory are reset e Inarestart the program is resumed at the point at which it was interrupted timers counters and bit memory are not reset A restart is only possible on 7 400 CPUs In the RUN mode the CPU executes the user program updates the inputs and output
28. Class Error OB OB85 00 ccc eee teens 11 22 11 14 Rack Failure OB OB86 0c eee eee 11 23 11 15 Communication Error OB OB87 0000s 11 24 11 16 Programming Error OB OB121 20 cece eee es 11 25 11 17 I O Access Error OB OB122 2 eee eens 11 26 A Sample Program for an Industrial Blending Process 0 5 A 1 Example of an Industrial Blending Process 0000eeeeeee A 2 A 2 Defining Logic BIOCKS 0 cece tenes A 4 A 3 Assigning Symbolic Names 000 eenaa A 5 A 4 Creating the FB for the Motor 00 00 cece eee eects A 7 A 5 Creating the FC for the Valves 00 0 cece eee eee eee eee A 11 A 6 Creating OB 4 0tvtecsttevieas ei oieeidues Side ci E A 13 B Sample Program for Communication SFBs for Configured Connections B 1 OVERVIOW aba ae se abe eee tA cele a aea Henrie ee gt E aaa p a anhaa aay aa aoe ahari s B 2 B 2 Sample Program on the Sending CPU 0 0 cece eee eee B 3 B 3 Sample Program on the Receiving CPU 0 cece eee eee B 4 Using the Sample Program 00 cece tee eee eee eae B 8 B 5 Call Hierarchy of the Blocks in the Sample Program Cc Data and Parameter TypeS 020c cee eeee eee eee e eens C 1 C 1 Datta TY OOS ie aes se a viele ieca EE R ne ened cetetes a eae span tte eee C 2 C 2 Using Complex Data Types 00 0 cece teeta C 6 C 3 Using
29. Control Programs 1 1 Planning the Automation Project Overview There are many ways of planning an automation project This section describes a basic procedure that you can use for any project Figure 1 1 outlines the basic steps Divide the process into tasks y Describe the individual tasks and areas y Define the safety requirements y Describe the required operator displays and controls y Create configuration diagrams of your programmable controller Figure 1 1 Basic Steps When Planning an Automation Project The individual steps are described in detail in Sections 1 2 tof1 6 System Software for S7 300 and S7 400 Program Design 1 2 C79000 G7076 C506 01 How to Design Control Programs 1 2 Dividing the Process into Individual Tasks Overview Identifying Areas and Tasks within the Process A process consists of individual tasks By identifying groups of related tasks within a process and then breaking these groups down into smaller tasks even the most complex process can be defined The following example of an industrial blending system can be used to illustrate how to organize a process into functional areas and individual tasks see Figure 1 2 M M gt AAE xt p Agitator motor Inlet Feed Feed Flow M Switch for tank valve pump valve sensor level measurem
30. Design C79000 G7076 C506 01 11 25 Diagnostics and Troubleshooting 11 17 I O Access Error OB OB122 Description Programming OB122 11 26 The operating system of the CPU calls OB 122 when a STEP 7 instruction accesses an input or output of a signal module to which no module was assigned at the last complete restart for example e Errors with direct I O access module defective or does not exist e Access to an I O address that is not known to the CPU You must generate the I O access error OB OB122 as an object in your S7 program using STEP 7 Write the program to be executed in OB122 in the generated block and download it to the CPU as part of your user program You can use OB122 for example for the following purposes e To evaluate the start information of OB122 e To call system function SFC44 and supply a replacement value for an output module so that the program has a feasible process dependent value for further processing If you do not program OB 122 the CPU changes to the STOP mode when an I O access error is detected System Software for S7 300 and S7 400 Program Design C79000 G7076 C506 01 Sample Program for an Industrial Blending Process What Does This Based on an example this chapter explains how you could design a program Chapter Describe for an industrial blending process The emphasis is not to teach programming style or to provide the technical knowledge required to control a part
31. FC to the formal parameters of a called FB Figure C 14 shows the formal parameters of FC10 that are assigned as actual parameters to the formal parameters of FB12 STEP 7 restricts the assignment of formal parameters of an FC to the formal parameters an FB You cannot for example assign parameters with a complex data type as actual parameters You can however assign input parameters of the types TIMER COUNTER or BLOCK to the input parameters of the called FB Table C 11 shows the restrictions for assigning parameters when an FC calls an FB Function FC FC10 Variable declaration Param_1 Input Param_2 Output Param_3 In out Call FB12 DB11 A_Param Param_1 B_ Param Param_2 C_Param Param_3 Call Function block FB FB12 with DB11 Variable declaration A_Param Input B Param Output C_Param In out Figure C 14 Restrictions when an FC Calls an FB Complex Data Types Elementary Data Types Transferring Parameters from an FC to an FB Parameter Types COUNTER BLOCK POINTER ANY Input gt Output Input gt In out Output gt Input Output gt Output Output gt In out In out gt Input In out gt Output In out gt In out C 22 System Software for S7 300 and S7 400 Program Design C79000 G7076 C506 01 Data and Parameter Types Restrictions when You can assign the
32. G7076 C506 01 6 7 System Software for S7 300 and S7 400 Program Design C79000 G7076 C506 01 Data Exchange Between Programmable Modules What Does This Chapter Describe Where to Find More Information Chapter Overview This chapter describes communication possible with the S7 300 and S7 400 programmable controllers Global data communication When data is exchanged using global data communication two or more networked CPUs share common data the global data For further information about the topic of global data communication and configuring connections refer to the STEP 7 online help and the STEP 7 user manual 231 The communication SFBs for configured connections are described in the reference manual 235 Heterogeneous communication using SIMATIC CPs is described in detail in the manuals 500 and 501 These manuals also describe the corresponding communication function blocks Section Description Page Types of Communication Data Exchange Using Communication SFBs for Configured 7 3 Connections 7 3 Configuring a Communication Connection between 7 5 Communication Partners 7 4 Working with Communication SFBs for Configured Connections 7 5 Data Exchange with Communication SFCs for 7 8 Non Configured Connections System Software for S7 300 and S7 400 Program Design C79000 G7076 C506 01 Data Exchange Between Programmable Modules 7 1 Types of Communication Overview S7 Communi
33. If you want your user program to react to an important signal that seldom occurs for example a limit value sensor indicates that a tank is full the section of program to be executed when this signal is output can be written in an OB that is not executed cyclically Apart from cyclic program execution STEP 7 provides the following types of program execution e Time driven program execution e Hardware interrupt driven program execution e Diagnostic interrupt driven program execution e Multicomputing interrupt driven program execution e Error handling Table 3 2 Organization Blocks that Can Interrupt OB1 Types of OB Start Events Time of day interrupt Date time of day OBs OB10 to OB17 Time delay OBs OB20 Delay time after programmed events to OB23 Cyclic interrupt OBs Intervals 1 ms to 1 minute OB30 to OB38 Hardware interrupt OBs Process signal from an I O module to the CPU or interrupt OB40 to OB47 from a function module Synchronous error OBs Errors in the user program programming errors and OB121 and OB122 access errors Asynchronous error OBs Priority class errors or faults on the PLC OB80 to OB87 Multicomputing interrupt SFC35 call OB OB60 System Software for S7 300 and S7 400 Program Design C79000 G7076 C506 01 Organization Blocks and Executing the Program Masking Start With system functions SFCs you can mask delay or disable the start events Events for severa
34. L SSTIME 0H_1H_1M_O0S_OMS L T 0D_1H_1M_0S_OMS L TIME 0D_1H_1M_0S_OMS L D 1994 3 15 L DATE 1994 3 15 TIME_OF_DAY CHAR Character Time in steps of 1 ms ASCII characters TOD 0 0 0 0 to TOD 23 59 59 999 A B etc System Software for S7 300 and S7 400 Program Design C79000 G7076 C506 01 L TOD 1 10 3 3 L TIME_OF_DAY 1 10 3 3 L E Data and Parameter Types Complex Data Types User Defined Data Types Complex data types define data groups that are larger than 32 bits or data groups consisting of other data types STEP 7 permits the following complex data types e DATE_AND_TIME e STRING e ARRAY e STRUCT e FBs and SFBs Table C 2 describes the complex data types They define structures and arrays either in the variable declaration of the logic block or in a data block Table C 2 Description of the Complex Data Types Daa DATE_AND_TIME Defines an area with 64 bits 8 bytes This data type saves the DT following information in binary coded decimal format year in byte 0 month in byte 1 day in byte 2 hours in byte 3 minutes in byte 4 seconds in byte 5 milliseconds in byte 6 and half of byte 7 weekday in the other half of byte 7 STRING Defines a group with a maximum of 254 characters data type CHAR The standard area reserved for a character string is 256 bytes long This is the space required to save 254 characters and a header of 2 bytes You can reduc
35. S7 300 and S7 400 Program Design C79000 G7076 C506 01 3 11 Organization Blocks and Executing the Program 3 7 Interrupting Program Execution Introduction Sequence of Program Execution Saving the Data 3 12 The operating system starts program execution by calling OB1 OB1 has the lowest priority This means that any other OB call is capable of interrupting the cyclic program When the operating system recognizes a start event for an OB with higher priority the execution of the program is interrupted after the currently active instruction The operating system saves the data of the interrupted block that will be required when the operating system resumes execution of the interrupted block An OB that interrupts the execution of another block can also call functions FCs and function blocks FBs The number of nested calls depends on the particular CPU Refer to the CPU descriptions 70 and 101 for the maximum nesting depth of your particular CPU If program execution is interrupted by a higher priority OB the operating system saves the current contents of the accumulators and address registers and the number and size of the open data blocks in the interrupt stack I stack Once the new OB has been executed the operating system loads the information from the I stack and resumes execution of the interrupted block at the point at which the interrupt occurred When the CPU is in the STOP mode you can display t
36. Table 6 2 Assignment of the Data Records Data Description Diagnostic data If the modules are capable of diagnostics you obtain the diagnostic data of the module by reading data records 0 and 1 Parameter data If the modules are configurable you transfer the parameters to the module by writing data records 0 and 1 You can use the information in the data records of a module to reassign parameters to configurable modules and to read diagnostic information from modules with diagnostic capability Table 6 3 shows which system functions you can use to access data records Table 6 3 System Functions for Accessing Data Records SFC Application Assigning parameters to modules SFC55 WR_PARM Transfers modifiable parameters data record 1 to the addressed signal module SFC56 Transfers the parameters data records 0 or 1 from WR_DPARM SDBs 100 to 129 to the addressed signal module SFC57 Transfers all parameters data records 0 and 1 from PARM_MOD SDBs 100 to 129 to the addressed signal module SFC58 WR_REC Transfers any data record to the addressed signal module Reading out diagnostic information SFC59 RD_REC Reads the diagnostic data You can access STEP 5 modules as follows e By connecting an S7 400 to SIMATIC S5 expansion racks using the network adapter IM 463 2 e By plugging in certain S5 modules in an adapter casing in the central rack of the S7 400 How you address S5 modules with SIMATIC S
37. The connection IDs are assigned by STEP 7 When you call the communication SFBs you must specify the corresponding connection ID as the input parameter for each block System Software for S7 300 and S7 400 Program Design C79000 G7076 C506 01 Data Exchange Between Programmable Modules 7 4 Working with Communication SFBs for Configured Connections System Function System function blocks and system functions are part of the operating system Blocks and System of an S7 CPU They can be called by the user program and are not loaded as Functions part of the user program Instance Data Just like function blocks system function blocks require an instance data Blocks block that contains the actual parameters and local data areas of the SFB Instance data blocks must be created with STEP 7 and loaded as part of the user program Addressing the The logical connection between two communication partners is identified by Communication their connection IDs Partner It is possible to use the same logical connection for different send receive jobs For this reason you must also specify a job ID R_ID in addition to the connection ID to indicate that the send and receive blocks belong together Communication partner1 local Communication partner2 remote Send block Receive block L ID USEND _ FO ru URCV O logical connection Receive block Send block URCV Pip R ID USEND
38. When you are creating the arrays you can assign an initial value to each element of the array STEP 7 provides two methods for entering initial values e Entry of individual values for each element of the array you specify a value that is valid for the data type of the array You specify the values in the order of the elements 1 1 Remember that the individual elements must be separated from each other by a comma e Specifying a repetition factor with sequential elements that have the same initial value you can specify the number of elements the repetition factor and the initial value for these elements The format for entering the repetition factor is x y where x is the repetition factor and y is the value to be repeated If you use the array declared in Figure C 4 you can specify the initial value for all six elements as follows 17 23 45 556 3342 0 You can set the initial value of all six elements to 10 by specifying 6 10 You could specify certain values for the first two elements and then set the remaining four elements to 0 by specifying the following 17 23 4 0 You access the data in an array using the index of the element of the array The index is used with the symbolic name Example If the array declared in Figure C 4 begins at the first byte of DB20 motor you access the second element in the array with the following address Motor Heat_2x3 1 2 You can transfer arrays as parameters If a parameter
39. about evaluating the diagnostic buffer refer to Section Table 11 4 Diagnostic Buffer of the System Status List Diagnostic events grouped For example the most recent events start messages from by topics standard OBs operating mode changes user defined events System Software for S7 300 and S7 400 Program Design C79000 G7076 C506 01 Diagnostics and Troubleshooting 11 3 Diagnostic Buffer Definition Uses Reading Out the Diagnostic Buffer Last Entry Before STOP One part of the system status list is the diagnostic buffer that contains more information about system diagnostic events and user defined diagnostic events in the order in which they occurred The information entered in the diagnostic buffer when a system diagnostic event occurs is identical to the start information transferred to the corresponding organization block The length of the diagnostic buffer depends on the particular CPU It is designed as a ring buffer in other words if the buffer is full the next entry overwrites the oldest entry in the buffer You cannot clear the entries in the diagnostic buffer and its contents are retained even after a memory reset The diagnostic buffer provides you with the following possibilities e If the CPU changes to the STOP mode you can evaluate the last events leading up to the STOP and locate the cause e The causes of errors can be detected far more quickly increasing the availability of the system
40. are described in detail in Appendix C You can specify initial values for all parameters and static data The value you select must be compatible with the data type If you do not specify an initial value a default value will be assigned depending on the data type of the variable System Software for S7 300 and S7 400 Program Design C79000 G7076 C506 01 Structuring the User Program 2 5 Range of Instructions of the S7 CPUs Overview The STEP 7 programming software is the link between the user and the S7 300 and S7 400 programmable logic controllers Using STEP 7 you can program your automation task in various programming languages The programming languages use the instructions provided by the S7 CPUs The range of instructions is described in detail in the instruction lists of the CPUs 72 and 102 The instructions can be divided into the following groups e Block instructions e Logic instructions bit word e Math instructions integer floating point e Comparison instructions e Logic control instructions e Load and transfer instructions e Logarithmic and trigonometric instructions e Shift and rotate instructions e Conversion instructions e Timer and counter instructions e Jump instructions Programming Table 2 3 shows the programming languages that are available and their most Languages important characteristics Which language you choose depends largely on your own experience and which language you personally
41. blending process Safety warning L stack overflow 3 13 Sample program data exchange between two S7 CPUs B 1 FB for the example of an industrial blending program A 7 44 10 OB for the blending process example A 15 JA 18 Sample programs example of an industrial blending process configuration diagram 1 11 describing the areas and tasks 1 5 1 7 description of the individual tasks and areas creating an I O diagram 1 7 description of the functions 1 5 description of the operator station dividing the process into tasks 1 3 functional areas of the equipment safety requirements industrial blending process A 2 inserting replacement values 11 14 11 16 reacting to battery faults 11 11 replacement values 11 14411 16 SCL Self test in complete restart Set actual module configuration SET_TINT 1 3 SFB 2 10 7 2 Index 6 SFB15 PUT SFB 19 START SFB9 URCV SFC SFC 36 MSK_FLT SFC_RTCB SFCO SET_CLK 4 4 8 4 SFC28 SET_TINT SFC29 CAN_TINT SFC3 CTRL_RTM B 4 SFC30 ACT_TINT SFC31 QRY_TINT SFC32 SRT_DINT SFC35 10 6 SFC37 DMSK_FLT SFC39 DIS_IRT SFC4 READ_RTM SFC40 EN_IRT SFC41 DIS_AIRT SFC42 EN_AIRT SFC44 RPL_VAL SFC46 STP SFC48 SFC_RTCB 8 4 SFC51 RDSYSST11 3 SFC52 WR_USMSG 11 8 SFC55 WR_PARM 6 5 8 3 SFC56 WR_DPARM 6 5 8 3 SFC57 PARM_MOD 6 5 SFC62 CONTROL SFC65 X_SEND 7 8 SFC66 X_RCV SFC67 X_GET SFC69 X_ABORT
42. complete restart the process image input table is read in and the STEP 7 user program processed starting with the first statement in OB1 A connection is established between stations that exchange data with each other A connection is only possible when the stations are attached to a common physical medium for example a bus system A logical connection software is then established between the stations Counters are an area in the system memory of the CPU The contents of these counters can be changed using STEP 7 instructions for example up counter down counter Static data are the local data of a function block that are saved in the instance data block and are therefore retained until the function block is executed again Temporary data are local data of a block that are located in the L stack while the block is being executed When execution of the block is completed the data are no longer available Data blocks are areas in the user program which contain user data There are shared data blocks which can be accessed by all logic blocks and there are instance data blocks which are associated with a particular function block FB call In contrast to all other block types data blocks do not contain any instructions Using a data type you specify how the value of a variable or constant is used in the user program In SIMATIC S7 there are two types of data type available complying with IEC 1131 3 elementary data types and comple
43. depends on its priority Higher priority OBs can interrupt lower priority OBs The lowest priority is 1 The background OB has the lowest priority namely 0 29 The events that lead to an OB being called are known as interrupts Table 3 1 shows the types of interrupt in STEP 7 and the priority of the organization blocks assigned to them Not all S7 CPUs have the complete range of organization blocks and priority classes listed in the table below see CPU descriptions 70 and 101 Table 3 1 Types of Interrupt and Priority Classes Type of Interrupt Organization Blocks Priority Class Main program scan OB1 Time of day interrupts OB10 to OB17 Time delay interrupts Cyclic interrupts System Software for S7 300 and S7 400 Program Design C79000 G7076 C506 01 Organization Blocks and Executing the Program Changing the Priority Start Information of an OB Table 3 1 Types of Interrupt and Priority Classes Type of Interrupt Organization Blocks Priority Class Hardware interrupts OB40 16 OB41 17 OB42 18 OB43 19 OB44 20 OB45 21 OB46 22 OB47 23 Multicomputing interrupt OB60 Multicomputing 25 Asynchronous error OB80 Time error 26 or 28 if the asynchronous error OB exists in the startup program OB81 Power supply error OB82 Diagnostic interrupt OB83 Insert remove module interrupt OB84 CPU hardware error OB85 Priority class error OB86 Rack failure OB87 Communication error interrupts Back
44. double word System Software for S7 300 and S7 400 Program Design C79000 G7076 C506 01 Addressing Peripheral I Os Module Start The module start address is the lowest byte address of a module It represents Address the start address of the user data area of the module and is used in many cases to represent the entire module The module start address is for example entered in process interrupts diagnostic interrupts insert remove module error interrupts and power supply error interrupts in the start information of the corresponding organization block and is used to identify the module that initiated the interrupt System Software for S7 300 and S7 400 Program Design C79000 G7076 C506 01 6 3 Addressing Peripheral I Os 6 2 Access to the Peripheral Data Area Overview User Data Diagnostic and Parameter Data The peripheral data area can be divided into the following e User data and e Diagnostic and parameter data Both areas have an input area can only be read and an output area can only be written User data is addressed with the byte address for digital signal modules or the word address for analog signal modules of the input or output area User data can be accessed with load and transfer commands communication functions operator interface access or by transferring the process image User data can be as follows e Digital and analog input output signals from signal modules e Control and status info
45. element of the UDT corresponds to the data type of the parameter System Software for S7 300 and S7 400 Program Design C79000 G7076 C506 01 Data and Parameter Types Advantages of DBs By using UDTs you have created once you can generate a large number of with an Assigned data blocks with the same data structure You can then use these data blocks UDT to enter different actual values for specific tasks If for example you structure a UDT for a formula for example for blending colors you can assign this UDT to several DBs each containing different amounts DB17 DARK_BLUE User defined data type DB22 LIGHT_BLUE mn UDT1 Formula DB23 TURQUOISE Figure C 10 Example of Assigning Several DBs to One UDT The structure of the data block is determined by the UDT assigned to it System Software for S7 300 and S7 400 Program Design C 14 C79000 G7076 C506 01 Data and Parameter Types C 6 Using the ANY Parameter Type Overview Assigning an Actual Parameter to an ANY Parameter You can define formal parameters for a block that are suitable for actual parameters of any data type This is particularly useful when the data type of the actual parameter that is provided when the block is called is unknown or can vary and when any data type is permitted In the variable d
46. exist or is too short Programming You must generate the communication error OB OB87 as an object in your OB87 S7 program using STEP 7 Write the program to be executed in OB87 in the generated block and download it to the CPU as part of your user program You can use OB87 for example for the following purposes e To evaluate the start information of OB87 e To create a data block if the data block for the status information of global data communication is missing If you do not program OB87 the CPU changes to the STOP mode when a communication error is detected System Software for S7 300 and S7 400 Program Design 11 24 C79000 G7076 C506 01 Diagnostics and Troubleshooting 11 16 Programming Error OB OB121 Description Programming OB121 The operating system of the CPU calls OB121 when a programming error occurs for example e Addressed timers do not exist e Acalled block is not loaded You must generate the programming error OB OB121 as an object in your S7 program using STEP 7 Write the program to be executed in OB121 in the generated block and download it to the CPU as part of your user program You can use OB121 for example for the following purposes e To evaluate the start information of OB121 e To enter the cause of an error in a message data block If you do not program OB121 the CPU changes to the STOP mode when a programming error is detected System Software for S7 300 and S7 400 Program
47. feed pump B fault Feed_pump_B_maint Q5 6 BOOL Lamp for feed pump B maintenance Agitator_running 11 0 BOOL Response signal of the agitator motor Agitator_start I1 1 BOOL Agitator start button Agitator_stop 11 2 BOOL Agitator stop button Agitator Q8 0 BOOL Activates the agitator Agitator_on Lamp for agitator running Agitator_fault Q8 3 BOOL Lamp for agitator motor fault Agitator_maint Q8 4 BOOL Lamp for agitator motor maintenance System Software for S7 300 and S7 400 Program Design A 6 C79000 G7076 C506 01 Sample Program for an Industrial Blending Process Table A 2 shows the symbolic names and the absolute addresses used to control the sensors and display the level in the tank Table A 2 Symbolic Addresses of the Sensors and for Displaying the Level of the Tank Symbolic Name Address Data Type Description Tank_below_max 11 3 BOOL Sensor mixing tank not full Tank_above_min 11 4 BOOL Sensor mixing tank above minimum level Tank_not_empty 11 5 BOOL Sensor mixing tank not empty Tank_max_disp Q9 0 BOOL Lamp for mixing tank full Tank_min_disp Q9 1 BOOL Lamp mixing tank below minimum level Tank_empty_disp Q9 2 BOOL Lamp for mixing tank empty Table A 3 shows the symbolic names and the absolute addresses used to control the drain valve Table A 3 Symbolic Addresses for the Drain Symbolic Name Address Data Type Description Drain_open 10 6 BOOL Bu
48. for S7 300 and S7 400 Program Design 2 C79000 G7076 C506 01
49. formal parameters of a calling FB to the formal an FB Calls parameters of the called FB Figure C 15 shows the formal parameters of Another FB FB 10 that are assigned as actual parameters to the formal parameters of FB12 STEP 7 restricts the assignment of the formal parameters of an FB to the formal parameters of another FB You cannot for example assign input and output parameters with complex data types as the actual parameters for the input and output parameters of a called FB You can however assign input parameters of the parameter types TIMER COUNTER or BLOCK to the input parameters of the called FB Table C 12 shows the restrictions for assigning parameters when an FB calls another FB Function block FB Call Function block FB FC10 with DB10 FB12 with DB11 Variable declaration Variable declaration Param_1 Input ON A_Param Input Param_2 Output B_Param Output Param_3 In out C_Param In out Call FB12 DB11 A_Param Param_1 B_ Param Param_2 C_Param Param_3 Figure C 15 Transferring Parameters from one FB to Another FB Table C 12 Restrictions when one FB Calls Another FB Elementary Complex Parameter Types Declaration Type Data T Data T ata ypes vata YPES TIMER COUNTER BLOCK POINTER ANY Input gt Input No No Input gt Output No No Input gt In out No No Output gt I
50. kW 134 hp at 1200 rpm The pumps are controlled start stop from an operator station located near the mixing tank The number of starts is counted for maintenance purposes Both the counters and the display can be reset with one button The following conditions must be satisfied for the pumps to operate The mixing tank is not full The drain valve of the mixing tank is closed The emergency stop is not active The pumps are switched off if the following condition is satisfied The flow sensor signals no flow 7 seconds after the pump motor is started The flow sensor signals that the flow has ceased Table 1 3 Description of the Inlet and Feed Valves Ingredients A B Inlet and Feed Valves The inlet and feed valves for ingredients A and B allow or prevent the flow of the ingredients into the mixing tank The valves have a solenoid with a spring return When the solenoid is activated the valve is opened When the solenoid is deactivated the valve is closed The inlet and feed valves are controlled by the user program System Software for S7 300 and S7 400 Program Design C79000 G7076 C506 01 1 5 How to Design Control Programs 1 6 Table 1 3 Description of the Inlet and Feed Valves continued Ingredients A B Inlet and Feed Valves 3 For the valves to be activated the following condition must be satisfied The feed pump motor has been running for at least 1 second
51. logic block FB21 Motor processing e CALL FB21 DB100 Variable declaration Data for motor_1 transfers data for Motor_1 stat Motor_1 FB22 Motor_2 Motor_3 stat Motor_2 FB22 Data for motor_2 stat Motor_3 FB22 Call FB22 from FB21 CALL Motor_1 CALL Motor_2 CALL Motor_3 Data for motor_3 FB22 Motors Figure 2 6 Using an Instance DB for Several Instances One Instance DB In a function block you can call the instances of other existing FBs The for Several example in Figure 2 7 shows the assigned instance data once again saved in Instances of a common instance DB Different FBs g Access only for FB12 call DB12 Motor 3 Pelee Lal CALL FB12 DB112 l Access only for FB13 call DB13 Pum FB13 Pump eee p CALL FB13 DB13 gt DB14 Access for FB14 FB13 and FB14 Agitator lt ______ FB12 call Variable declaration Data for agitator CALL FB14 DB14 stat Motor 10 FB12 transfers data for agitator A Motor_10 and Pump_10 stat Pump_10 FB13 Data for Motor 10 g Ps Call FB12 from FB14 Data for Pump_10 CALL Motor_10 Call FB13 from FB14 CALL Pump_10 Figure 2 7 Using one Instance DB for Several Instances of Different FBs System Software for S7 300 and S7 400 Program Design 2 16 C79000 G7076 C506 01 Structuring the User Program 2 11 Shared Data Blocks DB Definition Structure
52. mode selector is set to RUN and you attempt to set the CPU to STOP at the programming device the CPU will change to STOP because this mode has the highest priority Priority Mode Highest STOP HOLD START UP Lowest RUN System Software for S7 300 and S7 400 Program Design 9 4 C79000 G7076 C506 01 Operating Modes and Mode Changes 9 2 STOP Mode Features Memory Reset When the CPU is in the STOP mode the user program is not executed All the outputs are set to substitute values so that the controlled process is in a safe status The CPU makes the following checks e Are there any hardware problems for example modules not available e Should the default setting apply to the CPU or are there parameter records e Are the conditions for the programmed startup behavior satisfied e Are there any system software problems In the STOP mode the CPU can also receive global data and passive unilateral communication is possible using communication SFBs for configured connections and communication SFCs for non configured connections see also Table 9 5 The CPU memory can be reset in the STOP mode The memory can be reset manually using the keyswitch MRES or from the programming device for example before downloading a user program Resetting the CPU memory returns the CPU to its initial status as follows e The entire user program in the work memory and in the RAM load memory and all address areas are c
53. not the case an error message is entered in the diagnostic buffer and an asynchronous error routine is executed OB80 see Chapter I1 Time delay interrupt OBs that were deselected by the parameter assignment cannot be started The CPU recognizes a programming error and changes to the STOP mode System Software for S7 300 and S7 400 Program Design C79000 G7076 C506 01 4 5 Handling Interrupts 4 4 Cyclic Interrupts OB30 to OB38 Description The S7 CPUs provide cyclic interrupt OBs that interrupt cyclic program execution at certain intervals Cyclic interrupts are triggered at intervals The time at which the interval starts is the mode change from STOP to RUN Starting To start a cyclic interrupt you must specify the interval in the cyclic interrupts parameter field using STEP 7 The interval is always a whole multiple of the basic clock rate of 1 ms Interval n X basic clock rate 1 ms Each of the nine available cyclic interrupt OBs has a default interval see Table 4 3 The default interval becomes effective when the cyclic interrupt OB assigned to it is loaded You can however assign parameters to change the default values For the upper limit of the intervals for cyclic interrupts refer to the CPU descriptions 70 and 101 Phase Offset To avoid cyclic interrupts of different cyclic interrupt OBs being started at the same point and possibly causing a time error cycle time exceeded you can specify a phase off
54. opened The state of the interlocks is saved in the temporary local data L stack of FB1 Valve_enable and is logically combined with the inputs for opening and closing when the FC for the valves is executed Table A 7 shows the parameters that must be transferred to the FC Table A 7 Input In Out and Output Parameters Parameters for the Valves Open Close Dsp_open Dsp_closed Valve Specifying the Figure A 4 shows the inputs and outputs of the general FC for the valves Inputs and The devices that call the FB for the motor transfer input parameters The FC Outputs for the valves returns output parameters Open Close Valve Ventil Dsp_Open Dsp_Closed Figure A 4 Inputs and Outputs of the FC for the Valves System Software for S7 300 and S7 400 Program Design C79000 G7076 C506 01 Sample Program for an Industrial Blending Process Declaring the Just as with the FB for the motor you must also declare the input in out and Variables of the FC output parameters for the FC for the valves Tor Me valvas With FCs the temporary variables are saved in the L stack The input output and in out variables are saved as pointers to the logic block that called the FC Additional memory space in the L stack after the temporary variables is used for these variables Table A 8 Variable Declaration Table of the FC for the Valves Address Declaration Type Default 0 0 IN O
55. or not a timer is running On the S7 300 timers can be started and updated simultaneously only in OB 1 and OB100 Timers can only be started in all the other OBs System Software for S7 300 and S7 400 Program Design C79000 G7076 C506 01 8 11 Setting System Parameters 8 8 Changing the Priority Classes and Amount of Local Data Introduction Fixed Priority Classes Changing the Priority Local Data Changing the Amount of Local Data Deselected Interrupt OBs Uses 8 12 On S7 400 CPUs you can set parameters to change the priority of some of the interrupt OBs This means that you can decide which interrupt OBs can be interrupted by higher priority interrupt OBs You cannot change the priority classes of the following OBs e Main program scan OB1 e Background OB90 e Startup types OB100 and OB101 e Multicomputing OB60 e Asynchronous errors OB80 to 87 e Error OBs started by synchronous errors They are executed in the same priority class as the block being executed when the error occurred You can change the default priority of the interrupt OBs providing such a change is permitted by changing the parameters in the parameter fields time of day interrupts time delay interrupts cyclic interrupts and hardware interrupts see also Section 3 1 When creating logic blocks OBs FCs FBs you can declare temporary local data The local data area on the CPU is divided among the priority classes O
56. programs refer to the manuals for the programming languages 232 233 and 250 through 254 and the STEP 7 user manual 231 Table 9 6 Testing the User Program Test Function Description Display program status Displays the program status for each statement for example result of logic operation RLO status bit content of the registers and accumulators Set trigger points Allows you to display and modify variables addresses at monitor and control certain points in the program variables Display diagnostic buffer Allows you to evaluate errors and reasons for changing to the STOP mode Display stack contents Allows you to evaluate the contents of the B stack I stack and L stack Display cycle times Allows you to check the selected minimum cycle time the maximum and current cycle time Display operating mode Allows you to display the current operating mode of the CPU System Software for S7 300 and S7 400 Program Design C79000 G7076 C506 01 Multicomputing What Does This This chapter describes the following Chapter Describa What multicomputing means e How interrupt servicing functions e Points to remember when configuring the system e How to configure modules for the multicomputing mode e Points to remember when programming e How the CPUs are synchronized e What errors can occur in the multicomputing mode Configuring Modules 10 3 Programming the CPUs 10 4 Synchronizing the CPU
57. signal from the motor and pumps to indicate that the motor is running e It must calculate the time between sending the signal to activate the motor and receiving the response signal If no response signal is received in this time the motor must be switched off e Jt must turn the lamps on the operator station on and off e It supplies a signal to activate the motor These requirements can be specified as inputs and outputs to the FB Table A 5 shows the parameters of the FB for the motor in out sample process Table A 5 Input and Output Parameters Parameters for Pumps and In Out Motor Start Stop Response Reset_maint Timer_no Response_time Val Fault Start_dsp Stop_dsp Maint Motor a System Software for S7 300 and S7 400 Program Design C79000 G7076 C506 01 A 9 Sample Program for an Industrial Blending Process Declaring the Variables of the FB for the Motor Programming the FB for the Motor You must declare the input in out and output parameters of the FB for the motor With FBs the input output in out and static variables are saved in the instance DB specified in the call statement The temporary variables are stored in the L stack Table A 6 Variable Declaration Table of the FB for the Motor 0 3 Reset_maint BOOL FALSE a C r 6 0 Fault BOOL FALSE 6 3 oor S BOOL ease 10 0 star wsio o 12 0 Pm Time_BCD WORD wie 16 0 STAT BOOL FALSE In STEP
58. the CPU memory is automatically reset and a complete restart executed after the power is turned on or when power returns following a power outage The user program must be located on a flash EPROM memory card Following a power outage in the RUN mode followed by a return of power S7 400 CPUs run through an initialization routine and then automatically execute a restart During a restart the user program is resumed at the point at which its execution was interrupted The section of user program that had not been executed before the power outage is known as the remaining cycle see also Figure 9 2 The remaining cycle can also contain time and interrupt driven program sections A restart is only permitted when the user program was not modified in the STOP mode for example by reloading a modified block and when there are no other reasons for a complete restart refer to complete restart Both a manual and automatic restart are possible A manual restart is only possible with the appropriate parameter settings in the parameter record of the CPU and when the STOP resulted from the following causes e The mode selector was changed from RUN to STOP e The STOP mode was the result of a command from the programming device A manual restart can be triggered as follows e Using the mode selector The CRST WRST must be set to WRST e Using the menu option on the programming device or by communication functions when the mode selector is se
59. types for formal parameters that are transferred between blocks see Table C 3 STEP 7 recognizes the following parameter types e TIMER or COUNTER this specifies a particular timer or particular counter that will be used when the block is executed If you supply a value to a formal parameter of the TIMER or COUNTER parameter type the corresponding actual parameter must be a timer or a counter in other words you enter T or C followed by a positive integer e BLOCK specifies a particular block to be used as an input or output The declaration of the parameter determines the block type to be used FB FC DB etc If you supply values to a formal parameter of the BLOCK parameter type specify a block address as the actual parameter Example FC101 when using absolute addressing or Valve with symbolic addressing e POINTER references the address of a variable A pointer contains an address instead of a value When you supply a value to a formal parameter of the parameter type POINTER you specify an address as the actual parameter In STEP 7 you can specify a pointer in the pointer format or simply as an address for example M 50 0 Example of a pointer format for addressing the data beginning at M 50 0 P M50 0 e ANY this is used when the data type of the actual parameter is unknown or when any data type can be used For more information about the ANY parameter type refer to Section C 6 A parameter typ
60. used to measure the time The logic block also requires four outputs two to indicate the operating state of the motor one to indicate faults and one to indicate that the motor is due for maintenance An in out is also necessary to activate the motor This is also processed or modified in the motor block program Start Fault Stop Start_Dsp Response Stop_Dsp Reset_Maint Motor Maint Timer_No Response_Time Motor Figure 1 5 T O Diagram of the Agitator Motor Motor Block System Software for S7 300 and S7 400 Program Design C79000 G7076 C506 01 1 7 How to Design Control Programs Creating an I O Each valve is controlled by a valve block that is the same for all the valves Diagram for the used The logic block has two inputs one to open and one to close the valve Valves It also has two outputs one to indicate that the valve is open and the other to indicated that it is closed The block has an in out to activate the valve This is also processed or modified in the valve block program Open Dsp_Open Close Dsp_Closed Valve Valve Figure 1 6 T O Diagram of the Valves System Software for S7 300 and S7 400 Program Design 1 8 C79000 G7076 C506 01 How to Design Control Programs 1 4 Establishing the Safety Requirements Overview Defining Safety Requirements Creating a Safety Circuit Decide which additional elements are needed to ensure th
61. variable tables VAT 1 on the sending CPU and VAT 2 on the receiving CPU 4 On the receiving CPU enable the receive SFBs by setting memory bits M20 1 and M20 3 to 1 in variable table VAT 2 5 Start the data transfer on the sending CPU by setting the corresponding memory bit to 1 in variable table VAT 1 see Table B 2 6 If required change the content of the send areas 7 Ifan error occurs in the data transfer evaluate the output parameters ERROR and STATUS of the relevant communication SFB System Software for S7 300 and S7 400 Program Design B 8 C79000 G7076 C506 01 Sample Program for Communication SFBs for Configured Connections B 5 Call Hierarchy of the Blocks in the Sample Program Call Hierarchy on the Sending CPU OB100 lt FC EXAMPLE_ PRESET_SFBs_1 SFB DB IDB_USEND USEND OB35 FC EXAMPLE _ USEND FC EXAMPLE _ BSEND FC EXAMPLE _ GET FC EXAMPLE _ PUT ie FC EXAMPLE _ START LK FC EXAMPLE _ STOP lt FC EXAMPLE_ RESUME FC EXAMPLE_ STATUS FC EXAMPLE_ USTATUS AAA AA AA MA AA MA AA SFB DB IDB_USTATUS USTATUS SFB DB IDB_USEND USEND FC CHECK SFB BSEND DB IDB_BSEND FC CHECK DB IDB_GET SFB GE
62. 0 G7076 C506 01 Memory Areas of S7 CPUs Data Blocks Created with SFCs Data Blocks Not Relevant for Program Execution The CPU stores data blocks that were created using system functions for example SFC22 CREAT_DB in the user program only in the work memory and not in the load memory Data blocks that were programmed in a source file as part of an STL program can be identified as Not Relevant for Execution keyword UNLINKED This means that when they are downloaded to the CPU the DBs are stored only in the load memory The content of such blocks can if necessary be copied to the work memory using SFC20 BLKMOV This technique saves space in the work memory The expandable load memory is then used as a buffer for example for formulas for a mixture only the formula for the next batch is loaded in the work memory System Software for S7 300 and S7 400 Program Design C79000 G7076 C506 01 5 7 Memory Areas of S7 CPUs 5 4 Retentive Memory Areas on S7 300 CPUs Overview Using the NVRAM 5 8 If a power outage occurs or the CPU memory is reset MRES the memory of the S7 300 CPU dynamic load memory RAM work memory and system memory is reset and all the data previously contained in these areas is lost With S7 300 CPUs you can protect your program and its data in the following ways e You can protect all the data in the load memory work memory and in parts of the system memory with battery backup
63. 0 bytes IMJ in the L stack Figure 3 5 Assignment of Local Data to the Priority Classes Caution S7 CPUs change to the STOP mode if the permitted L stack size for a program is exceeded All the temporary variables TEMP of an OB and its associated blocks are saved in the L stack If you use too many nesting levels when executing your blocks the L stack can overflow Test the L stack the temporary variables in your program System Software for S7 300 and S7 400 Program Design C79000 G7076 C506 01 3 13 Organization Blocks and Executing the Program Assigning Local Different priority classes require different amounts of memory in the local Data to Priority data stack By assigning parameters with STEP 7 you can select the size of Classes the local data area for the individual priority classes on S7 400 CPUs If you are not using certain priority classes you can use their areas for other priority classes on S7 400 CPUs Deactivated OBs are ignored during program execution and save cycle time On S7 300 CPUs each priority class is assigned a fixed number of local data 256 bytes and this setting cannot be changed System Software for S7 300 and S7 400 Program Design 3 14 C79000 G7076 C506 01 Handling Interrupts What Does This This chapter describes the interrupt OBs for time of day interrupts Chapter Describe time delay interrupts cyclic interrupts and hardware i
64. 00cc cece ee eee eee eens 2 1 The Programs ina CPU 0 ccc nee 2 2 Elements of the User Program 0 cece eee eee ees 2 3 Call Hierarchy of the Blocks 0 000 eee cece eee eee eee 2 4 Variables of a Block 0 0 0 cece eects 2 5 Range of Instructions of the S7 CPUS 0 cece eee eens 2 6 Organization Blocks OB and Program Structure 2 7 System Function Blocks SFB and System Functions SFC 2 8 FUNCHIONS FG auch vous oti g itna EEN an elie wits Ge E was 2 9 Function Blocks FB 0 00 cece eee cece teen eee ees 2 10 Instance Data Blocks 0 0 eens 2 11 Shared Data Blocks DB 000s cece eee ee 2 12 Saving the Data of an Interrupted Block 00000 cee eee eee 2 13 Avoiding Errors when Calling Blocks 00000 eee eee e eee System Software for S7 300 and S7 400 Program Design C79000 G7076 C506 01 fe lal 25 lE i Contents 3 Organization Blocks and Executing the Program 0eeeeeeeeeees 3 1 3 1 Types of Organization Block 00 e eee 3 2 3 2 Organization Blocks for the Startup Program 20200000s 3 4 3 3 Organization Block for Cyclic Program Execution 4 3 5 3 4 Organization Block for Background Program Execution 3 7 3 5 Organization Blocks for Interrupt Driven Program Execution 3 8 3 6 Organization Blocks for Han
65. 01 2 17 Structuring the User Program 2 12 Saving the Data of an Interrupted Block Overview The CPU has a block stack B stack for saving information belonging to a logic block that has been interrupted Using this data the user program can then be resumed after the interrupt When one of the following events occurs block information is saved in the B stack e When a different block is called within a CPU program e When a block is interrupted by a higher priority class for more detailed information about priority classes refer to Chapter 3 Block Stack The block stack B stack is a memory area in the system memory of the CPU see also Chapter 5 If the execution of a block is interrupted by a call for a different block the following data is saved in the B stack e Number type OB FB FC SFB SFC and return address of the block that was interrupted e Numbers of the data blocks from the DB and DI register that were open when the block was interrupted If the CPU is in the STOP mode you can display the B stack with STEP 7 on a programming device The B stack lists all the blocks that had not been completely executed when the CPU changed to the STOP mode The blocks are listed in the order in which they were called in the program see Figure 2 9 Order in which the FB1 FC2 FC3 blocks are called Block stack B stack Data of FC3 Local data stack L stack e Bl
66. 1 Message points 2 and 3 MP2 MP3 All CPUs change from HOLD to STARTUP or RUN at the same time Execution of the user program is started again at the same time The selected startup was stopped due to a system or or user program error A message is sent to all CPUs The CPU changes to the HOLD mode All CPUs are instructed to interrupt their programs at the next command boundary and to change to the HOLD mode Message point 4 MP4 Message points 5 and 6 MP5 MP6 The CPU changes to the STOP mode All CPUs are instructed to interrupt their programs at the next command boundary and to change to the STOP mode The CPU changes to the STOP mode as a result of the mode selector on one or more CPUs being set to the STOP mode All CPUs are instructed to change to the STOP mode as well System Software for S7 300 and S7 400 Program Design C79000 G7076 C506 01 10 9 Multicomputing 10 5 Dealing with Errors Overview Checking the Consistency of the CPUs 10 10 Undesired statuses can occur in the multicomputing mode Possible causes of errors are described below e Ifa CPU is prevented from starting up no other CPU starts up since all CPUs change to STOP if one of the CPUs is in the STOP mode e If the mode selector on a CPU is set to STOP or if the CPU chages to STOP as a result of a command from the programming device all other CPUs are also in the STOP mode e Ifthe startup type COMPLETE R
67. 3 Description Assigning Parameters to a Newly Plugged In Module Programming OB83 11 20 S7 400 CPUs monitor the presence of modules in the central rack and expansion racks at intervals of approximately 1 second After the power supply is turned on the CPU checks whether all the modules listed in the configuration table created with STEP 7 are actually plugged in If all the modules are present the actual configuration is saved and is used as a reference value for cyclic monitoring of the modules In each scan cycle the newly detected actual configuration is compared with the previous actual configuration If there are discrepancies between the configurations an insert remove module interrupt is signaled and an entry is made in the diagnostic buffer and the system status list see also module monitoring in Section 8 3p In the RUN mode the insert remove module interrupt OB is started Note Power supply modules CPUs and IMs must not be removed in the RUN mode Between removing and inserting a module at least two seconds must be allowed to pass so that the CPU can detect that a module has been removed or inserted If a module is inserted in in the RUN mode the CPU checks whether the module type of the new module matches the original module If they match the module is assigned parameters Either the default parameters or the parameters you assigned with STEP 7 are transferred to the module The insert remove mo
68. 300 and S7 400 Program Design C79000 G7076 C506 01 How to Design Control Programs 1 5 Describing the Required Operator Displays and Controls Overview Every process needs an operator interface that allows human intervention in the process Part of the design specification includes the design of the operator station Defining an In the industrial blending process described in our example each device can Operator Station be started or stopped by a push button located on the operator station This operator station includes indicators to show the status of the operation see Figure 1 7 The console also includes display lamps for devices that require maintenance after a certain number of starts and the emergency stop switch with which the process can be stopped immediately The console also has a reset button for the maintenance display of the three motors Using this you can turn off the maintenance display lamps for the motors due for maintenance and reset the corresponding counters to 0 Ingr A Ingr B Start Open start start il agitator Tank full drain Ca CLD e stop stop agitator below mini drain l Reset maintenance Maint Maint Maint Tank pump A pump B agitator empty EMERGENCY STOP Figure 1 7 Example of an Operator Station Console System Software for S7 300 and S7 400 Program Design 1 10 C79000 G7076 C506 01 How to Design Control P
69. 400 Programming State Graphs Manual Continuous Function Charts for S7 300 S7 400 M7 Continuous Function Charts System Software for S7 300 and S7 400 Program Design C79000 G7076 C506 01 D 1 D 2 270 Manual S7 PDIAG for S7 300 and S7 400 Configuring Process Diagnostics for LAD FBD and STL 500 Manual SIMATIC NET NCM S7 for Industrial Ethernet 501 Manual SIMATIC NET NCM S7 for PROFIBUS System Software for S7 300 and S7 400 Program Design C79000 G7076 C506 01 Glossary A Actual Parameters Address Backplane Bus Backup Actual parameters replace the formal parameters when a function block FB or function FC is called Example the formal parameter Start is replaced by the actual parameter I 3 6 An address is part of a STEP 7 statement and specifies what the processor should execute the instruction on Addresses can be absolute or symbolic The backplane bus of a SIMATIC S7 programmable logic controller supplies the modules in the rack with the internal operating voltage and allows data exchange between the modules On the S7 400 the backplane bus is divided into the peripheral bus P bus and communication bus C bus On the S7 300 the backplane bus has a modular design in the form of U shaped profiles that connect two modules together In SIMATIC S7 information stored in the RAM areas in the work memory can be e Saved by means of a backup battery in this case the cont
70. 7 every block that is called by a different block must be created before the block that contains its call In the sample program you must therefore create the FB for the motor before OB1 The statement section of FB1 appears as follows in the STL programming language Network 1 Start Stop and latching AC O Start O Motor AN Stop 7 Motor System Software for S7 300 and S7 400 Program Design C79000 G7076 C506 01 Sample Program for an Industrial Blending Process Network 2 Startup monitoring A Motor L Response_time SD Timer_no AN Motor R Timer_no L Timer_no T Time_bin LC Timer_no T Time_BCD A Timer_no AN _ Response S Fault R Motor Network 3 Start lamp Fault response A Response Start_dsp R Fault Network 4 Stop lamp AN Response Stop_dsp Network 5 Counting the starts A Motor FP Start_edge JCN labil L Starts 1 T Starts lab1 NOP Network 6 Maintenance L Starts L 50 gt Maint Network 7 Maintenance reset AN Reset_maint A Maint JCN END L 0 T Starts END NOP 0 System Software for S7 300 and S7 400 Program Design C79000 G7076 C506 01 Sample Program for an Industrial Blending Process A 5 Creating the FC for the Valves What is Required The function for the inlet and feed valve and for the drain valve contains the of the FC following logical functions e There is an input for opening and an input for closing the valves e Interlocks allow the valves to be
71. 7 is explained in the manual 100 or in the description supplied with the adapter casing System Software for S7 300 and S7 400 Program Design C79000 G7076 C506 01 6 5 Addressing Peripheral I Os 6 3 Special Features of Distributed Peripheral I Os DP Distributed I Os Attachment to S7 Configuration Addressing the DP Master and DP Slaves Access to User Data Access to Diagnostic and Parameter Data 6 6 With SIMATIC S7 you can use the distributed peripheral I Os DP Distributed I Os are analog and digital modules installed close to the process and function modules FM installed on the P bus and therefore normally at some distance from the CPU You can attach distributed peripherals to the S7 programmable logic controller using the SINEC L2 DP bus system and one of the following e The integrated DP master interface of a CPU for example CPU 315 2 DP CPU 413 2 DP CPU 414 2 DP e An interface module assigned to a CPU FM for example IF 964 DP in the CPU 388 5 CPU 488 5 e An external DP master interface for example CP 443 5 CP 342 5 IM 467 Distributed modules are configured in the same way as central modules using STEP 7 refer to the STEP 7 user manual 231 The address area of the distributed I Os is the same for DP master and DP slave modules and corresponds to the peripheral I O address shown in Table 6 1 The DP master module provides a data area for the user data of the distribut
72. Arrays to Access Data 00 c ccc cect eect eens C 7 C 4 Using Structures to Access Data 000 ccc cece neces C 10 C 5 Using User Defined Data Types to Access Data 2 20055 C 12 C 6 Using the ANY Parameter Type 00 0c cece e eee eee eee C 15 C 7 Assigning Data Types to Local Data of Logic Blocks C 17 C 8 Restrictions When Transferring Parameters 0000eeeeee C 19 D REICKENCES eocen daedi ced ick eee na eee ee Cease owed eee System Software for S7 300 and S7 400 Program Design xII C79000 G7076 C506 01 How to Design Control Programs What Does This Chapter Describe Where to Find More Information Chapter Overview System Software for S7 300 and S7 400 Program Design C79000 G7076 C506 01 This chapter outlines the basic tasks involved in planning an automation project and designing a user program for a programmable controller PLC Based on an example of automating an industrial blending process you are guided step by step through the procedure The example of a program for an industrial blending process is described in Appendix A Section Description a Planning the Automation Project Dividing the Process into Individual Tasks Describing the Individual Tasks and Areas Establishing the Safety Requirements Describing the Required Operator Displays and Controls Creating a Configuration Diagram 1 1 How to Design
73. B40 to OB47 Description The S7 CPUs provide hardware interrupt OBs that react to signals from the modules for example signal modules SMs communications processors CPs function modules FMs With S7 you can decide which signal from a configurable digital or analog module starts the OB With CPs and FMs use the appropriate parameter assignment dialogs Hardware interrupts are triggered when a signal module with hardware interrupt capability and with an enabled hardware interrupt passes on a received process signal to the CPU or when a function module of the CPU signals an interrupt Assigning Each channel of a signal module with hardware interrupt capability can Parameters trigger a hardware interrupt For this reason you must specify the following in the parameter records of signal modules with hardware interrupt capability using STEP 7 e What will trigger a hardware interrupt e Which hardware interrupt OB will be executed the default for executing all hardware interrupts is OB40 Using STEP 7 you activate the generation of hardware interrupts on the function blocks You assign the remaining parameters in the parameter assignment dialogs of these function modules Priority The default priority classes for the hardware interrupt OBs are 16 to 23 see also Section 3 1 You can assign parameters to change the priority classes Note Hardware interrupts can only be executed when the corresponding organization block is located in
74. CPU This leads to the following behavior e The interrupted priority classes on the CPUs are continued at different times e A multicomputing interrupt is not serviced if it occurs during the execution of OB60 on any of the CPUs A message is however generated and you can check this and react accordingly see example step 3 RETVAL If OB60 is not loaded on one of the CPUs this CPU returns immediately to the last priority class and continues the program there System Software for S7 300 and S7 400 Program Design C79000 G7076 C506 01 10 7 Multicomputing 10 4 Synchronizing the CPUs Overview Message Points MP Wait Points WP Synchronization Points of a CPU 10 8 In the multicomputing mode the involved CPUs are synchronized automatically in other words the individual CPUs are forced to adopt the same operating mode If for example one CPU changes to the STOP mode all the CPUs are set to STOP This synchronization in the multicomputing mode makes use of two synchronization points e Message points MP e Wait points WP Message points ensure that the CPUs change to STOP as soon as possible At a message point one CPU signals a particular event to the other CPUs The message has high priority and causes all the other CPUs to interrupt the user programs at the next command boundary Wait points ensure that the user programs on all CPUs are started together and that an operating mode change only take
75. Discard diagnostic interrupts X X Update the system status list SZL X X Evaluate module parameters and transfer to X X modules or transfer default values Execution of the relevant startup OB X X Execute remaining cycle part of the user program 0 X not executed due to the power down Update the process image input table X X Enable digital outputs cancel OD signal X X System Software for S7 300 and S7 400 Program Design C79000 G7076 C506 01 9 9 Operating Modes and Mode Changes Aborting a Startup 9 10 If an error occurs during startup the startup is aborted and the CPU changes to or remains in the STOP mode An aborted complete restart must be repeated After an aborted restart both a complete restart and a restart are possible No startup complete restart or restart is executed or it is aborted in the following situations The keyswitch of the CPU is set to STOP A memory reset is requested A memory card with an application identifier that is not permitted for STEP 7 is plugged in for example STEP 5 More than one CPU is plugged in in the single processor mode If the user program contains an OB that the CPU does not recognize or that has been disabled When after power up the CPU recognizes that not all the modules listed in the configuration table created with STEP 7 are actually plugged in If errors occur when evaluating the module parameters A restart is not executed or is aborted in the fo
76. ECK FC EXAMPLE_STOP Call for SFB STOP and FC CHECK FC EXAMPLE_RESUME Call for SFB RESUME and FC CHECK FC EXAMPLE STATUS Call for SFB STATUS and FC CHECK FC Call for SFB USTATUS and FC CHECK EXAMPLE _USTATUS DB IDB_USEND DB IDB_BSEND Checks the status of the SFB Controlling SFB calls with FCs prevents the SFBs being called again before they are completed DB IDB_GET DB IDB_PUT DB IDB_START ae oe noe data of the SFBs Tastance DBs of the SFBs used DB IDB_STOP DB IDB_RESUME DB IDB_STATUS DB IDB_USTATUS DB data_usend Send control and check data for FC EXAMPLE _USEND DB data_bsend Send control and check data for FC EXAMPLE_BSEND DB data_get Send control and check data for FC EXAMPLE_GET DB data_put Source area control and check data for FC EXAMPLE_PUT DB data_program_cntr Control and check data for SFBs START STOP RESUME STATUS and USTATUS DB data_get_source DB on the remote CPU from which the data are read by SFB GET DB data_put_destination DB on the remote CPU in which the data are written by SFB PUT Shared DBs System Software for S7 300 and S7 400 Program Design B 4 C79000 G7076 C506 01 Sample Program for Communication SFBs for Configured Connections Defining Symbolic Names In the sample program on the sending CPU symbols are used that were defined with STEP 7 in the symbols table Table B 4 shows the symbolic names and the a
77. EPROM section refer to the CPU descriptions 70 and 101 Areas in data blocks can be declared as being retentive by assigning parameters with STEP 7 see Section 5 4 Use of a memory card RAM or FEPROM is required to expand the load memory on S7 400 CPUs The integrated load memory is a RAM memory and is used essentially for loading and correcting blocks individually The structure of the load memory RAM and FEPROM area affects the possibilities for downloading your user program or for downloading individual blocks Table 5 1 shows how the program and blocks are downloaded Table 5 1 Load Memory Structure and What can be Downloaded Memory Type Possible Functions Loading Method RAM Downloading and deleting PG CPU connection individual blocks Downloading and deleting PG CPU connection an entire S7 program Downloading individual PG CPU connection blocks later FEPROM integrated Downloading entire S7 only on S7 300 or programs plug in PG CPU connection FEPROM plug in Downloading entire S7 programs Uploading the FEPROM to the PG and plugging in the memory card in the CPU Downloading the FEPROM to the CPU Programs stored in RAM are lost when you reset the CPU memory MRES or if you remove the CPU or RAM memory card Programs saved on FEPROM memory cards are not erased by a CPU memory reset and are retained even without battery backup transport backup copies System Software for S7 300
78. ESTART RESTART is not uniform no startup takes place e Ifa CPU changes to the STOP mode due to an error or fault the error fault must first be eliminated The other CPUs will only change from STOP to RUN when the CPU that had the problem changes to RUN In the multicomputing mode all CPUs undergo a consistency check This checks whether the individual CPUs are obtainable and that the time stamps of the CPUs are identical If the existing CPUs are not consistent an event with ID 0x49A4 is signaled Depending on the type of entry in the diagnostic buffer this means e A CPU slot is not recorded e A CPU is not plugged in or is defective e The time stamps of the individual CPUs are not consistent The manual 235 explains the meaning of the event IDs System Software for S7 300 and S7 400 Program Design C79000 G7076 C506 01 Diagnostics and Troubleshooting What Does This This chapter describes the following ibe Chapter Describe System diagnostics on the S7 300 and S7 400 CPUs The chapter also tells you how to eliminate errors that have been detected and how to deal with various problems e Asynchronous and synchronous error OBs Where to Find It is also possible to identify problems based on the display elements on the More Information front panel of the modules This is however beyond the scope of this chapter For more information refer to the manuals 70 71 or 101 For a detailed description of the indivi
79. FB10 that are assigned as the actual parameters for the formal parameters of FC12 STEP 7 restricts the assignment of the formal parameters of an FB to the formal parameters of an FC You cannot for example assign parameters of the parameter type as actual parameters Table C 10 shows the restrictions for assigning parameters when an FB calls an FC Function block FB Call Function FC FB10 with DB10 Variable declaration Param_1 Input Param_2 Output Param_3 In out Call FC12 A_Param Param_1 B_ Param Param_2 C_Param Param_3 B_Param Output FC12 Variable declaration A_Param Input C_Param In out Figure C 13 Transferring Parameters from and FB to an FC Table C 10 Restrictions When an FC is Called by a FB P Elementary Complex Parameter Types Declaration Type Data Types Data Types PIVER COUNTER BLOCK POINTER ANY Input gt Input No No Input gt Output No No Input gt In out No No No No Output gt Output No No Output gt In out No No In out gt Input No No In out gt Output No No In out gt In out No No System Software for S7 300 and S7 400 Program Design C79000 G7076 C506 01 C 21 Data and Parameter Types Restrictions when an FC Calls an FB Table C 11 Declaration Type Input gt Input You can assign the formal parameters of a calling
80. I O module that does not exist Insert remove module interrupt e g an input module has been removed CPU hardware fault fault on the interface to the MPI network Priority class error e g OB is not loaded Rack failure Communication error e g wrong identifier in global data communication Figure 3 4 Types of Error 3 10 System Software for S7 300 and S7 400 Program Design C79000 G7076 C506 01 Organization Blocks and Executing the Program Using DBs for Synchronous Errors Using OBs for Asynchronous Errors Masking Start Synchronous errors occur during the execution of a particular instruction When these errors occur the operating system makes an entry in the I stack and starts the OB for synchronous errors The error OBs called as a result of synchronous errors are executed as part of the program in the same priority class as the block that was being executed when the error was detected OB 121 and OB122 can therefore access the values in the accumulators and other registers as they were at the time when the interrupt occurred You can use these values to react to an error and then return to your normal program for example if an access error occurs on an analog input module you can specify a substitute value in OB122 using SFC 44 RPL_VAL see Section 11 7 The local data of the error OBs do however take up additional space in the L stack of this priority class With S7 400 CPUs on
81. In the sample program on the sending CPU the data transfer is triggered by memory bits You can change the memory bits used in the variable table VAT 1 A rising edge at a memory bit starts the corresponding communication SFB The following table indicates the assignment of the memory area Table B 2 Assignment of the Memory Area Memory Bit Assignment M20 0 triggers USEND M20 2 triggers BSEND M20 4 triggers GET M20 5 triggers PUT M20 6 triggers START M20 7 triggers STOP M21 0 triggers RESUME triggers STATUS M21 2 triggers USTATUS System Software for S7 300 and S7 400 Program Design C79000 G7076 C506 01 B 3 Sample Program for Communication SFBs for Configured Connections Blocks on the Sending CPU Table B 3 User Defined Blocks on the Sending CPU OB100 Call for FC EXAMPLE_PRESET_SFBs_1 Startup OB When the SFBs are FC EXAMPLE _ Initialization call for SFBs PRESET_SFBs_1 USEND BSEND GET PUT START STOP RESUME STATUS USTATUS called later in the user program only control and diagnostic parameters need to be specified Cyclic interrupt OB for cyclic FC calls OB35 FC calls to control the SFBs FC CHECK Evaluation of DONE NDR ERROR STATUS FC EXAMPLE_USEND Call for SFB USEND and FC CHECK FC EXAMPLE BSEND Call for SFB BSEND and FC CHECK FC EXAMPLE _ GET Call for SFB GET and FC CHECK FC EXAMPLE _PUT Call for SFB PUT and FC CHECK FC EXAMPLE_START Call for SFB START and FC CH
82. OB81_RESERVED_1 Reserved TEMP OB81_RESERVED_2 Reserved TEMP Only relevant for error codes B 16 31 B 16 32 TEMP OB81_DATE_TIME DATE_AND __ Date and time at which the OB was started TIME Not with the S7 300 System Software for S7 300 and S7 400 Program Design 11 12 C79000 G7076 C506 01 Diagnostics and Troubleshooting Sample Program for the Error OB81 The sample STL program shows how you can read the error code in OB81 The program is designed as follows e The error code in OB81 OB81_FLT_ID is read and compared with the value of the event battery exhausted B 16 3921 e If the error code corresponds to the code for battery exhausted the program jumps to the label Berr and activates the output Battery_error e If the error code does not correspond to the code for battery exhausted the program compares the code with the code for Battery failure e If the error code corresponds to the code for Battery failure the program jumps to the label Berr and activates the output Battery_error Otherwise the block is terminated STL L BH16 3921 L 0B81_FLT_ID I JC Berr L b 16 3922 lt gt I BEC Berr S Battery_error Description Compare event code battery exhausted B 16 3921 with the error code for OB81 If the same battery is exhausted then jump to Berr Compare event code battery failure b 16 3922 with the error code for OB81 If not
83. PU can access inputs and outputs of central and distributed digital input output modules either indirectly using the process image tables or directly via the backplane P bus You assign the addresses used in your program to the modules when you configure the modules with STEP 7 as follows e With central I O modules arrangement of the rack and assignment of the modules to slots in the configuration table e With distributed I Os SINEC L2 DP arrangement of the DP slaves in the configuration table master system with the L2 address and assignment of the modules to slots By configuring the modules it is no longer necessary to set addresses on the individual modules using switches As a result of the configuration the PG sends data to the CPU that allows the CPU to recognize the modules assigned to it There is a separate address area for inputs and outputs This means that the address of a peripheral area must not only include the byte or word access type but also the I identifier for inputs and Q identifier for outputs To find out which address areas are possible on individual modules refer to the manuals 70 71 and 101 Table 6 1 Peripheral I O Address Areas Access With Units of the S7 Notation Address Area s Following Size Peripheral area inputs Peripheral input byte Peripheral input word Peripheral input double word Peripheral area outputs Peripheral output byte Peripheral output word Peripheral output
84. PU is restarted the remaining cycle is executed and as default the process image output table is cleared You can prevent the process image being cleared if you want the user program to continue with the old values following a restart see also Figure 9 2 On S7 300 CPUs you can set parameters to specify whether the CPU tests its internal RAM during a complete restart In the parameters you can decide whether the modules in the configuration table are checked to make sure they exist and that the module type matches before the startup If the module check is activated the CPU will not start up if a discrepancy is found between the configuration table and the actual configuration To make sure that the programmable controller starts up without errors you can select the following monitoring times e The maximum permitted time for transferring parameters to the modules e The maximum permitted time for the modules to signal that they are ready for operation after power up e On S7 400 CPUs the maximum time of an interruption following which a restart is permitted Once the monitoring times expire the CPU either changes to STOP and only a complete restart is possible System Software for S7 300 and S7 400 Program Design C79000 G7076 C506 01 8 5 Setting System Parameters 8 4 Settings for the Cycle Cycle Time Maximum Cycle Time Minimum Cycle The cycle time is the time required by the CPU to execute the cy
85. RT UP and RUN System Software for S7 300 and S7 400 Program Design C79000 G7076 C506 01 9 11 Operating Modes and Mode Changes 9 4 RUN Mode Features In the RUN mode the CPU executes the cyclic time driven and interrupt driven program as follows e The process image of the inputs is read in e The user program is executed e The process image output table is output The active exchange of data between CPUs using global data communication global data table and using communication SFBs for configured connections and communication SFCs for non configured connections is only possible in the RUN mode Table 9 5 shows examples of when data exchange is possible in different operating modes lt means data exchange is possible in both directions means data exchange is possible in only one direction X means data exchange is not possible Table 9 5 Data Exchange in Different Operating Modes Type of Mode of CPU 1 Directionof Mode of CPU 2 Communication Data E a Global data RUN communication RUN E ee HOLD STOP STOP STOP HOLD STOP HOLD Unilateral with RUN RUN communication SFBs RUN STOP HOLD Bilateral with RUN RUN communication SFBs communication SFCs RUN gt STOP HOLD Bilateral with RUN lt RUN communication SFCs System Software for S7 300 and S7 400 Program Design 9 12 C79000 G7076 C506 01 Operating Modes and Mode Changes 9 5 HOLD Mode Features The HOLD mode is a
86. S7 400 Program Design IV C79000 G7076 C506 01 Preface This symbol indicates the order in which you should read the manuals particularly if you are a first time user of S7 Symbol Meaning Primer 87 300 Programmable Controller Quick Start 30 4 Program System Software for S7 300 S7 400 ming Program Design Manual 234 _ Online Help This documentation introduces the methodology CJ Reference works which are only required selectively E The documentation is supported by an online help Manuals on Manual S7 300 S7 400 Hardware 5 Standard Software for S7 300 S7 400 User Standard Software for S7 and M7 User Converting S5 Programs Manual STEP 7 Manual 231 230 p Le I E r 1 STL LAD FBD SCL 232 233 i 236 250 eee Reference System Software for S7 300 400 Manual System and Standard Functions E E r 1 GRAPH HiGraph CFC for _ 2351 S7 251 252 1254 Language Packages xxx Number in the literature list System Software for S7 300 and S7 400 Program Design C79000 G7076 C506 01 Preface Title S7 300 Programmable Controller Quick Start Primer Subject The primer provides you with a very simple introduction to the methods of configuring and programming an S7 300 400 It is particularly
87. SIEMENS SIMATIC System Software for S7 300 and S7 400 Program Design Programming Manual C79000 G7076 C506 01 Preface Contents How to Design Control Programs Structuring the User Program Organization Blocks and Executing the Program Handling Interrupts Memory Areas of S7 CPUs Addressing Peripheral I Os Data Exchange Between Programmable Modules Setting System Parameters Operating Modes and Mode Changes Multicomputing Diagnostics and Troubleshooting Sample Program for an Industrial Blending Process Sample Program for Communication SFBs for Configured Connections Data and Parameter Types References Glossary Index m ee eon feo feat fos fer fees fico no eE oo 0 O U gt Safety Guidelines ZN ZN ZN Qualified Personnel Correct Usage ZN Trademarks This manual contains notices which you should observe to ensure your own personal safety as well as to protect the product and connected equipment These notices are highlighted in the manual by a warning triangle and are marked as follows according to the level of danger Danger indicates thatdeath severe personal injury orsubstantial property damage will resultif proper precautions are not taken Warning indicates thatdeath severe personal injury orsubstantial property damage can resultif proper precautions are not taken Caution indicates that minor personal injury or proper
88. Shared Data Blocks in the User Program In contrast to logic blocks data blocks do not contain STEP 7 instructions They are used to store user data in other words data blocks contain variable data with which the user program works Shared data blocks are used to store user data that can be accessed by all other blocks The size of DBs can vary Refer to the description of your CPU for the maximum possible size 70 and 101 You can structure shared data blocks in any way to suit your particular requirements If a logic block FC FB or OB is called it can occupy space in the local data area L stack temporarily In addition to this local data area a logic block can open a memory area in the form of a DB In contrast to the data in the local data area the data in a DB are not deleted when the DB is closed in other words after the corresponding logic block has been executed Each FB FC or OB can read the data from a shared DB or write data to a shared DB This data remains in the DB after the DB is exited A shared DB and an instance DB can be opened at the same time Figure 2 8 shows the different methods of access to data blocks FC10 le Shared Access by all blocks DB FC11 k DB20 FB12 Instance m DB DB112 Access only by FB12 ig Figure 2 8 Access to Shared DBs and Instance DBs System Software for S7 300 and S7 400 Program Design C79000 G7076 C506
89. T FC CHECK DB IDB_PUT SFB PUT FC CHECK SFB START DB IDB_START FC CHECK SFB STOP DB IDB_STOP FC CHECK SFB DB IDB_RESUME RESUME FC CHECK SFB DB IDB_STATUS STATUS FC CHECK SFB DB IDB_USTATUS USTATUS FC CHECK Figure B 2 Call Hierarchy on the Sending CPU System Software for S7 300 and S7 400 Program Design C79000 G7076 C506 01 B 9 Sample Program for Communication SFBs for Configured Connections Call Hierarchy on the Receiving CPU STL Program B 10 DB IDB_URCV SFB URCV OB100 Pa FC EXAMPLE _ PRESET_SFBs_2 DB IDB_BRCV SFB BRCV DB IDB_URCV ee SFB URCV OB35 FC EXAMPLE_ URCV eee FC CHECK DB IDB_BRCV eee SFB BRCV FC EXAMPLE _ Pe BRee Le Fo CHECK Figure B 3 Call Hierarchy on the Receiving CPU The code for the sample programs is in the directory step 7 examples com_sfb System Software for S7 300 and S7 400 Program Design C79000 G7076 C506 01 Data and Parameter Types What Does This This chapter describes the following ibe Chapter Rencnibe Which data types are available for static or temporary variables and parameters e Which data types yo
90. Table B 1 Communication SFBs in the Sample Program SFB Function SFB 8 USEND Uncoordinated data exchange using a send and a SFB 9 URCV receive SFB bilateral communication SFB12 BSEND _ Field oriented data exchange using a send and a SFB13 BRCV receive SFB bilateral communication SFB14 GET Reads data from the remote device unilateral communication SFB15 PUT Writes data to the remote device unilateral communication SFB19 START Triggers a complete restart on the remote device SFB20 STOP Sets the remote device to STOP SFB21 RESUME Triggers a restart on the remote device SFB22 STATUS Queries the status of the remote device SFB23 USTATUS Receives the status of the remote device sent unsolicited by the remote device Connection Type This example uses a bilateral configured homogeneous S7 connection Both the single and paired blocks are used on this connection The connection ID on both CPUs is W 16 0001 Hardware The description of this example is based on the following hardware Requirements configuration CPU 4xy CPU 4xy MPI Figure B 1 Hardware Configuration for the Sample Program System Software for S7 300 and S7 400 Program Design B 2 C79000 G7076 C506 01 Sample Program for Communication SFBs for Configured Connections B 2 Sample Program on the Sending CPU Introduction Memory Bits Used
91. ack overflow WORD range Work memory 5 6 WR_DPARM 6 5 8 3 WR_PARM 6 5 8 3 WR_USMSG System Software for S7 300 and S7 400 Program Design C79000 G7076 C506 01 Q ox Siemens AG AUT E 146 Ostliche Rheinbriickenstr 50 D 76181 Karlsruhe Federal Republic of Germany From Your Name Your Title Company Name Street City Zip Code Country Phone Please check any industry that applies to you Automotive Chemical Electrical Machinery Food Instrument and Control Nonelectrical Machinery OOodgaddd Petrochemical System Software for S7 300 and S7 400 Program Design C79000 G7076 C506 01 Ey a Ea E Pharmaceutical Plastic Pulp and Paper Textiles Transportation Other Remarks Form Your comments and recommendations will help us to improve the quality and usefulness of our publications Please take the first available opportunity to fill out this questionnaire and return it to Siemens Please give each of the following questions your own personal mark within the range from 1 very good to 5 poor Do the contents meet your requirements Is the information you need easy to find Is the text easy to understand Does the level of technical detail meet your requirements Oye Tee D Please rate the quality of the graphics tables Additional comments System Software
92. ackup battery retentive memory with battery 5 10 retentive memory without battery 5 10 Bit memory retentive BLKMOV BLOCK parameter type Block calls 2 4 Block variables BLOCK_DB BLOCK_FB BLOCK_FC BLOCK_SDB Blocks BOOL range C 2 7 3 C CALL situations in which data is overwritten 2 21 Call hierarchy 2 4 CAN_TINT CFC programming language Chain aalen aa od Changing modes CHAR range Clock assigning parameters synchronizing Index 1 Index Clock functions Clock memory byte Communication extending the cycle heterogeneous homogeneous Communication options Communication partner addressing 7 7 connection Communication SFBs sample program Communication SFCs for non configured con nections 7 8 Complete restart aborting 9 6 automatic automatic no battery backup manual 9 6 Configurable modules Configuration diagram for the example of an industrial blending process Configuring multicomputing 10 4 Connection one way two way to communication partner Connection ID 7 6 Connections configuring 7 6 Consistency check multicomputing CONTROL COUNTER parameter type Counter C memory area retentive 5 8 CPU central processing unit modes 9 2 p 4 CPU hardware fault OB 11 21 CPU mode relationship between modes 9 2 p 4 CREAT_DB 5 6 CRST WRST CTRL_RTM Cycle time 3 6 Cyclic interrupt 4 6 Cy
93. all SFC35 at any point in your program Since the call is only of practical use in the RUN mode the multicomputing interrupt is suppressed if it is triggered in the STARTUP mode The multicomputing interrupt can only be can only be triggered again after the current multicomputing interrupt has been serviced acknowledged The manual 235 contains a detailed description of SFC35 and the structure of OB60 System Software for S7 300 and S7 400 Program Design C79000 G7076 C506 01 Multicomputing Example The following example illustrates the use of SFC35 e You have a programmable controller S7 400 with four CPUs e If there is a hardware interrupt on CPU 1 you want the other three CPUs to react as well Step Explanation Call Parameters 1 On CPU 1 program an SFC35 call in CALL SFC35 the hardware interrupt OB OB40 2 Supply the call with a job identifier JOB JOB that informs the other user programs how they should react to the event 3 Check whether an SFC35 is currently RET_VAL RETVAL active using the RETVAL parameter RETVAL SFC35 causes the synchronized start of OB60 on all CPUs In OB60 the job identifier sent by CPU 1 is evaluated The job identifier is in the local data OB60_JOB and the CPU programs react accordingly Programming OB60 You can program a specific OB60 for each separate CPU and load it on the CPU This means that the execution times can differ from CPU to
94. alue a system function indicates whether or not the CPU was able to execute the SFC function correctly The return value is of the integer data type INT The sign of an integer indicates whether it is a positive or negative integer The relationship of the return value to the value 0 indicates whether or not an error occurred while the function was being executed see also Table 11 5 e If an error occurs while the function is being executed the return value is less than 0 The sign bit of the integer is 1 e If the function is executed free of errors the return value is greater than or equal to 0 The sign bit of the integer is 0 Table 11 5 Error Information in the Return Value Execution of the SFC by the Return Value Sign of the Integer CPU Error occurred Less than 0 Negative sign bit is 1 No error Greater than or equal to Positive 0 sign bit is 0 If an error occurs while SFC is being executed the SFC provides an error code in the return value RET_VAL A distinction is made between the following e A general error code that all SFCs can output e A specific error code that the SFC can output depending on its specific function Some SFCs also use the output parameter RET_VAL to transfer the function value for example SFC64 TIME_TCK transfers the system time it has read using RET_VAL For a detailed description of the RET_VAL output parameter and the meaning of t
95. am Memory word Memory double word Timer Timer T T This area provides storage for timers Counter Counter C C This area provides storage for counters Data block Data block opened with DB Data blocks contain information for the program OPN DB They can be defined for general use by all logic Data bit DBX blocks shared DBs or they are assigned to a specific Data byte DBB FB or SFB instance DB Data word DBW Data double word DBD Data block opened with DI OPN DI Data bit DIX Data byte DIB Data word DIW Data double word DID This area contains the temporary data of a block while the block is being executed The L stack also provides memory for transferring block parameters and for recording interim results from Ladder Logic networks The peripheral input and output areas allow direct access to central and distributed input and output modules DP see Section 6 3 System Software for S7 300 and S7 400 Program Design C79000 G7076 C506 01 Memory Areas of S7 CPUs 5 2 Absolute and Symbolic Addressing Types of Addressing Absolute Addressing Symbolic Addressing You can access addresses in a STEP 7 program using either absolute addressing for example I 1 7 or using symbolic addressing for example motor contact 1 The absolute address of a memory location contains the address identifier for example M and the type of access to the data area B byte W word or two bytes
96. and S7 400 Program Design C79000 G7076 C506 01 Memory Areas of S7 CPUs Using the Memory The memory of the S7 CPUs is divided into address areas see Table 5 2 Areas Using instructions in your program you address the data directly in the corresponding address areas To find out which address areas are available on your CPU refer to the CPU descriptions 70 101 or the instruction lists 1721 102 Table 5 2 Address Areas Access in Units of the S7 Description Address Area Following Size Notation Process image input Process image Input bit Input byte Input word Input double word Output bit At the beginning of the scan cycle the CPU reads the inputs from the input modules and records the values in this area During the scan cycle the program calculates output Local temporary data T O external inputs T O external outputs Local data bit Local data byte Local data word Local data double word Peripheral input byte Peripheral input word Peripheral input double word Peripheral output byte Peripheral output word Peripheral output double word PIB PIW PID PQB PQW PQD output Output byte values and places them in this area At the end of the Output word scan cycle the CPU sends the calculated output Output double word values to the output modules Bit memory Memory bit This area provides storage for interim results Memory byte calculated in the progr
97. and S7 400 Program Design C79000 G7076 C506 01 3 5 Organization Blocks and Executing the Program Process Images Programming Cyclic Program Execution Start Event Interrupts Cycle Time So that the CPU has a consistent image of the process signals during cyclic program execution the CPU does not address the input I and output Q address areas directly on the I O modules but rather accesses an internal memory area of the CPU that contains an image of the inputs and outputs You program cyclic program execution by writing your user program in OB1 and in the blocks called within OB1 using STEP 7 Cyclic program execution begins as soon as the startup program is completed without errors Cyclic program execution can be interrupted by the following e An interrupt e A STOP command mode selector menu option on the programming device SFC 46 STP SFB 20 STOP e A power outage The occurrence of a fault or program error The cycle time is the time required by the operating system to run the cyclic program and all the program sections that interrupt the cycle for example executing other organization blocks and system activities for example updating the process image The cycle time Tc is not the same in every cycle see also Section 8 4 Figure 3 2 illustrates different cycle times Tc Tc In the current cycle OB is interrupted by a time of day interrupt Current cycle Tot Next cycle T
98. arameter Table C 4 Using the Format for Constants for an ANY Parameter Actual Parameter Description p M 50 0 BYTE 10 Specifies 10 bytes in the byte memory area MB50 to MB59 p DB10 DBX5 0 SSTIME 3 Specifies 3 units of data of the data type SSTIME that are located in DB10 DB byte 5 to DB byte 10 p Q 10 0 BOOL 4 Specifies 4 bits in the outputs area Q 10 0 to Q 10 3 System Software for S7 300 and S7 400 Program Design C79000 G7076 C506 01 Data and Parameter Types C 7 Assigning Data Types to Local Data of Logic Blocks Valid Data Types With STEP 7 the data types elementary and complex data types and parameter types that can be assigned to the local data of a block in the variable declaration are restricted Table C 5 illustrates the restriction for declaring local data for an OB Since you cannot call an OB an OB cannot have parameters input output or in out Since an OB does not have an instance DB you cannot declare any static variables for an OB The data types of the temporary variables of an OB can be elementary or complex data types and the data type ANY Table C 6 illustrates the restrictions when declaring local data for an FB Due to the instance DB there are less restrictions when declaring local data for an FB When declaring input parameters there are no restrictions whatsoever for an output parameter you cannot declare any parameter types and for in out parameters only the pa
99. area for supplying parameters Data blocks These are data areas containing user data There are two Sections types of data block 2 11 e Instance data blocks that are assigned to an FB e Shared data blocks that can be accessed by all logic blocks Instructions of the S7 CPU The CPUs provide you with instructions with which you can Section 2 5 create blocks in various programming languages Addresses Memory and I O areas of the S7 CPUs Chapter 5 6 System Software for S7 300 and S7 400 Program Design C79000 G7076 C506 01 2 3 Structuring the User Program 2 3 Call Hierarchy of the Blocks Introduction Block Calls 2 4 Before the blocks in a user program can be processed they must be called These calls are special STEP 7 instructions known as block calls You can only program block calls within logic blocks OBs FBs FCs SFBs and SFCs They can be compared with jumps to a subroutine Each jump means that you change to a different block The return address in the calling block is saved temporarily by the system The order and nesting of the block calls is known as the call hierarchy The number of blocks that can be nested the nesting depth depends on the particular CPU E OB K FB FC 3 D FB FB SFC w a FC DB Figure 2 1 Example of the Call Hierarchy of a User Program Figure 2 2 shows the sequence of a block call within a us
100. as of the CPU and explain how the I Os are addressed Chapterd 7 and 8 Hescribe how you can exchange data between S7 CPUs and how you can adapt certain properties of a programmable logic controller by setting system parameters Chapter d provides an overview of the operating modes and the various types of startup on the S7 CPUs The chapter also explains how the operating system supports you when debugging your user program Chapter 10 describes the multicomputing mode and the points to note when programming for this mode Chapter 11 describes system diagnostics for S7 CPUs and explains how to eliminate errors and problems e Appendix Aland Appendix B contain sample programs for an industrial blending process and for the data exchange using communication function blocks Appendix d is a reference section listing data and parameter types Appendix D contains the list of Literature referred to in the manual e The Glossary explains important terms used in the manual The Index helps you to locate sections of text and topics quickly References to other manuals and documentation are indicated by numbers in slashes These numbers refer to the titles of manuals listed in Appendix KEIN MERKER If you have any questions regarding the software described in this manual and cannot find an answer here or in the online help please contact the Siemens representative in your area You will find a list of addresse
101. ata_put_destination DB in which the data will be written by SFB PUT B 6 System Software for S7 300 and S7 400 Program Design C79000 G7076 C506 01 Sample Program for Communication SFBs for Configured Connections Defining Symbolic In the sample program on the receiving CPU symbols are used that were Names defined with STEP 7 in the symbols table Table B 7 shows the symbolic names and the absolute addresses of the sample program Table B 7 Symbolic Names and Corresponding Addresses of the Sample Program on the Receiving CPU Symbolic Name Address Comment IDB_URCV DB9 Instance DBs IDB_BRCV DB13 data_urcv DB101 data_brev DB103 Shared DBs data_get_source DB107 data_put_destination DB108 CHECK FC99 EXAMPLE URCV FC104 He s EXAMPLE_BRCV FC106 EXAMPLE_ PRESET_SFBs 2 FC112 CYC_INT5 OB35 OBs COMPLETE RESTART OB100 URCV SFB9 SFBs BRCV SFB 13 System Software for S7 300 and S7 400 Program Design C79000 G7076 C506 01 B 7 Sample Program for Communication SFBs for Configured Connections B 4 Using the Sample Program Procedure To use the sample program follow the steps below 1 Reset the memory on both CPUs and then download the programs to the appropriate CPUs 2 Runa complete restart on both CPUs This sets the connection references and the send and receive areas The send areas have the number of the corresponding SFB entered the receive areas have the value 0 entered 3 Call up the
102. atch the formal and actual parameter of the block e Date and time data type DATE_AND_TIME the date and time data type stores the year month day hours minutes seconds milliseconds and weekday Figure C 1 shows how arrays and structures can structure data types in one area and save information You define an array or a structure either in a DB or in the variable declaration of an FB OB or FC Structures STRUCT INT 2 Integer BYTE m gt Byte CHAR Character REAL _ BOOL Real number Boolean value A KA Nays 1 1 Integer m lt 1 2 Integer 1 3 Integer ARRAY 1 2 1 3 INTEGER 2 1 Integer gt lt 22 Integer 2 l U x nteger Figure C 1 Structure of Arrays and Structures System Software for S7 300 and S7 400 Program Design C 6 C79000 G7076 C506 01 Data and Parameter Types C 3 Using Arrays to Access Data Arrays An array combines a group of one data type elementary or complex to form a unit You can create an array consisting of arrays When you define an array you must do the following e Assign a name to the array e Declare an array with the keyword ARRAY e Specify the size of the array using an index You specify the first and last number of the individual dimensions maximum 6 in the array You enter the index in square b
103. aximum of one connection in both directions is possible between two communication partners e If the communication partner is not in the same S7 station The logical connection is specified by the MPI address of the communication partners parameter DEST_ID You configured this with STEP 7 e If the communication partner is in the same S7 station The logical connection is specified by the address area ID parameter IOID and the logical address parameter LADDR of the communication partner System Software for S7 300 and S7 400 Program Design C79000 G7076 C506 01 7 9 System Software for S7 300 and S7 400 Program Design C79000 G7076 C506 01 Setting System Parameters What Does This This chapter explains how you can modify certain properties of S7 300 and Chapter Describe S7 400 programmable controllers by setting system parameters or using system functions SFCs Where to Find For detailed information about module parameters refer to the STEP 7 More Information online help and the manuals 70 71 and 101 The SFCs are described in detail in the reference manual 235 Chapter Section Description ome 8 2 Using the Clock Functions Specifying the Startup Behavior a Specifying Retentive Memory Areas Using Clock Memory and Timers Changing the Priority Classes and Amount of Local Data System Software for S7 300 and S7 400 Program Design C79000 G7076 C506 01 8 1 Setting System Parameters 8
104. ble logic controllers A project is a container for all objects in an automation task independent of the number of stations modules and how they are connected in a network When a CPU starts up for example when the mode selector is moved from STOP to RUN or when the power is turned on before cyclic program processing starts OB 1 either the organization block OB100 complete restart or the organization block OB101 restart only in the S7 400 is processed first In a restart the process image input table is read in and the STEP 7 user program processing is restarted at the point where it was interrupted by the last stop STOP power off An S7 program is a container for blocks source files and charts for S7 programmable modules Shared data are data which can be accessed from any logic block function FC function block FB organization block OB These are bit memory M inputs I outputs Q timers T counters C and elements of data blocks DB You can access shared data either absolutely or symbolically SINEC L2 DP is the Siemens product name for the PROFIBUS DP Start events are defined events such as errors or interrupts and cause the operating system to start the corresponding organization block The CPU goes through the STARTUP mode during the transition from the STOP mode to the RUN mode It can be set using the mode selector or following power on or by an operation on the programming device A dis
105. bsolute addresses of the sample program Table B 4 Symbolic Names and the Corresponding Addresses of the Sample Program on the Sending CPU Symbolic Name Address Data Type Comment IDB_USEND DB8 SFB8 IDB_BSEND DB12 SFB12 IDB_GET DB14 SFB14 IDB_PUT DB15 SFB15 IDB_START DB19 SFB19 Instance DBs IDB_STOP DB20 SFB20 IDB_RESUME DB21 SFB21 IDB_STATUS DB22 SFB22 IDB_USTAUTS DB23 SFB23 data_usend DB100 DB100 data_bsend DB102 DB102 data_get DB104 DB104 data_put DB105 DB105 Shared DBs data_program_cntr DB106 DB106 data_get_source DB107 DB107 data_put_destination DB108 DB108 CHECK FC99 FC99 EXAMPLE_USEND FC100 FC100 EXAMPLE_PUT FC101 FC101 EXAMPLE_STOP FC102 FC102 EXAMPLE_STATUS FC103 FC103 EXAMPLE_BSEND FC105 FC105 FCs EXAMPLE_GET FC107 FC107 EXAMPLE_START FC108 FC108 EXAMPLE_RESUME FC109 FC109 EXAMPLE_USTATUS FC110 FC110 EXAMPLE _ FC111 FC111 PRESET_SFBs 1 CYCL_EXC OB1 OB1 CYC_INT5 OB35 OB35 OBs COMPLETE RESTART OB100 OB100 BSEND SFB12 SFB12 GET SFB 14 SFB14 PUT SFB15 SFB15 START SFB19 SFB19 STOP SFB20 SFB20 oo RESUME SFB21 SFB21 STATUS SFB22 SFB22 USTATUS SFB23 SFB23 System Software for S7 300 and S7 400 Program Design C79000 G7076 C506 01 B 5 Sample Program for Communication SFBs for Configured Connections B 3 Sample Program on the Receiving CPU Introduction Memory Bits Used Block
106. c2 Next cycle OB10 Updates process Updates process Updates process Updates process Updates process image input OB1 OB1 image output image input OB1 image output image input OB1 table table table table table Figure 3 2 Cycle Times of Different lengths 3 6 System Software for S7 300 and S7 400 Program Design C79000 G7076 C506 01 Organization Blocks and Executing the Program 3 4 Organization Block for Background Program Execution Description If you have specified a minimum scan cycle time with STEP 7 and this is longer than the actual scan cycle time see Section 3 3 the CPU still has processing time available at the end of the cyclic program This time is used to execute the background OB If OB90 does not exist on your CPU the CPU waits until the specified minimum scan cycle time has elapsed Priority The background OB has priority class 29 which corresponds to priority 0 29 It is therefore the OB with the lowest priority Its priority class cannot be changed by reassigning parameters Priority A Next cycle lt OB10 OB10 A Updating of the Updating of the process input OB1 OB1 process image image table output table OB90 OB90 gt t la Tc Haa Twait Lg Tmin ra Tce the actual cycle time required for a main program cycle Tmin the minimum c
107. cation 7 2 The following types of communication are possible with SIMATIC S7 Homogeneous communication is communication between S7 components that use the S7 protocol Heterogeneous communication is communication between S7 components and S5 components and between S7 components and devices from other vendors using different protocols for example TF FMS Communication with communication SFBs for configured connections The S7 400 CPUs provide communication SFBs for configured connections for data exchange between programmable modules These include system function blocks SFBs with which you can exchange data between two communication partners on a subnet controlled by the program for example CPU FM CP SFBs are also available for checking and changing the operating modes of remote devices Communication with communication SFCs for non configured connections The S7 300 and S7 400 CPUs provide communication SFCs for non configured connections to allow data to be exchanged between two communication partners The two communication partners must be attached to the same MPI subnet or belong to the same S7 station modules capable of communication in the central rack in an expansion rack or in a DP station System Software for S7 300 and S7 400 Program Design C79000 G7076 C506 01 Data Exchange Between Programmable Modules 7 2 Data Exchange with SFBs for Configured Connections Prior Requirements Communica
108. ccess the data in bit 2 of byte 0 of the DB whose address is entered in the DB register in other words DB20 If however the DB register contains a different DB number you access the wrong data You can avoid errors when accessing data of the DB register by using the following methods to address data e Use the symbolic address e Use the complete absolute address for example DB20 DBX0 2 If you use these addressing methods STEP 7 automatically opens the correct DB If you use the AR1 register for indirect addressing you must always load the correct address in ARI System Software for S7 300 and S7 400 Program Design C79000 G7076 C506 01 Structuring the User Program Situations in which Data is Overwritten In the following situations the contents of the address register AR1 and the DB register of the calling block are overwritten e When an FB is called ARI and the DB register of the calling block are overwritten e After a call for an FC that transfers a parameter with a complex data type for example STRING DATE_AND_TIME ARRAY STRUCT or UDT the content of AR1 and the DB register of the calling block are overwritten e After you have assigned an actual parameter located in a DB to an FC for example DB20 DBX0 2 STEP 7 opens the DB DB20 by overwriting the content of the DB register In the following situations the contents of the address register AR1 and the DB register of the called block are overwritten
109. clic program and all the program sections resulting from interrupts during the cycle for example servicing hardware interrupts and the time required for system activities This time is monitored With STEP 7 you can modify the default maximum cycle time If this time expires the CPU either changes to the STOP mode or OB80 is called in which you can specify how the CPU should react to this error On S7 400 CPUs you can set a minimum cycle time using STEP 7 This is Time useful in the following situations e When the interval at which program execution starts in OB1 main program scan should always be the same or e When the process image tables would be updated unnecessarily often if the cycle time is too short Figure 8 1 illustrates the cycle monitoring time during program startup Tmax is the selectable maximum cycle time Twin is the selectable minimum cycle time Te is the actual cycle time Twait is the difference between Tmin and the actual cycle time During this time interrupt OBs can be serviced PC stands for priority class Current cycle Next cycle Trias D Reserve a Tmin T Twai a c gt a wait PC16 OB40 PCO7 OB10 OB10 Update process Update process Update process pco image input O81 OB1 image output image input OB1 table table table Figure 8 1 Cycle Monitoring Time 8 6 System Software for S7
110. clic program execution 2 9 Cycle monitoring time 8 6 8 6 4 0 Index 2 D Data block DB instance data blocks retentive shared situations in which data is overwritten b 21 structure Data exchange in various modes Data record writing 6 4 Data type user defined Data types 2 6 DATE_AND_TIME description C 2 C 4 Double word DWORD elementary C 2 FB SFB integer 16 bits INT integer 32 bits DINT C 2 parameter types ANY parameters C 15 real number REAL S5 TE situations in which data is overwritten p 21 TIME OF DAY WORD DATE_AND_TIME DB 2 17 Glossary 3 Glossary 5 Debugging user program Declaration types 4 Declaring local variables FB for the blending process example OB for the blending process example Declaring parameters FC for the blending pro cess example Defective CPU mode Delay start events System Software for S7 300 and S7 400 Program Design C79000 G7076 C506 01 Index Describing the areas and tasks for the example of an industrial blending process 1 5 Description of the operator station for the ex ample of an industrial blending process 1 10 Description of the safety requirements for the example of an industrial blending process 1 9 Design methods designing a structured pro gram A 4 14 Designing a control program Detectable errors Diagnostic buffer definition reading out
111. ctions Additional Information 2 10 You do not need to program every function yourself S7 CPUs provide you with preprogrammed blocks that you can call in your user program A system function block SFB is a function block integrated on the S7 CPU SFBs are part of the operating system and are not loaded as part of the program Like FBs SFBs are blocks with memory You must also create instance data blocks for SFBs and load them on the CPU as part of the program S7 CPUs provide the following SFBs e for communication on configured connections e for integrated special functions for example SFB29 HS_ COUNT on the CPU 312 IFM and the CPU 314 IFM A system function is a preprogrammed tested function that is integrated on the S7 CPU You can call the SFC in your program SFCs are part of the operating system and are not loaded as part of the program Like FCs SFCs are blocks without memory S7 CPUs provide SFCs for the following functions e Copying and block functions e Checking the program e Handling the clock and run time meters e Transferring data records e Transferring events from a CPU to all other CPUs in the multicomputing mode e Handling time of day and time delay interrupts e Handling synchronous errors interrupts and asynchronous errors e System diagnostics e Process image updating and bit field processing e Addressing modules e Distributed peripheral I Os e Global data communication
112. d a Boolean value Instead of entering all the data types singly or as a structure you only need to specify UDT20 as the data type and STEP 7 automatically assigns the corresponding memory space UDT20 INT lt Integer BYTE Byte CHAR Character REAL BOOL Real number gt Boolean value Figure C 7 User Defined Data Type You define UDTs with STEP 7 Figure C 8 illustrates a UDT consisting of the following elements an integer for saving the amount a byte for saving the original data a character for saving the control code a floating point number for saving the temperature and a Boolean memory bit for terminating the signal You can assign a symbolic name to the UDT in the symbol table for example process data oMa Stack_1 STRUCT TOLO Amount INT 100 TAA Original_data BYTE 4 0 Control code CHAR HORO Temperature REAL 120 ORNS End BOOL FALSE 10 0 END_STRUCT Figure C 8 Creating a User Defined Data Type System Software for S7 300 and S7 400 Program Design C79000 G7076 C506 01 Data and Parameter Types Assigning Initial Values for a User Defined Data Type Saving and Accessing Data in a User Defined Data Type Using User Defined Data Types as Parameters Once you have created a UDT you can use the UDT like a data type if for example you declar
113. ded by the calling logic block FB FC OUT Output parameter provided by the calling block FB FC IN_OUT Parameter whose value is supplied by the calling block modified by the called block and returned to the calling block STAT Static variable that is saved in an instance DB FB TEMP Temporary variable that is saved temporarily in the local FB FC OB data stack Once the logic block has been executed com pletely the value of the variable is no longer available With FBs the data that was declared as IN OUT IN_OUT and all static variables STAT are saved in the instance DB Temporary variables of the type TEMP are not saved FCs cannot have any static variables The input output and in out parameters are saved as pointers to the actual parameters made available by the calling block All the data used in a user program must be identified by a data type When you define the data type for parameters and static or temporary variables you also specify the length and structure of the variables The actual parameter supplied when the block is called must have the same data type as the formal parameter Variables can have the following data types e Elementary data types that are provided by STEP 7 e Complex data types that you can create by combining elementary data types e User defined data types e Parameter types that define special parameters that are transferred to FBs or FCs Data types and parameter types
114. detected during the startup The CPU is changed to STOP by the keyswitch or on the programming device e A stop command is executed in the startup OB The STOP communication function is executed 10 The CPU changes to the HOLD mode when a breakpoint is reached in the startup program The CPU changes to the STARTUP mode when the breakpoint in a startup program was set and the EXIT HOLD command was executed test functions The CPU returns to the STOP mode when The CPU is changed to STOP with the keyswitch or by the programming device The STOP communication command is executed If the startup is successful the CPU changes to RUN The CPU changes to the STOP mode again when e An error is detected in the RUN mode and the corresponding OB is not loaded The CPU is changed to STOP with the keyswitch or by the programming device e A stop command is executed in the user program The STOP communication function is executed The CPU changes to the HOLD mode when a breakpoint is reached in the user program The CPU changes to the RUN mode when a breakpoint was set and the EXIT HOLD command is executed System Software for S7 300 and S7 400 Program Design C79000 G7076 C506 01 Operating Modes and Mode Changes Priority of the If more than one mode change is requested at the same time the CPU Operating Modes changes to the mode with the highest priority If for example the
115. dition must be satisfied e You have configured your programmable controller as described in the manual 100 To operate CPUs in the multicomputing mode remember the following points when configuring the programmable controller e Plug in the CPUs that you want to operate in the multicomputing mode e When you then assign parameters to the modules with STEP 7 you must assign the modules to specific CPUs This automatically assigns interrupts e Parameter assignment for all CPUs must be completed when the configuration is downloaded to the programmable controller The configuration procedures are described in the manual 231 In the multicomputing mode each CPU is assigned an interrupt input Interrupts received at this input cannot be received by the other CPUs The assignment of a module to a particular CPU must be made in STEP 7 The assignment of the interrupt line is made automatically during parameter assignment Figure 10 2 illustrates this assignment Mod 1 Mod 2 iMod 3 Mod 4 Mod 5 CPU 4 Interrupt line 4 X CPU 3 Interrupt line 3 caus Interrupt line 2 i CPU 1 a Interrupt line 1 not possible Figure 10 2 Interrupt Assignment in the Multicomputing Mode System Software for S7 300 and S7 400 Program Design C79000 G7076 C506 01 Multicomputing Servicing Interrupts The fol
116. dling Errors 000 ce eee eee eee 3 10 3 7 Interrupting Program Execution 0 0 eee ees 3 12 3 8 Managing Local Data L Stack 0 00 c eee eee 3 13 4 Handling Interrupts 00 c eee eee eee e ene eeneeeee 4 1 Using Interrupt OBS 0 cece teens 4 2 4 2 Time of Day Interrupts OB10 to OB17 00 ccc eee eee eee 4 3 4 3 Time Delay Interrupts OB20 to OB23 0c ee eee 4 5 4 4 Cyclic Interrupts OB30 to OB38 0 cece 4 6 4 5 Hardware Interrupts OB40 to OB47 0 02 c eee ee 4 8 5 Memory Areas of S7 CPUS 0 0 cece ec eee e eee e eee e eee 5 1 5 1 Memory Areas of the CPU 2 0 cece eee 5 2 5 2 Absolute and Symbolic Addressing 00 c cee ee eee eee eens 5 5 5 3 Storing Programs on the CPU 00 aeaaaee 5 6 5 4 Retentive Memory Areas on S7 300 CPUS 2 000 cee eee ee 5 8 5 5 Retentive Memory Areas on S7 400 CPUS 2 00 cece eee 5 10 5 6 Process Image Input Output Tables 0 00 cece eee eens 5 11 5 7 Local Data Stack sis s se0s ced eesd nie ees oho eee eee Ea eee oe 5 13 6 Addressing Peripheral Os 00 cece cece eee eee eee eee 6 1 Access to Process Data 0 cece eee ete eens 6 2 6 2 Access to the Peripheral Data Area 0 0 cece cee 6 4 6 3 Special Features of Distributed Peripheral I Os DP 7 Data Exchange Between Programmable Modules
117. dual organization blocks and system functions refer to the reference manual 235 Overview Diagnostic Information System Status List SZL Diagnostic Buffer Sending Your Own Diagnostic Messages Evaluating the Output Parameter RET_VAL Error OBs as a Reaction to Detected Errors Using Replacement Values when an Error is Detected Time Error OB OB80 Power Supply Error OB OB81 11 10 Diagnostic Interrupt OB OB82 Insert Remove Module Interrupt OB OB83 CPU Hardware Fault OB OB84 11 17 I O Access Error OB OB122 11 26 System Software for S7 300 and S7 400 Program Design C79000 G7076 C506 01 11 1 Diagnostics and Troubleshooting 11 1 Diagnostic Information The Aim of SIMATIC S7 system diagnostics helps you to detect localize and evaluate Diagnostics errors and problems and to reduce the commissioning time and down times in your system Diagnostic You do not need to program the acquisition of diagnostic data by system Functions diagnostics This is a standard feature that runs automatically SIMATIC S7 provides various diagnostic functions Some of these functions are integrated on the CPU others are provided by the modules SMs CPs and FMs Internal and external module faults are displayed on the front panels of the module The LED displays and how to evaluate them are described in the manuals 70 71 and 101 The CPU recognizes system errors and errors in the user prog
118. dule interrupt OB OB83 must be created as an object in your S7 program using STEP 7 Write the program to be executed in OB83 in the generated block and download it to the CPU as part of your user program You can use OB83 for example for the following purposes e To evaluate the start information of OB83 e By including system functions SFC55 to 59 to assign parameters to a newly plugged in module see also Section 6 2 If you do not program OB83 the CPU changes from RUN to STOP when an insert remove module interrupt occurs System Software for S7 300 and S7 400 Program Design C79000 G7076 C506 01 Diagnostics and Troubleshooting 11 12 CPU Hardware Fault OB OB84 Description Programming OB84 The operating system of the CPU calls OB84 when an error is detected on the interface to the MPI network to the K bus or to the network card for the distributed I Os e For example an incorrect signal level on the line This OB is also called when the problem is eliminated OB called when an event comes and goes You must generate the CPU hardware fault OB OB84 as an object in your S7 program using STEP 7 Write the program to be executed in OB84 in the generated block and download it to the CPU as part of your user program You can use OB84 for example for the following purposes e To evaluate the start information of OB84 e By including system function SFC52 WR_USMSG to send a message to the diagnostic buffer
119. e 1000 ms Opsy run time load caused by operating system Upr run time load caused by user program The cycle load due to communication is now set to 50 e The operating system execution time continues to be 250 ms per second cycle time e The user program continues to run for 750 ms e The run time load caused by communication is 1500 ms per cycle System Software for S7 300 and S7 400 Program Design C79000 G7076 C506 01 8 7 Setting System Parameters 8 8 The time sequence is then as follows 0 1 2 t t t t t Opsy Comm Upr Opsy Comm Upr Opsy Comm 250ms 500 ms 250ms 250ms 500ms 250ms 250ms 500 ms 250 ms Total cycle time 3000 ms Communication 1500 ms Opsy run time load caused by operating system Comm run time load caused by communication Upr run time load caused by user program In this example setting the communication load to 50 extends the cycle time from 1 second to 3 seconds in other words the total cycle time is tripled System Software for S7 300 and S7 400 Program Design C79000 G7076 C506 01 Setting System Parameters 8 5 Specifying the MPI Parameters Multipoint Interface Values after Memory Reset Setting the Parameters Up to 32 devices that communicate with each other can be connected to the multipoint interface MPI of a CPU The following devices can be connected e Programmable controllers e Programming devices e Op
120. e When FB11 calls FC10 FB11 transfers a field of real numbers the temporary variable thermo a Boolean value M 1 3 and a timer T2 System Software for S7 300 and S7 400 Program Design C79000 G7076 C506 01 Data and Parameter Types Specifying a Data Area for an ANY Parameter C 16 FB10 with DB10 Variable declaration STAT Speed INT CALL FC100 in_par1 Speed in_par2 MW100 FC100 Variable declaration in_par3 DB10 DBD40 IN in_part ANY IN in_par2 ANY Fe __withDB20 IN in_par3 ANY Variable declaration TEMP Thermo ARRAY 1 _TEMP _ Thermo aay Thermo _ in_par M 1 3 in_par2 TA Figure C 11 Assigning Actual Parameters to an ANY Parameter It is however possible to assign not only individual addresses for example MW100 to an ANY parameter but you can also specify a data area If you want to assign a data area as the actual parameter use the following format of a constant to specify the amount of data to be transferred p Area ID Byte Bit Data Type Repetition Factor For the data type element you can specify all elementary data types and the data type DATE_AND_TIME in the format for constants If the data type is not BOOL the bit address of 0 x 0 must be specified Table C 4 illustrates examples of the format for specifying memory areas to be transferred to an ANY p
121. e can also be used in a user defined data type UDT For more information about UDTs refer to Section C 5 Table C 3 Parameter Types Description Indicates a timer to be used by the program in the called logic block Format T1 Indicates a particular counter to be used by the program in the called logic block Format C10 Indicates a particular block to be used by the program in the called logic block Format FC101 DB42 Identifies the address Format P M50 0 Parameter Size TIMER 2 Bytes COUNTER 2 Bytes BLOCK_FB 2 Bytes BLOCK_FC BLOCK_DB BLOCK_SDB POINTER 6 Bytes ANY 10 Bytes Is used when the data type of the current parameter is unknown see Section C 6 Format P M50 0 BYTE 10 P M100 0 WORD 5 System Software for S7 300 and S7 400 Program Design C79000 G7076 C506 01 C 5 Data and Parameter Types C 2 Using Complex Data Types Overview You can create new data types by combining the elementary and complex data types to create the following complex data types e Array data type ARRAY an array combines a group of one data type to form a single unit e Structure data type STRUCT a structure combines different data types to form a single unit e Character string data type STRING a character string defines a one dimensional array with a maximum of 254 characters data type CHAR A character string can only be transferred as a unit The length of the character string must m
122. e operating system of the CPU calls OB81 when one of the following fails on the CPU or in an expansion rack e The 24 V power supply e A battery e The complete backup This OB is also called when the problem has been eliminated the OB is called when an event comes and goes You must generate the power supply error OB OB81 as an object in your S7 program using STEP 7 Write the program to be executed in OB81 in the generated block and download it to the CPU as part of your user program You can for example use OB81 for the following purposes e To evaluate the start information of OB81 and determine which power supply error has occurred e To find out the number of the rack with the defective power supply e To activate a lamp on an operator station to indicate that maintenance personnel should replace a battery If you do not program OB81 the CPU does not change to the STOP mode if a power supply error is detected in contrast to all other asynchronous error OBs The error is however entered in the diagnostic buffer and the corresponding LED on the front panel indicates the error System Software for S7 300 and S7 400 Program Design C79000 G7076 C506 01 Diagnostics and Troubleshooting 11 10 Diagnostic Interrupt OB OB82 Description Programming OB82 The operating system of the CPU calls OB82 when a module with diagnostic capability on which you have enabled the diagnostic interrupt detects an error and when t
123. e operating system of the CPU calls OB86 when a rack failure is detected for example in the following situations e Rack failure missing or defective IM or break on the connecting cable e Distributed power failure on a rack e Failure of a DP slave in a master system of the SINEC L2 DP bus system The OB is also called when the error is eliminated OB call when the event comes and goes You must generate the rack failure OB OB86 as an object in your S7 program using STEP 7 Write the program to be executed in OB86 in the generated block and download it to the CPU as part of your user program You can use OB86 for example for the following purposes e To evaluate the start information of OB86 and determine which rack is defective or missing e By including system function SFC52 WR_USMSG to send a message to the diagnostic buffer and to a monitoring device If you do not program OB86 the CPU changes to the STOP mode when a rack failure is detected System Software for S7 300 and S7 400 Program Design C79000 G7076 C506 01 11 23 Diagnostics and Troubleshooting 11 15 Communication Error OB OB87 Description The operating system of the CPU calls OB87 when a communication error occurs in data exchange using communication function blocks or in global data communication for example e When receiving global data an incorrect frame ID was detected e The data block for the status information of the global data does not
124. e safety of the process based on legal requirements and corporate policy In your description you should also include any influences that the safety elements have on your process areas Find out which devices require hardwired circuits to meet safety requirements By definition these safety circuits operate independently of the programmable controller although the safety circuit generally provides an I O interface to allow coordination with the user program Normally you configure a matrix to connect every actuator with its own emergency off range This matrix is the basis for the circuit diagrams of the safety circuits To design safety mechanisms follow the steps outline below e Determine the logical and mechanical electrical interlocks between the individual automation tasks e Design circuits to allow the devices belonging to the process to be operated manually in an emergency e Establish any further safety requirements for safe operation of the process The sample industrial blending process uses the following logic for its safety circuit e One Emergency Stop push button shuts down the following devices independent of the programmable controller PLC Ingredient A feed pump Ingredient B feed pump Agitator motor Valves e The Emergency Stop push button is located on the operator station e An input to the controller indicates the state of the Emergency Stop push button System Software for S7
125. e synchronous error OB can start a further synchronous error OB This is not possible with S7 300 CPUs If the operating system of the CPU detects an asynchronous error it starts the corresponding error OB OB80 to OB87 The OBs for asynchronous errors have the highest priority and they cannot be interrupted by other OBs If more than one asynchronous error occurs the error OBs are executed in the order in which the errors occurred Using system functions SFCs you can mask delay or disable the start Events events for some of the error OBs For more detailed information about these SFCs and the organization blocks refer to the reference manual 235 Table 3 3 System Functions for Masking Disabling and Delaying Start Events Type of Error OB SFC Function of the SFC Synchronous error OBs Asynchronous error OBs SFC36 MSK_FLT Masks individual synchronous errors Masked errors do not start an error OB and do not trigger programmed reactions SFC37 Unmasks synchronous errors DMSK_FLT SFC39 DIS_IRT Disables all interrupts and asynchronous errors Disabled errors do not start an error OB in any of the subsequent CPU cycles and do not trigger programmed reactions SFC40 EN_IRT Enables interrupts and asynchronous errors SFC41 DIS_AIRT Delays higher priority interrupts and asynchronous errors until the end of the OB SFC42 EN_AIRT Enables higher priority interrupts and asynchronous errors System Software for
126. e the data type UDT200 for a variable in a DB or in the variable declaration of an FB Figure C 9 shows a DB with the variables process_data_ with the data type UDT200 You only specify UDT200 and process_data_1I The arrays shown in italics are created when you compile the DB 0 0 STRUCT ta Process_data_1 UDT200 6 0 END_STRUCT Figure C 9 Using a User Defined Data Type To assign initial values to each element of a UDT specify a value that is valid for the data type and the name of each element You could for example assign the following initial values for the UDT declared in Figure C 9 Amount 100 Original_data B O Control_code Temperature 120 End False If you declare a variable as a UDT the initial values of the variables are the values you specified when you created the UDT You access the individual elements of a UDT You can use symbolic addresses for example Stack_1 Temperature You can however specify the absolute address at which the element is located example if Stack_1 is located in DB20 starting at byte 0 the absolute address for amount is DB20 DBWO and the address for temperature is DB20 DBD6 You can transfer variables of the UDT type as parameters If a parameter is declared as UDT in the variable declaration you must transfer a UDT with the same structure An element of a UDT can however also be assigned to a parameter when you call a block providing the
127. e the memory required for a string by defining the number of characters that will be stored in the character string for example string 9 Siemens ARRAY Defines a multi dimensional grouping of one data type either elementary or complex For example ARRAY 1 2 1 3 OF INT defines and array in the format 2 x 3 consisting of integers You access the data stored in an array using the Index 2 2 You can define up to a maximum of 6 dimensions in one array The index can be any integer 32768 to 32767 STRUCT Defines a grouping of any combination of data types You can for example define an array of structures or a structure of structures and arrays FB SFB You determine the structure of the assigned instance data block and allow the transfer of instance data for several FB calls in one instance DB multiple instances see Section 2 10 In STEP 7 you can combine complex and elementary data types to create your own user defined data type UDT UDTs have their own name and can therefore be used more than once In a UDT you can structure large amounts of data and simplify the input of data types when you want to create data blocks or declare variables in the variable declaration System Software for S7 300 and S7 400 Program Design C79000 G7076 C506 01 Data and Parameter Types Parameter Types In addition to elementary complex and user defined data types you can also define parameter
128. e time exceeded Table 11 6 shows what types of errors can occur Refer to the CPU descriptions in the manuals 70 or 101 to find out whether your CPU provides the specified OBs System Software for S7 300 and S7 400 Program Design C79000 G7076 C506 01 Diagnostics and Troubleshooting Table 11 6 Error OBs Error Class Asynchronous Error Type Time error Priority 26 Power supply error or 28 if the error Diagnostic interrupt OB is called in the startup program Remove insert module interrupt CPU hardware fault Priority class error Rack failure Communication error Synchronous Example of Using Error OB81 Programming error Priority of the OB Access error that caused the error Using the local data start information of the error OB you can evaluate the type of error that has occurred If for example the CPU detects a battery fault the operating system calls OB81 see Figure 11 4 You can write a program that evaluates the event code triggered by the OB81 call You can also write a program that brings about a reaction such as activating an output connected to a lamp on the operator station battery fault The CPU detects a OB81 OB81 checks the type of power supply fault that was Le we p Z detected and indicates whether or not the problem resulted from a battery failure Types of power suppl
129. eclaration of the block you declare the parameter as data type ANY You can then assign an actual parameter of any data type in STEP 7 STEP 7 assigns 80 bits of memory for a variable of the ANY data type If you assign an actual parameter to this formal parameter STEP 7 codes the start address the data type and the length of the actual parameter in the 80 bits For more detailed information about the structure of the data saved in these 80 bits refer to Section B 11 The called block analyzes the 80 bits of data saved for the ANY parameter and obtains the information required for further processing If you declare the data type ANY for a parameter you can assign an actual parameter of any data type to the formal parameter In STEP 7 you can assign the following data types as actual parameters e Elementary data types you specify the absolute address or the symbolic name of the actual parameter e Complex data types you specify the symbolic name of the data with a complex data type for example arrays and structures e Timers counters and blocks you specify the number for example T1 C20 or FB6 Figure C 11 shows how data are transferred to an FC with parameters of the ANY data type In this example FC100 has three parameters in_par1 in_par2 and in_par3 declared as the ANY data type e When FB10 calls FC100 FB10 transfers an integer the static variable speed a word MW100 and a double word in DB10 DB10 DBD40
130. ed ON Enable_valve Close drain CALL Valve_block Open Open_drain Close Close_drain Dsp_open Drain_open_disp Dsp_closed Valve Drain_closed_disp Drain Network 15 Tank level display AN Tank _below_max Tank _max_disp AN Tank_above_min Tank _min_disp AN Tank_not_empty Tank _empty_disp System Software for S7 300 and S7 400 Program Design C79000 G7076 C506 01 A 19 System Software for S7 300 and S7 400 Program Design C79000 G7076 C506 01 Sample Program for Communication SFBs for Configured Connections What Does This Chapter Describe Chapter Overview System Software for S7 300 and S7 400 Program Design C79000 G7076 C506 01 This chapter explains the data exchange between two S7 400 CPUs and the use of communication SFBs for configured connections in the user program based on a simple example Section Description B 1 Overview B 2 Sample program on the sending CPU Sample program on the receiving CPU B 4 Using the Sample Program Call Hierarchy of the Blocks in the Sample Program B 1 Sample Program for Communication SFBs for Configured Connections B 1 Overview Introduction The sample program shows how data are exchanged between two S7 400 CPUs using communication SFBs for configured connections Communication The following communication SFBs are used in the sample program SFBs Used
131. ed I Os The CPU accesses this data area when it addresses the distributed I Os It is also possible to access user data just as with the central I Os using load and transfer commands communication functions operator interface and process image transfer The maximum data consistency is 4 bytes Just as with the central I Os diagnostic and parameter data can be accessed using SFCs see Table 6 3 exception DP standard slaves System Software for S7 300 and S7 400 Program Design C79000 G7076 C506 01 Addressing Peripheral I Os Addressing DP Standard Slaves If you want to exchange data longer than 4 bytes with DP standard slaves you must use special SFCs for this data exchange Table 6 4 System Functions for DP Standard Slaves Application Assigning parameters to modules SFC15 DPWR_DAT Reading diagnostic information SFC13 Reads the diagnostic information asynchronous read DPNRM_DG access SFC14 DPRD_DAT Reads consistent diagnostic data length 3 or greater than 4 bytes When a DP diagnostic frame arrives a diagnostic interrupt with 4 bytes of diagnostic data is signaled to the CPU You can read out these 4 bytes with SFC13 DPNRM_DG The entire DP diagnostic information can be read with SFC14 DPRD_DAT by specifying the diagnostic address of the DP standard slave Transfers any data record to the addressed signal module System Software for S7 300 and S7 400 Program Design C79000
132. el I stack results The I stack can be read out with a programming device Local data are assigned to a logic block and that were declared in its declaration table or variable declaration Depending on the block they include formal parameters static data temporary data System Software for S7 300 and S7 400 Program Design C79000 G7076 C506 01 Glossary 5 Glossary Local Data Stack Logic Block Memory Reset MRES Multicomputing Interrupt Multicomputing Mode Multipoint Interface N Network Glossary 6 The local data stack L stack in the system memory of the CPU contains part of the local data known as the temporary data In SIMATIC S7 a logic block is a block that contains part of the STEP 7 user program The other type of block is a data block which contains only data The following list shows the types of logic blocks e Organization block OB e Function block FB e Function FC e System function block SFB e System function SFC The memory reset function deletes the following memories in the CPU e Work memory e Read write area of the load memory e System memory with the exception of the MPI parameters and the diagnostic buffer The multicomputing interrupt belongs the priority classes of the operating system of an S7 CPU On the S7 400 it is generated by a CPU after the CPU has received an interrupt The appropriate organization block is then called The multicomputing mode on t
133. ent Ingredient A is A o 0 Osn nr M M To D OS ex b 4 eats Inlet Feed Feed valve pump valve M ingredient B Drain solenoid valve Figure 1 2 Example of an Industrial Blending Process After defining the process to be controlled divide the project into related groups or areas see Figure 1 3 As each group is divided into smaller tasks the tasks required for controlling that part of the process become less complicated System Software for S7 300 and S7 400 Program Design C79000 G7076 C506 01 1 3 How to Design Control Programs oe ee Se lt Area ingredient A ie ee iC nea 1 Area mixing tank Sk E Sk ll gt lt Ke Agitator motor Inlet Feed Feed Flow 9 valve pump valve sensor m Se ie qj Switch for tank level l D measurement AG Area ingredient B l 9A i l M M p I O Inlet Feed Feed Area drain valve pump valve a a ee 4 Drain valve et Se he Figure 1 3 Defining Areas Within a Process In our example of an industrial blending process you can identify four distinct areas see Table 1 1 In this example the area for ingredient A contains the same equipment as the area for ingredient B Table 1 1 Functional Areas and Equipment in the Sample Process Functional Area Equipment Used Ingredient A Feed pump f
134. ents of the work memory and the read write memory area of the load memory are retained as are counters timers and the bit memory the area can have parameters assigned e Saved without a backup battery less maintenance in this case a maximum CPU specific number of data from the work memory the read write memory area of the load memory and a maximum number of counters timers and memory bits can be saved permanently in the backup buffer of the CPU System Software for S7 300 and S7 400 Program Design C79000 G7076 C506 01 Glossary 1 Glossary Backup Memory Block Block Stack C Central Processing Unit CPU Communication Bus K Bus Communication SFBs for Configured Connections Communication SFCs for Non Configured Connections Glossary 2 The backup memory allows memory areas to be retained during power down without a backup battery A selectable number of timers counters memory bits and bytes of a data block can be declared as backed up or retentive Blocks are part of the user program and can be distinguished by their function their structure or their purpose STEP 7 provides the following types of blocks e Logic blocks FB FC OB SFB SFC e Data blocks DB SDB e User defined data types UDT The block stack B stack in the system memory of the CPU contains the return addresses and the data block register when blocks are called The CPU is the central module in a programmable c
135. er program The program calls the second block whose instructions are then executed completely Once the second or called block has been executed execution of the interrupted block that made the call is resumed at the operation following the block call Calling block Called block OB FB FC FB FC SFB or SFC Program execution Program Instruction that calls execution another block Pome Block end Figure 2 2 Calling a Block Before you program a block you must specify which data will be used by your program in other words you must declare the variables of the block System Software for S7 300 and S7 400 Program Design C79000 G7076 C506 01 Structuring the User Program 2 4 Variables of a Block Introduction Block Parameters Declaration Types Apart from the instructions of the user program blocks also contain block variables that you declare using STEP 7 when you program your own blocks In the variable declaration you can specify variables that the block will use when it is being executed Variables are as follows e Parameters that are transferred between logic blocks e Static variables that are saved in an instance data block and are retained after the function block to which they belong has been executed e Temporary variables that are only available while the block is being executed and are then free to be overwritten when the block is completed The op
136. eral I Os address area PG Glossary 8 Phase shift Planning an automation system 1 2 1 4 POINTER C 5 parameter type Pointer format Power off CPU mode System Software for S7 300 and S7 400 Program Design C79000 G7076 C506 01 Power supply error OB Preprogrammed blocks Priority changing 8 1 Priority class error OB Process subdividing 1 3 N Process image 8 5 clearing input table output table sections updating Program execution cyclic interrupt driven Programming cycle designing a structured program A 4 Ja 14 example of an FB example of an FC A 12 example of an OB A 15 transferring parameters using data blocks Programming error OB Programming example FC for the blending pro cess example A 11 Programming languages PUT Q QRY_TINT R R_ID Rack failure OB Real number data type range Remaining cycle Removing and inserting a module 11 20 Replacement values using SFC44 RPL_VAL 11 14 11 16 Restart 9 7 aborting 9 1 automatic manual Index 5 Index RESUME 7 3 Retentive memory after power outage configuring B 10 on S7 300 CPUs 5 8 on S7 400 CPUs 5 10 RPL_VAL 11 14 RUN CPU activities CPU mode 9 2 9 4 Run time error using OBs to react to errors 3 10 12 Run time meter 8 4 S S5 TIME range Safety requirements for the example of an industrial
137. erating system assigns a separate memory area for temporary data see also Section 3 8 Local Data Stack Since you can transfer parameters to blocks you can create general re usable blocks whose programs can be used by other blocks in your program There are two types of parameter as follows e Formal parameters that identify the parameters These are specified in the variable declaration e Actual parameters that replace the formal parameters when the block is called For every formal parameter you must specify a declaration type and a data type You specify how a parameter is used by the logic block You can define a parameter as an input value or output value You can also use a parameter as an in out variable that is transferred to the block and then output again by the block Figure 2 3 shows the relationship of the formal parameters to an FB called Motor Input Motor_data_1 IN Output Mot otor ae OUT Speed Motor_ ON 1 Run_time History N In Out ae IN_OUT Figure 2 3 Defining the Input Output and In Out Parameters of a Logic Block System Software for S7 300 and S7 400 Program Design C79000 G7076 C506 01 2 5 Structuring the User Program Data Types Initial Values 2 6 Table 2 2 describes the declaration types Table 2 2 Declaration Types for Parameters and Local Variables Parameter Description Permitted Variable in IN Input parameter provi
138. erator interface systems To ensure that a CPU can still communicate after a memory reset the MPI parameters are stored in a retentive memory area of the CPU and are retained after a memory reset after removing inserting the module and if a battery is defective or is not being used With STEP 7 you set the following parameters e The node address of the CPU e The extent of the MPI network highest node address in the MPI network default 16 System Software for S7 300 and S7 400 Program Design C79000 G7076 C506 01 8 9 Setting System Parameters 8 6 Specifying Retentive Memory Areas Uses To prevent data being lost during a complete restart and on the S7 300 CPUs following a power outage you can declare certain data areas as retentive For a detailed description of retentive memory areas on the S7 300 and S7 400 CPUs refer to Chapter 5 Setting the By setting parameters with STEP 7 you select the limits of the retentive Parameters memory areas as follows e For the S7 300 retentive areas for memory bits timers counters and areas in data blocks e For S7 400 CPUs the retentive areas for memory bits timers and counters System Software for S7 300 and S7 400 Program Design 8 10 C79000 G7076 C506 01 Setting System Parameters 8 7 Using Clock Memory and Timers Clock Memory Uses Possible Frequencies Timers The clock memory is a memory byte that changes its binary state periodically at a p
139. escribed in greater detail in Chapter ul For a detailed description of the individual organization blocks refer to the reference manual 235 Overview 3 1 Types of Organization Block 3 2 Organization Blocks for the Startup Program 3 3 Organization Block for Cyclic Program Execution 3 4 Organization Block for Background Program Execution 3 5 Organization Blocks for Interrupt Driven Program Execution 3 6 Organization Blocks for Handling Errors Interrupting Program Execution Managing the Local Data L Stack System Software for S7 300 and S7 400 Program Design C79000 G7076 C506 01 3 1 Organization Blocks and Executing the Program 3 1 Types of Organization Block Overview Priority Types of Interrupt and Organization Blocks 3 2 STEP 7 provides you with various types of organization block OB with which you can adapt the program to the requirements of your process as follows e Using the startup OBs you can decide the conditions under which the programmable logic controller goes through a complete restart or a restart e With some of the OBs you can execute a program at a certain point in time or at certain intervals Other OBs react to interrupts or errors detected by the CPU Organization blocks determine the order in which the individual program sections are executed The execution of an OB can be interrupted by calling a different OB Which OB is allowed to interrupt another OB
140. et Message point MP Minimum cycle time 8 6 Mode changes 9 2 Mode transitions in the multicomputing mode 10 9 Modes priority 9 4 Module assigning parameters 8 2 removing and inserting 11 20 Module parameters transferring with SFCs transferring with STEP 7 8 2 Module start address 6 3 Monitoring times MPI Glossary 6 MPI parameters MSK_FLT Multicomputing address area configuring consistency check errors examples of applications interrupt assignment parameter assignment programming 10 6 special features synchronizing 10 8 Multicomputing interrupt 10 6 Multiple instance 2 15 N Nested logic block calls effects on B stack and L stack 2 18 Nesting depth System Software for S7 300 and S7 400 Program Design C79000 G7076 C506 01 Index Non volatile RAM NVRAM 5 8 O OB Glossary 7 OB60 10 6 Operating system tasks Organization block creating an OB for the blending process ex ample A 1 5 1 18 definition priority classes 8 2 types 3 2 Organization block OB background OB OB 90 Organization blocks error detection OB 122 replacement values 11 14 11 16 reaction to errors 3 10 B 12 start information Output parameter RET_VAL 11 9 Output parameters order for declaring parame ters 2 6 P with STEP 7 Parameter types COUNTER POINTER TIMER PARM_MOD Peripheral data area Periph
141. et Time Reaction to Changing the Time Note You can change the time of day set for the interrupt as follows e Aclock master synchronizes the time for masters and slaves e SFCOSET_CLK can be called in the user program to set a new time Table 4 2 shows how time of day interrupts react after the time has been changed Table 4 2 Time of Day Interrupts After Changing the Time If the time was moved ahead and one or OB80 is started and the time of day more time of day interrupts were skipped interrupts that were skipped are entered in the start information of OB80 You have deactivated the skipped the skipped time of day interrupts are no time of day interrupts in OB80 longer executed You have not deactivated the skipped the first skipped time of day interrupt is time of day interrupts in OB80 executed the other skipped time of day interrupts are ignored By moving the time back the start events the execution of the time of day interrupt for the time of day interrupts occur again is not repeated Time of day interrupts can only be executed when the interrupt has been assigned parameters and a corresponding organization block exists in the user program If this is not the case an error message is entered in the diagnostic buffer and an asynchronous error routine is executed OB80 see Chapter m Periodic time of day interrupts must correspond to a real date Repeating an OB 10 monthly starting on the 31
142. executed is interrupted at a command boundary and a different organization block that is assigned to the particular event is called Once the organization block has been executed the cyclic program is resumed at the point at which it was interrupted In SIMATIC S7 the following non cyclic types of program execution are possible e Time driven program execution e Process interrupt driven program execution e Diagnostic interrupt driven program execution e Processing of synchronous and asynchronous errors e Processing of the different types of startup e Multicomputing controlled program execution e Background program execution For more detailed information about program execution and the interrupt OBs refer to Sections 3land4 You can write your entire user program in OB1 linear programming This is only advisable with simple programs written for the S7 300 CPU and requiring little memory Complex automation tasks can be controlled more easily by dividing them into smaller tasks reflecting the technological functions of the process see Section 1 2 or that can be used more than once These tasks are represented by corresponding program sections known as the blocks structured programming System Software for S7 300 and S7 400 Program Design C79000 G7076 C506 01 2 9 Structuring the User Program 2 7 System Function Blocks SFB and System Functions SFC Preprogrammed Blocks System Function Blocks System Fun
143. find easiest to use Table 2 3 Programming Languages in STEP 7 Programming User Group Application Incremental Source Block can be Language Input oriented Decompiled Input from the CPU Statement list Users who prefer Programs yes STL programming in a optimized in language similar to terms of run time machine code and memory requirements Ladder Logic Users who are Programming yes LAD accustomed to working logic controls with circuit diagrams Function Block Users who are familiar Programming yes no yes Diagram with the logic boxes of logic controls FBD Boolean algebra System Software for S7 300 and S7 400 Program Design C79000 G7076 C506 01 2 7 Structuring the User Program Table 2 3 Programming Languages in STEP 7 continued Programming User Group Application Incremental Source Block can be Language Input oriented Decompiled Input from the CPU SCL Structured Users who have Programming Control Language programmed in data process high level languages tasks Optional package such as PASCAL or C GRAPH Users who want to work Convenient oriented on the description of technological functions sequential Optional package without extensive processes programming or PLC experience HiGraph Users who want to work Convenient oriented on the description of technological functions asynchronous Optional package without extensive non sequential programming or PLC processes experience
144. for example a structure consisting of structures containing arrays STRUCT INT ra Integer BYTE gt Byte CHAR Character REAL e gt BOOL Real number gt Boolean value Figure C 5 Structure You define structures when you declare data within a DB or in the variable declaration of a logic block Figure C 6 illustrates the declaration of a structure Stack_1 that consists of the following elements an integer for saving the amount a byte for saving the original data a character for saving the control code a floating point number for saving the temperature and a Boolean memory bit for terminating the signal 0 0 Stack 1 STRUCT 0 0 Amount INT 100 TASA Original_data BYTE 4 0 Control_code CHAR 60 Temperature REAL 120 Heal End BOOL FALSE 10 0 END_STRUCT Figure C 6 Creating a Structure System Software for S7 300 and S7 400 Program Design C79000 G7076 C506 01 Data and Parameter Types Assigning Initial Values fora Structure Saving and Accessing Data in Structures Using Structures as Parameters If you want to assign an initial value to every element of a structure you specify a value that is valid for the data type and the name of the element You can for example assign the following initial values to the structure declared in Figure C 6 Amount 100 O
145. form of smaller units blocks A variable defines an item of data with variable content which can be used in the STEP 7 user program A variable consists of an address for example M 3 1 and a data type for example BOOL and can be identified by means of a symbolic name for example BELT_ON The variable declaration includes the specification of a symbolic name a data type and possibly an initialization value an address and comment The local data of a logic block are declared in the variable declaration table when the program is created using incremental input The variable table is used to collect together the variables that you want to monitor and modify and set their relevant formats System Software for S7 300 and S7 400 Program Design C79000 G7076 C506 01 Index Symbols ACT_TINT Actual parameter 2 52 11 Address area multicomputing 10 3 Address areas description 5 4 5 6 Addresses 2 3 Addressing absolute communication partner S5 modules symbolic types of Addressing modules ANY ANY parameters description and use C 15 ARRAY ARRAY data type description number of nested levels C 6 Assigning memor for an FB 2 6 in the L stack 3 13 Asynchronous error using OBs to react to er rors 3 1 o b 12 Asynchronous errors OB 81 11 12 System Software for S7 300 and S7 400 Program Design C79000 G7076 C506 01 B stack data stored in nested calls 2 18 B
146. g the Program 3 3 Organization Block for Cyclic Program Execution Introduction Cyclic program execution is the normal type of program execution on programmable logic controllers The operating system calls OB1 cyclically and with this call it starts cyclic execution of the user program Sequence of Figure 3 1 illustrates the phases of cyclic program execution Program are i e The operating system starts the cycle monitoring time Execution p 8 SY y 8 e The CPU reads the state of the inputs of the input modules and updates the process image table of the inputs e The CPU processes the user program and executes the instructions contained in the program e The CPU writes the values from the process image table of the outputs to the output modules e At the end of a cycle the operating system executes any tasks that are pending for example loading and deleting blocks receiving and sending global data see Chapter 7 Finally the CPU returns to the start of the cycle and restarts the cycle monitoring time Startup program Start of cycle time monitoring lt _ Reads the inputs from the modules and updates the data in the process image input table Executes the user program OB1 and all the blocks called in it Main program scan Writes the process image output table to the modules Operating system tasks Figure 3 1 Main Program Scan System Software for S7 300
147. ge only the MPI parameters for example the MPI address of the CPU are retained This means that the CPU remains capable of communication following a power outage or memory reset If you use a battery to back up your memory e The entire content of all RAM areas is retained when the CPU restarts following a power outage e During a complete restart the address areas for memory bits timers and counters is cleared The contents of data blocks are retained e The contents of the RAM work memory are also retained apart from memory bits timers and counters that were designed as non retentive You can declare a certain number of memory bits timers and counters as retentive the number depends on your CPU During a complete restart when you are using a backup battery this data is also retained during a complete restart When you assign parameters with STEP 7 you define which memory bits timers and counters should be retained during a complete restart You can only back up as much data as is permitted by your CPU For more detailed information about defining retentive memory areas refer to the manual 101 System Software for S7 300 and S7 400 Program Design C79000 G7076 C506 01 Memory Areas of S7 CPUs 5 6 Process Image Input Output Tables Introduction Prior Requirement Updating the Process Image If the input I and output Q address areas are accessed in the user program the program does not scan the signa
148. ground cycle OB90 291 Startup OB100 Complete restart 27 OB101 Restart 27 Priority of the OB that caused the error Synchronous error interrupts OB121 Programming error OB122 Access error The priority class 29 corresponds to priority 0 29 The background cycle has a lower priority than the main program cycle The priority of organization blocks on S7 300 CPUs is fixed With S7 400 CPUs you can change the priority of the organization blocks OB10 through OB47 and the priority in the RUN mode of organization blocks OB81 through OB87 with STEP 7 Priority classes 2 through 23 are permitted for OB 10 through OB87 and priority classes 24 through 26 for OB81 through OB87 You can assign the same priority to several OBs OBs with the same priority are processed in the order in which their start events occur Every organization block has a start information field of 20 bytes that is transferred by the operating system when the OB is started The start information specifies the start event of the OB the date and time of the OB start errors that have occurred and diagnostic events For example OB40 a hardware interrupt OB contains the address of the module that caused the interrupt in its start information System Software for S7 300 and S7 400 Program Design C79000 G7076 C506 01 Organization Blocks and Executing the Program 3 2 Organization Blocks for the Startup Program Types of Startup There are two different t
149. he I stack on a programming device using STEP 7 This allows you to find out why the CPU changed to the STOP mode System Software for S7 300 and S7 400 Program Design C79000 G7076 C506 01 Organization Blocks and Executing the Program 3 8 Managing Local Data L Stack Overview Local Data Stack When you are programming organization blocks you can declare temporary variables TEMP that are only available when the block is executed and are then overwritten again see also Section p a In addition to this every organization block also requires 20 bytes of local data for its start information The CPU has a limited amount of memory for the temporary variables local data of blocks currently being executed The size of this memory area the local stack depends on the particular CPU refer to the CPU descriptions 70 and 101 The local data stack is divided up equally among the priority classes default This means that every priority class has its own local data area which ensures that the high priority classes and their OBs have space for local data Figure 3 5 shows an example of the L stack in which OB1 is interrupted by OB 10 that is in turn interrupted by OB81 OB81 SFC L stack Priority class 26 needs 20 bytes in the L stack OB10 FB Priority class 2 needs 20 bytes NI in the L stack E Priority OB1 FB gt Ec class 1 needs 2
150. he S7 400 is the simultaneous operation of more than one maximum four CPUs in one rack The multipoint interface is the programming device interface in SIMATIC S7 It allows simultaneous use of more than one programming device text display or operator panel with one or more CPUs The stations on the MPI are interconnected by a bus system A network connects network nodes via a cable and allows communication between the nodes System Software for S7 300 and S7 400 Program Design C79000 G7076 C506 01 Glossary Node Address O Organization Block OB Parameter Peripheral Bus P Bus Priority Class Process Image PROFIBUS Programmable Controller PLC A node address is used to access a device for example a programming device or a programmable module for example a CPU in a network for example MPI PROFIBUS Organization blocks form the interface between the CPU operating system and the user program The sequence in which the user program should be processed is laid down in the organization blocks A parameter is a variable of an S7 logic block actual parameter formal parameter or a variable for setting the behavior of a module Every configurable module has a basic parameter setting when it is supplied from the factory but this can be changed using STEP 7 The peripheral bus P bus is part of the backplane bus in the programmable logic controller It is optimized for the fast exchange of signals bet
151. he block comments remain on the programming device To ensure fast execution of the user program and to avoid unnecessary load on the work memory that cannot be expanded only the parts of the blocks relevant for program execution are loaded in the work memory see Figure 5 2 Parts of blocks that are not required for executing the program for example block headers remain in the load memory The load memory can be expanded using memory cards For the maximum size of your load memory refer to the CPU descriptions 70 and 101 Depending on whether you select a RAM or an FEPROM memory card to expand the load memory the load memory may react differently during downloading reloading or memory reset see also Section 5 1 Programming S7 400 S7 300 m device MUN BIU e Logic blocks Data blocks Comments Symbols Load memory Work memory Entire logic Parts of logic and blocks data blocks relevant to Entire data program execution blocks Saved on the hard disk Figure 5 2 5 6 Downloading the Program to the CPU Memory System Software for S7 300 and S7 400 Program Design C7900
152. he error codes of a return value refer to the reference manual 235 System Software for S7 300 and S7 400 Program Design C79000 G7076 C506 01 Diagnostics and Troubleshooting 11 6 Error OBs as a Reaction to Detected Errors Detectable Errors Programming Reactions Error OBs 11 10 The system program can detect the following errors e CPU functioning incorrectly e Error in the system program execution e Error in the user program e Error in the I Os Depending on the type of error the CPU is set to the STOP mode or an error OB is called You can design programs to react to the various types of errors and to determine the way in which the CPU reacts The program for a particular error can then be saved in an error OB If the error OB is called the program is executed An error occurs y The CPU calls the corresponding error OB y If an error OB is programmed the CPU executes the program in the OB If no OB is programmed the CPU changes to the STOP mode exception OB81 Figure 11 3 Error OBs as a Reaction to Detected Errors A distinction is made between synchronous and asynchronous errors as follows e Synchronous errors can be assigned to an MC7 instruction for example load instruction for a signal module that has been removed e Asynchronous errors can be assigned to a priority class or to the entire programmable logic controller for example cycl
153. he error is eliminated OB called when the event comes and goes You must generate the diagnostic interrupt OB OB82 as an object in your S7 program using STEP 7 Write the program to be executed in OB82 in the generated block and download it to the CPU as part of your user program You can for example use OB82 for the following purposes e To evaluate the start information of OB82 e To obtain exact diagnostic information about the error that has occurred When a diagnostic interrupt is triggered the module on which the problem has occurred automatically enters 4 bytes of diagnostic data and their start address in the start information of the diagnostic interrupt OB and in the diagnostic buffer This provides you with information about when an error occurred and on which module With a suitable program in OB82 you can evaluate further diagnostic data for the module which channel the error occurred on which error has occurred Using SFC51 RDSYSST you can read out the module diagnostic data and can enter this information in the diagnostic buffer with SFC52 WR_USRMSG You can also send a user defined diagnostic message to a monitoring device see also Section 11 4 If you do not program OB82 the CPU changes to the STOP mode when a diagnostic interrupt is triggered System Software for S7 300 and S7 400 Program Design C79000 G7076 C506 01 11 19 Diagnostics and Troubleshooting 11 11 Insert Remove Module Interrupt OB OB8
154. he memory areas Communicating with programming devices and other communications partners If you change operating system parameters the operating system default settings you can influence the activities of the CPU in certain areas see Chapter 8 You yourself must create the user program and load it on the CPU This contains all the functions required to process your specific automation task The tasks of the user program include the following e Specifying the conditions for a complete restart and warm restart on the CPU for example initializing signals with a particular value e Processing process data for example logically combining binary signals reading in and evaluating analog signals specifying binary signals for output outputting analog values e Specifying the reaction to interrupts e Handling disturbances in the normal running of the program System Software for S7 300 and S7 400 Program Design C79000 G7076 C506 01 Structuring the User Program 2 2 Elements of the User Program Overview The STEP 7 programming software allows you to structure your user program in other words to break down the program into individual self contained program sections This has the following advantages e Extensive programs are easier to understand e Individual program sections can be standardized e Program organization is simplified e Itis easier to make modifications to the program e Debugging is simplified since
155. he valves is executed automatically in every cycle of the PLC The program uses the FB for the motor with different instance DBs to handle the tasks for controlling the feed pumps and the agitator motor System Software for S7 300 and S7 400 Program Design C79000 G7076 C506 01 Sample Program for an Industrial Blending Process Declaring Variables for OB1 Table A 9 contains the variable declaration table for OB1 The first 20 bytes contain the start information of OB1 and must not be modified Table A 9 Variable Declaration Table for OB1 Address Declaration Type 0 0 TEMP OB1_EV_CLASS BYTE 1 0 TEMP OB1_SCAN1 BYTE OB1_PRIORITY BYTE OB1_OB_NUMBR BYTE OB1_RESERVED_1 BYTE OB1_RESERVED_2 BYTE OB1_PREV_CYCLE INT OB1_MIN_CYCLE INT OB1_ MAX CYCLE INT OB1_DATE_TIME DATE_AND_TIME Enable_motor BOOL Enable_valve BOOL Start_fulfilled BOOL Stop_fulfilled BOOL Inlet_valve_A_open BOOL 20 5 TEMP Inlet_valve_A_closed BOOL Feed_valve_A_open BOOL Feed_valve_A_closed BOOL 21 0 TEMP Inlet_valve_B_open BOOL Inlet_valve_B_closed BOOL Feed_valve_B_open BOOL 21 3 TEMP Feed_valve_B_closed BOOL Open_drain BOOL Close_drain 22 6 TEMP Valve_closed_fulfilled BOOL System Software for S7 300 and S7 400 Program Design C79000 G7076 C506 01 BOOL Sample Program for an Industrial Blending Process Creating the In STEP 7 every block that is called b
156. icular process The example is simply intended to illustrate the steps that must be followed to design a program Overview Example of an Industrial Blending Process Defining Logic Blocks Assigning Symbolic Names Creating the FB for the Motor Creating the FC for the Valves Creating OB1 Note The sample program is supplied with a variable table with which you can modify and monitor the individual variables System Software for S7 300 and S7 400 Program Design C79000 G7076 C506 01 A 1 Sample Program for an Industrial Blending Process A 1 Example of an Industrial Blending Process Introduction The sample program is based on the configuration introduced in earlier chapters as an example of an industrial blending process Task Two ingredients ingredient A and ingredient B are mixed together in a mixing tank by an agitator The finished product is drained from the tank through a drain valve Figure A 1 is a diagram of the sample process Area Ingredient B o eg a ee ae 7 Area Ingredient A Poe te i seen 1 Area Mixing tank K a Sk ll b 4 a ll l Agitator motor Inlet Feed Feed Flow li valve pump valve sensor m SS SS E E r aj Switch for tank level ey f measurement o0 valve pump valve M M i N o gt i 00 Inlet Feed Feed j J San
157. ined text that you can call up based on the number e Event classes A and B included messages with freely selectable numbers A00 to BFF and freely selectable text In addition to making a user defined entry in the diagnostic buffer you can also send your own user defined diagnostic messages to logged on display devices using SFC52 WR_USMSG When SFC52 is called with SEND 1 the diagnostic message is written to the transmit buffer and automatically sent to the station or stations logged on at the CPU If it is not possible to send a diagnostic message for example because no station is logged on or because the transmit buffer is full the user defined entry is nevertheless made in the diagnostic buffer If you acknowledge a user defined diagnostic event and want to record the acknowledgment follow the steps below e When the event enters the event state write 1 to a variable of the type BOOL when the event leaves the event state write O to the variable e You can then monitor this variable using SFB33 ALARM For information about using SFB33 refer to the reference manual 235 System Software for S7 300 and S7 400 Program Design C79000 G7076 C506 01 Diagnostics and Troubleshooting 11 5 Evaluating the Output Parameter RET_VAL Introduction Error Information in the Return Value Reacting to Error Information Transferring the Function Value Further Information Using the RET_VAL output parameter return v
158. ing on the block structure of your S7 program It describes the following e The programs of a CPU operating system and user program e The structure of user programs e The elements of a user program The reference manual 235 contains a detailed description of the individual organization blocks and system functions The Instruction Lists 72 and 102 contain an overview of the range of instructions of the S7 300 and S7 400 CPUs System Function Blocks SFB and System Functions SFC Functions FC Function Blocks FB Instance Data Blocks Shared Data Blocks DB Saving the Data of an Interrupted Block Avoiding Errors when Calling Blocks System Software for S7 300 and S7 400 Program Design C79000 G7076 C506 01 2 1 Structuring the User Program 2 1 The Programs in a CPU Introduction Operating System User Program 2 2 Two different types of program run on a CPU e The operating system e The user program Every CPU has an operating system that organizes all the functions and sequences of the CPU that are not associated with a specific control task The tasks of the operating system include the following e Handling a complete restart and restart e Updating the process image table of the inputs and outputting the process image table of the outputs e Calling the user program e Detecting interrupts and calling the interrupt OBs e Detecting and dealing with errors e Managing t
159. is declared in the variable declaration as ARRAY you must transfer the entire array and not individual elements An element of an array can however be assigned to a parameter when you call a block providing the element of the array corresponds to the data type of the parameter If you use arrays as parameters the arrays do not need to have the same name they do not even need a name Both arrays the formal parameter and the actual parameter must however have the same structure An array in the format 2 x 3 consisting of integers for example can only be transferred as a parameter when the formal parameter of the block is defined as an array in the format 2 x 3 consisting of integers and the actual parameter that is provided by the call operation is also a field in the format 2 x 3 consisting of integers System Software for S7 300 and S7 400 Program Design C79000 G7076 C506 01 C 9 Data and Parameter Types C 4 Using Structures to Access Data Structures Creating a Structure C 10 A structure combines various data types elementary and complex data types including fields and structures to form one unit You can group the data to suit your process control You can therefore also transfer parameters as a data unit and not as single elements Figure C 5 illustrates a structure consisting of an integer a byte a character a floating point number and a Boolean value A structure can be nested to a maximum of 8 levels
160. l OBs Refer to Table 3 3 System Software for S7 300 and S7 400 Program Design C79000 G7076 C506 01 3 9 Organization Blocks and Executing the Program 3 6 Organization Blocks for Handling Errors Types of Errors The errors that can be detected by the S7 CPUs and to which you can react with the help of organization blocks can be divided into two basic categories e Synchronous errors these errors can be assigned to a specific part of the user program The error occurs during the execution of a particular instruction If the corresponding synchronous error OB is not loaded the CPU changes to the STOP mode when the error occurs e Asynchronous errors these errors cannot be directly assigned to the user program being executed These are priority class errors or faults on the programmable logic controller for example a defective module If the corresponding asynchronous error OB is not loaded the CPU changes to the STOP mode when the error occurs exception OB81 Figure 3 4 shows the two categories of error OBs and describes the types of errors that can occur Asynchronous Errors Synchronous Errors y y Error OB Error OB OB80 OB81 OB82 OB83 OB84 OB85 OB86 OB87 Time error e g cycle time exceeded OB121 Programming error e g DB is not Power supply error e g battery problem loaded Diagnostic interrupt e g short circuit in OB122 I O access error e g accessing an an input module
161. l states on the digital signal modules but accesses a memory area in the system memory of the CPU and distributed I Os This memory area is known as the process image The process image is divided into two parts the process image input table and the process image output table The CPU can only access the process image of the modules that you have configured with STEP 7 or that are obtainable using the default addressing The process image is updated cyclically by the operating system At the beginning of cyclic program execution the signal states of the input modules are transferred to the process image input table At the end of each program cycle the signal states are transferred from the process image output table to the output modules Startup program Read the inputs from the modules and update the data in the process image input table Execute the user program OB1 and all the blocks called in it Transfer the values of the process image output table to the modules Main program scan Figure 5 4 Updating the Process Image System Software for S7 300 and S7 400 Program Design C79000 G7076 C506 01 5 11 Memory Areas of S7 CPUs Advantages Updating Sections of the Process Images Using SFCs 5 12 Compared with direct access to the input output modules the main advantage of accessing the process image is that the CPU has a consistent image of the process signals for
162. leared e The system parameters and the CPU and module parameters are reset to the default settings The MPI parameters set prior to the memory reset are retained e Ifamemory card Flash EPROM is plugged in the CPU copies the user program from the memory card to the work memory including the CPU and module parameters if the appropriate configuration data are also on the memory card The diagnostic buffer the MPI parameters the time and the run time meters are not reset System Software for S7 300 and S7 400 Program Design C79000 G7076 C506 01 9 5 Operating Modes and Mode Changes 9 3 STARTUP Mode Features Complete Restart Manual Complete Restart Automatic Complete Restart 9 6 Before the CPU can start executing the user program a startup program must first be executed By programming startup OBs in your startup program you can specify certain settings for your cyclic program There are two types of startup complete restart and restart S7 300 CPUs are only capable of a complete restart A restart is only possible when this is explicitly specified in the parameter record of the CPU using STEP 7 The features of the STARTUP mode are as follows e The program in the startup OB is processed OB 100 for a complete restart and OB101 for a restart No time or interrupt driven program execution is possible e Timers are updated e Run time meters start running e Disabled digital outputs on signal m
163. llowing situations The CPU memory was reset only a complete restart is possible after memory reset The interruption time limit has been exceeded this is the time between exiting the RUN mode until the startup OB including the remaining cycle has been executed The module configuration has been changed for example module replaced The parameter assignment only permits a complete restart When blocks have been loaded deleted or modified while the CPU was in the STOP mode System Software for S7 300 and S7 400 Program Design C79000 G7076 C506 01 Operating Modes and Mode Changes Sequence of Activities Figure 9 2 shows the activities of the CPU during STARTUP and RUN RUN STARTUP Clear PI input output table peripheral Complete restart y Complete request VOs and restart OB Js non retentive memory bits timers and counters nn ie d h Enable the Hr x outputs d A i Restart request ji Read process image input table Restart OB 4 Execute user Remaining cycle program y Output process image output table Output process image output table Delete process image output table and peripheral outputs selectable p pE i d TEE PE yes Interruption time p N STOP limit exceeded N S no Figure 9 2 CPU Activities in STA
164. lock always indicates the time minimum resolution 1 s date and weekday With some CPUs it is also possible to indicate milliseconds refer to the CPU descriptions 70 and 101 You set the time and date for the CPU clock by calling SFC 0 SET_CLK in the user program or with a menu option on the programming device to start the clock Using SFC1 READ_CLK or a menu option on the programming device you can read the current date and time on the CPU If more than one module equipped with a clock exists in a network you must set parameters using STEP 7 to specify which CPU functions as master and which as slave when the time is synchronized When setting these parameters you also decide whether the time is synchronized via the K bus or via the MPI interface and the intervals at which the time is automatically synchronized To make sure that the time is the same on all modules in the network the slave clocks are synchronized by the system program at regular selectable intervals You can transfer the date and time from the master clock to the slave clocks using system function SFC48 SFC_RTCB A run time meter counts the run time hours of connected equipment or the total run time hours of the CPU In the STOP mode the run time meter is stopped Its count value is retained even after a memory reset During a complete restart the run time meter must be restarted by the user program following a restart it continues automatically if it had al
165. lost after the block has been executed you cannot assign any values to them Table 2 5 Assigning Initial Values to the Variables of an FB Data Type Variable Elementary Data Complex Data Type Parameter Type Type Input Initial value permitted Initial value permitted ie Seal Output Initial value permitted Initial value permitted a In out Initial value permitted Static Initial value permitted Initial value permitted Temporary System Software for S7 300 and S7 400 Program Design C79000 G7076 C506 01 Structuring the User Program 2 10 Instance Data Blocks Definition An instance data block is assigned to every function block call that transfers parameters The actual parameters and the static data of the FB are saved in the instance DB The variables declared in the FB determine the structure of the instance data block Instance means a function block call If for example a function block is called five times in the S7 user program there are five instances of this block Creating an Before you create an instance data block the corresponding FB must already Instance DB exist You specify the number of the FB when you create the instance data block An Instance Data If you assign several instance data blocks to a function block FB that Block for Every controls a motor you can use this FB to control different motors Instance pe i The data for each specific motor for example speed run up time total
166. lowing rules apply to interrupt servicing e Hardware interrupts and diagnostic interrupts are sent to only one CPU e If there is a module failure the interrupt is services by the CPU to which the module was assigned with STEP 7 e Ifarack fails OB86 is called on every CPU Interrupts can be passed on to other CPUs using SFC35 gt MP_ALM see Section 10 3 System Software for S7 300 and S7 400 Program Design C79000 G7076 C506 01 10 5 Multicomputing 10 3 Programming the CPUs Programming Calling SFC35 10 6 Programming for the multicomputing mode is essentially the same as programming a single CPU Extra steps are however necessary if you want to synchronize the CPUs so that they react to events together If you want all the CPUs to react to events for example interrupts together in the multicomputing mode you program an SFC35 MP_ALM call Calling SFC35 triggers a multicomputing interrupt that causes a synchronized request for OB60 on all CPUs This OB contains local variables that specify the triggering event in greater detail When SFC35 is called the information about the events is transferred to all CPUs in a job identifier The job identifier allows 16 different events to be distinguished When they service the multicomputing interrupt both the sending user program and the user programs on the other CPUs check whether or not they recognize the job and then react as programmed You can c
167. n Dsp_closed Inlet_valve_A_closed Valve Inlet_valve_A Network 5 Feed valve control for ingredient A AN Flow_A AN Feed_pump_A Close_valve_fulfilled CALL Valve_block Open Enable_valve Close Close_valve_fulfilled Dsp_open Feed_valve_A_open Dsp_closed Feed_valve_A_closed Valve Feed_valve_A Network 6 Interlocks for for feed pump B A EMER_STOP_ off A Tank below_max AN Drain Enable_motor Network 7 Calling FB Motor for ingredient B A Feed_pump_B_ start A Enable_motor Start_fulfilled A O Feed_pump_B_stop ON Enable_motor Stop_fulfilled CALL Motor_block DB_feed_pump_B Start Start_fulfilled Stop Stop_fulfilled Response Flow_B Reset_maint Reset_maint Timer_no T14 Response_time SST 7S Fault Feed_pump_B_fault Start_dsp Feed_pump_B_on Stop_dsp Feed_pump_B_off Maint Feed_pump_B_maint Motor Feed_pump_B System Software for S7 300 and S7 400 Program Design C79000 G7076 C506 01 A 17 Sample Program for an Industrial Blending Process Network 8 Delaying valve enable for ingredient B A Feed_pump_B L SST 1S SD T 15 AN Feed_pump_B R T 15 A T 15 Enable_valve Network 9 Inlet valve control for ingredient B AN Flow_B AN Feed_pump_B Close_valve_fulfilled CALL Valve_block Open Enable_valve Clo
168. n S7 400 CPUs you can change the amount of local data per priority class in the priority classes parameter field using STEP 7 Each OB must have at least 20 local data bytes that are required to transfer the OB start information If you assign priority class 0 or assign less than 20 bytes of local data to a priority class the corresponding interrupt OB is deselected The handling of deselected interrupt OBs is restricted as follows Inthe RUN mode they cannot be copied or linked in your user program e Inthe STOP mode they can be copied or linked in your user program but when the CPU goes through a complete restart they stop the startup and an entry is made in the diagnostic buffer By deselecting interrupt OBs that you do not require you increase the amount of local data area available and this can be used to save temporary data in other priority classes System Software for S7 300 and S7 400 Program Design C79000 G7076 C506 01 Operating Modes and Mode Changes What Does This This chapter provides you with an overview of the operating modes of the S7 Chapter Describe CPUs and describes the different types of startup on S7 CPUs This chapter also explains how the operating system supports you when debugging your user program Chapter 9 1 Operating Modes and Mode Changes 9 2 STOP Mode pe sing er Poga U System Software for S7 300 and S7 400 Program Design C79000 G7076 C506 01 9 1 Operating Modes and Mode
169. n continue to operate with feasible values OB1 Pa EN L PIBO N T IBO N Oe SFC44 N N RPL_VAL Figure 11 5 Using a Replacement Value If an input module fails the L_PIBO statement generates a synchronous error and starts OB122 As standard the load instruction reads in the value 0 With SFC44 however you can define any replacement value suitable for the process The SFC replaces the accumulator content with the specified replacement value Replacement value 0001 0 010 Start_swi 10 0 Stop_swi 10 1 Stand_sel I 0 3 Full_swi 10 4 Figure 11 6 Examples of Replacement Values in the Program System Software for S7 300 and S7 400 Program Design C79000 G7076 C506 01 Diagnostics and Troubleshooting The following sample program could be written in OB122 Table 11 8 shows the temporary variables that must be declared in this case in the variable declaration table of OB122 Table 11 8 Local Variables TEMP of OB122 Description Error class error ID 29xx 16 42 16 43 16 44 1 16 45 OB122_PRIORITY Priority class priority of the OB in which the error occurred TEMP OB122_OB_NUMBR 122 OB122 TEMP OB122_BLK_ TYPE Block type in which the error occurred TEMP OB122_ MEM_AREA Memory area and type of access TEMP OB122 MEM_ADDR Address in the memory at which the error occurred TEMP OB122_BLK_ NUM WORD Number of the block in which the err
170. n the STEP 7 user program when required The system memory is integrated in the CPU and executed in the form of RAM The address areas timers counters bit memory etc and data areas required internally by the operating system for example backup for communication are stored in the system memory The system status list SZL describes the current status of a programmable logic controller it provides information about the configuration the current parameter assignment the current statuses and sequences on the CPU and about the modules assigned to the CPU The data of the system status list can only be read and cannot be modified It is a virtual list that is only created when requested Timers are an area in the system memory of the CPU The contents of these timers is updated by the operating system asynchronously to the user program You can use STEP 7 instructions to define the exact function of the timer for example on delay timer and start processing it Start System Software for S7 300 and S7 400 Program Design C79000 G7076 C506 01 Glossary 9 Glossary U User Program V Variable Variable Declaration Variable Declaration Table Variable Table VAT Glossary 10 The user program contains all the statements and declarations and the data required for signal processing to control a plant or a process The program is linked to a programmable module for example CPU FM and can be structured in the
171. ncluding rights created by patentgrantorregistration of a utility model or design are reserved Siemens AG Automation Group Industrial Automation S ystems Postfach 4848 D 90327 N rnberg Disclaimer of Liability We have checked the contents of this manual for agreement with the hardware and software described Since deviations cannot be precluded entirely we cannot guarantee full agreement However the data in this manual are reviewed regularly and any necessary corrections included in subsequent editions Suggestions for improvement are welcomed Technical data subject to change Siemens AG 1996 Siemens Aktiengesellschaft C79000 G7076 C506 Preface Purpose Audience Scope of the Manual This manual describes the various ways in which you can program your S7 300 S7 400 programmable logic controller PLC The manual focuses primarily on the tasks you need to perform when designing a project on paper The manual has the following aims e To familiarize you with the operating systems of the 7 300 and S7 400 CPUs e To support you when designing your user program e To inform you about the opportunities for communication and diagnostics with the 7 300 and S7 400 CPUs For information about the different programming languages refer to the corresponding manuals refer also to the overview of the STEP 7 documentation This manual is intended for users involved in controlling processes and who are re
172. ndix B the source code is in the directory step7 examples com slb System Software for S7 300 and S7 400 Program Design C79000 G7076 C506 01 Data Exchange Between Programmable Modules 7 3 Configuring a Communication Connection Between Partners Communication Data exchange using communication function blocks is possible between the Partners following partners e S7CPUs e M7CPUs e 7 CPUs and M7 CPUs e CPUs and FMs e CPUs and CPs Figure 7 3 and Table 7 2 are examples indicating which communication partners can exchange data Non Siemens PGI system PROFIBUS Industrial Ethernet S7 400_1 S7 400_2 S7 300_1 cpul fu CP 1 CPU2 FM1 CP2 CPU4 FM2 CP3 K bus K bus Backplane bus MPI M7 S7 300_3 CPU3 aaa FM4 FM5 CPUS FM3 L S Lj K bus Backplane bus Figure 7 3 Communication Partners that Can Exchange Data System Software for S7 300 and S7 400 Program Design C79000 G7076 C506 01 7 5 Data Exchange Between Programmable Modules Configuring a Connection Unilateral Bilateral Connections Connection ID Table 7 2 Examples of Communication Partners that Can Exchange Data Data Exchange Possible Between Type of Commu nication CPU 1 amp CPU 2 homogeneous CPU 1 lt CPU 3 homogeneous CPU 2 gt CPU 4 only with homogeneous PUT GET START STOP STATUS CPU
173. ng your program The program is executed only in the work memory and system memory areas The system memory RAM contains the memory elements provided by every CPU for the user program such as the process image input and output tables bit memory timers and counters The system memory also contains the block stack and interrupt stack In addition to the areas above the system memory of the CPU also provides temporary memory local data stack that contains temporary data for a block when it is called This data only remains valid as long as the block is active Figure 5 1 illustrates the memory areas of the CPU CPU Dynamic load memory RAM integrated or on a memory card contains the user program Work memory RAM contains the executable user program for example logic and data blocks System memory RAM contains CPUs Retentive load memory FEPROM bit memory timers counters on memory card or integrated in S7 300 f 2 contains the user program process image input output tables Diagnostic buffer Figure 5 1 Memory Areas of S7 CPUs System Software for S7 300 and S7 400 Program Design C79000 G7076 C506 01 Memory Areas of S7 CPUs Special Features of the S7 300 Special Features of the S7 400 Consequences of the Load Memory Structure With S7 300 CPUs the load memory can have both an integrated RAM as well as an integrated F
174. nication Instance Instance Data Block DB Instruction Interrupt Stack Local Data According to the International Electrotechnical Commission s IEC 1131 3 standard function blocks are logic blocks that have a memory A function block allows you to pass parameters in the user program which means they are suitable for programming complex functions that are required frequently for example control systems operating mode selection Important Since a function block has a memory instance data block it is possible to access their parameters at any point in the user program Global data communication is a procedure with which global data are transferred between CPUs Instance means the call for a function block If for example a function block is called five times in an S7 user program five instances exist An instance data block is assigned to every call An instance data block is used to save the formal parameters and the static local data of function blocks An instance DB can be assigned to a function block call or to a call hierarchy of function blocks An instruction is part of a STEP 7 statement and specifies what the processor should do If an interrupt or error occurs the CPU enters the address of the point at which the interrupt occurred and the current status bits and contents of the accumulators in the interrupt stack I stack in the system memory If more than one interrupt has occurred a multi lev
175. nk area e The activation of the agitator motor must be interlocked when the tank level sensor indicates level below minimum or the drain valve is open e The agitator motor sends a response signal after reaching the rated speed If this signal is not received within 10 seconds after the motor is activated the motor must be turned off e The number of times that the agitator motor starts must be counted maintenance interval e Three sensors must be installed in the mixing tank Tank full a normally closed contact When the maximum tank level is reached the contact is opened Level in tank above minimum a normally open contact If the minimum level is reached the contact is closed Tank not empty a normally open contact If the tank is not empty the contact is closed Drain area e Drainage of the tank is controlled by a solenoid valve e The solenoid valve is controlled by the operator but must be closed again at the latest when the tank empty signal is generated e Opening the drain valve is interlocked when the agitator motor is running the tank is empty System Software for S7 300 and S7 400 Program Design C79000 G7076 C506 01 A 3 Sample Program for an Industrial Blending Process Operator Station To allow an operator to start stop and monitor the process an operator station is also required see also Section 1 5 The operator station is equipped with the following e S
176. nput No No Output gt Output No No Output gt In out No No In out gt Input No No No No In out gt In out No No System Software for S7 300 and S7 400 Program Design C79000 G7076 C506 01 C 23 System Software for S7 300 and S7 400 Program Design C79000 G7076 C506 01 References 30 70 71 72 100 101 102 230 231 232 233 235 236 250 251 252 254 Primer 7 300 Programmable Controller Quick Start Manual 7 300 Programmable Controller Hardware and Installation Reference Manual S7 300 M7 300 Programmable Controllers Module Specifications Instruction List 87 300 Programmable Controller Manual 7 400 M7 400 Programmable Controllers Hardware and Installation Reference Manual S7 400 M7 400 Programmable Controllers Module Specifications Instruction List 87 400 Programmable Controller Manual Standard Software for S7 Converting S 5 Programs User Manual Standard Software for S7 and M7 STEP 7 Manual Statement List STL for S7 300 and S7 400 Programming Manual Ladder Logic LAD for S7 300 and S7 400 Programming Reference Manual System Software for S7 300 and S7 400 System and Standard Functions Manual FBD for S7 300 and S7 400 Programming Manual Structured Control Language SCL for S7 300 and S7 400 Programming Manual GRAPH for S7 300 and S7 400 Programming Sequential Control Systems Manual HiGraph for S7 300 and S7
177. nterrupts Where to Find The use of synchronous and asynchronous error OBs is described in More Information Chapter Li For a detailed description of the individual organization blocks refer to the reference manual 235 For further information about assigning parameters for interrupts refer to the manuals 70 and 101 Overview Using Interrupt OBs Time of Day Interrupts OB10 to OB17 Time Delay Interrupts OB20 to OB23 4 4 Cyclic Interrupts OB30 to OB38 4 5 Hardware Interrupts OB40 to OB47 System Software for S7 300 and S7 400 Program Design C79000 G7076 C506 01 4 1 Handling Interrupts 4 1 Using Interrupt OBs Interrupt Driven Program Execution Types of Interrupt and Applications Using Interrupt OBs Assigning Parameters for Interrupts 4 2 By providing interrupt OBs the S7 CPUs allow the following e Program sections can be executed at certain times or intervals time driven e Your program can react to external signals from the process The cyclic user program does not need to query whether or not interrupt events have occurred If an interrupt does occur the operating system makes sure that the user program in the interrupt OB is executed so that there is a programmed reaction to the interrupt by the programmable logic controller Table 4 1 shows how the different types of interrupt can be used Table 4 1 Examples of Applications Type of Interrupt Examples of Applications In
178. o kate urd ae eee wena ete gla eee s 9 6 Testing the User Program 2c c eects 10 Multicomputing 0c ccs 10 1 OVGEIVIOW neice E EE oud ae ec ee eeu aerate eee aerate ae 10 2 Configuring Modules 00 cece eee eee eens 10 3 Programming the CPUS 00 6 c cece tenes 10 4 Synchronizing the CPUS 000 cece eee eens 10 5 Dealing with Errors 0 0 0 2 00 cect n eee eee 11 Diagnostics and Troubleshooting 0ceeee cece eee eee eee eens 11 1 Diagnostic Information 0 cece eee teens 11 2 System Status List SZL 0 eee 11 3 Diagnostic Buffer errer een iinit EE E EEE EE AT E AK de 11 4 Sending Your Own Diagnostic Messages 000ee eee eens 11 5 Evaluating the Output Parameter RET_VAL 020000 00s 11 6 Error OBs as a Reaction to Detected Errors 000eeeeeeee 11 7 Using Replacement Values When an Error is Detected 11 8 Time Error OB OB80 0 0 cece eet eens 11 9 Power Supply Error OB OB81 00 cece eects 11 10 Diagnostic Interrupt OB OB82 00 cee 11 11 Insert Remove Module Interrupt OB OB83 202 ee eee 11 12 CPU Hardware Fault OB OB84 0 c ccc System Software for S7 300 and S7 400 Program Design C79000 G7076 C506 01 5 3 amp ENNEA EI P P F Fare rG i ara Mylo Lo 3 5 8 nO xi Contents 11 13 Priority
179. ock number e Return address The numberof Local data of FC3 Data of FC2 blocks that can e Block number gt be stored in the e Return address B stack per Local data of FC2 priority class Data of FB1 depends on the e Block number CPU e Return address Local data of FB1 H DB and DI register e No of open DB e No of open instance DB Figure 2 9 Information in the B Stack and L Stack System Software for S7 300 and S7 400 Program Design 2 18 C79000 G7076 C506 01 Structuring the User Program Local Data Stack Data Block Registers The local data stack L stack is a memory area in the system memory of the CPU The L stack saves the temporary variables local data of the block see also Section 3 8 Note The L stack not only saves the temporary data of a block but also provides additional memory space for example for transferring parameters There are two data block registers These contain the numbers of opened data blocks as follows The DB register contains the number of the open shared data block e The DI register contains the number of the open instance data block System Software for S7 300 and S7 400 Program Design C79000 G7076 C506 01 2 19 Structuring the User Program 2 13 Avoiding Errors when Calling Blocks STEP 7 Overwrites Data in the DB Register ZN Saving Correct Data 2 20 STEP 7 modifies the registers of the S7 300 S7 400 CPU
180. odules can be set by direct access A complete restart is always permitted unless the system has requested a memory reset A complete restart is the only possible option after e Memory reset Downloading the user program with the CPU in the STOP mode e Istack B stack overflow e Complete restart aborted due to a power outage or changing the mode selector setting e When the interruption before a restart exceeds the selected time limit A manual complete restart can be triggered by the following e The mode selector The CRST WRST switch must be set to CRST e The corresponding menu on the programming device or by communication functions mode selector set to RUN or RUN P An automatic complete restart can be triggered following power up in the following situations e The CPU was not in the STOP mode when the power outage occurred e The mode selector is set to RUN or RUN P e No automatic restart is programmed following power up e The CPU was interrupted by a power outage during a complete restart regardless of the programmed type of restart The CRST WRST switch has no effect on an automatic complete restart System Software for S7 300 and S7 400 Program Design C79000 G7076 C506 01 Operating Modes and Mode Changes Automatic Complete Restart Without a Backup battery Restart Manual Restart Automatic Restart If you operate your CPU without a backup battery if maintenance free operation is necessary
181. off The tank level sensor is not signaling Tank_empty The emergency stop is not active 4 The drain valve is switched off if the following condition is satisfied The tank level measurement indicates Tank empty Table 1 6 Description of the Mixing Tank Level Switches Mixing Tank Level Switches 1 The switches in the mixing tank indicate the level in the tank and are used to interlock the feed pumps and the agitator motor System Software for S7 300 and S7 400 Program Design C79000 G7076 C506 01 How to Design Control Programs Creating After writing a physical description of each device to be controlled draw Input Output diagrams of the inputs and outputs for each device or task area see Diagrams Figure 1 4 These diagrams correspond to the logic blocks to be programmed Input Output 1 Input n i Output n In out 1 Device Pe In out n Figure 1 4 Input Output Diagram Creating an I O In the example of the industrial blending process two feed pumps and an Diagram for the agitator are used The required motors are controlled by a motor block that Motor is the same for all three devices This block requires six inputs two to start or stop the motor one to reset the maintenance display one for the motor response signal motor running not running one for the time during which the response signal must be received and one for the number of the timer
182. ogram and run them on a separate fast CPU e If your system consists of various parts that can be clearly delineated and can be controlled relatively autonomously run the program for system section on CPU and system section Blon CPU 2 etc System Software for S7 300 and S7 400 Program Design C79000 G7076 C506 01 Multicomputing Special Features Example System Software for S7 300 and S7 400 Program Design C79000 G7076 C506 01 The following features characterize multicomputing You can operate up to four CPUs at the same time in the central rack You can plug the CPUs into the rack in any order Each individual CPU has its own interrupt line All CPUs are in the same operating mode When the CPUs exit the STOP mode the startup types are compared COMPLETE RESTART RESTART This prevents one or more CPUs going through a COMPLETE RESTART while others go through a RESTART The CPUs are interconnected via the K bus corresponds to a connection via MPI Figure 10 1 shows a programmable controller that will operate in the multicomputing mode Each CPU can access the modules assigned to it FM CP SM et ee Figure 10 1 Example of Multicomputing 10 3 Multicomputing 10 2 Configuring Modules Requirements Configuring with STEP 7 Interrupt Assignment 10 4 Before you can configure modules in your programmable controller for the multicomputing mode the following con
183. ombined with the start and stop inputs when the FB for the motor is executed e Responses from the devices must appear within a certain time Otherwise it is assumed that an error or fault has occurred The function then stops the motor e The point in time and the duration of the response or error fault cycle must be specified e If the start button is pressed and the motor enabled the device switches itself on and runs until the stop button is pressed e If the device is switched on a timer starts to run If the response signal from the device is not received before the timer has expired the device stops Specifying the Figure A 3 illustrates the inputs and outputs of the general FB for the motor Inputs and Outputs Start Fault Stop Start_Dsp Response Stop_Dsp Reset_Maint Maint Motor Timer_No Response_Time Motor Figure A 3 Inputs and Outputs of the FB for the Motor System Software for S7 300 and S7 400 Program Design A 8 C79000 G7076 C506 01 Sample Program for an Industrial Blending Process Defining the If you use a multiple instance FB for the motor for controlling both pumps Parameters for the and the motor you must define general parameter names for the inputs and FB outputs The FB for the motor in the sample process requires the following e It must have signals from the operator station to stop and start the motor and pumps e It requires a response
184. ontroller in which the user program is stored and processed It consists of an operating system processing unit and communication interfaces The communication bus K bus is part of the backplane bus of the SIMATIC S7 300 S7 400 programmable logic controllers It allows fast communication between programmable modules the CPU and the programming device This means that for example all the programmable modules in a programmable controller can be programmed using one programming device connected to the CPU The communication SFBs are system function blocks for exchanging data and for program management Examples for data exchange USEND ERCV GET Examples of program management setting the CPU of the remote communication partner to the STOP mode querying the status of the remote communication partner The communication SFCs are system functions for exchanging data and for aborting existing connections established by communication SFCs System Software for S7 300 and S7 400 Program Design C79000 G7076 C506 01 Glossary Complete Restart Connection Counter C D Data Static Data Temporary Data Block DB Data Type Data Type Complex When a CPU starts up for example when the mode selector is moved from STOP to RUN or when power is turned on before cyclic program processing starts OB 1 either the organization block OB101 restart only in the S7 400 or OB100 complete restart is processed first In a
185. or D double word or four bytes If you do not specify B W or D it is assumed that bit access is required The absolute address also contains the number of the first byte and the bit number for bit access Table 5 3 Examples of Absolute Addressing Absolute Description Address MD 100 This relates to a double word a double word consists of 4 bytes beginning in memory byte 100 in other words bytes 100 101 102 and 103 Relates to bit 1 in memory byte 100 By assigning a symbol to an address you can identify the function of the address and make your program easier to understand The following distinction is made when you assign a symbolic name Global symbols in other words the symbolic name is valid for all blocks in an S7 program these are declared in the symbol table of the S7 program e Block local symbols in other words the symbolic name is valid for only one block this is declared in the local data for example parameters in the declaration table of the block System Software for S7 300 and S7 400 Program Design C79000 G7076 C506 01 5 5 Memory Areas of S7 CPUs 5 3 Storing Programs on the CPU Downloading the User Program Distribution of the Program in the Load and Work Memory When you download the user program from the programming device to the CPU only the logic and data blocks are loaded in the load and work memory of the CPU The symbolic address assignment symbol table and t
186. or S7 300 and S7 400 Program Design C79000 G7076 C506 01 Diagnostics and Troubleshooting 11 8 Time Error OB OB80 Description Programming OB80 The operating system of the CPU calls OB80 when a time error occurs Time errors include the following e Maximum cycle time exceeded see also Section 8 4 e Time of day interrupts skipped by moving the time forward e Delay too great when processing a priority class The time error OB OB80 must be generated as an object in your S7 program using STEP 7 Write the program to be executed in OB80 in the generated block and download it to the CPU as part of your user program You can use OB80 for example for the following purposes e To evaluate the start information of OB80 and to determine which time of day interrupts were skipped e By including SFC29 CAN_TINT you can deactivate the skipped time of day interrupt so that it is not executed and only time of day interrupts relative to the new time will be executed If you do not deactivate skipped time of day interrupts in OB80 the first skipped time of day interrupt is executed all others are ignored see also Section 4 2 If you do not program OB80 the CPU changes to the STOP mode when a time error is detected System Software for S7 300 and S7 400 Program Design C79000 G7076 C506 01 11 17 Diagnostics and Troubleshooting 11 9 Power Supply Error OB OB81 Description Programming OB81 11 18 Th
187. or declaring parame ters 2 6 Indirect parameter assignment Information overview Index 3 Index Input parameters order for declaring parame ters 2 6 Insert remove module interrupt OB 11 20 Instance Instance data block assigning memory for an FB 2 6 creating multiple instances for an FB 2 12 retentive situations in which data is overwritten Instruction set 2 3 Instructions Integer 16 bits INT range Integer 32 bits DINT range Interrupt types Interrupt assignment multicomputing 10 4 Interrupt OB assigning parameters deselecting 8 12 Interrupt OBs uses Interrupt stack Interrupt driven program execution 2 9 Interruption time limit 10 J Job identifier R_ID L L stack assigning memory to local variables E apart from storing variables 2 19 L stack overflow processing data in a nested call 2 18 p 21 storing tempora variables 2 12 L stack overflow LAD 2 7 Linear programming Load memory unlinked DBs Loading the user program Loading the program Local data 19 changing the amount of Local data stack 5 13 Local variables VAR order for declaring pa rameters Logic blocks defining example Index 4 Masking start events Maximum cycle time Memory areas 5 2 5 7 address areas load memory 5 2 5 6 retentive memory 5 8 10 special features of the S7 300 5 3 system memory work memory Memory card 5 6 Memory res
188. or ingredient A Inlet valve for ingredient A Feed valve for ingredient A Flow sensor for ingredient A Ingredient B Feed pump for ingredient B Inlet valve for ingredient B Feed valve for ingredient B Flow sensor for ingredient B Mixing tank Agitator motor Tank level switches Drain Drain valve System Software for S7 300 and S7 400 Program Design C79000 G7076 C506 01 How to Design Control Programs 1 3 Describing the Individual Tasks and Areas Overview As you describe each area and task within your process you define not only the operation of each area but also the various elements that control the area These include e Electrical mechanical and logical inputs and outputs for each task e Interlocks and dependencies between the individual tasks Describing How The sample industrial blending process uses pumps motors and valves the Areas Function These must be described precisely to identify the operating characteristics and type of interlocks required during operation Tables 1 2 to 1 6 provide examples of the description of the equipment used in an industrial blending process When you have completed description you could also use it to order the required equipment Table 1 2 Description of the Feed Pump Motors for Ingredients A and B Ingredients A B Feed Pump Motors The feed pump motors convey ingredients A and B to the mixing tank Flow rate 400 1 100 gallons per minute Rating 100
189. or occurred TEMP OB122_PRG_ADDR WORD Relative address of the instruction that caused the error TEMP OB122_DATE_TIME DATE_AND_ Date and time at which the OB was started TIME TEMP Fehler INT Saves the error code of SFC44 Not for the S7 300 Note The error codes of all organization blocks are described in the STEP 7 online help and in the reference manual 235 System Software for S7 300 and S7 400 Program Design C79000 G7076 C506 01 11 15 Diagnostics and Troubleshooting STL Description L BH16 2942 Compare the event code of OB122 with L 0B122_ SW_FLT the event code BH 16 2942 for the acknowledgment of a time error when JC Aerr reading the I Os If the same jump to Aerr L B 16 2943 Compare the event code of OB122 with Sna the event code B 16 2943 for an JC Stop addressing error writing to a module that does not exist If not the same jump to Stop Aerr CALL REPL VAL Label Aerr transfers DW 16 2912 VAL DW 16 2912 binary 10010 to SFC44 REPL_VAL RET_VAL Error SFC44 loads this value in accumulator 1 L Error and replaces the value triggered by L 0 the OB122 call The SFC error code is saved in Error BEC Compare Error with 0 if the same no error occurred when executing OB122 Terminate the block if no error occurred Stop CALL STP Stop label calls SFC46 STP and changes the CPU to the STOP mode 11 16 System Software f
190. ou require the Converting S5 Programs User Manual if you want to convert existing S5 programs and to run them on S7 CPUs The manual explains how to use the converter The online help system provides more detailed information about using the specific converter functions The online help system also includes an interface description of the available converted S7 functions STL LAD FBD SCL The manuals for the language packages STL LAD FBD and SCL contain both Manuals instructions for the user and a description of the language To program an S7 300 400 you only require one of the languages but you can if required mix the languages within a project When using one of the languages for the first time it is advisable to familiarize yourself with the methods of creating a program as explained in the manual When working with the software you can use the online help system which provides you with detailed information about using the editors and compilers GRAPH HiGraph The GRAPH HiGraph and CFC languages provide you with optional methods for CFC implementing sequential control systems status control systems or graphical Manuals interconnection of blocks The manuals contain both the user instructions and the description of the language When using one of these languages for the first time it is advisable to familiarize yourself with the methods of creating a program based on the S7 300 and S7 400 Program Design
191. ows the formal parameters of an FB that uses actual parameters saved in the instance DB FB20 Motor DB202 Motor_2 Start INT IN gt Integer 16 bits start Speed INT IN _ _ Integer 16 bits speed History DT IN OUT gt Date and time 48 bits pointer Run_time TIME IN OUT to the address of the history eee ee Time 32 bits run time Figure 2 4 Relationship Between the Declarations of the FB and the Data of the Instance DB System Software for S7 300 and S7 400 Program Design C79000 G7076 C506 01 Structuring the User Program Variables of the Data Type FB Assigning Actual Parameters to Formal Parameters If your user program is structured so that an FB contains calls for further already existing function blocks you can include the FBs to be called as static variables of the data type FB in the variable declaration table of the calling FB This technique allows you to nest variables and concentrate the instance data in one instance data block multiple instance see also Section It is not generally necessary in STEP 7 to assign actual parameters to the formal parameters of an FB There are however exceptions to this Actual parameters must be assigned in the following situations e For an in out parameter of a complex data type for example STRING ARRAY or DATE_AND_TIME e For all parameter types for example TIMER COUNTER or POINTER
192. pen BOOL FALSE 0 1 Close BOOL FALSE Dsp_closed BOOL FALSE 4 0 IN_OUT Valve BOOL FALSE Programming the The FC1 function for the valves must be created before OB1 since the called FC for the Valves blocks must be created before the calling blocks The statement section of FC1 appears as shown below in the STL programming language Network 1 Open close and latching A O Open O Valve AN Close Valve Network 2 Display Valve open A Valve Dsp_open Network 3 Display Valve closed AN Valve Dsp_closed System Software for S7 300 and S7 400 Program Design C79000 G7076 C506 01 A 13 Sample Program for an Industrial Blending Process A 6 Creating OB1 Overview OB1 decides the structure of the sample program OB1 also contains the parameters that are transferred to the various functions for example The STL networks for the feed pumps and the motor supply the FB for the motor with the input parameters for starting Start stopping Stop the response Response and for resetting the maintenance display Reset_maint The FB for the motor is executed in every cycle of the PLC If the FB for the motor is executed the inputs Timer_no and Response_time inform the function of the timer being used and which time must be measured The outputs of the FB for the motor are saved at the addresses Error and Motor in the network that called the FB The FC for t
193. races with each dimension separated by a comma and the first and last number of the dimension by two periods The following index defines for example a three dimensional field 1 5 2 3 30 32 e You specify the data type of the data to be contained in the array Example Figure C 2 shows an array with three integers You access the data stored in an array using the index The index is the number in square braces The index of the second integer for example is Op_temp 2 An index can be any integer 32768 to 32767 including negative values The array in Figure C 2 could also be defined as ARRAY 1 1 The index of the first integer would then be Op_temp 1 the second would be Op_temp 0 and the third integer would then be Op_temp 1 Ke STRUCT a5 0 Op_temp ARRAY 1 3 2D 30 INT 3 0 END STRUCT 1 Op_temp 1 Op_temp ARRAY 1 3 INTEGER 2 Op_temp 2 3 Op_temp 3 Figure C 2 Array System Software for S7 300 and S7 400 Program Design C79000 G7076 C506 01 C 7 Data and Parameter Types Creating Arrays C 8 An array can also describe a multi dimensional group of data types Figure C 3 shows a two dimensional array consisting of integers You access the data in a multi dimensional array using the index In this example in Figure C 3 the first integer is Op_temp 1 1 the third is Op_temp 1 3 the fourth is Op_temp 2
194. ram Inserting removing modules You can read out the diagnostic entries using SFC51 RDSYSST in the user program or display the diagnostic messages in plain language with STEP 7 They provide information about the following Where and when the error occurred The type of diagnostic event to which the entry belongs user defined diagnostic event synchronous asynchronous error operating mode change The CPU enters events of the standard diagnostics and extended diagnostics see Section 11 3 in the diagnostic buffer It also generates a process control group message for the standard diagnostic events if the following conditions are met You have specified that process control messages will be generated in STEP 7 At least one display unit has logged on at the CPU for process control messages A process control group message is only generated when there is not currently a process control group message of the corresponding class there are seven classes One process control group message can be generated per class System Software for S7 300 and S7 400 Program Design C79000 G7076 C506 01 Diagnostics and Troubleshooting 11 2 System Status List SZL Definition Content Reading out the SZL The system status list SZL describes the current status of the programmable logic controller It provides an overview of the configuration the current parameter assignment the current statuses and sequences on the CPU and the
195. ram and enters diagnostic messages in the system status list and the diagnostic buffer You can read out these diagnostic messages on the programming device Signal and function modules with diagnostic capability detect internal and external module errors and generate a diagnostic interrupt to which you can react using an interrupt OB Figure 11 1 shows how diagnostic information is provided in SIMATIC S7 CPU Modules The CPU diagnostic function The diagnostic detects a system error function of a module detects an error and generates a The CPU diagnostic function detects an error in the user ogram diagnostic eee interrupt OB82 System Diagnostic interrupt Status List o ee be Diagnostic SSS SS gt buffer a gt SFCs STEP 7 YY User program Figure 11 1 Flow of Diagnostic Information System Software for S7 300 and S7 400 Program Design 11 2 C79000 G7076 C506 01 Diagnostics and Troubleshooting Diagnostic Event Reading Out the Diagnostic Information Generating Process Control Group Messages A diagnostic event causes a diagnostic message from the CPU or a diagnostic interrupt from a signal or function module Diagnostic events include the following Internal and external faults on a module System errors Operating mode changes Errors in the user prog
196. rameter types POINTER and ANY are permitted You can declare temporary variables as the ANY data type All other parameter types are illegal Table C 7 shows the restrictions when declaring local data for an FC Since an FC does not have an instance DB it also has no static variables For input output and in out parameters of an FC only the parameter types POINTER and ANY are permitted You can also declare temporary variables of the ANY parameter type Table C 5 Valid Data Types for the Local Data of an OB Declaration Type Elementary Complex Parameter Types Data Types Data Types TIMER COUNTER BLOCK POINTER In out Static Temporary Located in the L stack of the OB System Software for S7 300 and S7 400 Program Design C79000 G7076 C506 01 Data and Parameter Types Table C 6 Valid Data Types for the Local Data of an FB Declaration enema Pane Parameter Types ata es ata es Type YP yPes TIMER COUNTER BLOCK POINTER Any Input Output In out Static Temporary Located as 48 bit pointer in the instance DB 2 Located in the L stack of the FB Table C 7 Valid Data Types for the Local Data of an FC Declaration ee ay ae Parameter Types ata es ata es Type 1 IP TIMER COUNTER BLOCK POINTER 1 Located in the L stack of the FC System Software for S7 300 and S7 400 Program Design C 18 C79000 G7076 C506 01 Data and Parameter T
197. rated CPU with backup battery CPU without backup battery Data Logic Memory bits timers Logic Memory bits timers blocks counters blocks counters defined as defined as defined as defined as defined as defined as retentive non retentive non retentive non retentive retentive retentive Complete restart on S7 300 Complete restart on S7 400 Restart on Pie eee complete restart permitted 7 400 System Software for S7 300 and S7 400 Program Design 9 8 C79000 G7076 C506 01 Operating Modes and Mode Changes Table 9 3 Data Retention in the RAM Load Memory RAM memory card or integrated CPU with backup battery CPU without backup battery Logic Memory bits timers Logic Memory bits timers blocks counters blocks counters Complete X 0 0 restart on defined as defined as S7 300 retentive non retentive Complete 0 restart on S7 400 Restart on X X X Only complete restart permitted S7 400 Startup Activities The activities performed by the CPU during startup are illustrated by Table 9 4 X means is performed 0 means is not performed Table 9 4 Startup Activities Activities in Order of Execution In Complete In Restart Restart Clear I stack B stack X 0 Clear non retentive memory bits timers counters X 0 Clear process image output table X selectable Clear outputs of digital signal modules X selectable Discard hardware interrupts X 0
198. ready been started You can set the run time meter to an initial value using SFC2 SET_RTM You can start or stop the run time meter with SFC3 CTRL_RTM You can read the current total operating hours and the state of the counter stopped or counting with SFC4 READ_RTM A CPU can have up to eight run time meters refer to the CPU descriptions 70 and 101 Numbering starts at 0 System Software for S7 300 and S7 400 Program Design C79000 G7076 C506 01 Setting System Parameters 8 3 Specifying the Startup Behavior Introduction Startup After Manual Start Startup After Automatic Start Clearing the Process Image Self Test During a Complete Restart Module Exists Type Monitoring Monitoring Times The startup behavior of S7 CPUs is described in Chapterl9 When you select parameters to determine the startup behavior remember that only S7 400 CPUs are capable of a restart A manual complete restart is the only option on S7 300 CPUs On S7 400 CPUs you can restart manually using the mode selector and the startup type switch CRST WRST if this is permitted by the parameter assignment you made with STEP 7 A manual complete restart is possible without specifically assigning parameters On S7 300 CPUs only a COMPLETE RESTART is possible following power up With S7 400 CPUs you can specify whether an automatic startup following power up leads to a COMPLETE RESTART or a RESTART When an S7 400 C
199. riginal_data B O Control_code MC Temperature 120 End False You access the individual elements of a structure You can use symbolic addresses for example Stack_1 Temperature You can however specify the absolute address at which the element is located example if Stack_1 is located in DB20 starting at byte 0 the absolute address for amount is DB20 DBWO and the address for temperature is DB20 DBD6 You can transfer structures as parameters If a parameter is declared as STRUCT in the variable declaration you must transfer a structure with the same components An element of a structure can however also be assigned to a parameter when you call a block providing the element of the structure corresponds to the data type of the parameter If you use structures as parameters both structures for the formal parameters and the actual parameters must have the same components in other words the same data types must be arranged in the same order System Software for S7 300 and S7 400 Program Design C79000 G7076 C506 01 C 11 Data and Parameter Types C 5 Using User Defined Data Types to Access Data User Defined Data Types Creating a User Defined Data Type User defined data types UDTs can combine elementary and complex data types You can assign a name to UDTs and use them more than once Figure C 7 illustrates the structure of the UDT consisting of an integer a byte a character a floating point number an
200. rmation from function modules e Information for point to point and bus connections from communication modules only S7 300 When transferring user data a consistency of a maximum of 4 bytes can be achieved with the exception of DP standard slaves see Section 6 3 If you use the transfer double word statement four contiguous and unmodified consistent bytes are transferred If you use four separate transfer input byte statements a hardware interrupt OB could be inserted between the statements and transfer data to the same address do that the content of the original 4 bytes is changed before they were all transferred The diagnostic and parameter data of a module cannot be addressed individually but are always transferred in the form of complete data records This means that consistent diagnostic and parameter data are always transferred The diagnostic and parameter data is accessed using the start address of the module and the data record number Data records are divided into input and output data records Input data records can only be read output data records can only be written You can access data records using system functions or communication functions user interface Table 6 2 shows the relationship between data records and diagnostic and parameter data System Software for S7 300 and S7 400 Program Design C79000 G7076 C506 01 Addressing Peripheral I Os Accessing Data Records Addressing S5 Modules
201. rogram and user defined diagnostic events Distributed I Os are modules located at some distance from the central rack for example analog and digital modules The distributed I Os are characterized by the techniques used to install them The aim is to reduce wiring and costs by installing the modules close to the process DP standard indicates data exchange complying with EN 50170 previously DIN E 19245 Part 3 A formal parameter is a placeholder for the actual parameter in logic blocks that can be assigned parameters In FBs and FCs the formal parameters are declared by the user in SFBs and SFCs they already exist When a block is called an actual parameter is assigned to the formal parameter so that the called block works with the latest value The formal parameters belong to the local data of the block and are declared as input output and I O parameters According to the International Electrotechnical Commission s IEC 1131 3 standard functions are logic blocks that do not have a memory A function allows you to transfer parameters in the user program which means they are suitable for programming complex functions that are required frequently for example calculations Important Since there is no memory the calculated values must be processed immediately following the FC call System Software for S7 300 and S7 400 Program Design C79000 G7076 C506 01 Glossary Function Block FB G Global Data Commu
202. rograms 1 6 Creating a Configuration Diagram Overview After you have documented the design requirements you must then decide on the type of control equipment required for the project Determining the By deciding which modules you want to use you also specify the structure of PLC Configuration the programmable controller Create a configuration diagram specifying the following aspects e Type of CPU e Number and type of I O modules e Configuration of the physical inputs and outputs Figure 1 8 illustrates the configuration for the industrial blending process in our example i Digital Digital Digital input output output module module module 10 0 Q 4 0 Q 8 0 S7 300 CPU to to to 11 7 Q5 0 Q 9 0 A ARG ea O O o4 EMER ee nk Q 4 STOP QD xP circuit Ey x Operator Industrial blending process station Figure 1 8 Example of an S7 Configuration Diagram System Software for S7 300 and S7 400 Program Design C79000 G7076 C506 01 1 11 System Software for S7 300 and S7 400 Program Design C79000 G7076 C506 01 Structuring the User Program What Does This Chapter Describe Where to Find More Information Chapter Overview This chapter will help you when you are decid
203. rrupt should be repeated for example every minute every hour daily To allow the CPU to start a time of day interrupt you must first set and then activate the time of day interrupt There are three ways of starting the interrupt e Automatic start of the time of day interrupt by assigning appropriate parameters with STEP 7 parameter field time of day interrupts e Setting and activating the time of day interrupt with SFC28 SET_TINT and SFC30 ACT_TINT from within the user program e Setting the time of day interrupt by assigning parameters with STEP 7 and activating the time of day interrupt with SFC30 ACT_TINT in the user program To query which time of day interrupts are set and when they are set to occur you can do one of the following e Call SFC31 QRY_TINT e Request the list interrupt status of the system status list see Chapter 11 You can deactivate time of day interrupts that have not yet been executed with SFC29 CAN_TINT Deactivated time of day interrupts can be set again using SFC28 SET_TINT and activated with SFC30 ACT_TINT All eight time of day interrupt OBs have the same priority class 2 as default see also Section 3 1 and are therefore processed in the order in which their start event occurs You can however change the priority class by selecting suitable parameters System Software for S7 300 and S7 400 Program Design C79000 G7076 C506 01 4 3 Handling Interrupts Changing the S
204. s Dealing with Errors System Software for S7 300 and S7 400 Program Design C79000 G7076 C506 01 10 1 Multicomputing 10 1 Overview Introduction When to Use Multicomputing 10 2 The multicomputing mode of the S7 400 means simultaneous operation of more than one CPU up to a maximum of four in one central rack This mode allows you to distribute the user program and run it synchronized on several CPUs In the multicomputing mode e The CPUs change their operating modes automatically and mode changes are synchronized with each other e The individual CPUs can access the modules assigned to them during configuration with STEP 7 e All the events occurring on one CPU are passed on to the other CPUs as programmed Note Simultaneous unsynchronized operation of more than one CPU ina segmented rack physically segmented cannot be set by user is also possible This is however not multicomputing The CPUs in a segmented rack form their own subsystem and behave like single processors There is no shared address area The multicomputing mode and unsynchronized operation in a segmented rack at the same time is not possible Multicomputing has advantages in the following situations e When your user program is too large for one CPU and memory is used up distribute your program on more than one CPU e If part of your system must be processed quickly take these program sections out of the main pr
205. s services interrupts and process error messages In the HOLD mode execution of the user program is halted and you can test the user program step by step The HOLD mode is only possible when you are testing using the programming device In all these modes the CPU can communicate on the MPI interface System Software for S7 300 and S7 400 Program Design C79000 G7076 C506 01 Operating Modes and Mode Changes Other Operating If the CPU is not ready for operation it is in one of the following modes Modes e Off in other words the power supply is turned off e Defective in other words a fault has occurred To check whether the CPU is really defective switch the CPU to STOP and turn the power switch off and then on again If the CPU starts up read out the diagnostic buffer to analyze the problem If the CPU does not start up it must be replaced Operating Mode Table 9 1 shows the conditions under which the operating modes can change Changes Table 9 1 Point 1 2 Changing the Modes of the CPU Explanation of Figure 9 1 Description After you turn on the power supply the CPU is in the STOP mode The CPU changes to the STARTUP mode e After the CPU is changed to RUN or RUN P using the keyswitch or by the programming device e After a startup triggered automatically by turning on the power In both cases the keyswitch must be set to RUN or RUN P The CPU changes back to the STOP mode when e An error is
206. s in the Appendix of 70 or 100 or in catalogs and in Compuserve go aut forum You can also speak to our Hotline under the following phone or fax number Tel 49 911 895 7000 Fax 7001 System Software for S7 300 and S7 400 Program Design C79000 G7076 C506 01 vii Preface If you have any questions or comments on this manual please fill out the remarks form at the end of the manual and return it to the address shown on the form We would be grateful if you could also take the time to answer the questions giving your personal opinion of the manual Siemens also offers a number of training courses to introduce you to the SIMATIC S7 automation system Please contact your regional training center or the central training center in Nuremberg Germany for details D 90327 Nuremberg Tel 49 911 895 3154 z System Software for S7 300 and S7 400 Program Design vill C79000 G7076 C506 01 Contents 1 How to Design Control Programs 000e cece e eens 1 1 Planning the Automation Project 0 cece e ee eens 1 2 Dividing the Process into Individual Tasks 0 0000eeeeee 1 3 Describing the Individual Tasks and Areas 0220ee0eeeeee 1 4 Establishing the Safety Requirements 22 0eeeeeee ees 1 5 Describing the Required Operator Displays and Controls 1 6 Creating a Configuration Diagram 06 0 c cece eee eee 2 Structuring the User Program 0
207. s on the Receiving CPU In the sample program on the receiving CPU the data transfer is triggered by memory bits You can change the memory bits used in the variable table VAT 2 Signal state 1 in a memory bit enables the corresponding receive SFB The following table indicates the assignment of the memory area Table B 5 Assignment of the Memory Area M20 1 Enables URCV M20 3 Enables BRCV Table B 6 User Defined Blocks on the Receiving CPU Block Content Function OB100 Call for the FC Startup OB When the SFB is called EXAMPLE_PRESET_SFBs 2 later in the user program only control FC Initialization calls for the SFBs and diagnostic parameters need to be EXAMPLE_PRESET_SFBs 2 URCV BRCV specified OB35 Call for the FCs to control the SFBs Cyclic interrupt OB cyclic FC calls FC CHECK Evaluation of DONE NDR ERROR STATUS Checks the status of the SFB FC EXAMPLE_URCV Call for SFB URCV and FC CHECK Controlling SFB calls with FCs FC EXAMPLE BRCV DB IDB_URCV DB IDB_BRCV DB data_urcv prevents the SFBs being called again Call for SFB BRCV and before they are completed FC CHECK Actual parameters and static data of the SFBs used Instance DBs of the SFBs used Receive control and check data for FC EXAMPLE_URCV DB data_brev Receive control and check data for FC EXAMPLE_BRCV Shared DBs DB data_get_source DB with the data for the SFB GET of the communication partner DB d
208. s place when all synchronized CPUs are ready to change Wait points guarantee simultaneous activities If for example one CPU cannot change mode immediately the mode change is delayed on the other CPUs until the last CPU is ready There are several synchronization points at the mode transitions Figure 10 3 shows these synchronization points and their functions are explained in Table 10 1 System Software for S7 300 and S7 400 Program Design C79000 G7076 C506 01 Multicomputing STARTUP User program Complete System restart OB Power up rogram prog Restart Rem cycle OB of restart Figure 10 3 Synchronization Points of an S7 400 CPU Table 10 1 Explanation of the Synchronization Points Synchronization Point Wait point 1 WP1 Wait point 2 WP2 Wait point 3 WP3 Explanation All CPUs exit the STOP mode at the same time At this point there is a check to make sure that the same startup type was selected on all CPUs If different startup types are selected the startup of the programmable controller is prevented All CPUs start up together Among other things make sure that a CPU does not access semaphores in the user program that another CPU deletes during startup due to the different run times of their system programs All CPUs change from STARTUP to RUN at the same time Wait points 4 and 5 WP4 WP5 Message point 1 MP
209. se Close_valve_fulfilled Dsp_open Inlet_valve_B_open Dsp_closed Inlet_valve_B_closed Valve Inlet_valve_B Network 10 Feed valve control for ingredient B AN Flow_B AN Feed_pump_B Close_valve_fulfilled CALL Valve_block Open Enable_valve Close Close_valve_fulfilled Dsp_open Feed_valve_B_open Dsp_closed Feed_valve_B_closed Valve Feed_valve_B Network 11 Interlocks for agitator A EMER_STOP_ off A Tank _above_min AN Agitator_fault AN _ Drain Enable_motor System Software for S7 300 and S7 400 Program Design A 18 C79000 G7076 C506 01 Sample Program for an Industrial Blending Process Network 12 Calling FB motor for agitator A Agitator_start A Enable_motor Start_fulfilled AC O Agitator_stop ON Enable_motor Stop_fulfilled CALL Motor_block DB_agitator Start Start_fulfilled Stop Stop_fulfilled Response Agitator_running Reset_maint Reset_maint Timer_no T16 Response_time S5T 10S Fault Agitator_fault Start_dsp Agitator_on Stop_dsp Agitator_off Maint A gitator_maint Motor Agitator_B Network 13 Interlocks for drain valve A EMER_STOP_ off A Tank _not_empty AN Agitator Enable_valve Network 14 Drain valve control A Drain_open A Enable_valve AN Agitator Open_drain A O Drain_clos
210. set The phase offset ensures that the execution of a cyclic interrupt is delayed by a certain time after the interval has expired Phase offset m X basic clock rate where 0 lt m lt n Figure 4 1 shows how a cyclic interrupt OB with phase offset is executed in contrast to a cyclic interrupt without phase offset Clockpulse 1 1 11 OB38 n 8 m 0 OB37 n 16 m 5 0 8 16 21 24 32 37 40 48 53 t Ims Figure 4 1 Executing Cyclic Interrupts with and without Phase Offset System Software for S7 300 and S7 400 Program Design 4 6 C79000 G7076 C506 01 Handling Interrupts Priority Note Table 4 3 shows the default intervals and priority classes of the cyclic interrupt OBs You can assign parameters to change the interval and the priority class Table 4 3 Intervals and Priority Classes of the Cyclic Interrupt OBs Defaults Interval in ms Priority Class OB34 200 11 OB37 20 14 OB38 10 15 When you specify the intervals make sure that there is enough time between the start events of the individual cyclic interrupts for processing the cyclic interrupts themselves If you assign parameters to deselect cyclic interrupt OBs they can no longer be started The CPU recognizes a programming error and changes to the STOP mode System Software for S7 300 and S7 400 Program Design C79000 G7076 C506 01 Handling Interrupts 4 5 Hardware Interrupts O
211. signing parameters with STEP 7 you can also include system functions in the S7 program to modify module parameters Table 8 2 illustrates which SFCs transfer which module parameters see also Section 6 2 Table 8 2 System Functions for Accessing Data Records SFC Application SFC55 WR_PARM Transfers the modifiable parameters data record 1 to the addressed signal module SFC56 Transfers parameters data records 0 or 1 from SDBs WR_DPARM 100 to 129 to the addressed signal module SFC57 Transfers all parameters data records 0 and 1 from PARM_MOD SDBs 100 to 129 to the addressed signal module SFC58 WR_REC Transfers any data record to the addressed signal module The system functions are described in detail in the reference manual 235 Which module parameters can be modified dynamically is explained in the manuals 70 71 or 101 System Software for S7 300 and S7 400 Program Design C79000 G7076 C506 01 8 3 Setting System Parameters 8 2 Using the Clock Functions Overview Time Format Setting and Reading the Time Assigning Parameters for the Clock Synchronizing the Time Using a Run Time Meter 8 4 All 7 300 S7 400 CPUs are equipped with a clock real time clock or software clock The clock can be used in the programmable controller both as clock master or clock slave with external synchronization The clock is required for time of day interrupts and run time meters The c
212. special mode This is only used for test purposes during startup or in the RUN mode The HOLD mode means the following e All timers are frozen timers and run time meters are not processed monitoring times are stopped the basic clock pulses of the time driven levels are stopped e The real time clock runs e Outputs are not enabled but can be enabled explicitly for test purposes e Inputs and outputs can be set and reset e Ifa power outage occurs on a CPU with a backup battery while in the HOLD mode the CPU changes to stop when the power returns but does not execute an automatic restart or complete restart CPUs without battery backup execute an automatic complete restart when power returns e Global data can be received and passive unilateral communication using communication SFBs for configured connections and communication SFCs for non configured connections is possible see also Table 9 5 System Software for S7 300 and S7 400 Program Design C79000 G7076 C506 01 9 13 Operating Modes and Mode Changes 9 6 Testing the User Program Introduction Test Functions 9 14 The operating system supports you when testing and debugging the user program as follows e It provides information about the program e It allows you to monitor and modify variables in your user program Table 9 6 shows the various options available for testing your program in STEP 7 For more detailed information about testing and debugging user
213. sponsible for designing programs for programmable controllers The manual describes the tasks that can be performed without using the STEP 7 software such as determining the program sequence for a design project This manual applies to the following CPUs of the S7 300 and S7 400 Order Number Version or higher CPU 312 IFM 6ES7312 5AC00 0ABO 03 CPU 313 6ES7313 1AD00 0AB0 01 CPU 314 6ES7314 1AE00 0ABO 04 CPU 314 IFM 6ES7312 5AE00 0ABO 01 CPU 315 6ES73 14 1 AFO0 OABO 03 CPU 315 2 DP 6ES73 14 2AF00 0OABO 03 CPU 412 1 6ES7412 1XF00 0OABO 01 CPU 413 1 6ES7413 1XG00 0ABO 01 CPU 413 2 6ES7413 2XG00 0ABO 01 CPU 414 1 6ES7414 1XG00 0ABO 01 CPU 414 2 with 128K 6ES7414 2XG01 0ABO 01 System Software for S7 300 and S7 400 Program Design C79000 G7076 C506 01 Preface CPU Order Number Version or higher CPU 414 2 with 384K 6ES7414 2XJO0 OABO CPU 416 1 6ES7416 1XJO1 0ABO CPU 416 2 with 0 8M 6ES7416 2XK00 0ABO 01 CPU 416 2 with 1 6M 6ES7416 2XL00 0ABO 01 The CPU functions described in this manual can be used from Version 3 1 or higher of the STEP 7 standard software Overview of the There is a wide range of general and specific user documentation available to STEP 7 support you when configuring and programming an S7 programmable logic Documentation controller The following tables and the figure below will help you find the user documentation you require System Software for S7 300 and
214. st January is not possible In this case the OB would only be started in the months that have 31 days A time of day interrupt activated during startup complete restart or restart is only executed after the startup is completed Time of day interrupt OBs that are deselected by the parameter assignment cannot be started The CPU recognizes a programming error and changes to the STOP mode Following a complete restart time of day interrupts must be set again for example using SFC30 ACT_TINT in the startup program System Software for S7 300 and S7 400 Program Design C79000 G7076 C506 01 Handling Interrupts 4 3 Time Delay Interrupts OB20 to OB23 Description Starting Priority Note The S7 CPUs provide time delay OBs with which you can program the delayed execution of parts of your user program Time delay interrupts are triggered when the delay time specified in SFC32 SRT_DINT has expired To start a time delay interrupt you must specify the delay time in SFC32 after which the corresponding time delay interrupt OB is called For the maximum permitted length of the delay time refer to the individual CPU descriptions 70 and 101 The default priority for the time delay interrupt OBs is priority class 3 to 6 see also Section 3 T You can assign parameters to change the priority classes Time delay interrupts can only be executed when the corresponding organization block exists in the CPU program If this is
215. stem memory of the CPU see also Section 3 8 It contains the following e The temporary variables of the local data of blocks e The start information of the organization blocks e Information about transferring parameters e Interim results of the logic in Ladder Logic programs The size of the local data stack depends on the particular CPU refer to the CPU descriptions 70 and 101 The local data stack is divided up equally among the priority classes default This means that each priority class has its own local data area which ensures that higher priority classes and their OBs also have space for their local data see also Section 3 8 System Software for S7 300 and S7 400 Program Design C79000 G7076 C506 01 5 13 System Software for S7 300 and S7 400 Program Design C79000 G7076 C506 01 Addressing Peripheral I Os What Does This This chapter describes how the peripheral I O data areas are addressed user Chapter Describe data diagnostic and parameter data Where to Find For further information about the system functions mentioned in this chapter More Information refer to the reference manual 235 one CS Access to the Peripheral Data Area Special Features of the Distributed Peripheral I Os DP System Software for S7 300 and S7 400 Program Design C79000 G7076 C506 01 6 1 Addressing Peripheral I Os 6 1 Access to Process Data Overview Addressing Modules Peripheral I O Addressing The C
216. stem response for example multicomputing and language description of the CPU Memory areas Memory configuration of the module for example size of the work memory load memory integrated plugged in size of the backup memory System areas System memory of the module for example number of memory bits timers counters memory type Block types Which blocks OB DB SDB FC FB exist on the module the maximum number of blocks of one type and the maximum size of a block type Existing priority classes Which priority classes exist on the module List of permitted system Which SDBs exist on the module can be copied cannot data blocks SDBs be copied whether or not generated as default T O configuration only Maximum I O configuration how many racks number S7 300 CPUs of slots Assignment of interrupts Assignment of interrupts errors to OBs and errors Interrupt status Current status of interrupt processing interrupts generated Status of the priority classes Which OB is being executed which priority class is disabled due to the parameter setting Operating mode and mode Which operating modes are possible the last operating transition mode change the current operating mode Capability parameters for Communication options available for example operator communication interface O T System Software for S7 300 and S7 400 Program Design C79000 G7076 C506 01 11 5 Diagnostics and Troubleshooting
217. suitable for first time users of an S7 programmable controller S7 300 and S7 400 Program Design Programming Manual The S7 300 400 Program Design programming manual provides you with the basic information you require about the structure of the operating system and a user program for an S7 CPU First time users of an S7 300 400 should use this manual to get a basic overview of programming methods on which to base the design of a user program S7 300 and S7 400 System and Standard Functions Reference Manual The S7 CPUs have system functions and organization blocks integrated in the operating system that can be used when programming The manual provides you with an overview of the system functions organization blocks and loadable standard functions available with an S7 programmable controller and contains detailed interface descriptions explaining how to use the functions and blocks in your user program STEP 7 User Manual The STEP 7 User Manual explains the basic use and functions of the STEP 7 automation software Whether you are a first time user of STEP 7 or an experienced STEP 5 user the manual will provide you with an overview of the procedures for configuring programming and getting started with an S7 300 400 programmable controller When working with the software you can call up the online help which supports you with information about specific details of the program Converting S5 Programs Manual Y
218. t called the FC System Software for S7 300 and S7 400 Program Design C79000 G7076 C506 01 2 11 Structuring the User Program 2 9 Function Blocks FB Definition Application FBs and Instance DBs 2 12 Function blocks FBs belong to the blocks that you program yourself A function block is a block with memory It is assigned a data block as its memory instance data block The parameters that are transferred to the FB and the static variables are saved in the instance DB Temporary variables are saved in the local data stack Data saved in the instance DB is not lost when execution of the FB is complete Data saved in the local data stack is however lost when execution of the FB is completed Note To avoid errors when working with FBs read Section An FB contains a program that is always executed when the FB is called by a different logic block Function blocks make it much easier to program frequently occurring complex functions An instance data block is assigned to every function block call that transfers parameters By calling more than one instance of an FB you can control more than one device with one FB An FB for a motor type can for example control various motors by using a different set of instance data for each different motor The data for each motor for example speed ramping accumulated operating time etc can be saved in one or more instance DBs see also Section 2 10 Figure 2 4 sh
219. t to RUN or RUN P e When a manual restart following power down is set in the parameter record of the CPU An automatic restart can be triggered by a power up in the following situations e The CPU was not in the STOP mode when the power outage occurred e The mode selector is set to RUN or RUN P e Automatic restart following power up is set in the parameter record of the CPU The CRST WRST switch has no effect on an automatic restart System Software for S7 300 and S7 400 Program Design C79000 G7076 C506 01 9 7 Operating Modes and Mode Changes Retentive Data S7 300 and S7 400 CPUs react differently to power up following a power Areas Following outage Power Down S7 300 CPUs are only capable of a complete restart With STEP 7 you can however specify memory bits timers counters and areas in data blocks as retentive to avoid data loss caused by a power outage When the power returns an automatic complete restart with memory is executed S7 400 CPUs react to the return of power by executing either a complete restart or a restart depending on the parameter settings Tables 9 2 and 9 3 show the data that are retained on S7 300 and S7 400 CPUs during a complete restart or a restart X means data retained 0 means data reset or cleared contents of DBs I means data set to the initialization value taken from the EPROM Table 9 2 Data Retention in the EPROM Load Memory EPROM memory card or integ
220. terrupt OBs Time of day OB10 to Calculation of the total flow into a blending interrupt OB17 process at the end of a shift Time delay OB20 to Controlling a fan that must continue to run for interrupt OB23 20 seconds after a motor is switched off Cyclic OB30 to Scanning a signal level for a closed loop interrupt OB38 control system Hardware OB40 to Signaling that the maximum level of a tank has interrupt OB47 been reached To allow the operating system to execute an interrupt OB you must perform the following steps e Create the required interrupt OB as an object in your S7 program using STEP 7 e Write the program to be executed in the interrupt OB in the block you have created Download the interrupt OB to the CPU as part of your user program Interrupts can be assigned parameters with STEP 7 By assigning parameters you can for example deselect interrupt OBs or modify priority classes System Software for S7 300 and S7 400 Program Design C79000 G7076 C506 01 Handling Interrupts 4 2 Time of Day Interrupts OB10 to OB17 Description Starting Querying Deactivating Priority The S7 CPUs provide the time of day interrupt OBs that can be executed at a specified date or at certain intervals Time of day interrupts can be triggered as follows e Once at a particular time specified in absolute form with the date e Periodically by specifying the start time and the interval at which the inte
221. the CPU program If this is not the case an error message is entered in the diagnostic buffer and an asynchronous error routine is executed see Chapter I1 If you have deselected hardware interrupt OBs in the parameter assignment these cannot be started The CPU detects a programming error and changes to the STOP mode System Software for S7 300 and S7 400 Program Design 4 8 C79000 G7076 C506 01 Memory Areas of S7 CPUs What Does This This chapter describes the memory areas of the S7 300 and S7 400 CPUs Chapter Describe Chapter Overview Section Description Memory Areas of the CPU 5 2 Absolute and Symbolic Addressing 5 3 Storing Programs on the CPU 5 4 Retentive Memory Areas on S7 300 CPUs Retentive Memory Areas on S7 400 CPUs Process Image Input Output Tables Local Data Stack 5 7 System Software for S7 300 and S7 400 Program Design C79000 G7076 C506 01 5 1 Memory Areas of S7 CPUs 5 1 Memory Areas of the CPU Distribution of the The memory of the S7 CPUs has three basic areas Memory Areas The load memory is used for user programs without symbolic address assignments or comments these remain in the memory of the programming device The load memory can be either RAM or FEPROM Blocks identified as being not relevant to the running of your program are all located in the load memory The work memory integrated RAM contains the parts of the S7 program relevant for runni
222. the duration of one program cycle If a signal state on an input module changes while the program is being executed the signal state in the process image is retained until the process image is updated again at the beginning of the next cycle Access to the process image also requires far less time than direct access to the signal modules since the process image is located in the internal memory of the CPU With some CPUs you can create and update up to eight sections of the process image tables refer to the CPU descriptions 70 and 101 This means that the user program can update sections of the process image table when necessary independent of the cyclic updating of the process image table You define the process image sections with STEP 7 SFCs are used to update a section of the process image By using the following SFCs the user program can update an entire process image table or sections of a process image table e SFC26 UPDAT_PI updates the process image input table e SFC27 UPDAT_PO updates the process image output table Note On S7 300 CPUs inputs and outputs that are not used for the process image tables can be used as additional bit memory areas Programs that make use of this option cannot run on S7 400 CPUs System Software for S7 300 and S7 400 Program Design C79000 G7076 C506 01 Memory Areas of S7 CPUs 5 7 Local Data Stack L Stack Size The local data stack L stack is a memory area in the sy
223. the same no battery failure in the CPU then terminate the block Berr sets the output Battery error if a battery failure or an exhausted battery is detected Note The error codes of all organization blocks are described in the STEP 7 online help and in the reference manual 235 System Software for S7 300 and S7 400 Program Design C79000 G7076 C506 01 11 13 Diagnostics and Troubleshooting 11 7 Using Replacement Values When an Error is Detected Overview Sample Program for Replacing a Value 11 14 With certain types of error for example a wire break affecting an input signal you can supply replacement values for values that are not available due to the error There are two ways of supplying replacement values e You can assign replacement values for configurable output modules using STEP 7 Output modules that cannot be configured have the default replacement value 0 e Using SFC 44 RPL_VAL you can program replacement values in error OBs only for input modules For all load instructions that lead to synchronous errors you can specify a replacement value for the accumulator content in the error OB In the following sample program a replacement value is made available in SFC 44 RPL_VAL Figure 11 5 shows how OB122 is called when the CPU recognizes that an input module is not reacting In this example the replacement value in Figure 11 6 is entered in the program so that the program ca
224. tinction is made between a complete restart and a restart In the S7 300 a complete restart is executed In the S7 400 either a complete restart or a restart is executed depending on the position of the mode selector System Software for S7 300 and S7 400 Program Design C79000 G7076 C506 01 Glossary Symbol Symbol Table System Error System Function SFC System Function Block SFB System Memory System Status List SZL T Timer T A symbol is a name defined by the user taking syntax rules into consideration This name can be used in programming and in operating and monitoring once you have defined it for example as a variable a data type a jump label or a block Example Address I 5 0 Data Type BOOL Symbol Emer_Off_Switch A table used to assign symbols or symbolic names to addresses for shared data and blocks Examples Emer_Off Symbol I 1 7 Address Controller Symbol SFB24 Block System errors are errors which can occur within a programmable logic controller and are not related to the process Some examples of system errors are program errors in the CPU and defects on modules A system function SFC is a function integrated in the CPU operating system which can be called in the user program when required Its associated instance data block is found in the work memory A system function block SFB is a function block integrated in the CPU operating system which can be called i
225. tion SFBs for Configured Connections To transfer data between communication partners using communication SFBs for configured connections the following conditions must be satisfied e The partners must be on one subnet MPI PROFIBUS Industrial Ethernet e You have configured a connection between the partners e You call the required system function blocks and corresponding instance data blocks in the user program S7 CPUs provide communication SFBs for configured connections to exchange to control local com Table 7 1 SFB8 SFB9 data between communication partners CPU CP FM in a network a remote device and to monitor or query the internal status of a munication SFB SFBs and SFC for Data Exchange SFB SFC Brief Description Connection Send and receive functions USEND Uncoordinated data exchange usinga bilateral URCV send and a receive SFB Exchange of blocks of data of bilateral variable length between a send SFB and a receive SFB SFB 15 Reads data from a remote device unilateral PUT Writes data to a remote device unilateral Control functions SFB19 START Initiates a complete restart on a unilateral remote device SFB20 STOP Sets a remote device to the STOP unilateral mode SFB21 RESUME Initiates a restart on a remote device unilateral Monitori ng functions SFB22 STATUS Specific query of the status of a unilateral remote device SFB23 USTATUS Receives sta
226. tton for opening the drain valve Drain_closed 10 7 BOOL Button for closing the drain valve Drain Q9 5 BOOL Activates the drain valve Drain_open_disp Q9 6 BOOL Lamp for drain valve open Drain_closed_disp Q9 7 BOOL Lamp for drain valve closed Table A 4 shows the symbolic names and the absolute addresses used to control the other elements of the program Table A 4 Symbolic Addresses of the Other Program Elements Symbolic Name Address Data Type Description EMER_STOP_off 11 6 BOOL EMERGENCY STOP switch Reset_maint 11 7 BOOL Reset button for the maintenance display lamps of the three motors Motor_block FB1 FB1 FB for controlling pumps and motor Valve_block FC1 FC1 FC for controlling the valves DB_feed_pump_A DB1 FB1 Instance DB for controlling feed pump A DB_feed_pump_B DB2 FB1 Instance DB for controlling feed pump B DB_agitator DB3 FB1 Instance DB for controlling the agitator motor System Software for S7 300 and S7 400 Program Design C79000 G7076 C506 01 A 7 Sample Program for an Industrial Blending Process A 4 Creating the FB for the Motor What is Required The FB for the motor contains the following logical functions of the FB f e There is a start and a stop input e Interlocks allow the operation of the devices pumps and agitator motor The status of the interlocks is saved in the temporary local data L stack of OB1 Motor_enable Valve_enable and is logically c
227. tus messages from bilateral remote devices Query function SFC62 CONTROL Queries the internal state of a local communication SFB using its instance DB System Software for S7 300 and S7 400 Program Design C79000 G7076 C506 01 7 3 Data Exchange Between Programmable Modules Types of Communication Pogramming Example The following types of communication are distinguished when exchanging data with communication SFBs e Bilateral communication indicated by the local and remote communication partners each having one SFB of a pair e Unilateral communication indicated by the fact that only the local communication partner has a communication SFB Figures 7 1 and 7 2 illustrate the two types of communication Communication partner1 local Communication partner2 remote O O O O USEND uRrcV O O ie ie logical connection Figure 7 1 Bilateral Communication Communication partner1 local Communication partner2 remote S No SFB exists o Communication PUT amp provided by system Oy O 0 logical connection Figure 7 2 Unilateral Communication A sample program for transferring data between communication partners using communication SFBs for configured connections is supplied with STEP 7 This sample program is described in Appe
228. tware for S7 300 and S7 400 Program Design C79000 G7076 C506 01 Memory Areas of S7 CPUs Using Battery Backup to Protect Data Configuring the Data of the NVRAM By using a backup battery the data of the load memory and the work memory are protected from loss in case of a power outage If you configure your CPU so that timers counters and memory bits are saved in the NVRAM this information is also retained regardless of whether you use a backup battery or not When you configure your CPU with STEP 7 you can decide which memory areas will be retentive The amount of memory that can be configured in the NVRAM depends on the CPU you are using You cannot back up more data than specified for your CPU For more detailed information about retentive memory refer to the manual 70 System Software for S7 300 and S7 400 Program Design C79000 G7076 C506 01 5 9 Memory Areas of S7 CPUs 5 5 Retentive Memory Areas on S7 400 CPUs Operation Without Battery Backup Operation With Battery Backup Configuring Retentive Data Areas 5 10 If you operate your system without battery backup when a power outage occurs or when you reset the CPU memory MRES the memory of the S7 400 CPU dynamic load memory RAM work memory and system memory is reset and all the data contained in these areas is lost Without battery backup only a complete restart is possible and there are no retentive memory areas Following a power outa
229. ty damage can result if proper precautions are not taken Note draws your attention to particularly importantinformation on the product handling the product orto a particular part of the documentation The device system may only be setup and operated in conjunction with this manual Only qualified personnel should be allowed to install and work on this equipment Qualified persons are defined as persons who are authorized to commission to ground and to tag circuits equipment and sys tems in accordance with established safety practices and standards Note the following Warning This device and its components may only be used forthe applications described in the catalog or the technical description and only in connection with devices or components from other manufacturers which have been approved or recommended by Siemens This product can only function correctly and safely if itis transported stored setup and installed correctly and operated and maintained as recommended SIMATIC and SINEC are registered trademarks of SIEMENS AG Third parties using for their own purposes any other names in this document which refer to trademarks might infringe upon the rights of the trademark owners Copyright Siemens AG 1996 All rights reserved The reproduction transmission or use of this documentor its contents is not permitted withoutexpress written authority Offenders will be liable for damages Allrights i
230. u can assign to the local data of the individual block types e Restrictions you should note when transferring parameters Overview Data Types Using Complex Data Types Using Arrays to Access Data Using Structures to Access Data Using User Defined Data Types to Access Data Using the ANY Parameter Type Assigning Data Types to Local Data of Logic Blocks Restrictions when Transferring parameters C 19 System Software for S7 300 and S7 400 Program Design C79000 G7076 C506 01 C 1 Data and Parameter Types C 1 Data Types Introduction All the data in a user program must be identified by a data type The following data types are available e Elementary data types provided by STEP 7 e Complex data types that you yourself can create by combining elementary data types e User defined data types e Parameter types with which you define parameters to be transferred to FBs or FCs Elementary Data Each elementary data type has a defined length The data type BOOL has for Types example only one bit a byte BYTE consists of 8 bits a word WORD consists of 2 bytes 16 bits a double word DWORD has 4 bytes 32 bits Table C 1 lists the elementary data types Table C 1 Description of the Elementary Data Types Type and Size Format Options Range and Numeric Example Description in Representation lowest to Bits highest value BOOL Bit BYTE B16 0 to B16 FF L B 16 10 Byte L byte 16 10
231. ulse pause ratio of 1 1 You select which memory byte is used on the CPU when you assign parameters for the clock memory using STEP 7 You can use clock memory bytes in the user program for example to activate flashing lights or to trigger periodic activities for example measuring an actual value Each bit of the clock memory byte is assigned a frequency Table 8 3 illustrates the assignment Table 8 3 Possible Frequencies of a Clock Memory Byte Bit 7 6 5 4 Frequency Hz 0 5 0 625 1 1 25 2 2 5 5 10 Note Clock memory bytes are not synchronous with the CPU cycle in other words in long cycles the state of the clock memory byte may change several times Timers are a memory area of the system memory You specify the function of a timer in the user program for example on delay timer The number of timers available depends on the CPU see 70 and 101 If you use less timers in the user program than are actually available you can set the parameters so that only this number of timers is updated in the STARTUP and RUN modes This optimizes the operating system run time Note If you use more timers in your user program than the CPU permits a synchronous error is signaled and OB121 started If you use more timers in your user program than you have selected in the parameter settings no error is signaled however the timers do not run You can use the STEP 7 debugging functions to check whether
232. ustrates the formal parameters of Another FC FC10 that are assigned as actual parameters to the formal parameters of FC12 STEP 7 restricts the assignment of formal parameters of an FC as actual parameters for the formal parameters of a different FC You cannot for example assign parameters with complex data types or a parameter type as the actual parameter Table C 9 shows the restrictions when assigning parameters when one FC calls another Function FC Call t F unction FC FC10 FC12 Variable declaration Variable declaration Param_1 Input A_Param Input Param_2 Output B_ Param Output Param_3 In out C_Param In out Call FC12 A_Param Param_1 B_ Param Param_2 C_Param Param_3 Figure C 12 Transferring Parameters from One FC to Another FC Table C 9 Restrictions When One FC Calls Another Elementary Complex Parameter Types Declaration Type Data T Data T ah E COUNTER BLOCK POINTER ANY Input gt Input Yes Input gt Output No Input gt In out No Output gt Input No Output gt Output Yes Output gt In out No In out gt Input Yes In out gt Output Yes In out gt In out Yes C 20 System Software for S7 300 and S7 400 Program Design C79000 G7076 C506 01 Data and Parameter Types Restrictions When an FC is Called by an FB You can assign the formal parameters of a calling FB to the formal parameters of a called FC Figure C 13 shows the formal parameters of
233. ween the CPU s and the signal modules User data for example digital input signals of a signal module and system data for example default parameter records of a signal module are transferred on this bus The operating system of an S7 CPU provides a maximum of 28 priority classes or program execution levels to which various organization blocks OBs are assigned The priority classes determine which OBs can interrupt other OBs If a priority class includes more than one OB these do not interrupt each other but are executed in the order in which they are called The signal states of the digital input and output modules are stored in the CPU in a process image There is a process image input table PII and a process image output table PIQ PROFIBUS stands for Process Field Bus and is an open communications standard for networking field devices for example programmable controllers drives actuators sensors A programmable logic controller consists of a central rack a CPU and various input and output modules System Software for S7 300 and S7 400 Program Design C79000 G7076 C506 01 Glossary 7 Glossary Programming Device PG Project R Restart S S7 Program Shared Data SINEC L2 DP Start Event STARTUP Mode Glossary 8 A personal computer with a special compact design suitable for industrial conditions A programming device is completely equipped for programming the SIMATIC programma
234. when various instructions are executed The contents of the DB and DI registers are for example swapped when you call an FB This allows the instance DB of the called FB to be opened without losing the address of the previous instance DB If you work with absolute addressing errors can occur accessing data saved in the registers In some cases the addresses in the register AR1 address register 1 and in the DB register are overwritten This means that you could read or write to the wrong addresses Warning Risk of personal injury or damage to equipment The following programming techniques can cause the contents of the DB registers DB and DJ the address register ARI and AR2 and the accumulators ACCU1 and ACCU2 to be modified e CALL FC CALL FB CALL multiple instance e Accessing a DB using the complete absolute address for example DB20 DBW10 e Accessing variables of a complex data type In addition you cannot use the RLO bit of the status word as an additional implicit parameter when you call an FB or FC When using the programming techniques mentioned above you must make sure that you save and restore the contents yourself otherwise errors may occur The contents of the DB register can cause critical situations if you access the absolute addresses of data using the abbreviated format If for example you assume that DB20 is open and that its number is saved in the DB register you can specify DBX0 2 to a
235. witches for controlling the most important stages of the process e Display lamps to indicate the status of the process e The emergency stop switch System Software for S7 300 and S7 400 Program Design C79000 G7076 C506 01 Sample Program for an Industrial Blending Process A 2 Defining Logic Blocks Overview You structure the program by distributing the user program in various blocks and by establishing a hierarchy for block calls Hierarchy of the Figure A 2 shows the hierarchy of the blocks to be called in the structured Block Calls program e The feed pump for ingredient A the feed pump for ingredient B and the agitator motor can be controlled by a single logic block FB1 e The actual parameters and the static data of FB1 are entered in three separate instance DBs for ingredient A ingredient B and for the agitator motor respectively e The inlet and feed valves for ingredients A and B and the drain valve also use a common logic block FC1 The function block and the function are called in OB1 and the specific parameters required for controlling the process are then transferred OB1 Feed pump ingredient A Feed pump Motor ingredient B eee Agitator motor Inlet valves AandB a eee FC1 Feed valves Valves AandB Lea Drain valve DB1 gt Ingredient A DB2 gt Ingredient B DB3
236. x data types Complex data types are created by the user with the data type declaration They do not have a name of their own and cannot be used more than once A distinction is made between arrays and structures The data types STRING and DATE AND TIME belong to this category System Software for S7 300 and S7 400 Program Design C79000 G7076 C506 01 Glossary 3 Glossary Data Type Elementary Data Type User Defined UDT Diagnostic Buffer Diagnostic Event Distributed Peripheral I Os DP DP Standard Formal Parameter Function FC Glossary 4 Elementary data types are predefined data types complying with IEC 1131 3 Examples data type gt BOOL defines a binary variable bit data type INT defines a 16 bit fixed point variable User defined data types are created by the user with the data type declaration They have their own names and can therefore be used more than once A user defined data type can for example be used to create several data blocks with the same structure for example a controller The diagnostic buffer is a retentive area of memory within the CPU which stores the diagnostic events in the order they occurred A diagnostic event causes an entry in the diagnostic buffer of the CPU The diagnostic events are divided into the following groups faults on a module faults in the system wiring system errors on the CPU itself mode change errors on the CPU errors in the user p
237. y a different block must be created Program for OB1 before the block containing its call In the sample program you must therefore create both the FB for the motor and the FC for the valves before the program in OB1 The statement section of OB1 appears as shown below in the STL programming language Network 1 Interlocks for feed pump A A EMER_STOP_off A Tank _below_max AN Drain Enable_motor Network 2 Calling FB motor for ingredient A A Feed_pump_A_ start A Enable_motor Start_fulfilled A O Feed_pump_A_stop ON Enable_motor Stop_fulfilled CALL Motor_block DB_feed_pump_A Start Start_fulfilled Stop Stop_fulfilled Response Flow_A Reset_maint Reset_maint Timer_no T12 Response_time S5T 7S Fault Feed_pump_A_fault Start_dsp Feed_pump_A_on Stop_dsp Feed_pump_A_off Maint Feed_pump_A_maint Motor Feed_pump_A Network 3 Delaying the valve enable ingredient A A Feed_pump_A L SST 1S SD T 13 AN Feed_pump_A R T 13 A T 13 Enable_valve System Software for S7 300 and S7 400 Program Design A 16 C79000 G7076 C506 01 Sample Program for an Industrial Blending Process Network 4 Inlet valve control for ingredient A AN Flow_A AN Feed_pump_A Close_valve_fulfilled CALL Valve_block Open Enable_valve Close Close_valve_fulfilled Dsp_open Inlet_valve_A_ope
238. y fault Operating system Program 21 being executed central 22 central 23 1 Not with the S7 300 central 31 32 33 Battery exhausted No backup power 24 V power supply failed Battery exhausted expansion rack 1 No backup power expansion rack 1 24 V power supply failed expansion rack 1 rack rack rack 1 Figure 11 4 Using the Local Data of an Error OB System Software for S7 300 and S7 400 Program Design C79000 G7076 C506 01 11 11 Diagnostics and Troubleshooting Local Data of the Table 11 7 describes the temporary TEMP variables declared in the variable Error OB81 declaration table of OB81 The symbol Battery_error BOOL must also be identified as an output in the symbol table for example Q 4 0 so that other parts of the program can access this data Table 11 7 Variable Declaration Table of OB81 TEMP OB81_EV_CLASS BYTE Error class error identifier 39xx TEMP OB81_FLT_ID Error code b 16 21 At least one backup battery of the CPU is exhausted b 16 22 No backup voltage in the CPU b 16 23 Failure of the 24 V power supply in the CPU b 16 31 At least one backup battery of an expansion rack is exhausted b 16 32 Backup voltage not present in an expansion rack b 16 33 Failure of the 24 V power supply of an expansion rack TEMP OB81_PRIORITY Priority class 26 28 TEMP OB81_OB_NUMBR BYTE 81 OB81 TEMP
239. ycle time specified with STEP 7 Twait the time available before the start of the next cycle Figure 3 3 Example of the Background Cycle the Main Program Cycle and OB10 Programming OB90 The run time of OB90 is not monitored by the CPU operating system so that you can program loops of any length in OB90 Make sure that the data you use in the background program are consistent by taking the following into account in your program The reset events of OB90 see Reference Manual 235 e The asynchronous process image table updating of OB90 System Software for S7 300 and S7 400 Program Design C79000 G7076 C506 01 3 7 Organization Blocks and Executing the Program 3 5 Organization Blocks for Interrupt Driven Program Execution Overview Non Cyclic Program Execution 3 8 STEP 7 provides different types of OBs that can interrupt OB1 at certain intervals or when certain events occur You can configure these OBs either with STEP 7 or by programming a system function SFC For more detailed information about configuring OBs refer to the STEP 7 user manual 231 For more detailed information about SFCs refer to the reference manual 235 With STEP 7 you can select parts of your user program that do not need to be executed cyclically and only execute these sections when the situation makes it necessary The user program can be divided up into subroutines and distributed in different organization blocks
240. you can test separate sections e Commissioning your system is made much easier The example of an industrial blending process in Chapter I illustrated the advantages of breaking down an automation process into individual tasks The program sections of a structured user program correspond to these individual tasks and are known as the blocks of a program An S7 user program consists of blocks instructions and addresses Table 2 1 provides you with an overview Table 2 1 Elements of a User Program Organization Blocks OBs OBs determine the structure of the user program Section 2 6 e They form the interface between the operating system Chapters 3 4 and the user program They control the startup of the programmable logic controller the cyclic and interrupt driven program execution and are responsible for handling errors and system functions SFCs need to program yourself SFBs and SFCs are integrated in Chapters the S7 CPU They can be called by the user program Since these blocks are part of the operating system they do not need to be loaded as part of the program like other blocks System function blocks SFBs These are standard preprogrammed blocks that you do not Seco Functions FCs and function These are logic blocks that you yourself must program FBs Sectiong 2 8 2 9 blocks FBs are blocks with an associated memory area that is used to supply parameters FCs are blocks that do not have an associated memory
241. ypes C 8 Restrictions When Transferring Parameters Restrictions When Transferring Parameters Between Blocks When you assign actual parameters to formal parameters you can either specify an absolute address a symbolic address or a constant STEP 7 restricts the valid assignments for the various parameters Output and in out parameters for example cannot be assigned a constant value since the purpose of an output or an in out parameter is to change its value These restrictions apply particularly to parameters with complex data types to which neither an absolute address nor a constant can be assigned Table C 8 illustrates the restrictions involving the data types of actual parameters that are assigned to formal parameters Table C 8 Restriction When Transferring Parameters Between Blocks Elementary Data Types Declara Absolute Symbolic Name Local Block Constant tion Type Address in the Symbol Table Symbol Yes Yes Yes No Yes No Complex Data Type Declara Absolute Symbolic Name of the Local Block Constant tion Type Address Element of the DB Symbol in the Symbol Table Yes No Yes No Yes No System Software for S7 300 and S7 400 Program Design C79000 G7076 C506 01 C 19 Data and Parameter Types Restrictions When You can assign the formal parameters of a calling FC to the formal an FC Calls parameters of a called FC Figure C 12 ill
242. ypes of startup COMPLETE RESTART and RESTART see also Chapter 9 S7 300 CPUs only have the COMPLETE RESTART type During startup the operating system calls the appropriate startup OB as follows e Inacomplete restart the complete restart OB OB 100 e Inarestart the restart OB OB101 Start Events The startup OBs are started following the following events e POWER UP e after switching from the STOP mode to the RUN mode e when acomplete restart or restart is triggered on the programming device or using communication functions Whether or not the complete restart or restart OB is called depends on the type of startup specified during parameter assignment for manual and automatic startup the setting of the startup switch CRST WRST and whether the mode selector has been set to POWER OFF see also Section 8 3 Startup Program You can specify the conditions for starting up your CPU initialization values for RUN startup values for I O modules by writing your program for the startup in the organization blocks OB100 for complete restart or OB101 for a restart There are no restrictions to the length of the startup program and no time limit since the cycle monitoring is not active Time or interrupt driven execution is not possible in the startup program During the start up all digital outputs have the signal state 0 System Software for S7 300 and S7 400 Program Design 3 4 C79000 G7076 C506 01 Organization Blocks and Executin

Download Pdf Manuals

image

Related Search

Related Contents

WR10-CP-LED 10 W Art.-No.: 1 20 02 10020 WR20-CP  Psicoterapia do Eu Profundo, Vereshack  - Northstar  Philips Fiber optic cable SWA4303S  「VS-IX009」取扱説明書  Radar ad onda guidata - Service, Support  EE4413K 仕様書  KS-2500(約1.7MB)  User Guide  Char-Broil 12701705  

Copyright © All rights reserved.
Failed to retrieve file