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

NameTypeNotes
sourceDINT, INT, SINT, REALThe value to write. A tag or a number
destDINT, INT, SINT, REAL, TIMER, COUNTER, CONTROLOne element — where the run starts
lengthDINT, INT or SINTHow 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.

SourceDestinationResultWhy
2.5 (REAL)DINT[]2Halves round to even
3.5 (REAL)DINT[]4Halves round to even
300SINT[]44Wrapped to 8 bits, not clipped
70000INT[]4464Wrapped to 16 bits
3.0e9DINT[]-1294967296Wrapped 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 FLL on a timer to set its preset. It fills every member. Use MOVE.
  • Expecting 300 into a SINT array to clip at 127. It wraps to 44.
  • Naming the bare array — FLL(0, Readings, 20). Name an element: Readings[0].

On this page