Skip to content

FFU — FIFO Unload

Category
Shift / Sequencer
Type
Output
Availability
All platforms

FFU instruction block: File Jobs, Dest Next_Job, Length 4, Position, with DN and EM indicators


FFU (FIFO Unload) takes the oldest entry off the front of a first-in, first-out queue each time its rung goes from false to true, writes it to Dest, and moves the remaining entries down one place. It pairs with the FFL (FIFO Load) that fills the same queue on the same control tag. Use it at the consuming end of a buffer: the packer, the printer, the station that works jobs off in the order they arrived. Do not unload every scan; the instruction is edge-triggered, and a rung held true takes exactly one entry.


Operand Type Format Valid Range Required Description
Control CONTROL tag Tag or Tag[n] Shared with exactly one FFL Yes Holds LEN, POS and the status bits.
File INT or DINT array tag Tag Same as the FFL’s Yes The queue.
Dest Writable INT or DINT tag, member or element Tag Any Yes Where the unloaded entry is written.
Length Whole number 4 Same as the FFL’s Yes Queue capacity.
Position Whole number 0 0 to Length No Entries at power-up; normally 0.

LEN is loaded from Length and POS from Position.

EU is cleared. Nothing is unloaded; Dest holds.

On the scan the rung turns true, if POS is above 0 then File[0] is written to Dest, elements 1 to POS − 1 move down one place, and POS decrements. If POS is 0 nothing happens and Dest holds. EM is set while POS is 0, DN while POS equals LEN.

Nothing.

Condition EU DN EM POS Dest
Power-up 0 0 1 0 holds
Rung false 0 holds holds holds holds
False → true, POS > 0 1 0 POS = 0 after −1 File[0]
False → true, POS = 0 1 0 1 holds holds
RES on the control 0 0 0 0 holds

The control tag is shared with the FFL; the full table is on the FFL page. From the FFU’s side:

Bit Mnemonic Data type Set by Cleared by Operation description
Enable unload .EU BOOL The FFU rung being true The FFU rung being false, or RES Mirrors the unload rung and holds its edge memory. .EN belongs to the FFL.
Done .DN BOOL POS reaching LEN An unload, or RES The queue was full; one unload clears it.
Empty .EM BOOL POS at 0 after an unload A load, or RES Nothing left to unload; Dest keeps its last value.
Position .POS INT Each load (+1) Each unload (−1), RES (to 0) Entries in the queue.

The FFU shares its example with the FFL; the three frames are on the FFL page. In short: Load_Job pushes New_Job (7) into Jobs, Position 1; then Unload_Job takes it out, Next_Job reads 7, Position 0, EM lit.

Figure 1 — FFU rung true after one edge: Next_Job 7, Position 0, EM lit, FFU rung lit

An unload on an empty queue leaves Next_Job at its old value, so test XIO Jobs_Ctl.EM before acting on it.


Error definitions

.ER cause Condition that sets it .POS / status value Meaning
None .ER is never set by LadderIDE — A File that is not an INT/DINT array, a Length of array size or more, or a third instruction on the control tag is refused at validation.

Troubleshooting hints

Symptom: Dest shows a stale value after an unload. Likely cause: The queue was empty; an unload with POS 0 writes nothing. Fix: Gate the consumer with XIO Jobs_Ctl.EM.

Symptom: The same entry comes out twice. Likely cause: Two unload rungs, or an unload rung that toggles twice per event. Fix: One FFU per queue, driven by a clean rising edge.



Order of rungs. Put the FFL rung before the FFU rung when both can fire on the same scan, so a value pushed and pulled in one scan goes through the queue rather than around it.

The block colours neutral. Watch the rung wire, the Position row and the DN/EM indicators.

Applies to LadderIDE >=1.2.2 · Last reviewed 2026-09-11 · Screenshots verified 2026-09-11