SEMA

Function Block - Semaphore.

Inputs

CLAIM : BOOL    Takes the semaphore
RELEASE : BOOL  Releases the semaphore

Outputs

BUSY : BOOL     True if semaphore is busy

Remarks

The function block implements the following algorithm:

    BUSY := mem;
    if CLAIM then
       mem := TRUE;
    else if RELEASE then
       BUSY := FALSE;
       mem := FALSE;
    end_if;

In LD language, the input rung is the CLAIM command. The output rung is the BUSY output signal.

ST Language

(* MySema is a declared instance of SEMA function block *)
MySema (CLAIM, RELEASE);
BUSY := MyBlinker.BUSY;

FBD Language

LD Language

IL Language:

(* MySema is a declared instance of SEMA function block *)
Op1: CAL MySema (CLAIM, RELEASE)
     LD  MyBlinker.BUSY
     ST  BUSY