Siemens CPU 948 Programming Manual page 150

Simatic s5 s5-155u
Table of Contents

Advertisement

Semaphore Operations
Application example for
semaphores
Tasks:
Four CPUs are plugged into an S5-155U. They output status messages to a
status signalling device via a common memory area of the O peripherals
(OW 6). A CPU must output each status message for 10 seconds. Only after a
10 second output can a new message be output from the same CPU or a
different CPU overwrite the first message. The use of peripheral word OW 6
(extended I/O area, no process image) is controlled by a semaphore. Only the
CPU that was able to reserve this area for itself by disabling the assigned
semaphore can write this message to OW 6. The semaphore remains disabled for
10 seconds at a time (TIMER T 10). The CPU re-enables the semaphore only
after this timer has elapsed. After the semaphore has been re-enabled, the
other CPUs can access the reserved area. The new message can then be written
to OW 6.
Implementation:
The following program can run in all four CPUs, each with a different
message. The blocks shown below are loaded.
FB 1:
MAIN PROGRAM
5 flags are used as follows:
F 10.0 = 1:
a message was requested or is being processed
F 10.1 = 1:
the semaphore was disabled successfully
F 10.2 = 1:
the timer was started
F 10.3 = 1:
the message was transmitted
F 10.4 = 1:
the semaphore was re-enabled
3 - 78
FB 10:
REPORT
FB 100:
DISABLE SEMAPHORE
FB 110:
OUTPUT REPORT
FB 101:
ENABLE SEMAPHORE
Continued on next page
CPU 948 Programming Guide
C79000-G8576-C848-04

Advertisement

Table of Contents
loading

Table of Contents