Function Block - Semaphore.
CLAIM : BOOL Takes the semaphore
RELEASE : BOOL Releases the semaphore
BUSY : BOOL True if semaphore is busy
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.
(* MySema is a declared instance of SEMA
function block *)
MySema (CLAIM, RELEASE);
BUSY := MyBlinker.BUSY;
(* MySema is a declared instance of SEMA
function block *)
Op1: CAL MySema (CLAIM, RELEASE)
LD MyBlinker.BUSY
ST BUSY