Understanding FIFO and LIFO Advanced Data Buffer Sequences in PLC Programming
- 〡
- 〡 by WUPAMBO
Data handling represents a critical component of advanced factory automation. While discrete logic controls simple machine states, handling bulk materials or component tracking requires robust data buffering. Programmers routinely manage these data arrays using two fundamental queuing structures: FIFO (First-In, First-Out) and LIFO (Last-In, First-Out).
This technical brief explains the mechanical operation, instruction block parameters, and deployment strategies for these stack sequences within modern industrial control systems.
The Role of Array Registers in Industrial Automation
Modern production environments require PLCs to track product movement, log timestamps, or queue material codes. Therefore, engineers deploy shifting registers to organize variable data arrays sequentially. Manufacturers like Allen-Bradley (Rockwell), Siemens, and Schneider Electric integrate dedicated stack instructions directly into their programming software. These instruction blocks manipulate an array of data words, shifting values dynamically based on physical production events.
FIFO Mechanics: Implementing First-In, First-Out Logic
The FIFO architecture processes data chronologically. Consequently, the data packet that enters the register array first is always the first data packet retrieved.
Block Parameter Interface and Signal Pins
A standard PLC FIFO structure consists of two companion instructions, usually called the FIFO Load (FFL) and FIFO Unload (FFU). The instruction block operates using three critical control inputs and two status outputs:
-
Reset (RST): A rising edge on this bit clears the array index pointer and empties the entire buffer.
-
Storage / Load (Source): A false-to-true transition captures the current integer or word value and appends it to the stack.
-
Retrieval / Unload (Destination): A rising edge shifts out the oldest stored value into a target register.
-
Empty Bit (EM): This diagnostic flag goes high when the register contains zero active data packets.
-
Full Bit (DN/UL): This safety flag turns true when the buffer reaches its maximum configured length, blocking further writes.
LIFO Mechanics: Implementing Last-In, First-Out Logic
Conversely, the LIFO architecture reverses the retrieval order. In this configuration, the newest data element written into the stack becomes the first element extracted.
Structural Variations in Stack Processing
The LIFO block uses an identical pin configuration to the FIFO instruction, including Load, Unload, Full, and Empty elements. However, the internal pointer manipulation differs significantly. When the retrieval input transitions to true, the PLC reads the data from the highest active index position. Therefore, the last item stored exits the array immediately, while the older historical data remains trapped at the bottom of the stack until the upper layers clear.
Expert Developer Insights: Edge Cases and Memory Behavior
Expert Engineering Advisory: Programmers must isolate the activation bits for loading and unloading sequences. If you trigger the storage and retrieval inputs simultaneously, the index pointer may lock up, causing severe data corruption within your array.
Furthermore, you must evaluate how your hardware platform behaves during power cycles:
-
Cold Restart Performance: During a full cold boot, the CPU wipes the scratchpad memory. This action completely resets the array boundaries, erasing your active tracking data.
-
Warm Restart Behavior: Most industrial control systems retain retentive data tags during minor power losses. Consequently, the stack indexes remain intact. However, you must explicitly configure these memory registers as retentive inside your tag database to prevent tracking discrepancies on the factory floor.
Industrial Application Scenarios
FIFO Application: Material Tracking on Conveyor Lines
In a bottling facility, a vision system inspects defective containers and logs a reject code into a FIFO register. As the physical bottles travel down the conveyor, the reject mechanism operates out of the same FIFO queue. Because the first bottle inspected is the first bottle to reach the pneumatic reject arm, the FIFO sequence aligns perfectly with the linear flow of the plant floor.
LIFO Application: Stacking Buffers and Overhead Cranes
In heavy metallurgical plants, automated overhead cranes stack steel coils in vertical holding bays. The crane deposits incoming coils on top of one another. To retrieve a coil, the crane must remove the top unit first. By utilizing a LIFO data structure, the PLC accurately tracks the inventory layout, ensuring the system retrieves the actual physical asset sitting at the top of the physical pile.
About the Author: Lin Xiaoyu
Lin Xiaoyu is a veteran industrial automation specialist with 15 years of technical expertise focusing on PLC/DCS software architecture, process optimization, and industrial communication protocols. She has engineered large-scale SCADA environments and safety-instrumented systems (SIS) for complex marine, automotive, and logistics hubs globally.
- Posted in:
- Data Buffer
- FIFO Sequence
- Industrial Automation
- LIFO Stack










