FIFO and LIFO: tracking parts that are already moving
Load, unload, and the shift register they compete with. Where a queue is the right model, and where it silently loses a part.
By the LADX engineering team
Short answer
FIFO load and unload maintain a first in, first out queue in a data file, used to carry information about parts through a process: a part is loaded with its data at the infeed and unloaded in the same order at the outfeed. LIFO does the same in reverse order, for a stack. The failure mode to design against is a part removed from the line by hand, which leaves the queue permanently offset.
Almost every line has a version of this problem: information known at one end of a machine has to arrive at the other end attached to the right part.
The weight measured at the checkweigher decides where the part goes at the diverter, six metres and forty seconds later.
The queue model
FIFO load takes a source word and places it at the end of a file. FIFO unload takes the oldest entry off the front and puts it in a destination.
Load when the part enters. Unload when it leaves. Provided the parts stay in order and none are added or removed, the queue mirrors the line.
LIFO exists for stacks, where the last item placed is the first retrieved. Genuinely useful for a magazine or a buffer that fills and empties from one end, and much rarer than FIFO.
FIFO or shift register
The choice comes down to what is being tracked.
A shift register is positional. Each bit is a physical position on the conveyor, and the whole register shifts one place when the conveyor moves one pitch. Right when the line has fixed pitch positions and each one holds a yes or no.
A FIFO is a queue. It does not know where anything is, only the order. Right when items carry more than a bit and the spacing varies.
Tracking a reject flag through a twelve position indexer is a shift register. Tracking a part number, a weight and a timestamp through a variable length oven is a FIFO.
The failure that costs a shift
The queue is a model of reality, and reality is under no obligation to match it.
Somebody lifts a part off the conveyor to look at it. The queue still holds its entry. Every part after that is now associated with the data of the part in front of it, and the machine confidently rejects good product and passes bad.
Nothing in the instruction detects this. The queue has no idea what is physically on the line.
Designing against it
An operator reset. A clearly labelled action that empties the queue, to be used after any manual intervention. It has to exist, be documented, and be reachable.
A physical crosscheck. Where a part carries an identity, read it again at the outfeed and compare it with the front of the queue. A mismatch means the queue has drifted, and knowing that is worth the reader.
Depth against reality. A queue deeper than the number of parts the line can physically hold hides a problem. Size it to the line, so a full queue means something.
An alarm on full. A FIFO that reaches full is discarding data. That is never routine.
Timestamps as an alternative
Where the process has a known transit time and parts genuinely cannot overtake, a timestamped queue is more robust than a positional one.
Record the time at the infeed with the data. At the outfeed, discard entries older than the maximum plausible transit time before matching. A part removed by hand ages out rather than corrupting everything behind it.
It costs more memory and it degrades gracefully, which on a line with people on it is worth more than efficiency.
Sources and further reading
- Logix 5000 controllers general instructions reference (Rockwell, PDF)literature.rockwellautomation.com
- FIFO (Wikipedia)en.wikipedia.org
Common questions
- When should I use a FIFO instead of a shift register?
- Use a shift register when the movement is tied to physical positions and each position holds one bit of information, such as a reject flag on a conveyor. Use a FIFO when items carry more than a bit and the queue length varies, such as a part number and a weight travelling through an oven.
- What happens if the FIFO is full?
- The load instruction sets a full bit and refuses further loads, so the data is discarded. Handle that condition explicitly. A full FIFO usually means the outfeed has stopped and the machine has a bigger problem than the queue, so it deserves an alarm rather than silence.
- How do I handle a part removed by hand?
- You cannot detect it from the queue, so design a reset. A part pulled from a conveyor for inspection leaves the queue one entry longer than reality, and everything after it is offset by one. Provide an operator action that clears the queue, and a physical check that catches the offset.
Keep reading
- Instructions
Bit shift registers, and the conveyor they were made for
BSL, BSR, the shift bit that must be a one shot, and why the pitch of the conveyor decides the length of the register.
- Instructions
Studio 5000 MSG instruction: path, setup and error codes
How to set up a Studio 5000 MSG instruction: message types, the communication path, connected and cached messages, and what each .ERR and .EXERR code means.
- Instructions
Sequencer instructions, and the state machine that replaced them
SQO, SQI and SQL, what they were for, why they are rare in new code, and what to write instead.