LFL — LIFO Load

Description
Section titled “Description”LFL (LIFO Load) pushes a value onto a last-in, first-out stack each time its rung goes from false to true. The stack is an array tag; the control tag’s position is the number of entries and the index the next push lands in. LFL pairs with an LFU (LIFO Unload) on the same control tag and array, which pops the newest entry. Use a stack to retrace steps: the last position visited, the last recipe change, the last fault. Do not use it where order of arrival matters; that is a FIFO.
Operands
Section titled “Operands”| Operand | Type | Format | Valid Range | Required | Description |
|---|---|---|---|---|---|
| Control | CONTROL tag | Tag or Tag[n] |
Shared with exactly one LFU | Yes | Holds LEN, POS and the status bits. |
| Source | INT or DINT tag, member, element or literal | Tag, 9 |
Any | Yes | The value pushed. |
| File | INT or DINT array tag | Tag |
At least Length + 1 elements | Yes | The stack. Entries occupy elements 0 to POS − 1; the newest is at POS − 1. |
| Length | Whole number | 4 |
1 to array size − 1 | Yes | Stack capacity. |
| Position | Whole number | 0 |
0 to Length | No | Entries at power-up; normally 0. |
Scan Behavior
Section titled “Scan Behavior”Prescan
Section titled “Prescan”LEN is loaded from Length and POS from Position.
Rung-condition-in is false
Section titled “Rung-condition-in is false”EN is cleared. Nothing is pushed.
Rung-condition-in is true
Section titled “Rung-condition-in is true”On the scan the rung turns true, if POS is below LEN the Source is written to File[POS] and POS increments. DN is set while POS equals LEN, so a push against a full stack is ignored. EM is set while POS is 0.
Postscan
Section titled “Postscan”Nothing.
| Condition | EN | DN | EM | POS | File |
|---|---|---|---|---|---|
| Power-up | 0 | 0 | 1 | 0 | holds |
| Rung false | 0 | holds | holds | holds | holds |
| False → true, POS < LEN | 1 | POS = LEN after | 0 | +1 | File[POS] = Source |
| False → true, POS = LEN | 1 | 1 | 0 | holds | holds |
| RES on the control | 0 | 0 | 0 | 0 | holds |
Member Bits
Section titled “Member Bits”| Bit | Mnemonic | Data type | Set by | Cleared by | Operation description |
|---|---|---|---|---|---|
| Enable | .EN |
BOOL | The LFL rung being true | The LFL rung being false, or RES | Mirrors the load rung, and is the load half’s edge memory. |
| Enable unload | .EU |
BOOL | The LFU rung being true | The LFU rung being false, or RES | Mirrors the unload rung, and is the unload half’s edge memory. Two bits, so the two rungs never disturb each other’s edge. |
| Done | .DN |
BOOL | POS reaching LEN | An unload, or RES | The stack is full; further loads are ignored. |
| Empty | .EM |
BOOL | POS at 0 after a load or unload | The first load, or RES | The stack is empty; an unload does nothing. |
| Error | .ER |
BOOL | Never | RES | Reserved. Bad operands are refused at validation. |
| Unload | .UL |
BOOL | Never | RES | Not used by LIFO. |
| Inhibit | .IN |
BOOL | Never | RES | Reserved. |
| Found | .FD |
BOOL | Never | RES | Not used by LIFO. |
| Length | .LEN |
INT | Length at power-up | Never (RES preserves it) | Stack capacity. |
| Position | .POS |
INT | Each load (+1) and unload (−1) | RES (to 0) | Number of entries; also the index of the next push. |
Example
Section titled “Example”Scenario: A pick-and-place records each position it visits so an operator can step it back through them in reverse order after a jam.
Tags:
Push— Position reached, BOOLPush_Val— Position number, INTStack— The stack, INT[8]Stack_Ctl— Control, CONTROL, Length 4Pop— Step back, BOOLPop_Val— Position to return to, INT
Rungs 1 and 2:
—] [Push———[LFL Stack_Ctl Push_Val Stack 4]————] [Pop———[LFU Stack_Ctl Stack Pop_Val 4]———Scan 1 — both rungs false. Push_Val reads 9. Position 0 and EM lit say the stack is empty. The stack has already been through one push and pop here, which is why Stack still lists a 9 in element 0 and Pop_Val still reads 9: a pop moves Position, it does not erase anything, and Dest keeps its last value.

Scan 2 — Push = 1. 9 is pushed: Stack[0] becomes 9, Position 1, EM dark.

Scan 3 — Pop = 1. The LFU pops the newest entry: Pop_Val reads 9, Position 0, EM lit.

Push 9, 12 and 15 in turn and three pops return 15, 12, 9: the reverse of the order they went in, which is what “step back” needs.
Control Tag Errors and Troubleshooting
Section titled “Control Tag Errors and Troubleshooting”Error definitions
| .ER cause | Condition that sets it | .POS / status value |
Meaning |
|---|---|---|---|
| None | .ER is never set by LadderIDE |
— | A File that is not an INT/DINT array, a Length of array size or more, or a third instruction on the control tag is refused at validation. |
Troubleshooting hints
Symptom: Pushes are lost. Likely cause: The stack is full;
.DNis set. Fix: Increase Length and the array, or block the push withXIO Stack_Ctl.DN.
Symptom: Pops come out in arrival order. Likely cause: An FFU was placed instead of an LFU. Fix: Read the block title; LFU pops from
File[POS − 1], FFU fromFile[0].
See Also
Section titled “See Also”- LFU — LIFO Unload (the other half of the pair)
- FFL — FIFO Load (a queue instead of a stack)
- RES — Reset (empty the stack)
- Shift/Sequencer Instructions — Category index
No shifting. Unlike a FIFO, a pop does not move the other entries; POS simply steps back, so a LIFO costs nothing per entry.
The block colours neutral. Watch the rung wire, the Position row and the DN/EM indicators.
Applies to LadderIDE >=1.2.2 · Last reviewed 2026-09-11 · Screenshots verified 2026-09-11