1. Date: 02.04.2023
File: PRO1_13E.1
SIMATIC S7
Siemens AG 1999. All rights reserved.
Information and Training Center
Knowledge for Automation
Organization Blocks
Operating
system
OB1
FC
FB
SFC
SFB
Other
OBs
FC
FB
2. Date: 02.04.2023
File: PRO1_13E.2
SIMATIC S7
Siemens AG 1999. All rights reserved.
Information and Training Center
Knowledge for Automation
OB 10...17
(Time-of-day
interrupts)
OB 80...87
(Asynchronous errors)
OB 20...23
(Time-delay interrupts)
Overview of the Organization Blocks
Periodic
program
execution
OB 30...38
(Cyclic interrupts)
Event-driven
program
execution
OB 40...47
(Hardware interrupts)
Startup
OB 102
OB 100
OB 101
Cyclic
program
execution
OB 1
OB 121, 122
(Synchronous errors)
Interrupt OBs Error OBs
3. Date: 02.04.2023
File: PRO1_13E.3
SIMATIC S7
Siemens AG 1999. All rights reserved.
Information and Training Center
Knowledge for Automation
Read in PII
Execute OB1
Output PIQ
Complete restart
automatic manual
S7-300 / 400
Power ON
S7-300
STOP->RUN
S7-400
STOP->RUN
+ CRST
Deleting the process images,
non-retentive M, T, C
Execution of OB 100
Enable outputs
Read in PII
Enable outputs
STOP
yes
no
Monitoring time
for restart exceeded ?
Delete PIQ (parameter-assignable)
Process residual scan cycle
Execution of OB 101
Execute OB1
Restart (manual)
• only for S7-400
(according to setting in HW Config):
STOP -> RUN + WRST
Startup OBs
Output PIQ
C
Y
C
L
E
C
Y
C
L
E
4. Date: 02.04.2023
File: PRO1_13E.4
SIMATIC S7
Siemens AG 1999. All rights reserved.
Information and Training Center
Knowledge for Automation
E.g. OB82 (Prio.26) =
Error handling.
Executed in event of
wire break at analog
input PIW 352
E.g. OB10 (Prio.2) =
Time-of-day interrupt.
Executed once a
minute from 9:30
OB1
is
executed
continu-
ously .....
OB 1
3
Time-of-day interrupt
Cyclic interrupt
1
16
Error handling
Cyclic program
Time-delay interrupt
Hardware interrupt
2
12
26 / 28
OB 20
OB 40
OB 10
OB 35
OB 82
OB No. OB Type Priority
E.g. OB20 (Prio.3) =
Time-delay interrupt.
Execution starts 3.25s
after a part is
detected.
Interrupting the Cyclic Program
...... until it is interrupted
by another OB
5. Date: 02.04.2023
File: PRO1_13E.5
SIMATIC S7
Siemens AG 1999. All rights reserved.
Information and Training Center
Knowledge for Automation
Time-of-Day Interrupt (OB10)
6. Date: 02.04.2023
File: PRO1_13E.6
SIMATIC S7
Siemens AG 1999. All rights reserved.
Information and Training Center
Knowledge for Automation
Cyclic Interrupt (OB35)
RUN OB35 OB35 OB35
Interval
O
OB1 B1
OB1 OB1 OB1 OB1 OB1 O B1
Interval Interval
7. Date: 02.04.2023
File: PRO1_13E.7
SIMATIC S7
Siemens AG 1999. All rights reserved.
Information and Training Center
Knowledge for Automation
Analog input module
Upper limit
value
Lower limit
value
+27648
0
Hardware Interrupt (OB40)
HW Config:
Properties of the
analog input module
Properties
of the CPU
8. Date: 02.04.2023
File: PRO1_13E.8
SIMATIC S7
Siemens AG 1999. All rights reserved.
Information and Training Center
Knowledge for Automation
( P ) ( )
I 0.0 M0.1 SFC 32
(SRT_DINT)
EN ENO
OB_NR
DTIME
SIGN
RET_VAL
20
T#500ms
W#16#01
MW10
M2.0
Time-Delay Interrupt (OB20)
9. Date: 02.04.2023
File: PRO1_13E.9
SIMATIC S7
Siemens AG 1999. All rights reserved.
Information and Training Center
Knowledge for Automation
Analog input module
Wire break
+27648
0
Diagnostic Interrupt, Asynchronous Error Interrupt (OB81...87)
HW Config:
Properties of the
analog input module
Properties
of the CPU
10. Date: 02.04.2023
File: PRO1_13E.10
SIMATIC S7
Siemens AG 1999. All rights reserved.
Information and Training Center
Knowledge for Automation
Asynchronous Error OBs
Type of error Example OB
Time error Maximum scan cycle time exceeded OB80
26 / 28
Priority
26
Power supply fault Backup battery failure OB81
Diagnostic interrupt
Wire break at input of diagnostics-capable
module
OB82
Insert / remove
interrupt
Removal of a signal module during operation
of an S7-400
OB83
CPU hardware fault Incorrect signal level at the
MPI interface
OB84
Program execution error
Error in updating the process image
(module defective)
OB85
Rack fault Failure of an expansion device or a
DP slave
OB86
Communication error Error in reading message frame OB87
11. Date: 02.04.2023
File: PRO1_13E.11
SIMATIC S7
Siemens AG 1999. All rights reserved.
Information and Training Center
Knowledge for Automation
Synchronous Errors
Type of error Example OB Priority
Same as that
of the OB
interrupted
as a result of
the error
Programming error
A block that is not present in the
CPU is called in the program OB121
Access error
A module which is either defective
or not present is addressed in the
program (e.g. direct access to a
non-existent I/O module)
OB122
12. Date: 02.04.2023
File: PRO1_13E.12
SIMATIC S7
Siemens AG 1999. All rights reserved.
Information and Training Center
Knowledge for Automation
System Functions for Controlling Interrupt OBs
Organization block
Function Number
Priority
in S7-300
SFCs for
controlling OBs
Remarks
Time-of-day interrupt OB 10 ... 17 2 SFC 28 ... 31 Alternative to HW Config
Time-delay interrupt OB 20 ... 23 3 SFC32 ... 34 Mandatory
Hardware interrupt OB 40 ... 47 16 none
Diagnostic interrupt OB 81 ... 87 26 none
Cyclic interrupt OB 30 ... 38 none
12
13. Date: 02.04.2023
File: PRO1_13E.13
SIMATIC S7
Siemens AG 1999. All rights reserved.
Information and Training Center
Knowledge for Automation
4 / 5
6 / 7
8 / 9
10 / 11
Data formats of L-Bytes 8, 9, 10, 11
Additional info 1 (e.g. start address of interrupt module)
Additional info 2 (e.g. interrupt status)
Additional info 3 (e.g. channel number)
L-Byte
0 / 1
2 / 3
Start event
Priority
Consecutive number
OB No.
12 / 13
14 / 15
16 / 17
18 / 19
Year
Day
Minutes
1/10 Second, 1/100 Second
Month
Hours
Seconds
1 /1000 Second, Weekday
Management
information
Start
information
Start
time
Start Information of OBs
14. Date: 02.04.2023
File: PRO1_13E.14
SIMATIC S7
Siemens AG 1999. All rights reserved.
Information and Training Center
Knowledge for Automation
Step What to Do Result
1
You are to insert the OB100 block in
the S7 program of the HW-Station "My
Station" and write a program for the
OB100 according to the task.
The type of startup is programmed
in the startup block
2
Download the OB100 block
in the CPU
3 Test your program
The LEDs on the simulator light up
depending on the type of startup.
Exercise: Determining the Type of Startup in OB100
15. Date: 02.04.2023
File: PRO1_13E.15
SIMATIC S7
Siemens AG 1999. All rights reserved.
Information and Training Center
Knowledge for Automation
Exercise: Setting the System Time
16. Date: 02.04.2023
File: PRO1_13E.16
SIMATIC S7
Siemens AG 1999. All rights reserved.
Information and Training Center
Knowledge for Automation
Exercise: Creating a Flashing Light with Cyclic Interrupt
You are to assign parameters to the call
interval for OB 35 according to the task
Step What to Do Result
1
Create and save OB 35 and download it
2
3
Check the function Bit memory M 35.0 flashes with 3 Hz
17. Date: 02.04.2023
File: PRO1_13E.17
SIMATIC S7
Siemens AG 1999. All rights reserved.
Information and Training Center
Knowledge for Automation
Exercise: Writing a Program for a Time-of-Day Interrupt
You are to assign parameters to the CPU
so that the time-of-day interrupt is executed
at the end of the course
Step What to Do Result
1
Create and save OB 10 according to the
task and then download it
2
3
Check the function At the end of the course, the horn sounds
Deactivate the time-of-day interrupt and
download the changed configuration.
4