Chapter 4. Ladder Diagram (LD) Programming
182
PACSystems* RX7i, RX3i and RSTi-EP CPU Programmer's Reference Manual
GFK-2950C
4.9.5
LIFO Read
The Last-In-First-Out (LIFO) Read (LIFO_RD) function moves data out
of tables. Values are always moved out of the top of the table. If the
pointer reaches the last location and the table becomes full, LIFO_RD
must be used to remove the entry at the pointer location and
decrement the pointer by one. LIFO_RD is used in conjunction with the
LIFO_WRT function, which increments the pointer and writes entries
into the table.
Mnemonics:
LIFO_RD_DINT
LIFO_RD_DWORD
LIFO_RD_INT
LIFO_RD_UINT
LIFO_RD_WORD
1.
LIFO_RD copies data indicated by the pointer to output parameter Q. Additional program logic
must then be used to place the data in the input reference.
2.
LIFO_RD decrements the pointer by one.
3.
Steps 1 and 2 are repeated each time the instruction is executed, until the table is empty (PTR =
LEN).
The pointer does not wrap around when the table is full.
When LIFO_RD receives power flow, the data at the pointer location is copied to output Q, then the
pointer is decremented. If this causes the pointer location to become 0, the output EM is set ON, i.e.,
EM indicates whether or not the table is empty. If the table is empty when LIFO_RD receives power
flow, no read occurs. The pointer always indicates the last item entered into the table.
LIFO_RD passes power to the right if the pointer was in range for an element to be read.
Note:
A LIFO table is a stack. A FIFO table is a queue.
Operands for LIFO Read
Note:
For each mnemonic, use the corresponding data type for the TB and Q operands. For
example, LIFO_RD_DINT requires TB and Q to be DINT variables.
Parameter
Description
Allowed Operands
Optional
Length (??)
1
Length
32,767.
Constant
No
TB (must be the same
type as Q)
The elements in the table
All except constants
No
PTR
Pointer. Index of the next
element to read.
All except constants, S - SC, and data flow No
EM
Energized when the last
element of the table is read
Power flow
No
Q (must be the same
type as TB)
The element read from the
table
All except constants and S. SA, SB, SC
allowed only for WORD, DWORD.
No
Example for LIFO Read
PRODUCT is a LIFO table with 100 word-sized elements. When
the enabling input PACK_IT is ON, the data item at the top of the
table is copied into the reference indicated by the nickname
CART. The reference identified by STK_PTR contains the table
pointer. Output coil EMPTY indicates when the table is empty.
Содержание PACSystems RSTi-EP
Страница 357: ......
Страница 466: ...Chapter 9 Diagnostics GFK 2950C February 2018 451 ...