FLL — Fill
FLL in rungs.dev writes one value into every element of a run of an array. Use it to clear a buffer, preset a recipe, or zero a structure in one rung.
FLL
Source
source
Dest
dest
Length
length
Writes one value into every element of a run of an array.
What it does
FLL is the fast way to clear or preset a block of memory: zero a buffer before a new batch,
set every alarm limit to a default, blank a display array.
Like COP, it runs on every scan the rung is true — not once per rising edge.
Operands
| Name | Type | Notes |
|---|---|---|
source | DINT, INT, SINT, REAL | The value to write. A tag or a number |
dest | DINT, INT, SINT, REAL, TIMER, COUNTER, CONTROL | One element — where the run starts |
length | DINT, INT or SINT | How many elements to fill. A tag or a number |
length clamps to the destination, exactly as COP's does, and never faults.
Converting on the way in
For an ordinary array, the source is converted to the destination's type once, then written
into every element — the same rule MOVE uses.
| Source | Destination | Result | Why |
|---|---|---|---|
2.5 (REAL) | DINT[] | 2 | Halves round to even |
3.5 (REAL) | DINT[] | 4 | Halves round to even |
300 | SINT[] | 44 | Wrapped to 8 bits, not clipped |
70000 | INT[] | 4464 | Wrapped to 16 bits |
3.0e9 | DINT[] | -1294967296 | Wrapped to 32 bits |
This is conversion, not saturation: a value too big for the type wraps round rather than sticking at the maximum.
Filling a structure
A TIMER, COUNTER or CONTROL destination is different: the source is written raw, with
no conversion, into every word of the structure — the numbers and the status bits alike.
FLL(0, Dwell, 1) is the useful case: it zeroes the whole timer, preset included.
FLL(7, Dwell, 1) does not set the preset to 7 and stop there
It writes 7 into .PRE and .ACC, because both are words of the same structure. And a
value with a high bit set lands in the status bits too: FLL(2.5, Dwell, 1) writes the
decimal's bit pattern, which switches .TT on.
To set just one member, use MOVE: MOVE(5000, Dwell.PRE).
Example — Clear a Buffer
0
NewBatch
FLL
Source
0
Dest
Readings[0]
Length
20
1
NewBatch
FLL
Source
0
Dest
Total
Length
1
Structured Text
FLL has no Structured Text form. In a Structured Text routine, write a FOR loop, or use
COP with the replicate idiom.
Common Mistakes
- Using
FLLon a timer to set its preset. It fills every member. UseMOVE. - Expecting
300into aSINTarray to clip at127. It wraps to44. - Naming the bare array —
FLL(0, Readings, 20). Name an element:Readings[0].
Related
- Array instructions overview
- COP and CPS — copy a run instead of filling it
- MOVE — one value into one destination
COP and CPS — Copy
COP and CPS in rungs.dev copy a run of elements from one array into another. Use them to snapshot a buffer, replicate a value, or move a batch of readings in one rung.
SIZE — Size In Elements
SIZE in rungs.dev counts the elements of an array and stores the count in a tag, so a rung never has to hardcode how long an array is.