How the S7-1200 works
4.4 Execution of the user program
Easy Book
38
Manual, 05/2009, A5E02486774-01
Event Type (OB)
Quantity
Valid OB
Numbers
Queue
Depth
Priority
Group
Priority
Program cycle
1 program cycle event
Multiple OBs allowed
1 (default)
200 or greater
1
1
Startup
1 startup event
1, 2
Multiple OBs allowed
100 (default)
200 or greater
1
1
1
Time delay
Up to 4 time events
3
1 OB per event
200 or greater
8
3
Cyclic
Up to 4 time events
3
1 OB per event
200 or greater
8
4
Edges
16 rising edge events
16 falling edge events
1 OB per event
200 or greater
32
5
HSC
6 CV = PV events
6 direction changed events
6 external reset events
1 OB per event
200 or greater
16
6
Diagnostic Error
1 event (OB 82 only)
82 only
8
2
9
Time error
1 time-error event
1 MaxCycle time event
(OB 80 only)
1 2xMaxCycle
80 only
8
3
26
27
1
Special case for the startup event: The startup event and the program cycle event will never occur
at the same time because the startup event will run to completion before the program cycle event
will be started (controlled by the operating system).
2
Special case for the startup event: Only the diagnostic error event (associated with OB 82) is
allowed to interrupt the startup event. All other events are queued for later processing after the
startup event is finished.
3
The CPU provides a total of 4 time events that are shared by the time-delay OBs and the cyclic
OBs. The number of time-delay and cyclic OBs in your user program cannot exceed 4.
In general, events are serviced in order of priority (highest priority first). Events of the same
priority are serviced on a "first-come, first-served" basis.
After the execution of an OB has started, processing of the OB cannot be interrupted by the
occurrence of another event from the same or lower priority group. Such events are queued
for later processing, allowing the CPU to complete the execution of the current OB. An OB
within a priority group does not interrupt another OB within the same priority group. However,
an event in priority group 2 will interrupt the execution of an OB in priority group 1, and an
event in priority group 3 will interrupt the execution of any OB in either priority group 1 or 2.
An event from a higher priority group interrupts the execution of the OB currently being
processed, and the CPU then executes the OB for the higher-priority event. For example, a
time event (priority group 2) for a cyclic OB will interrupt the processing of a program cycle
OB (priority group 1). The CPU executes the cyclic OB and then processes any other events
from priority group 2 that might have been queued during the execution of the cyclic OB. If
the CPU had queued any events from priority group 2, the CPU then executes each OB
within priority group 2 to completion, according to the priority level for the event. After
processing all of the events priority group 2, the CPU then returns to the program cycle OB
that had been interrupted and resumes the execution of that OB at the point where it had
been interrupted. If the CPU were to detect a time error event (priority group 3), the time-
error OB (OB 80) would interrupt either the program cycle OB or the cyclic OB. The CPU
would execute the time-error OB and then return to the execution of the OB that was
interrupted.