Chapter 4. Ladder Diagram (LD) Programming
GFK-2950C
February 2018
183
4.9.6
LIFO Write
The Last-In-First-Out (LIFO) Write (LIFO_WRT) function increments
the table pointer by one and then adds an entry at the new pointer
location in a table. Values are always moved in at the top of the
table. If the pointer reaches the last location and the table becomes
full, LIFO_WRT cannot add further values. LIFO_RD must then be
used to remove the entry at the pointer location and decrement the
pointer by one.
Mnemonics:
LIFO_WRT_DINT
LIFO_WRT_DWORD
LIFO_WRT_INT
LIFO_WRT_UINT
LIFO_WRT_WORD
1.
LIFO_WRT increments the table pointer by one.
2.
LIFO_WRT copies data from input parameter IN to the position in the table indicated by the
pointer. (It writes over any value currently at that location.) Additional program logic must then
be used to place the data in the input reference.
3.
Steps 1 and 2 are repeated each time LIFO_WRT is executed, until the table is full (PTR=LEN).
The pointer does not wrap around when the table is full.
When LIFO_WRT receives power flow, the pointer increments by 1; then the new data is written at
the pointer location. If the pointer was already at the last location in the table, no data is written and
LIFO_WRT does not pass power to the right. The pointer always indicates the last item entered into
the table. If the table is full, it is not possible to add more entries to it.
LIFO_WRT passes power to the right after a successful execution (PTR < LEN).
Note:
A LIFO table is a stack. A FIFO table is a queue.
Operands for LIFO Write
Note:
For each mnemonic, use the corresponding data type for the TB and IN operands. For
example, LIFO_WRT_DINT requires TB and Q to be DINT variables.
Parameter
Description
Allowed Operands
Optional
Length (??)
1
Length
32,767.
Constants
No
TB (must be the
same type as IN)
The elements in the table
All except constants, S, data flow. SA -
SC allowed only for WORD, DWORD.
No
PTR
Pointer. Index of the next element to
write.
All except constants, S - SC, and data
flow
No
IN (must be the
same type as TB)
The element to write to the table
All. S
–
SC allowed only for WORD,
DWORD
No
FL
Energized when IN is written to the
last element of the table
All
No
Example for LIFO Write
PRODUCT is a LIFO table with 100 word-sized elements. When the
enabling input STORE is ON, a data item from NEW_ITEM is copied
to the table location pointed to by the value in STK_PTR. Output FL
passes power when PTR = LEN, firing the FULL coil. No further data
from NEW_ITEM can be added to the table without first copying
data out, using the LIFO_RD function.
Summary of Contents for PACSystems RSTi-EP
Page 357: ......
Page 466: ...Chapter 9 Diagnostics GFK 2950C February 2018 451 ...