FIFO Load FFL
At the right of a rung in a program's ladder routine. Not in a Logic Class. Placing it creates its control tag.
| Tag | After two scans |
|---|---|
| FFL1 | LEN 8 POS 1 EN 1 DN 0 EM 0 FU 0 |
| FFL1_Data | [0, 0, 0, 0, 0, 0, 0, 0] |
| FFL1_Execute | 1 |
| FFL1_Reset | 0 |
How it works
Each time Execute turns on, writes Source at the end of the queue, the element at POS, and adds 1 to POS. The oldest entry stays at element 0, so FIFO Unload hands entries on in the order they went in. A full queue is left as it is.
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 is on. |
| .EU | On while the Execute of the unload is on. It is there once an unload uses this Control tag. |
| .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. The next load writes to this element of the array. |
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.
- The oldest entry is at element 0. FIFO Unload takes it from there.
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 FFL to line parts up for a station that takes them in the order they arrived. This queue holds 2.
1. Load 11. Execute was already on in the first scan, and it loaded once. 11 is at position 0 and POS is 1.
2. Hold Load on. Execute is still on, but it did not turn on again. Nothing loads.
3. Turn Load off. Execute is off. Nothing moves.
4. Load 22. 22 goes behind 11. The queue is full: POS is 2 and FU is on.
5. Turn Load off. Execute is off. Nothing moves.
6. Load 33. The queue is full, so nothing is written. There is no fault and 33 is lost.
7. Reset. Reset sets POS to 0. 11 and 22 are still in the array, but the queue now counts as empty.
| Step | Part | Queue | Infeed.POS | Infeed.FU | Infeed.DN |
|---|---|---|---|---|---|
| 1. Load 11 | 11 | [11, 0] | 1 | 0 | 0 |
| 2. Hold Load on | 11 | [11, 0] | 1 | 0 | 0 |
| 3. Turn Load off | 11 | [11, 0] | 1 | 0 | 0 |
| 4. Load 22 | 22 | [11, 22] | 2 | 1 | 1 |
| 5. Turn Load off | 22 | [11, 22] | 2 | 1 | 1 |
| 6. Load 33 | 33 | [11, 22] | 2 | 1 | 1 |
| 7. Reset | 33 | [11, 22] | 0 | 0 | 0 |
The queue went [0, 0] to [11, 0] to [11, 22]. The third load found it full, so 33 was lost and POS stayed 2. Reset set POS to 0 and left 11 and 22 in the array.
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 |
| Source | The value added to the queue. | BOOL, DINT, REAL or a number | Reads |
| Array | The array that holds the queue. | Array of BOOL, DINT, REAL | Writes |
| Control | The CONTROL tag that tracks the position, length and status. | CONTROL | Reads and writes |
Common mistakes
- Holding Execute on and expecting more loadsA load happens once each time Execute turns on. Turn it off and on again for the next entry.
- 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.