FIFOPLCopen motion icon

FunctionClosed A function calculates a result according to the current value of its inputs. A function has no internal data and is not linked to declared instances. block - Manages a "first in / first out" list

Inputs

PUSH BOOL Push a new value (on rising edgeClosed A rising edge is the transition of a digital signal from low to high. It is also called positive edge)
POP BOOL Pop a new value (on rising edge)
RST BOOL Reset the list
IN ANY Value to be pushed
@Tail ANY Value of the oldest pushed value - updated after call!
Buf[] ANY Array for storing values

Outputs

EMPTY BOOL TRUE if the list is empty
OFLO BOOL TRUE if overflow on a PUSH command
Count DINT Number of values in the list
pRead DINT Index in the buffer of the oldest pushed value
pWrite DINT Index in the buffer of the next push position

Remarks

IN, @Tail and Buf[] must have the same data type and cannot be STRING.

The @Tail argument specifies a variable which is filled with the oldest push value after the block is called.

Values are stored in the "BUF" array. Data is arranged as a roll over buffer and is never shifted or reset. Only read and write pointers and pushed values are updated. The maximum size of the list is the dimension of the array.

The first time the block is called, it remembers on which array it should work. If you call later the same instance with another BUF input, the call is considered as invalid and makes nothing. Outputs reports an empty list in this case.

In FFLD language, input rung is the PUSH input. The output rung is the EMPTY output.

ST Language

(* MyFIFO is a declared instance of FIFO function block *)
MyFIFO (PUSH, POP, RST, IN, @Tail , BUFFER);
EMPTY := MyFIFO.EMPTY;
OFLO := MyFIFO.OFLO;
COUNT := MyFIFO.COUNT;
PREAD := MyFIFO.PREAD;
PWRITE := MyFIFO.PWRITE;

FBD Language

FFLD Language

IL Language

(* MyFIFO is a declared instance of FIFO function block *)
Op1: CAL MyFIFO (PUSH, POP, RST, IN, @Tail , BUFF[])
FFLD  MyFIFO.EMPTY
STClosed "Structured text" A high-level language that is block structured and syntactically resembles Pascal  EMPTY
FFLD  MyFIFO.OFLO
ST  OFLO
FFLD  MyFIFO.COUNT
ST  COUNT
FFLD  MyFIFO.PREAD
ST  PREAD
FFLD  MyFIFO.PWRITE
ST  PWRITE

See also

LIFO