FP_LIFO_WRITE

Write to LIFO buffer

This FP instruction writes the data specified by s into the LIFO (Last-In-First-Out) buffer specified by d_Start.

Remarks

  • The variables s and d_Start have to be of the same data type.

  • If this instruction is executed when the LIFO buffer is full (number of stored data = n_Words, the size of the LIFO buffer defined by FP_LIFO_DEFINE), an error occurs and writing is not carried out.

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

Parameters

Input

s (WORD, INT, UINT)

Data area or equivalent constant for storing data to write in the LIFO buffer

Output

d_Start (WORD, INT, UINT)

Starting data area of the buffer

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 writing pointer > buffer size (n_Words).

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

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 writing pointer > buffer size (n_Words).

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

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;
		bWriteToBuffer: BOOL:=FALSE;
		iWords: INT:=8;
		arrLifo: ARRAY [0..11] OF INT:=[12(0)];
	END_VAR
	VAR_EXTERNAL
		g_arrValuesWORD: ARRAY [0..7] OF WORD:=[16#0000,16#0001,16#7FFF,16#8000,16#FFFF,16#1234,16#89AB,16#ABCD];
	END_VAR
	VAR 
	END_VAR

POU body

When the variable bWriteToBuffer 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_VARIN,,iWords,10,3,12,5,);
B(B_VAROUT,,arrLifo[0],22,3,24,5,);
B(B_CONTACT,,bDefineBuffer,5,2,7,4,);
B(B_F,FP_LIFO_DEFINE!,,12,1,21,5,,?DEN?Dn_Words?AENO?Cd_Start);
L(1,3,5,3);
L(7,3,12,3);
L(21,4,22,4);
L(1,0,1,5);
        END_NETWORK_BODY
    END_NET_WORK
    NET_WORK
        NETWORK_TYPE := NWTYPELD ;
        NETWORK_LABEL :=  ;
        NETWORK_TITLE :=  ;
        NETWORK_HEIGHT := 6 ;
        NETWORK_BODY
B(B_VARIN,,g_arrValuesWORD[0],10,3,12,5,);
B(B_VAROUT,,arrLifo[0],22,3,24,5,);
B(B_CONTACT,,bWriteToBuffer,5,2,7,4,);
B(B_F,FP_LIFO_WRITE!,,12,1,21,5,,?DEN?D@'s'?AENO?Cd_Start);
L(1,3,5,3);
L(7,3,12,3);
L(21,4,22,4);
L(1,0,1,6);
        END_NETWORK_BODY
    END_NET_WORK
END_BODY

ST body

if (bWriteToBuffer) then
    FP_LIFO_WRITE(s := g_arrValuesWORD[0],
                  d_Start => arrLifo[0]);
end_if;

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