0% found this document useful (0 votes)
56 views4 pages

Ob and Events

Events can start OBs or trigger default system reactions. Events that start OBs are placed in a queue based on priority if the OB cannot immediately be called. The OB or default reaction then executes. Common event types include cyclic, time-related, hardware, and error events. OBs are assigned to events and have priorities from 1 to 27 that determine their execution order. As of firmware V4.0, interruptibility of OBs can be configured per CPU.

Uploaded by

Avinash Shinde
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
56 views4 pages

Ob and Events

Events can start OBs or trigger default system reactions. Events that start OBs are placed in a queue based on priority if the OB cannot immediately be called. The OB or default reaction then executes. Common event types include cyclic, time-related, hardware, and error events. OBs are assigned to events and have priorities from 1 to 27 that determine their execution order. As of firmware V4.0, interruptibility of OBs can be configured per CPU.

Uploaded by

Avinash Shinde
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 4

Events and OBs (S7-1200)

Events and OBs

Events and OBs


The operating system of S7-1200-CPUs is based on events. There are two types of events:
• Events which can start an OB
• Events which cannot start an OB

An event which can start an OB triggers the following reaction:


• It calls the OB you possibly assigned to this event. The event is entered in a queue according to its
priority if it is currently not possible to call this OB.
• The default system reaction is triggered if you did not assign an OB to this event.

An event which cannot start an OB triggers the default system reaction for the associated event class.
The user program cycle is therefore based on events, the assignment of OBs to those events, and on
the code which is either contained in the OB, or called in the OB.
The following table provides an overview of the events which can start an OB, including the associ‐
ated event classes and OBs. The table is sorted based on the default OB priority. Priority class 1 is
the lowest.

Event class OB no. Number Start event OB priority (default)


of OBs
1, >= Starting or end of the last pro‐
Cyclic program >= 1 1
123 gram cycle OB
100, >=
Startup >=0 STOP to RUN transition 1
123
Time-of-day interrupt >= 10 Max. 2 Start time has been reached 2
• 3
• Firmware version
V4.0 or higher: 3
for OB20, 4 for
Time-delay interrupt >= 20 Delay time expired
OB21, 5 for
OB22, 6 for
OB23, 3 for
OB123 to 32767
• 8
• Firmware version
Max. 4 V4.0 or higher: 8
for OB30, 9 for
OB31, 10 for
OB32, 11 for
Cyclic interrupt >= 30 Constant bus cycle time expired OB33, 12 for
OB34, 13 for
OB35, 14 for
OB36, 16 for
OB37, 17 for
OB38, 7 for
OB123 to 32767

-1-
Events and OBs (S7-1200)

• Positive edge (max. 16)


Max. 50 18
(more can
• Negative edge (max. 16)
be used • HSC: Count value = reference
Hardware interrupt >= 40 with DE‐ value (max. 6)
TACH • HSC: Count direction changed 18
and AT‐ (max. 6)
TACH) • HSC: External reset (max. 6)
CPU has received status inter‐
Status interrupt 55 0 or 1 4
rupt
CPU has received update inter‐
Update interrupt 56 0 or 1 4
rupt
CPU has received manufacturer-
Manufacturer- or pro‐
57 0 or 1 specific or profile-specific inter‐ 4
file-specific interrupt
rupt
Diagnostic error inter‐
82 0 or 1 Module has detected an error 5
rupt
Removal/insertion of modules of
Pull/plug interrupt 83 0 or 1 6
distributed I/O
Error in the I/O system of the
Rack error 86 0 or 1 6
distributed I/O
• Maximum cycle time excee‐
ded
• Called OB is still being execu‐
ted
• Time-of-day interrupt missed
Time error 80 0 or 1 22
• Time-of-day interrupt missed
during STOP
• Queue overflow
• Interrupt loss due to high in‐
terrupt load

The following table describes events which do not trigger an OB start, including the corresponding re‐
action of the operating system. The table is sorted based on event priority.

Event class Event Event priority System reaction


Insert/remove central
Insert/remove a module 21 STOP
modules
I/O access error during I/O access error during process im‐
22 Ignore
process image update age update
Programming error in a block for
which you use system reactions
provided by the operating system
Programming error 23 RUN
(note: the error handling routine in
the block program is executed if you
activated local error handling).
I/O access error in a block for which
you use system reactions provided
I/O access error 24 RUN
by the operating system (note: the
error handling routine in the block

-2-
Events and OBs (S7-1200)

program is executed if you activated


local error handling).
Maximum cycle time ex‐ Maximum cycle time exceeded
27 STOP
ceeded twice twice

Assignment between OBs and events


With the exception of the cyclic program and startup program and event can only be assigned to one
OB. However, in certain event classes such as hardware interrupts one and the same OB can be as‐
signed to several events.
The assignment between OBs and events is defined in the hardware configuration. Defined assign‐
ments can be changed at runtime by means of ATTACH and DETACH instructions.

OB priority and runtime behavior


S7-1200-CPUs support the priority classes 1 (lowest) to 27 (highest). An OB is assigned the priority of
its start event.
OBs are always executed on a priority basis: The OBs with the highest priority are executed first.
Events of the same priority are processed in order of occurrence.
As of firmware version V4.0 of the S7-1200 CPUs you can specify in the device configuration, under
properties of the CPU, if the OBs are interruptible or not. This parameter assignment has an effect on
all OBs with exception of the cycle OBs which are always interruptible.
The following applies to S7-1200 CPUs with firmware version < V4.0:
• Any OB with priority >= 2 will interrupt cyclic program execution.
• An OB of priority 2 to 25 cannot be interrupted by any event of priority group 2 to 25. This rule also
applies to events of a priority higher than that of the currently active OB. Such events are pro‐
cessed later.
• A time error (priority 26) will interrupt any other OB.

The following applies to S7-1200 CPUs as of firmware version V4.0:


If you do not configure the OBs as interruptible, an OB is always processed completely even if an
event of a higher priority occurs during its runtime. Specifically, this means:
• Any OB with priority >= 2 will interrupt cyclic program execution.
• An OB of priority 2 to 25 cannot be interrupted by any event. This rule also applies to events of a
priority higher than that of the currently active OB, which also includes a time error. Such events
are processed later.
If you do configure the OBs as interruptible and an event of a higher priority occurs during the runtime
of an OB, the running OB is interrupted and the OB associated with the occurring event is processed.
Once this OB has been completed, processing of the interrupted OB continues. Specifically, this
means:
• Any OB with priority >= 2 will interrupt cyclic program execution.
• An OB of priority 2 to 25 can be interrupted by any event whose priority is higher than that of the
running OB. This is also true for time errors: A time error (priority 26) will interrupt any OB.

OB start information
Certain OBs have start information, while others do not. This is explained in greater detail in the de‐
scription of the relevant OB.

See also

-3-
Events and OBs (S7-1200)

Event-based program execution (S7-1200)


Organization blocks (OB)
ATTACH: Attach an OB to an interrupt event (S7-1200, S7-1500)
DETACH: Detach an OB from an interrupt event (S7-1200, S7-1500)
Overview of mechanisms for error handling

-4-

You might also like