Topic: DMD0465 LIFOLOAD - Load Last In / First Out |
|
The Load Last In / First Out (LIFOLOAD) instruction will store data values into a user-created data block with the intention of using the Unload Last In / First Out (LIFOUNLOAD) to retrieve them from the user block in the opposite order in which they were stored. Data that is managed this way is commonly referred to as a Stack. The user data block can consist of any of the simple types (Byte, Word, DWord, Real), or any of the built-in structures, or any user-defined structures.
This instruction will use an associated Queue Control Structure (the structure's fields shown below). The fields in this structure are used in the ladder logic program to add data to the LIFO Queue and monitor its current state. Use the Reset LIFO Queue (LIFORESET) instruction to clear the Queue Control Structure's state data and optionally clear the data from the LIFO's associated data block.
|
|
Parameters:Note: Use the F9 key or click the 'three dot box' at the right edge of the parameter field to open the Default Element Selection Tool (the Element Picker or the Element Browser) or use the Down-Arrow key (Auto-Complete) on any parameter field to see a complete list of the memory locations that are valid for that parameter of the instruction.
Queue Control Structure is the data structure this instruction will use to manage the process of adding data in the user data block. The associated LIFOUNLOAD instruction should use the same Queue Control Structure. Different Queues should use different Queue Control Structures with different user data blocks.
User Block is the user-created data block this instruction will use to store the data. This must be a user created block, and the entire block will be used as the LIFO Queue. You cannot use a portion of an existing user-created or built-in data block.
Value to Load into User Block contains the data to store in the data block. This should be the same type as the data in the user block.
Load on Input Leg selects which power-flow conditions will cause this instruction to load the value:
Note: if the LIFO User Block is full (the .Full bit is ON) when a LIFOLOAD is executed, the system status bit $QueueFull (ST156) will turn ON, and no change will be made to the User Block's data.
|
|
Status Display:If the LIFO Queue contains more then 7 items the status display of this instruction will show the first 3 and the last 3 locations.
If the LIFO Queue's User Block contains one of the simple types (Bit, Byte, Word, DWord, Real) or contains only Strings, the Memory View is a convenient way to see the contents of the User Block.
If the LIFO Queue's User Block contains structures the Data View can be used to view the contents of each element in the block.
|
|
Queue Control Structure Fields:
.Depth is the number of data values stored in the Queue.
.Head is the location in the Queue where the data will be stored when a Load FIFO or Load LIFO instruction is executed, and where data will be read from when an Unload LIFO instruction is executed.
.Tail is the location in the Queue where the data will be read from when the Unload FIFO instruction is executed.
.Empty will be ON when none of the locations in the Queue are being used. An attempt to unload a value when the Queue is empty will not be processed and so this will not generate a Warning message.
.Full will be ON when all of the locations in the Queue have been used. Any attempt to load a value when the Queue is full will fail; no data in the user data block will be overwritten, but a Warning message will be generated.
|
|
See Also:LIFOLOAD - Load Last In / First Out
LIFOUNLOAD - Unload Last In / First Out
|
|
Related Topics:FIFOLOAD - Load First In / First Out
FIFOUNLOAD - Unload First In / First Out
|
|
Example:
|
|