Вы находитесь на странице: 1из 5

Menu

1 of 1

http://plcguide.mrplc.com/menu.shtml

Menu
Command Index
Basic Instructions
Timer & Counter
Compare
Data
Math
Register and Sequencer
Program Control
Communication
Programming References
Example Programs
PLC GuestBook
Links
Down Loads

Send Comments

2001-2006
All Rights Reserved
Your IP Address is: 117.222.1.67

02-07-2013 16:01

PLC Programming Command Guide Reference Web Site

1 of 4

http://plcguide.mrplc.com/data/lifo.html

LIFO Load (LFL) and


LIFO Unload (LFU)
Instructions
[Introduction Page] [Command Index] [Programming References]
The LFL and LFU instructions are
used together. The LFL loads logic
words into a user created file called a
LIFO stack. The LFU instruction is
used to unload the words from the
LIFO stack, in the opposite order as
the words were entered. The last word
entered is the first word out.

Note: These instructions are only available with the Allen Bradley ML1000, SLC 5/02, SLC 5/03, and
SLC 5/04 processors.

The LFL command

has several parameters that must be set:

The Source is a word address or a constant ranging from -32,768 to 32,767 that becomes the next
value in the stack.
The LIFO is the first word address in the stack that stores the word specified in the source. The
pound symbol will be automatically entered when an address is typed in.
The Control is a control file address used to store the status bits, the stack length, and the position
value. Do not use the control file address for any other instruction.
The Length specifies the maximum number of words in the stack. For SLC processors this is 128
words and 105 words for the MicroLogix 1000 controllers.
The Position is the next available location where the instruction loads data into the stack. The first
address in the stack is position 0. As each word is entered into the stack, the position counter, on
both the LFL and the LFU will increment up by one. The stack is considered full when the position
value equals the length.
When the rung condition goes from being false to true, the Enable Bit (EN) is then set, and copies the
Source into the LIFO at the next available position. When all the positions are filled, the Done Bit (DN) is
then activated to prohibit loading any more words to the stack.
The LFU command

has several parameters that must be set:

The LIFO is the first word address in the stack that stores the word specified in the source. The
word address needs to be the same address that was entered in the LFL command.
02-07-2013 16:01

PLC Programming Command Guide Reference Web Site

2 of 4

http://plcguide.mrplc.com/data/lifo.html

The Destination is a word address that is the location where you want to store the word after it is
unloaded from the stack.
The Control is a control file address used to store the status bits, the stack length, and the position
value. Do not use the control file address for any other instruction. Note, since the LFL and LFU
commands are used in pairs, the Control File address needs to be the same.
The Length specifies the maximum number of words in the stack. For SLC processors this is 128
words and 105 words for the MicroLogix 1000 controllers. The length must be the same.
The Position is the next available location where the instruction unloads data from the stack to the
destination. Since the LFL and the LFU commands work together, each time a value is unloaded
from the stack, the position counter on both the LFL and LFU will decrement.
When the rung condition goes from being false to true, the Enable Bit (EU) is then set, and unloads the
last word copied into the stack into the destination address. The position decreases after each operation.
When the position equals zero, this indicates that all words have been unloaded, the Empty Bit (EM) is
activated.

PLEASE NOTE:
If you fill the stack using the LFL command and the Done Bit (DN)activates when the stack is full and
then unload the stack using the LFU command and activate the Empty Bit (EU) when the stack is empty,
the Done Bit and Empty Bit will not RESET (RES).

The above figure demonstrates a simple rung to reset the position counter when the DN bit is activated.
To Reset the position counter; insert a rung. Incorporate an examine if closed switch to activate the reset.
Specify the examine if closed switch with the control file used in your program. If you specify R6:0 as
your control file then, specify the switch as R6:0/DN. This means that when the DN bit becomes active,
the reset command will take place. The reset command can only be specified to the element. Therefore, to
reset the position, the reset command needs to be specified as "R6:0".
Values and addresses are assigned to the LFL and LFU commands by positioning the cursor to the right of
the of the parameter you want to set, and and then double clicking the left mouse button. This opens a text
box so that the address can be typed. If integer addresses are used, then the integer data must be placed
into the integer data base.

Programming Problem
An operator loads a value into a system for the number of parts he/she wants for assembly by a certain
machine. Develop a ladder rung that will take this input, and stores it in a stack. Then remove the inputs
based on last in, first out, principle.

02-07-2013 16:01

PLC Programming Command Guide Reference Web Site

3 of 4

http://plcguide.mrplc.com/data/lifo.html

In this example a decimal value, 5 was entered into the word address N7:0. When the rung containing the
LFL command became true, 5 was entered into the stack starting at position 0, N7:10. Then the value 10
was placed in N7:0 followed by 15 and when the rung became true each time, the values were place in the
next postions 1 and 2 respectively.

When the rung for the LFU command became true, the value 15 stored in position 2 was moved to the
destination address N7:20. Even though it looks like 15 was just copied into the destination, if another
value would be entered into the stack, it would go in the position where 15 was stored since that is the
next available position. If no other values would be entered, and the LFU command became true again,
the value 10 would then be moved into the destination, writing over the previous stored value. The figure
below shows the ladder logic program.

02-07-2013 16:01

PLC Programming Command Guide Reference Web Site

4 of 4

http://plcguide.mrplc.com/data/lifo.html

[Back] [Next Command]

02-07-2013 16:01

Вам также может понравиться