Professional Documents
Culture Documents
PRO1 13E Organization Blocks
PRO1 13E Organization Blocks
FC
FB
OB1
Operating
system
FB
FC
SFC
System Functions
SFB
System Function
Blocks
Other
OBs
SIMATIC S7
Siemens AG 2005. All rights reserved.
Date:
File:
14.10.2005
PRO1_13E.1
Contents
Page
Objectives ........................................................................................................................................
Overview of the Organization Blocks ................................................................................................
Startup OBs for Warm Restart and Hot Restart ................................................................................
Startup OB for Cold Restart ..............................................................................................................
Interrupting the Cyclic Program ........................................................................................................
Time-of-Day Interrupt (OB10) ...........................................................................................................
Cyclic Interrupt (OB35) .....................................................................................................................
Hardware Interrupt (OB40) ...............................................................................................................
Asynchronous Errors
.....................................................................................................................
Diagnostic Interrupt (OB82) ..............................................................................................................
Synchronous Errors .........................................................................................................................
OB Start Information ........................................................................................................................
Exercise 1: Displaying the Startup Type (OB100) and Acknowledging It ...........................................
Page 1
2
3
4
5
6
7
8
9
10
11
12
13
14
ST-PRO1
Organization Blocks (1)
Objectives
Upon completion of the chapter the participant will ...
...
...
...
...
...
...
...
SIMATIC S7
Siemens AG 2005. All rights reserved.
Date:
File:
14.10.2005
PRO1_13E.2
Page 2
ST-PRO1
Organization Blocks (1)
Periodic
program
execution
Event-driven
program
execution
OB 10 to 17
OB 1
(Time-of-day
interrupts)
OB 30 to 38
(Cyclic Interrupts)
OB 20 to 23
(Time-delay interrupts)
OB 80 to 87
OB 40 to 47
(Hardware interrupts)
OB 121, 122
Interrupt OBs
SIMATIC S7
Date:
File:
14.10.2005
PRO1_13E.3
(Asynchronous errors)
(Synchronous errors)
Error OBs
Startup
A startup program is carried out before the cyclic program execution after a
power recovery, or a change of operating mode (through the CPUs mode
selector or by the PG). OBs 100 to OB 102 are available for this.
In these blocks you can, for example, preset the communications connections.
Cyclic Program
Execution
Periodic Program
Execution
With periodic program execution, you can interrupt the cyclic program execution
at fixed intervals. With cyclic interrupts, an OB 30 to OB 38 organization block is
executed after a preset timing code has run out, every 100 ms for example.
Control-loop blocks with their sampling interval are called, for example, in these
blocks.
With time-of-day interrupts, an OB is executed at a specific time, for example
every day at 17:00 hours (5:00 p.m.), to save the data.
Event-driven
Program
Execution
The hardware interrupt can be used to respond quickly to a process event. After
the event occurs, the cycle is immediately interrupted and an interrupt program
is carried out.
The time-delay interrupt reponds after a delayed time period to a process event.
With the error OBs you can determine how the system is to behave, for
example, if the backup battery fails.
Page 3
ST-PRO1
Organization Blocks (1)
manual
S7-300 / 400
S7-300
S7-400
Execute OB 101
STOPRUN
Power ON STOPRUN
+ CRST
Execute OB 100
Monitoring time
for restart
exceeded ?
Output PIQ
Enable outputs
C
Y
C
L
E
no
Execute OB1
C
Y
C
L
E
Output PIQ
Date:
File:
STOP
Output PIQ
Enable outputs
Read in PII
SIMATIC S7
yes
14.10.2005
PRO1_13E.4
Read in PII
Execute OB1
Output PIQ
Warm Restart
The warm restart type of startup deletes the process images (PII, PIQ) and all
non-retentive bit memories, timers and counters. Retentive bit memories, timers
and counters as well as the data blocks current values are retained (only with
battery backup. With the S7-300 even without battery backup if an EPROM is
used and the CPUs retentive behavior has been parameterized).
The program stored in OB 100 is executed once and then cyclic program
execution begins.
Hot Restart
The hot restart type of startup retains the states of all addresses (bit memories,
timers, counters, process images, the data blocks current values). The program
stored in OB 101 is executed once.
Then, program execution resumes from the point where the interruption
occurred (power off, CPU STOP).
After this "residual cycle time" has been executed, the cyclic program execution
begins once more.
Page 4
ST-PRO1
Organization Blocks (1)
Output PIQ
Enable outputs
Read in PII
C
Y
C
L
E
SIMATIC S7
Output PIQ
Date:
File:
Cold Restart
Execute OB1
14.10.2005
PRO1_13E.5
The S7-400 CPUs and the CPU 318-2 DP also have the additional cold restart
type of startup. This type of startup can be set up for power recovery in the
Hardware Configuration tool when the CPU is parameterized.
The only difference between a cold restart and a warm restart is that in addition
to the process images, all bit memories, timers and counters (even the retentive
ones!) are deleted.
As well, the data blocks current values are overwritten with the initial values
stored in the load memory or with those that were originally downloaded with the
data blocks to the CPU.
Page 5
ST-PRO1
Organization Blocks (1)
Such as OB82
(Prio.26) = Error
handling. Executed in
event of wire break at
analog input PIW 352
SIMATIC S7
OB1
is
executed
continuously.....
Date:
File:
Such as OB10
(Prio.2) = Time-ofday interrupt.
Executed once a
minute from 9:30
14.10.2005
PRO1_13E.6
OB Type
Cyclic Program
Time-of-day interrupt
Time-delay interrupt
Cyclic interrupt
Hardware interrupt
Error handling
Priority
1
2
3
12
16
25 / 28
OB Calls
Organization blocks (OBs) are the interface between the CPUs operating
system and the user program.
The operating system calls the organization blocks exclusively. There are
various start events (time-of-day interrupts, hardware interrupts - see slide) that
each lead to the start of their associated organization block.
Interrupting
the Cyclic Program
When the operating system calls another OB, it interrupts the cyclic program
execution because OB1 has the lowest priority. Any other OB can therefore
interrupt the main program and execute its own program. Afterwards, OB1
resumes execution at the point of interruption.
If an OB with a higher priority than the one currently being executed is called,
the lower priority OB is interrupted after the current statement has been
completed. The operating system then saves the entire register stack for the
interrupted block. This register information is restored when the operating
system resumes execution of the interrupted block.
Priorities
Page 6
ST-PRO1
Organization Blocks (1)
SIMATIC S7
Date:
File:
14.10.2005
PRO1_13E.7
Time-of-Day
Interrupts
Active
Note
S7-400
There are up to eight different time-of-day interrupt OBs (OB 10 to 17) for the
S7-400 PLC.
Page 7
ST-PRO1
Organization Blocks (1)
RUN
OB35
Interval
OB1
OB35
OB35
Interval
OB1
SIMATIC S7
B1
OB1
OB1
Date:
File:
Prio 12
Interval
OB1
14.10.2005
PRO1_13E.8
OB1
B1
Prio 1
Cyclic Interrupt
Cyclic (watchdog) interrupts are used for executing blocks at fixed intervals. The
cyclic interrupt OB for the S7-300 is OB 35.
The default call interval for OB 35 is 100ms. You can change this to a value
within the permitted range of 1ms to 1 minute.
Starting Time
When you activate a time-controlled interrupt, you specify the interval in relation
to the "starting time". The starting time begins every time the CPU mode
changes from STOP to RUN.
Interval
You must make sure that the interval you specify is longer than the time
required for execution. The operating system calls OB35 at the specified time. If
OB35 is still active at this time, the operating system calls OB80 (cyclic interrupt
error OB).
Note
S7-400
There are up to nine different cyclic interrupt OBs (OB30 to 38) for the S7-400
PLC.
Page 8
ST-PRO1
Organization Blocks (1)
CPU
properties
+27648
Upper limit
value
Lower limit
value
SIMATIC S7
Date:
File:
14.10.2005
PRO1_13E.9
Hardware Interrupt
Example
In the example above, suitable limit values have been configured for an analog
input module. If the measured value exceeds the limit, OB40 is called.
This has the same effect as including a comparison operation in OB1 which
causes an FB or FC to be called when the upper limit is reached. However, if
you use OB40 you don't need to write a program in another block.
You can use the program in OB40 for interrupt generation or for process control.
S7-400
There are up to eight different hardware interrupt OBs (OB40 to 47) for the
S7-400 PLC.
Page 9
ST-PRO1
Organization Blocks (1)
Asynchronous Errors
Type of error
Example
OB
Priority
Time error
OB80
26
OB81
Diagnostic interrupt
OB82
Insert / remove
interrupt
OB83
OB84
OB85
Rack fault
OB86
Communication error
OB87
SIMATIC S7
Siemens AG 2005. All rights reserved.
Date:
File:
14.10.2005
PRO1_13E.10
26 / 28
Asynchronous
Errors
Response
If a fault is detected in RUN mode and the relevant error OB has been programmed,
the OB is called and the program in it is executed. This program could, for example,
contain:
instructions for switching on a siren
instructions for data backup, followed by a STOP instruction
a program for recording the frequency with which the fault occurs, without
causing the CPU to go into STOP mode.
Note
If the error OB for a particular fault is not present, the CPU automatically goes into
STOP mode.
Priority
The error OBs called in response to asynchronous errors are executed immediately
because they have the highest priority of all interrupt and error OBs:
Priority 26 if the error occurs while an OB with lower priority (<26) is being
executed
Priority 28 if the error occurs while a startup OB (priority 27) is being executed.
Page 10
ST-PRO1
Organization Blocks (1)
CPU
properties
Wirebreak
+27648
SIMATIC S7
Date:
File:
14.10.2005
PRO1_13E.11
Diagnostic Interrupt
When a diagnostics capable module in our training unit the analog module
detects an error, the operating system calls OB 82.
OB 82 is called not only when the error occurs but also when it has been
eliminated. If no OB 82 exists in the CPU, the CPU goes into the STOP state.
Example
Page 11
ST-PRO1
Organization Blocks (1)
Synchronous Errors
Type of Error
Example
OB
Programming error
OB121
Access error
SIMATIC S7
Date:
File:
Synchronous
Errors
14.10.2005
PRO1_13E.12
OB122
Priority
Same as that
of the OB
interrupted
as a result of
the error
These errors can be traced to a particular point in the program, if the error occurred
during execution of a particular statement. The error OBs called in response to
synchronous errors are executed as part of the program, with the same priority as
the block that was being executed when the error was detected.
Page 12
ST-PRO1
Organization Blocks (1)
OB Start Information
L-Byte
0/1
Start event
Consecutive number
2/3
Priority
OB No.
4/5
6/7
Additional info 1
8/9
Additional info 2
10 / 11
Additional info 3
12 / 13
Year
Month
14 / 15
Day
Hours
16 / 17
Minutes
Seconds
18 / 19
SIMATIC S7
Date:
File:
14.10.2005
PRO1_13E.13
Management
information
Start
information
Start
time
Start Information
You have a uniform system start information in the local data stack when the the
operating system calls the organization blocks.
This start information has a length of 20 bytes and is available after the OB
starts execution.
Access to
Start Information
The STEP 7 software makes a standard declaration table available for the
symbolic access to start information (example for OB 81).
Note
Page 13
ST-PRO1
Organization Blocks (1)
DO Q 4/5....
I 0.0
System_ON
I 0.1
System_OFF
.0
I 0.2
I 0.3
Jog_RIGHT
I 0.4
AUTO / MANUAL
System
.1
MANUAL
.2
.3
Jog_LEFT
AUTO
.4
I 0.5
Accept
man.w.rest.
I 0.6
.5
Qty./ Weight
auto.w.rest.
.6
I 0.7
Ackn_W.Rest.
.7
I 1.0
Ackn_Fault
.0
I 1.1
Fault 1
Fault 1
.1
I 1.2
I 1.3
Fault 2
Fault 2
Fault 3
Fault 3
.2
.3
I 1.4
.4
I 1.5
.5
I 1.6
.6
I 1.7
.7
SIMATIC S7
Date:
File:
14.10.2005
PRO1_13E.14
Notes
In the S7-300 system, there is only the startup block OB 100 for manual as
well as automatic warm restart (exception CPU 318).
If different program reactions are necessary depending on the type of startup of
the controller, then the corresponding start information has to be evaluated in
OB 100.
You can find more information on OB-specific start information in the Online
Help.
Task
What to Do
1. Program the startup display in OB 100 according to the task. Program the
acknowledgement of the startup display in FC 15 (FC_Modes).
2. Only when the startup is acknowledged, should it be possible for the system
operator to bring the system into the "System On" (Q 4.1) mode.
Note
Switch off the type check, so that you can continue to display your program in
LAD or FBD.
You can make the necessary settings for this in the LAD / FBD / STL Editor with
the menu options : Options Settings LAD / FBD.
Page 14
ST-PRO1
Organization Blocks (1)