FIFO & LIFO instruction

LIFO,FIFO

FIFO instruction is a part of many PLC's instruction set.
LIFO on the other hand is not.
FIFO is an asynchronous shift register. There is also a synchronous
shift register instruction in just about every PLC. That is not to be
confused with LIFO.
LIFO is used primarily as a stack in Assembly language programming
i.e. push and pop from stack.
FIFO applications are varied, one example would be to schedule parts
on a merging conveyor system. Instead of using round robin logic
the FIFO would schedule the parts on to a merge conveyor on a first come first go basis. You could also use it to track parts on a conveyor belt. There are many other applications in data aquisition etc.
 
I think all that labingtone is looking for is “what-the-heck-is-it” type information. If so, then maybe this will help.

LIFO stands for “Last In First Out”.
FIFO stands for “First In First Out”.

Here is a simple example of each:

Suppose that I have boxes of parts coming into my warehouse. A barcode reader is located at the warehouse door and it reads the barcode labels on each incoming box. This barcode information is to be stored in a PLC to keep track of what parts I have available in my warehouse. Suppose (to keep it simple) that the first box is number 111; the second box is number 222; and the third box is number 333.

Now how should I store the boxes? I have two basic ways – let’s start with a “stack”.

If I “stack” the boxes as they come in, then box 111 will be on the bottom. Box 222 will be in the middle. And box 333 will be on the top of my stack of boxes. Now suppose that I need to send a box of parts out of my warehouse to fill an order. The natural thing to do would be to send out box 333 from the top of the stack. This is what we mean by LIFO (Last In First Out) – in other words, the LAST one to come INto the stack (number 333) is the FIRST one to be sent OUT of the stack. This LIFO method is usually the most convenient method for storing things like lumber that don’t spoil or “go bad” while waiting in storage.

So as far as the PLC is concerned, the best way to program this “stacking” operation is with a LIFO arrangement.

But instead of stacking the boxes, suppose that I store them by lining them up on a shelf as they come into my warehouse. Many programmers call this storage method a “queue” (rhymes with CUE) which is a word that the British people use to describe a line of people waiting to get into a theater (or as they would say, “theatre”). So using this storage method, when box number 111 comes into my warehouse, I store it at the start of the queue (or line). Then when box 222 comes in, I place it next in the queue. Finally, box 333 goes at the end of the queue. Now suppose that I need to send a box of parts out of my warehouse to fill an order. The natural thing to do would be to send out box 111 from the head of the queue. This is what we mean by FIFO (First In First Out) – in other words, the FIRST one to come INto the queue (111) is the FIRST one to be sent OUT of the queue. Just like the people lined up at the theater. The first one to get into the line, is the first one to get out of the line - and on into the theater. This FIFO method is usually the best method for storing things like food that DO spoil or “go bad” while waiting in storage.

So as far as the PLC is concerned, the best way to program this “queue-ing” (or lineup) operation is with a FIFO arrangement.

So that’s what we mean by LIFO and FIFO. Now how to actually program either one of these methods into your PLC depends (as others have pointed out) on what type of PLC you have and on what you’re trying to accomplish with your program.

Hope this helps.
 
A LIFO is a Temporary Holding Place for thingees - whatever they might be. Those thingees are held in place, in the same order that they were entered or loaded. Example: Push 1/2" marbles into a 1/2" hose. All of the marbles maintain their relative positions.

A FIFO is a Temporary Holding Place for thingees - whatever they might be. Those thingees are held in place, in the same order that they were entered or loaded. Example: Push 1/2" marbles into a 1/2" hose. All of the marbles maintain their relative positions.

Notice that both descriptions, up to this point, are the EXACTLY the same... at least, up 'til now.

