SEMAPLCopen motion icon

Function BlockClosed A function block groups an algorithm and a set of private data. It has inputs and outputs. - 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 FFLD 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

FFLD Language

IL Language:

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