s
Preface, Contents
Organization Blocks
1
Common Parameters for SFCs
2
Copy and Block Functions
3
SFCs for Controlling Program
Execution
4
SFCs for Handling the System Clock
5
SFCs for Handling Run-Time Meters
6
SFCs for Transferring Data Records
7
DPV1 SFBs According to
PNO AK 1131
8
SFCs for Handling Time-of-Day
Interrupts
9
SFCs for Handling Time-Delay
Interrupts
10
SFCs for Handling Synchronous Errors
11
SFCs for Handling Interrupts and
Asynchronous Errors
SFBs for Integrated Control
25
SFBs for Compact CPUs
26
SFCs for H CPUs
27
Integrated Functions
(for CPUs with Integrated I/Os)
28
Plastics Techology
29
Diagnostic Data
30
System Status Lists (SSL)
31
SIMATIC
System Software
for S7-300/400 System and
Standard Functions
Reference Manual
This manual is part of the documentation
package with the order number:
6ES7810-4CA07-8BW1
Events
32
©Siemens AG 2004
Technical data subject to change.
Siemens Aktiengesellschaft A5E00261410-01
Safety Guidelines
This manual contains notices intended to ensure personal safety, as well as to protect the products and
connected equipment against damage. These notices are highlighted by the symbols shown below and
graded according to severity by the following texts:
!
Danger
indicates that death, severe personal injury or substantial property damage will result if proper
precautions are not taken.
!
Warning
indicates that death, severe personal injury or substantial property damage can result if proper
precautions are not taken.!
Caution
indicates that minor personal injury can result if proper precautions are not taken.
System Software for S7-300/400 System and Standard Functions
A5E00261410-01
iii
Preface
Purpose
This manual provides you with a comprehensive overview of the organization
blocks (OB), system functions (SFC), system and standard function blocks (SFC),
and IEC functions contained in the operating systems of the CPUs of the S7-300
and S7-400. The appendix describes the diagnostic data, system status lists (SZL),
and events. Note
Refer to the reference section of the "S7-300 Automation System
CPU Specifications: CPU 31xC and CPU 31x" and " S7-300 Automation System
CPU Specifications: CPU 312IFM - 318-2 DP“ /70/
or the
"Automation System S7-400: CPU Specifications" reference manual /101/
or the
Instruction List: S7-400 Programmable Controller /102/
(whichever version applies
to your CPU) for details of which of these functions and blocks are available on
which CPU. The properties of the CFBs and the S7 signaling functions for specific
CPUs are described in /70/
and /101/.
For information about the CPU operating systems, program design, and the
communications and diagnostic capabilities of the CPUs, refer to the
"Configuring Hardware and Communication Connections STEP 7 V5.3" manual
/234/
programmable controllers.
6ES7810-4CA07-8BW0
STEP 7 Reference with
• Ladder Logic (LAD)/Function Block
Diagram (FBD)/Statement List (STL)
for S7-300/400 manuals
• Standard and System Functions for
S7-300/400
Provides reference information
and describes the programming
languages LAD, FBD, and STL,
and standard and system
functions extending the scope of
the STEP 7 basic information.
6ES7810-4CA07-8BW1
Online Helps Purpose Order Number
Help on STEP 7 Basic information on
programming and configuring
hardware with STEP 7 in the form
of an online help.
Part of the STEP 7
Standard software.
Reference helps on STL/LAD/FBD
Reference help on SFBs/SFCs
Reference help on Organization Blocks
Context-sensitive reference
Feedback on Documentation
To help us to provide the best possible documentation for you and future STEP 7
users, we need your support. If you have any comments or suggestions relating to
this manual or the online help, please complete the questionnaire at the end of the
manual and send it to the address shown. Please include your own personal rating
of the documentation.
Other Manuals
The various S7-300 and S7-400 CPUs and the S7-300 and S7-400 modules are
described in the following manuals:
• For the S7-300 programmable logic controller, refer to the manuals: "
Automatisierungssystem S7-300 CPU-Daten: CPU 31xC und CPU 31x und
Automatisierungssystem S7-300 CPU-Daten: CPU 312 IFM bis 318-2 DP“ "
/70/, "S7-300, M7-300 Programmable Controllers Module Specifications" /71/
and in the Instruction List /72/.
• For the S7-400 programmable logic controller, refer to the manual:
" Automatisierungssystem S7-400: CPU Daten " /101/ and in the Instruction
List /102/.
Preface
System Software for S7-300/400 System and Standard Functions
vi A5E00261410-01
How to Use this Manual
This manual covers the following topics:
• Chapter 1 explains the functions of all the organization blocks.
• Chapter 2 describes the common parameters RET_VAL, REQ and BUSY.
• Chapters 3 to 29 describe the SFCs, SFBs and IEC-FCs.
• The Chapters sections 30 to 33 contain a description of the structure of the
diagnostic data, an overview of the SZL-IDs, the possible events, lists of the
SFCs, SFBs and FCs described in this manual, an overview of the SDBs.
• The bibliography contains a list of further manuals.
Nuernberg
Johnson City Worldwide (Nuernberg)
Technical Support
24 hours a day, 365 days a year
Phone: +49 (180) 5050-222
Fax: +49 (180) 5050-223
E-Mail: adsupport@
siemens.com
GMT: +1:00 Europe / Africa (Nuernberg)
Authorization
Local time: Mon Fri. 8:00 to 5:00 PM
Phone: +49 (180) 5050-222
Fax: +49 (180) 5050-223
E-Mail: adsupport@
siemens.com
GMT: +1:00
United States (Johnson City)
Technical Support and
Authorization
• Information on field service, repairs, spare parts and more under "Services".
System Software for S7-300/400 System and Standard Functions
A5E00261410-01
ix
Contents
1 Organization Blocks 1-1
1.1 Overview of the Organization Blocks (OBs) 1-1
1.2 Program Cycle Organization Block (OB1) 1-4
1.3 Time-of-Day Interrupt Organization Blocks (OB10 to OB17) 1-6
1.4 Time-Delay Interrupt Organization Blocks (OB20 to OB23) 1-10
1.5 Cyclic Interrupt Organization Blocks (OB30 to OB38) 1-12
1.6 Hardware Interrupt Organization Blocks (OB40 to OB47) 1-14
1.7 Status Interrupt OB (OB 55) 1-16
1.8 Update Interrupt OB (OB 56) 1-17
1.9 Manufacturer Specific Interrupt OB (OB57) 1-18
1.10 Multicomputing Interrupt Organization Block (OB60) 1-19
1.11 Synchronous Cycle Interrupt OBs (OB 61 to OB 64) 1-21
1.12 I/O Redundancy Error OB (OB70) 1-22
1.13 CPU Redundancy Error OB (OB72) 1-24
1.14 Communication Redundancy Error OB (OB73) 1-27
1.15 Time Error Organization Block (OB80) 1-28
1.16 Power Supply Error Organization Block (OB81) 1-30
1.17 Diagnostic Interrupt Organization Block (OB82) 1-32
1.18 Insert / Remove Module Interrupt Organization Block (OB83) 1-34
1.19 CPU Hardware Fault Organization Block (OB84) 1-37
1.20 Priority Class Error Organization Block (OB85) 1-38
1.21 Rack Failure Organization Block (OB86) 1-42
1.22 Communication Error Organization Block (OB87) 1-45
1.23 Processing Interrupt OB (OB 88) 1-47
4.5 Controlling CiR with SFC104 "CiR" 4-4
5 SFCs for Handling the System Clock 5-1
5.1 Setting the TOD with SFC0 "SET_CLK" 5-1
5.2 Reading the Time with SFC1 "READ_CLK" 5-2
5.3 Synchronizing Slave Clocks with SFC48 "SNC_RTCB" 5-3
5.4 Setting the Time-of-Day and the TOD Status with SFC100 "SET_CLKS" 5-4
6 SFCs for Handling Run-Time Meters 6-1
6.1 Runtime Meters 6-1
6.2 Handling Runtime meters with SFC101 "RTM" 6-2
6.3 Setting the Runtime Meter with SFC2 "SET_RTM" 6-4
6.4 Starting and Stopping a Run-time Meter with SFC3 "CTRL_RTM" 6-5
6.5 Reading a Runtime Meter with SFC4 "READ_RTM" 6-6
6.6 Reading the System Time with SFC64 "TIME_TCK" 6-7
7 SFCs for Transferring Data Records 7-1
7.1 Writing and Reading Data Records 7-1
7.2 Reading Defined Parameters with SFC54 "RD_DPARM" 7-3
7.3 Reading Predefined Parameters with SFC102 "RD_DPARA" 7-4
7.4 Writing Dynamic Parameters with SFC55 "WR_PARM" 7-5
7.5 Writing Default Parameters with SFC56 "WR_DPARM" 7-7
7.6 Assigning Parameters to a Module with SFC57 "PARM_MOD" 7-8
7.7 Writing a Data Record with SFC58 "WR_REC" 7-11
7.8 Reading a Data Record with SFC59 "RD_REC" 7-13
7.9 Further Error Information for SFCs 55 to 59 7-18
8 DPV1 SFBs According to PNO AK 1131 8-1
8.1 Reading a Data Record from a DP Slave with SFB52 "RDREC" 8-1
8.2 Writing a Data Record in a DP Slave with SFB53 "WRREC" 8-3
8.3 Receiving an Interrupt from a DP Slave with SFB54 "RALRM" 8-5
8.4 Sending an Interrupt to the DP Master with SFB75 "SALRM" 8-14
9 SFCs for Handling Time-of-Day Interrupts 9-1
9.1 Handling Time-of-Day Interrupts 9-1
12.5 Enabling the Processing of Higher Priority Interrupts
and Asynchronous Errors with SFC42 "EN_AIRT" 12-8
13 SFCs for Diagnostics 13-1
13.1 System Diagnostics 13-1
13.2 Reading OB Start Information with SFC6 "RD_SINFO" 13-1
13.3 Reading a System Status List or Partial List with SFC51 "RDSYSST" 13-4
13.4 Writing a User-Defined Diagnostic Event
to the Diagnostic Buffer with SFC52 "WR_USMSG" 13-10
13.5 Determining the OB Program Runtime with SFC78 "OB_RT" 13-14
13.6 Diagnosis of the Current Connection Status with SFC87 "C_DIAG" 13-18
13.7 Identifying the Bus Topology of a DP Master System
with SFC103 "DP_TOPOL" 13-23
14 SFCs and SFBs for Updating the Process Image and Processing Bit Fields 14-1
14.1 Updating the Process Image Input Table with SFC26 "UPDAT_PI" 14-1
14.2 Updating the Process Image Output Table with SFC27 "UPDAT_PO" 14-3
14.4 Updating the Process Image Partition Input Table
in a Synchronous Cycle with SFC 126 "SYNC_PI" 14-6
14.5 Updating the Process Image Partition Output Table
in a Synchronous Cycle with SFC 127 "ISO_PO" 14-8
14.6 Resetting a Bit Field in the I/O Area with SFC80 "RSET" 14-10
14.7 Implementing a Sequencer with SFB32 "DRUM" 14-11
15 System Functions for Addressing Modules 15-1
15.1 Querying the Logical Base Address of a Module with SFC5 "GADR_LGC" 15-1
15.2 Querying the Module Slot Belonging to a Logical Address with SFC49
18.2 Data Consistency 18-4
18.3 Overview of the S7 Communication Blocks 18-6
18.4 Overview of the Blocks for the S7 Basic Communication 18-8
19 S7 Communication 19-1
19.1 Common Parameters of the SFBs/FBs and SFCs/FCs
for S7 Communication 19-1
19.2 Startup Routine of SFBs for Configured S7 Connections 19-5
19.3 How SFBs React to Problems 19-7
19.4 Uncoordinated Sending of Data with SFB8/FB8 "USEND" 19-9
19.5 Uncoordinated Receiving of Data with SFB/FB9 "URCV" 19-12
19.6 Sending Segmented Data with SFB/FB12 "BSEND" 19-15
19.7 Receiving Segmented Data with SFB/FB13 "BRCV" 19-18
19.8 Writing Data to a Remote CPU with SFB/FB15 "PUT" 19-21
19.9 Read Data from a Remote CPU with SFB/FB14 "GET" 19-24
19.10 Sending Data to a Printer with SFB16 "PRINT" 19-27
19.11 Initiating a Warm or Cold Restart on a Remote Device
with SFB19 "START" 19-33
19.12 Changing a Remote Device to the STOP State with SFB20 "STOP" 19-36
19.13 Initiating a Hot Restart on a Remote Device with SFB21 "RESUME" 19-38
19.14 Querying the Status of a Remote Partner with SFB22 "STATUS" 19-40
19.15 Receiving the Status Change of a Remote Device
with SFB23 "USTATUS" 19-42
19.16 Querying the Status of the Connection Belonging
to an SFB Instance with SFC62 "CONTROL" 19-44
19.17 Querying the Connection Status with FC62 "C_CNTRL" 19-46
19.18 Work Memory Requirements of the S7 Communication SFBs/FBs 19-48
System Software for S7-300/400 System and Standard Functions
A5E00261410-01
xiii
21
PROFInet 21-1
21.1 Background Information on SFCs 112, 113 and 114 21-1
21.2 Updating the Inputs of the User Program Interface
for the PROFInet Component with SFC112 "PN_IN" 21-4
21.3 Updating the Outputs of the User Program Interface
for the PROFInet Component with SFC113 "PN_OUT" 21-5
21.4 Updating DP Interconnections with SFC114 "PN_DP" 21-6
22 Generating Block-Related Messages 22-1
22.1 Introduction to Generating Block-Related Messages with SFBs 22-1
22.2 Generating Block-Related Messages without Acknowledgment
with SFB36 "NOTIFY" 22-5
22.3 Generating Block Related Messages without Acknowledgement Display
with SFB31 "NOTIFY_8P" 22-7
22.4 Generating Block-Related Messages with Acknowledgment
with SFB33 "ALARM" 22-10
22.5 Generating Block-Related Messages with Associated Values
for Eight Signals with SFB35 "ALARM_8P" 22-13
22.6 Generating Block-Related Messages without Associated Values
for Eight Signals with SFB34 "ALARM_8" 22-16
23.5 Counting Down with SFB1 "CTD" 23-8
23.6 Up / Down Count with SFB2 "CTUD" 23-9
Contents
System Software for S7-300/400 System and Standard Functions
xiv A5E00261410-01
24 IEC Functions 24-1
24.1 Overview 24-1
24.2 Technical Data of the IEC Functions 24-3
24.3 Date and Time as Complex Data Types 24-5
24.4 Time-of-Day Functions 24-6
24.5 Comparing DATE_AND_TIME Variables 24-10
24.6 Comparing STRING Variables 24-13
24.7 Editing Number Values 24-16
24.8 Example in STL 24-17
24.9 Example in STL 24-18
24.10 Editing STRING Variables 24-19
24.11 Converting Data Type Formats 24-24
25 SFBs for Integrated Control 25-1
25.1 Continuous Control with SFB41/FB41 "CONT_C" 25-1
25.2 Step Control with SFB42/FB42 "CONT_S" 25-8
25.3 Pulse Generation with SFB43/FB43 "PULSEGEN" 25-14
25.4 Example of the PULSEGEN Block 25-25
26 SFBs for Compact CPUs 26-1
26.1 Positioning With Analog Output Using SFB44 "Analog" 26-1
26.2 Positioning with Digital Output Using SFB46 "DIGITAL" 26-13
26.3 Controlling the Counter with SFB47 "COUNT" 26-23
26.4 Controlling the Frequency Measurement with SFB48 "FREQUENC" 26-28
26.5 Controlling Pulse Width Modulation with SFB49 "PULSE" 26-32
26.6 Sending Data (ASCII, 3964(R)) with SFB60 "SEND_PTP" 26-35
26.7 Receiving Data (ASCII, 3964(R)) with SFB61 "RCV_PTP" 26-38
31.7 SSL-ID W#16#xy13 - Memory Areas 31-9
31.8 SSL-ID W#16#xy14 - System Areas 31-10
31.9 SSL-ID W#16#xy15 - Block Types 31-12
31.10 SSL-ID W#16#xy19 - Status of the Module LEDs 31-13
31.11 SSL-ID W#16#xy1C - Component Identification 31-15
31.12 SSL ID W#16#xy25 - Assigning Process Images Partitions to the OBs 31-18
31.13 SSL-ID W#16#xy32 - Communication Status Data 31-21
31.14 Data Record of the Partial List Extract
with SSL-ID W#16#0132 Index W#16#0005 31-22
31.15 Data Record of the Partial List Extract
with SSL-ID W#16#0132 Index W#16#0008 31-23
31.16 Data Record of the Partial List Extract
with SSL-ID W#16#0132 Index W#16#000B 31-25
31.17 Data Record of the Partial List Extract
with SSL-ID W#16#0132 Index W#16#000C 31-26
31.18 Data Record of the Partial List Extract
with SSL-ID W#16#0232 Index W#16#0004 31-27
31.19 SSL-ID W#16#xy71 - H CPU Group Information 31-28
31.20 SSL-ID W#16#xy74 - Status of the Module LEDs 31-30
31.21 SSL-ID W#16#xy75 - Switched DP Slaves in the H system 31-32
31.22 SSL-ID W#16#xy90 - DP Master System Information 31-34
31.23 SSL-ID W#16#xy91 - Module Status Information 31-36
31.24 SSL-ID W#16#xy92 - Rack / Station Status Information 31-40
31.25 SSL-ID W#16#xy95 - Extended DP Master System Information 31-43
31.26 SSL-ID W#16#xyA0 - Diagnostic Buffer 31-45
System Software for S7-300/400 System and Standard Functions
A5E00261410-01
1-1
1 Organization Blocks
1.1 Overview of the Organization Blocks (OBs)
What Are Organization Blocks?
Organization Blocks (OBs) are the interface between the operating system of the
CPU and the user program. OBs are used to execute specific program sections:
• At the startup of the CPU
• In a cyclic or clocked execution
• Whenever errors occur
• Whenever hardware interrupts occur.
Organization blocks are executed according to the priority they are allocated.
Which OBs Are Available?
Not all CPUs can process all of the OBs available in STEP 7. Refer to Operations
lists /72/ and /102/ to determine which OBs are included with your CPU.
Where to Find More Information?
Refer to the online help and the following manuals for more information:
• /70/: this manual contains the technical data that describe the capabilities of
the different S7-300 CPUs.
• /101/: this manual contains the technical data that describe the capabilities of
the different S7-400 CPUs.
Organization Blocks
System Software for S7-300/400 System and Standard Functions
2
2
No default time
specified
OB20
OB21
OB22
OB23
Time-delay interrupt 0
Time-delay interrupt 1
Time-delay interrupt 2
Time-delay interrupt 3
3
4
5
6
No default time
specified
OB30
OB31
OB32
OB33
OB34
OB35
OB36
OB37
OB38
Cyclic interrupt 0 (default interval: 5 s)
Cyclic interrupt 1 (default interval: 2 s)
Cyclic interrupt 2 (default interval: 1 s)
Hardware interrupt 6
Hardware interrupt 7
16
17
18
19
20
21
22
23
Hardware interrupts
OB55 Status interrupt 2 DPV1 interrupts
OB56 Update interrupt 2
OB57 Manufacturer specific interrupt 2
OB60 SFC35 "MP_ALM" call 25 Multicomputing
interrupt
OB 61
OB 62
OB 63
OB 64
Synchronous Cycle Interrupt 1
Synchronous Cycle Interrupt 2
Synchronous Cycle Interrupt 3
Synchronous Cycle Interrupt 4
25
25
25
25
Synchronous Cycle
Interrupt
Power supply fault
Diagnostic interrupt
Insert/remove-module interrupt
CPU hardware fault
Program error
Failure of an expansion rack, DP master
system or station for distributed I/Os
Communication error
Processing interrupt
26, 28
1)
25, 28
1)
25, 28
1)
25, 28
1)
25, 28
1)
25, 28
1)
25, 28
1)
25, 28
1)
28
Asynchronous error
interrupts
Priority of the OB
causing the error
Priority of the OB
causing the error
Synchronous error
interrupts
1)
Priority classes 27 and 28 are valid in the priority class model of the startup.
2)
Priority class 29 corresponds to priority 0.29. This means that the background
cycle has lower priority than the free cycle.
Organization Blocks
System Software for S7-300/400 System and Standard Functions
1-4 A5E00261410-01
1.2 Program Cycle Organization Block (OB1)
Description
The operating system of the S7 CPU executes OB1 periodically. When OB1 has
been executed, the operating system starts it again. Cyclic execution of OB1 is
started after the startup has been completed. You can call other function blocks
(FBs, SFBs) or functions (FCs, SFCs) in OB1.
Understanding the Operation of OB1
OB1 has the lowest priority of all of the OBs whose run-times are monitored, in
other words, all of the other OBs except OB90 can interrupt the execution of OB1.
The following events cause the operating system to call OB1:
• The startup is completed.
• The execution of OB1 (the previous cycle) has finished.
When OB1 has been executed, the operating system sends global data. Before
restarting OB1, the operating system writes the process-image output table to the
output modules, updates the process-image input table and receives any global
OB1_PRIORITY BYTE Priority class 1
OB1_OB_NUMBR BYTE OB number (01)
OB1_RESERVED_1 BYTE Reserved
OB1_RESERVED_2 BYTE Reserved
OB1_PREV_CYCLE INT Run time of previous scan (ms)
OB1_MIN_CYCLE INT Minimum cycle time (ms) since the last startup
OB1_MAX_CYCLE INT Maximum cycle time (ms) since the last startup
OB1_DATE_TIME DATE_AND_TIME DATE_AND_TIME of day when the OB was called
Organization Blocks
System Software for S7-300/400 System and Standard Functions
1-6 A5E00261410-01
1.3 Time-of-Day Interrupt Organization Blocks
(OB10 to OB17)
Description
STEP 7 provides up to eight OBs (OB10 to OB17) which can be run once or
periodically. You can assign parameters for CPU using SFCs or STEP 7 so that
these OBs are processed at the following intervals:
• Once
• Every minute
• Hourly
• Daily
• Weekly
• Monthly
• At the end of each month Note
For monthly execution of a time-of-day interrupt OBs, only the days 1, 2, 28 can
be used as a starting date.
Note
If you configure a time-of-day interrupt in such a way that the corresponding OB is to be
processed once, the DATE_AND_TIME must not be in the past (relative to the real-time
clock of the CPU).
If you configure a time-of-day interrupt in such a way that the corresponding OB is to be
processed periodically, the start DATE_AND_TIME, however, are in the past, then the time-
of-day interrupt will be processed the next time it is due. This is illustrated in the following
figure.
You can disable or delay and re-enable time-of-day interrupts using SFCs 39 to 42.
Preset
star
start time
Current
time
Preset
interval
Point at which the time-of-day
interrupt OB is first executed.Organization Blocks
System Software for S7-300/400 System and Standard Functions
1-8 A5E00261410-01
Conditions That Affect Time-of-Day Interrupt OBs
Since a time-of-day interrupt occurs only at specified intervals, certain conditions
can affect the operation of the OB during the execution of your program. The
following table shows some of these conditions and describes the effect on the
repeated.
S7-400-CPUs and CPU 318:
If the time-of-day OB had already been activated before
the clock was set back, it is not called again.
S7-300-CPUs: The time-of-day OB is executed.
The CPU runs through a warm or cold restart. Any time-of-day OB that was configured by an SFC is
changed back to the configuration that was specified in
STEP 7.
If you have configured a time-of-day interrupt for a one-
time start of the corresponding OB, set it with STEP 7,
and activated it, the OB is called once after a warm or
cold restart of the operating system, if the configured
start time is in the past (relative to the real-time clock of
the CPU).
A time-of-day OB is still being executed when
the start event for the next interval occurs.
The operating system calls OB80. If OB80 is not
programmed, the CPU changes to the STOP mode.
If OB80 is loaded, both OB80 and the time-of-day
interrupt OB are first executed and then second the
requested interrupt is executed.
Organization Blocks
System Software for S7-300/400 System and Standard Functions
A5E00261410-01
1-9
Local Data for Time-of-Day Interrupt OBs
The following table describes the temporary (TEMP) variables for a time-of-day
interrupt OB. The variable names are the default names of OB10.
Variable Type Description