FIFO
Inputs
Inputs |
Data Type |
Range |
Unit |
Default |
Description |
---|---|---|---|---|---|
@Tail |
ANY |
|
|
|
Value of the oldest pushed value. Updated after call. |
Buf[] |
ANY |
|
|
|
Array for storing values. |
IN |
ANY |
|
|
|
Value to be pushed. |
POP |
BOOL |
|
|
|
Pop a new value on the rising edge. |
PUSH |
BOOL |
|
|
|
Push a new value on the rising edge. |
RST |
BOOL |
|
|
|
Reset the list. |
Outputs
Outputs |
Data Type |
Range |
Unit |
Description |
---|---|---|---|---|
EMPTY |
BOOL |
|
|
TRUE if the list is empty. |
OFLO |
BOOL |
|
|
TRUE if the overflow is 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.
- It cannot be a STRING.
- The @Tail argument specifies a variable 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 an instance of the FIFO function block is called, that instance stores which array is passed to BUF[].
- If a later call to the same instance passes a different array for the BUF[] argument, the call is considered invalid and no action is performed.
- In this instance, the EMPTY output returns TRUE.
FBD Language Example
FFLD Language Example
- In the FFLD Language, the input rung is the PUSH input.
- The output rung is the EMPTY output.
IL Language Example
(* MyFIFO is a declared instance of FIFO function block *)
Op1: CAL MyFIFO (PUSH, POP, RST, IN, @Tail , BUFF[])
FFLD MyFIFO.EMPTY
ST EMPTY
FFLD MyFIFO.OFLO
ST OFLO
FFLD MyFIFO.COUNT
ST COUNT
FFLD MyFIFO.PREAD
ST PREAD
FFLD MyFIFO.PWRITE
ST PWRITE
ST Language Example
(* 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;
See Also