Sie sind auf Seite 1von 5

Organization Block for Cyclic Program Processing (OB1)

Organization Block for Cyclic Program Processing (OB1)


Cyclic program processing is the "normal" type of program execution on programmable logic controllers. The
operating system calls OB1 cyclically and with this call it starts cyclic execution of the user program.
Sequence of Cyclic Program Processing
The following table shows the phases of cyclic program processing:

Step Sequence in CPUs to 10/98 Sequence in CPUs from 10/98


1 The operating system starts the cycle monitoring time. The operating system starts the cycle monitoring time.
2 The CPU reads the state of the inputs of the input The CPU writes the values from the process image table
modules and updates the process image table of the of the outputs to the output modules.
inputs.
3 The CPU processes the user program and executes the The CPU reads the state of the inputs of the input
instructions contained in the program. modules and updates the process image table of the
inputs.
4 The CPU writes the values from the process image table The CPU processes the user program and executes the
of the outputs to the output modules. instructions contained in the program.

5 At the end of a cycle, the operating system executes At the end of a cycle, the operating system executes
any tasks that are pending, for example downloading any tasks that are pending, for example downloading
and deleting blocks, receiving and sending global data. and deleting blocks, receiving and sending global data.
6 Finally, the CPU returns to the start of the cycle and Finally, the CPU returns to the start of the cycle and
restarts the cycle monitoring time. restarts the cycle monitoring time.

Process Images
So that the CPU has a consistent image of the process signals during cyclic program processing, the CPU does
not address the input (I) and output (Q) address areas directly on the I/O modules but rather accesses an internal
memory area of the CPU that contains an image of the inputs and outputs.
Programming Cyclic Program Processing
You program cyclic program processing by writing your user program in OB1 and in the blocks called within OB1
using STEP 7.
Cyclic program processing begins as soon as the startup program is completed without errors.
Interrupts
Cyclic program processing can be interrupted by the following:
1. An interrupt
2. A STOP command (mode selector, menu option on the programming device, SFC46 STP, SFB20
STOP)
3. A power outage
4. The occurrence of a fault or program error
Scan Cycle Time
The scan cycle time is the time required by the operating system to run the cyclic program and all the program
sections that interrupt the cycle (for example, executing other organization blocks) and system activities (for
example, updating the process image). This time is monitored.
The scan cycle time (TC) is not the same in every cycle. The following figures show different scan cycle times
(TC1 � TC2) for CPUs up to 10/98 and CPUs from 10/98:
Organization Block for Cyclic Program Processing (OB1)

In the current cycle, OB1 is interrupted by a Time璒f璂ay interrupt.


Cycle Monitoring Time
With STEP 7, you can modify the default maximum cycle monitoring time. If this time expires, the CPU either
changes to STOP mode or OB80 is called in which you can specify how the CPU should react to this error.
Minimum Cycle Time
With STEP 7, you can set a minimum cycle time for S7-400 CPUs and the CPU 318. This is useful in the following
situations:
1. When the interval at which program execution starts in OB1 (main program scan) should always be the
same or
2. When the process image tables would be updated unnecessarily often if the cycle time is too short.
The following figures show the function of the cycle monitoring time in program processing in CPUs up to 10/98
and in CPUs from 10/98.
Organization Block for Cyclic Program Processing (OB1)

Updating the Process Image


During cyclic program processing by the CPU, the process image is updated automatically. With the S7-400
CPUs and the CPU 318 you can deselect the update of the process image if you want to:
1. Access the I/O directly instead or
2. Update one or more process image input or output sections at a different point in the program using
system functions SFC26 UPDAT_PI and SFC27 UPDAT_PO.
Communication Load
You can use the CPU parameter "Scan Cycle Load from Communication" to control within a given framework the
Organization Block for Cyclic Program Processing (OB1)

duration of communication processes that always increase the scan cycle time. Examples of communication
processes include transmitting data to another CPU by means of MPI or loading blocks by means of a
programming device.
Test functions with a programming device are barely influenced by this parameter. However, you can increase the
scan cycle time considerably. In the process mode, you can limit the time set for test functions (S7-300 only).
How the Parameter works
The operating system of the CPU constantly provides the communication with the configured percent of the entire
CPU processing capacity (time slice technique). If this processing capacity is not needed for the communication, it
is available to the rest of the processing.
Effect on the Actual Scan Cycle Time
Without additional asynchronous events, the OB1 scan cycle time is extended by a factor that can be calculated
according to the following formula:

Example 1 (no additional asynchronous events):


When you set the load added to the cycle by communication to 50%, the OB1 scan cycle time can be doubled.

At the same time, the OB1 scan cycle time is also influenced by asynchronous events (such as hardware
interrupts or cyclic interrupts). From a statistical point of view, even more asynchronous events occur within an
OB1 scan cycle because of the extension of the scan cycle time by the communication portion. This causes an
additional increase in the OB1 scan cycle. This increase depends on how many events occur per OB1 scan cycle
and on the duration of event processing.
Example 2 (additional asynchronous events considered):
For a pure OB1 execution time of 500 ms, a communication load of 50% can result in an actual scan cycle time of
up to 1000 ms (provided that the CPU always has enough communication jobs to process). If, parallel to this, a
cyclic interrupt with 20 ms processing time is executed every 100 ms, this cyclic interrupt would extend the scan
cycle by a total of 5*20 ms = 100 ms without communication load. That is, the actual scan cycle time would be
600 ms. Because a cyclic interrupt also interrupts communication, it affects the scan cycle time by 10 * 20 ms with
50% communication load. That is, in this case, the actual scan cycle time amounts to 1200 ms instead of 1000
ms.

Note
1. Check the effects of changing the value of the "Scan Cycle Load from Communication"
parameter while the system is running.
2. The communication load must be taken into account when setting the minimum scan
cycle time; otherwise time errors will occur.

Recommendations
1. Where possible, apply the default value.
2. Increase this value only if you are using the CPU primarily for communication purposes and your user
program is not time critical.
3. In all other cases, only reduce the value.
4. Set the process mode (S7-300 only), and limit the time needed there for test functions.

See also:
Process-Image Input/Output Tables
Organization Blocks for Interrupt-Driven Program Processing
Checking Scan Cycle Times to Avoid Time Errors
Module Information Functions
Organization Block for Cyclic Program Processing (OB1)

Background Organization Block (OB90)


Basic Procedure for Creating Logic Blocks
Block Folder Object

Das könnte Ihnen auch gefallen