FP_LIFO_READ

Read from LIFO buffer

This FP instruction reads the data from the starting data area of the LIFO (Last-In-First-Out) buffer specified by s_Start and stores the data in the area specified by d.

Parameters

Input

s_Start (WORD, INT, UINT)

Starting data area of the buffer

Output

d (WORD, INT, UINT)

Data area for storing the data read from LIFO buffer

Remarks

  • The variables s_Start and d have to be of the same data type.

  • If this instruction is executed when the number of stored data is 0, an error occurs.

  • If this instruction is executed when the reading pointer is equal to the writing pointer, an error occurs and reading is not carried out.

  • If this instruction is executed when the reading pointer is indicating the final address in the LIFO buffer (n_Words defined by FP_LIFO_DEFINE minus 1), the reading pointer is set to 0.

Error flags

sys_bIsOperationErrorHold (turns to TRUE and remains TRUE)
  • if the size (n_Words) of the buffer specified by d_Start is n_Words = 0, or when n_Words > 4096.

  • if the number of stored data items of the buffer = 0.

  • if the number of stored data items of the buffer > buffer size (n_Words).

  • if the reading pointer > buffer size (n_Words).

  • if the reading pointer is 4096 (16#1000) or higher after the data has been read.

sys_bIsOperationErrorNonHold (turns to TRUE for one scan)
  • if the size (n_Words) of the buffer specified by d_Start is n_Words = 0, or when n_Words > 4096.

  • if the number of stored data items of the buffer = 0.

  • if the number of stored data items of the buffer > buffer size (n_Words).

  • if the reading pointer > buffer size (n_Words).

  • if the reading pointer is 4096 (16#1000) or higher after the data has been read.

Example

POU header

All input and output variables used for programming this function have been declared in the POU header.The same POU header is used for all programming languages.

	VAR
		bDefineBuffer: BOOL:=FALSE;
		bReadFromBuffer: BOOL:=FALSE;
		iWords: INT:=8;
		arrLifo: ARRAY [0..11] OF INT:=[12(0)];
		arrResultReadLifo: ARRAY [0..7] OF WORD:=[8(0)];
	END_VAR

POU body

When the variable bDefineBuffer is set to TRUE, the function is carried out.

LD body

BODY
    WORKSPACE
        NETWORK_LIST_TYPE := NWTYPELD ;
        ACTIVE_NETWORK := 0 ;
    END_WORKSPACE
    NET_WORK
        NETWORK_TYPE := NWTYPELD ;
        NETWORK_LABEL :=  ;
        NETWORK_TITLE :=  ;
        NETWORK_HEIGHT := 5 ;
        NETWORK_BODY
B(B_F,FP_FIFO_DEFINE!,,13,1,22,5,,?DEN?Dn_Words?AENO?Cd_Start);
B(B_VARIN,,iWords,11,3,13,5,);
B(B_VAROUT,,arrLifo[0],22,3,24,5,);
B(B_CONTACT,,bDefineBuffer,5,2,7,4,);
L(7,3,13,3);
L(1,3,5,3);
L(1,0,1,5);
        END_NETWORK_BODY
    END_NET_WORK
    NET_WORK
        NETWORK_TYPE := NWTYPELD ;
        NETWORK_LABEL :=  ;
        NETWORK_TITLE :=  ;
        NETWORK_HEIGHT := 5 ;
        NETWORK_BODY
B(B_F,FP_FIFO_READ!,,13,1,21,5,,?DEN?Ds_Start?AENO?Cd);
B(B_VARIN,,arrLifo[0],11,3,13,5,);
B(B_VAROUT,,arrResultReadLifo[0],21,3,23,5,);
B(B_CONTACT,,bReadFromBuffer,5,2,7,4,);
L(7,3,13,3);
L(1,3,5,3);
L(1,0,1,5);
        END_NETWORK_BODY
    END_NET_WORK
END_BODY

ST body

if (bReadFromBuffer) then
    FP_LIFO_READ(s_Start := arrLifo[0],
                 d => arrResultReadLifo[0]);
    end_if;

Modified on: 2022-08-23Feedback on this pagePanasonic hotline