FIFO Unload FFU
At the right of a rung in a program's ladder routine. Not in a Logic Class. Place a FIFO Load first; it takes that load's control tag.
| Tag | After two scans |
|---|---|
| FFL1 | LEN 8 POS 0 EN 1 DN 0 EM 1 FU 0 EU 1 |
| FFL1_Data | [0, 0, 0, 0, 0, 0, 0, 0] |
| FFU1_Dest | 0 |
| FFU1_Execute | 1 |
| FFU1_Reset | 0 |
How it works
Each time Execute turns on, writes the oldest entry, element 0, to Dest, moves every other entry down one place and takes 1 from POS. An empty queue is left as it is and Dest keeps its value.
Status bits
The Control tag holds the state. Read a bit with the tag name and a dot, such as Control.DN.
| Bit | Meaning |
|---|---|
| .EN | On while the Execute of the load that owns this Control tag is on. |
| .EU | On while the Execute of this unload is on. |
| .EM | Empty: on while POS is 0. |
| .FU | Full: on while POS equals LEN. |
| .DN | Done: on while the queue is full, the same as FU. |
| .LEN | Length: how many entries it can hold. It cannot be more than the size of the array. |
| .POS | Position: how many entries are in the queue. An unload takes 1 from it. |
Rules
- A queue acts once when Execute turns on, not on every scan. If Execute is already on in the first scan, it acts once then.
- A load into a full queue does nothing and raises no fault, so the value is lost.
- An unload from an empty queue does nothing and leaves Dest as it was.
- Reset sets POS to 0 and does not clear the array. The old values stay in the array until they are written over.
- It takes element 0, the oldest entry, and moves every other entry down one place.
- It uses the queue and Control tag of the FIFO Load it is paired with.
Over time
| Scan | Execute | .EN | .POS |
|---|---|---|---|
| 1 | Off | Off | 0 |
| 2 | On | On | 1 |
| 3 | On | On | 1 |
| 4 | Off | Off | 1 |
| 5 | On | On | 2 |
| 6 | On | On | 2 |
| 7 | On | On | 2 |
| 8 | Off | Off | 2 |
The chart shows a FIFO Load; the others act on Execute the same way. One step happens on the scan where Execute turns on. Holding Execute on does nothing more, so turn it off and on for the next step.
How it's used
Use FFU to hand the oldest part to the next station. It works on the queue and control tag of its FFL.
1. Unload. The oldest entry, 11, goes to Taken. 22 moves down to position 0 and POS is 1.
2. Turn Unload off. Execute is off. Nothing moves.
3. Unload again. 22 goes to Taken. The queue is empty: POS is 0 and EM is on.
4. Turn Unload off. Execute is off. Nothing moves.
5. Unload from empty. The queue is empty, so Taken is left as it was: 22. There is no fault.
| Step | Taken | Queue | Infeed.POS | Infeed.EM |
|---|---|---|---|---|
| 1. Unload | 11 | [22, 0] | 1 | 0 |
| 2. Turn Unload off | 11 | [22, 0] | 1 | 0 |
| 3. Unload again | 22 | [0, 0] | 0 | 1 |
| 4. Turn Unload off | 22 | [0, 0] | 0 | 1 |
| 5. Unload from empty | 22 | [0, 0] | 0 | 1 |
Taken went 0, 11, 22. Each unload moved the rest down and POS fell from 2 to 0. The third unload found the queue empty, so Taken stayed 22.
Operands
| Operand | What it is for | Data type | Read or write |
|---|---|---|---|
| Execute | A BOOL that makes the instruction act once each time it turns on. | BOOL | Reads |
| Reset | A BOOL that, while on, clears the control tag and starts over. | BOOL | Reads |
| Array | The array that holds the queue. Use the one the FIFO Load fills. | Array of BOOL, DINT, REAL | Reads and writes |
| Control | The CONTROL tag that tracks the position, length and status. | CONTROL | Reads and writes |
| Dest | The tag that receives the oldest entry. | BOOL, DINT, REAL | Writes |
Common mistakes
- Placing it before any FIFO LoadPlace the FIFO Load first. The unload takes the control tag and queue of that load.
- Rung already true on the first scanA rung that is already true on the first scan after a reset acts once, the same as any other scan where Execute turns on.