Now, you are told, by some loud voice in the sky, to "re-acquire" those thingees, those marbles - in order. (Notice that I didn't use the word "retrieve".)

If you are sharper than those marbles you've been loading, you might ask... "Which order? I could re-acquire those marbles from this-end-of-the-hose or that-end-of-the-hose."

So, the loud voice in the sky that's telling you to get those damned marbles back says, "In the SAME order that you got them". So you go to the far-end-of-the-hose and "re-acquire" the marble-thing-a-ma-bobbers.

That is a FIFO operation.

Or, the loud voice in the sky that's telling you to get those damned marbles back says, "In the REVERSE order that you got them". So you go to the near-end-of-the-hose and "re-acquire" the marble-thing-a-ma-bobbers.

That is a LIFO operation.

NOTICE...
The difference is in "how" those thingees are "re-acquired".

I didn't use the word "retrieve" because the word "retrieve" is "loaded". That is, "retrieve" implies, to a certain degree, that you "re-acquire" the marbles in a particular order - namely, "Reverse Order" - as in LIFO.

Having used the word "re-acquire" instead, the method of retrieval is completely ambiguous and, therefore, no particular method is implied. And so it should be!

You are then forced to consider the specific method that you need; "Last In, First Out", or "First In, Last Out"

FIFO is being a person standing in a check-out line at the grocery store.
LIFO is being a person standing in a "standing-room-only" subway-train.

The real-world applications, in terms of PLC's, are very similar, and, can, in fact, be EXACTLY the same! That is, you just might have a PLC that is monitoring people (or things) going through a Grocery check-out line. You could also have a PLC that is monitoring people with particular ID Numbers entering and exiting a "standing-room-only" subway-train.

In some cases, it's instances of things moving in/out of a que.
In other cases, it's data being placed on a "STACK". That is the way that ASSEMBLY LANGUAGE (which is about as close to Machine-Language as we are likely to get to, these days) handles its data and related instructions.
 
labingtone said:
Hi to everyone.

Kindly discuss when to used LIFO & FIFO Instruction. I appreciate if you can give actual application on the use of this instruction.

Ah, I see that NYP is back in session.

"actual application". Tracking information (serial numbers, status, destinations)

FIFO emulates a conveyor belt (the first item to go onto it is the first one to come off)

LIFO emulates a storage compartment (with only one entrance - you have to take the last one you put in, before you can get to the one behind it)
 
Thanks to everyone for your effort is answering my query.

As I read your answers, I understand now what is FIFO and LIFO.As far is my understanding is concerned and correct if im wrong. FIFO is just like SHIFT Register(BIT) with specify lenght of bit, let say 8 bit. IN is the bit to shifted in, Q is the bit shifted out.
This is a shift register functional block of GE FANUC PLC.


________
EN ___: SHFR_ :
: BIT :
: :
___: R Q:__
: :
: :
: :
___:IN :
: :
___:ST :
:________:
 
Last edited:
They're not the same

A shift register operates synchronously - for every item shifted in, one is shifted out.
A FIFO operates asynchronously - load and unload (shift in & out) happen at differrent times (normally).
Data entered in a shift register must be shifted the length of the register (one position per shift pulse) before it is available to shift out.
Data loaded in a FIFO can be immediately available for unload, regardless of length.
For tracking applications, a shift register will track position, whereas a FIFO will track sequence.
 
PLC software?

hello my fellow engineers, i have a problem about our Siemens S7-300/400 PLC that we have in our company. I dont have the latest PLC software which is window based. if anyone of you do have the software plz send it to my email at [email protected]. thanks in advance!
 
An engineer I am sure would "know" how to obtain the proper software for his companies needs. Step 7/Simatic for the S7300/400 requires an activation disk (similar to AB RSLogix). The software is no good without it.
 
Those are all good examples of LIFO/FIFO use. But now for something completely different, as an application.

I use the FIFO as a storage file to average or smooth out "nervous" analog input signals.

Use a self re-triggering timer to load the naalog value into the stack, and when the stack is full, average the file. The lag of the filter is determined by the timer preset and the file length.

The thing is easy in processors with a "average file" command, but a little trickier with those that don't. If you don't have the "average file" command, you have to keep a running total of the sum of the values loaded into the stack by adding a value to the total when it is loaded, as well as subtracting a value from the total when it is unloaded.

It works very well as a filter, and I've used it many times.
 

Similar Topics

Hi friends, I have a big question and a big problem, I'm new to programming PLC, I have a system where we use a cognex data reader to read a code...
Replies
2
Views
1,826
I have been trying to get to grips with the LIFO and FIFO functions using Compact Logix but it seems that if you have multiple LFL instructions on...
Replies
3
Views
2,170
Hi, We have an application where we are using a FIFO list to track parts moving through a queue. the FIFO Load/Unload pair is working without...
Replies
9
Views
11,769
Well HI all I am trying to use the FiFo/LiFo with a S7 300 and I am not to sure how to use it. I think I need the ATT table so that I could store...
Replies
4
Views
4,498
I’m new user of S7, so I want to use the FIFO LIFO, I do as the help says,I create a DB1 and put the information, but it does not work when I test...
Replies
2
Views
2,200
Back
Top Bottom