TB_FIFO

Representation in FBD

General Information

With TB_FIFO (first in, first out), data records are saved sequentially and can be read out again in the same order at a later time. Up to 256 data records can be saved.

When x_Enable = TRUE, the module is activated. Successful activation is signaled with TRUE at the x_Active output. From this point, data records can be saved and read. A data record consists of one to four data words.

Saving data:
The data record active at di_InVal0..3 is saved with the positive edge at input x_Put. If the data record was accepted, this is reported with TRUE at the x_PutDone output for one cycle. If the data record could not be saved (FIFO full), x_PutDone remains FALSE and an error is output. Up to 256 data records can be saved.

Reading data:
With a positive edge at the x_Get input, the oldest data set is read, output at di_OutVal0..3 and deleted internally. This means that a read data record cannot be read out a second time. Successful output is indicated with TRUE at the x_GetDone output for one cycle. If no data records could be read (FIFO empty), x_GetDone remains FALSE and an error is output.

Deleting FIFO:
When the enable is cancelled (x_Enable = FALSE), the FIFO is deleted and all saved data records are deleted.

Acknowledging errors:
Errors are deleted automatically via a valid command. If, for example, a data record is saved after an error -2 (FIFO empty), x_Error becomes FALSE and i_Error becomes 0.

Recommended task: Event / Cyclic
Libraries used: -

InOut Parameter

none

Input Parameter

Marking: Data type: Description:
x_Enable BOOL TRUE: Enabling of the module and deleting of the FIFO. Successful enabling is indicated at x_Active.
x_Get BOOL With the positive edge, the oldest data record is output at di_OutVal0..3. Successful output is indicated at x_PutDone.
x_Put BOOL With the positive edge, the data record is accepted at di_InVal0..3. Successful acceptance is indicated at x_PutDone.
di_InVal0 DINT First data word of the data record entered in the FIFO.
di_InVal1 DINT Second data word of the data record entered in the FIFO.
di_InVal2 DINT Third data word of the data record entered in the FIFO.
di_InVal3 DINT Fourth data word of the data record entered in the FIFO.

Output Parameter

Marking: Data type: Description:
x_Active BOOL TRUE: Module active. Data records can be written and read.
x_GetDone BOOL TRUE: Indicates that the data output at di_OutVal0..3 is valid for one cycle.
x_PutDone BOOL TRUE: Indicates that the data active at di_InVal0..3 is accepted for one cycle.
di_OutVal0 DINT First data word of the data record read out of the FIFO.
di_OutVal1 DINT Second data word of the data record read out of the FIFO.
FALSE: when error list was created successfully
di_OutVal2 DINT Third data word of the data record read out of the FIFO.
di_OutVal3 DINT Fourth data word of the data record read out of the FIFO.
i_Elements INT Number of data records currently saved in FIFO.
x_Error BOOL TRUE: An error was identified.
i_Error INT Current error number. See table above.
i_Error Description
0 No error
-1 Write error. An attempt was made to write a data record, even though FIFO is full.
-2 Read error. An attempt was made to read a data record, even though FIFO is empty.