LIFO Unload (LFU)
This table lists the controllers and applications that support this instruction.
Architecture | Standard applications | Safety applications |
---|---|---|
CompactLogix 5370, ControlLogix 5570, Compact GuardLogix 5370, and GuardLogix 5570 controllers | Yes | No |
CompactLogix 5380, CompactLogix 5480, ControlLogix 5580, Compact GuardLogix 5380, and GuardLogix 5580 controllers | Yes | Yes |
The LFU instruction unloads the value at .POS of the LIFO and stores 0 in that location.
Use the LFU instruction with the LFL instruction to store and retrieve data in a last-in/first-out order.
When enabled, the LFU instruction unloads the value at .POS of the LIFO and places that value in the Destination. The instruction unloads one value and replaces it with 0 each time the instruction is enabled, until the LIFO is empty. If the LIFO is empty, the LFU returns 0 to the Destination.
IMPORTANT:
You must test and confirm that the instruction does not change data that you don’t want it to change.
The LFU instruction operates on contiguous memory. The scope of the instruction is constrained by the base tag. The LFL instruction will not write data outside of the base tag but can cross member boundaries. If you specify an array that is a member of a structure, and the length exceeds the size of that array you must test and confirm that the LFL instruction does not change data you do not want changed.
The data is constrained by the specified member.
If the instruction tries to read past the end of an array, the instruction sets the .ER bit and generates a major fault.
Typically, the Source and the LIFO are the same data type. If Source and LIFO data types mismatch, the instruction converts the Source value to the data type of the FIFO tag.
A smaller integer converts to a larger integer by sign-extension.
Available Languages
Ladder Diagram
Operands
There are data conversion rules for mixed data types within an instruction.
Ladder Diagram
Operand | Type | Format | Description |
---|---|---|---|
LIFO | SINT INT DINT REAL String type structure | array tag | LIFO to modify Specify the first element of the LIFO Not use CONTROL.POS in the subscript |
Destination | SINT INT DINT REAL String type structure | tag | Value unloaded from the LIFO. |
Control | CONTROL | tag | Control structure for the operation Typically use the same CONTROL as the associated LFL. |
Length | DINT | immediate | Maximum number of elements the LIFO can hold at one time |
Position | DINT | immediate | Next location in the LIFO where the instruction unloads data Initial value is typically 0 |
CONTROL Structure
Mnemonic | Data Type | Description |
---|---|---|
.EU | BOOL | The enable bit indicates the LFU instruction is enabled. |
.DN | BOOL | The done bit is set to indicate that the LIFO is full (.POS = .LEN). |
.EM | BOOL | The empty bit indicates the LIFO is empty. If .LEN < or = to 0 or .POS < 0, both the .EM bit and .DN bit are set. |
.LEN | DINT | The length specifies the maximum number of elements the LIFO can hold at one time. |
.POS | DINT | The position identifies the end of the data that has been loaded into the LIFO. |
Affects Math Status Flags
No
Major/Minor Faults
A major fault will occur if: | Fault Type | Fault Code |
---|---|---|
If the specified Length is past the end of LIFO array | 4 | 20 |
See Common Attributes for operand-related faults.
Execution
All conditions occur only during Normal Scan mode
Ladder Diagram
Condition/State | Action Taken |
---|---|
Prescan | See LFU Flow Chart (Prescan) |
Rung-condition-in is false | See LFU Flow Chart (False) |
Rung-condition-in is true | See LFU Flow Chart (True) |
Postscan | N/A |
LFU Flow Chart (Prescan)
LFU Flow Chart (False)
LFU Flow Chart (True)
Examples
Example 1
Ladder Diagram
Example 2
Destination array is STRING array or Structure array
Ladder Diagram
Example 3
Data type of LIFO source array mismatch data type of destination array
Ladder Diagram
Provide Feedback