Clear a V-memory range in a PLC with the FILL instruction

5 min read · Published November 11, 2026

To clear a block of user V-memory in one rung, load the location count, load the starting address, and execute the FILL instruction with the fill value. For V10000 through V10456 that count is K12F, hexadecimal for the 303 locations between the two octal addresses. Gate the fill to a one-time initialization condition and let the HMI write only after the block reads zero.

To zero a block of user V-memory in one rung, load the location count, load the starting address, then execute the FILL instruction with the value the block should hold. On a DL405 D4-450, clearing V10000 through V10456 takes three instructions: LD K12F, LDA 10000, FILL K0. That writes zero into all 303 locations once, before the HMI puts its data into the block. The entry that tempts everyone first, a load of K0 with an OUT aimed at the range, is not a block write; OUT addresses one location at a time. The rest of this article shows the sequence, the octal arithmetic that produces the count, the gating that keeps the fill from erasing HMI data later, and the checks that confirm the block is clear before the load starts.

Why a load-and-OUT entry does not fill the range

OUT writes the accumulator to its one destination. The instruction has no range form on this family, so an operand written as V10000 through V10456 produces no block write. Clearing the block by hand means one output instruction per word, 303 of them, which is exactly the typing this job should avoid.

The family's table instructions are the tool for it. FILL writes one value into a counted range of locations, and the DL405 user manual from the controller's manufacturer documents the instruction set and the V-memory map it works on.

What you need

  • The programming software for the controller, connected to the CPU with the program available for editing.
  • The block boundaries from the memory map: first word V10000, last word V10456, both inclusive.
  • The fill count for those boundaries; the worked example below computes it as K12F, 303 locations.
  • A program condition that is true only once at startup, such as a first-scan bit or a dedicated initialization step, to gate the rung.
  • The user manual for the CPU model, for the operand formats of the load, address-load and fill instructions.

Enter the FILL sequence

  1. Load the count. LD K12F puts the number of locations onto the accumulator stack. The count constant is entered in hexadecimal, so 303 locations becomes K12F.
  2. Load the starting address. LDA 10000 loads the address of the block's first word, V10000.
  3. Fill the block. FILL K0 writes zero into every location counted from that starting address.

The order matters: the count and the address together define the block, and FILL carries the value written into it. As entered in the ladder:

Worked example: counting the 303 words from V10000 to V10456

Inputs:

  • First word V10000, the block's start address, taken from the memory map.
  • Last word V10456, inclusive, from the same map.
  • Numbering: the DL405 labels these user addresses in octal, so each digit place is a power of 8 and the digits run 0 to 7.
  • Word size: every V-memory location on the family is one 16-bit word, per the manufacturer's product literature for the DL405 PLCs.

The rule: convert both octal endpoints to decimal, subtract the start from the end, add one because the range includes both endpoints, then write the result as a hexadecimal K constant.

The arithmetic:

  • V10000 octal to decimal: 1 × 4096 + 0 × 512 + 0 × 64 + 0 × 8 + 0 = 4096.
  • V10456 octal to decimal: 1 × 4096 + 0 × 512 + 4 × 64 + 5 × 8 + 6 = 4096 + 256 + 40 + 6 = 4398.
  • Words from 4096 through 4398, inclusive: 4398 - 4096 + 1 = 303.
  • 303 decimal to hexadecimal: 303 - 256 = 47, and 47 = 2 × 16 + 15, so the value is 12F hex and the entry is K12F.

Result: the block holds 303 sixteen-bit words, and the count entry is K12F.

Decision: enter LD K12F for this range. Subtracting the labels as plain decimal gives 10456 - 10000 = 456, which counts 153 words too many, because the labels are octal; displaying an octal V-memory address shows how those labels read. For any other block, run the same four steps on its endpoints. A count longer than the real span writes zeros past the intended last word, and a shorter count leaves old data at the top of the block, so the count is what sets the boundary.

Run the fill once, before the HMI writes

The block holds a table the HMI writes into, so the fill and the load must not overlap. Put the three rungs behind the initialization condition so the fill executes once during startup, and hold the HMI load enable off until the fill rung has run. A fill left enabled during running rewrites zeros over the HMI's words scan after scan, and a load that starts while the fill is still enabled lets the two sides write the same words.

Cleared first, the table starts from a defined state, and the HMI then writes current values into part of it. That order is the setup half of storing HMI recipe tables in PLC memory and loading the values. If some words in the block must stay untouched while a stage runs, extend the same idea with locking a PLC V-memory value from HMI writes during a stage.

Recommendation: Gate the FILL rung to a first-scan or initialization condition and interlock the HMI load so it starts only after the fill has executed once. For V10000 through V10456, enter LD K12F, LDA 10000, FILL K0. For any other block, recompute the count from its endpoints with the worked example above before entering the rung. Below roughly ten words, individual output instructions are simpler to read and maintain.

How to check it worked

  1. Hold the HMI load off and run the initialization once, from a controlled startup.
  2. Monitor the first word V10000, the last word V10456, and a word near the middle: V10227 sits 151 words in from the start, the 152nd of the 303. All three should read zero.
  3. Monitor the word just past V10456 and check that it still holds its previous value.
  4. Release the HMI load and confirm the words it writes take their values.

If V10456 is not zero, or the word outside the block has changed, disable the rung and recheck the start address, the inclusive count and the operand entries. Correct the arithmetic offline; do not tune the count by trial and error against live data. The release order matters on any panel that writes to the controller: verify the writes behave before the process depends on them, which is the discipline in the operator panel PLC link setup walkthrough.

Questions

Why do HMI values written into the block disappear again?

The fill rung is still being enabled after startup. A fill that executes every scan rewrites zeros over whatever the HMI has just written, so new values vanish within a scan or two of appearing. Watching the rung's enable while the HMI writes shows whether it is still firing.

Can the HMI clear the block instead of the PLC?

It can, and that is the slow path. Each word travels to the controller as its own write request, so clearing 303 locations takes hundreds of round trips over the link. The PLC fills all 303 words with one rung during its own scan, with no traffic on the panel link, and clearing first also means the two sides do not write the same word at the same time.

Why is the count entered in hexadecimal when the addresses are octal?

Only the address labels count in octal. The fill count is a plain number of words, 303 here, and the K constant for it is entered in hexadecimal, which is why 303 is written K12F. The controller stores the count, the address and the fill value as binary internally, so there is no mixing problem at run time. Convert the endpoints to decimal for the subtraction and convert the result to hex only for the entry.

Planning information, not legal or engineering advice. Rules differ by place: check codes and permits with your local authority and your licensed trades.

Keep reading

Build your signAsk for a quote