IMDHMIControls LibraryShop main store

Troubleshooting

Why a CLICK PLC DS register will not reset from a subroutine

PLC programming Published 6 min read

Short answer

The DS register keeps its value because rungs inside a CLICK PLC subroutine execute only on scans where the main program calls that routine; an uncalled routine leaves every register, coil and timer frozen at its last value. Move the reset Copy of constant 0 into the main program, placed after any rung that increments the register, or guarantee the call is scanned every cycle.

On this page
  1. The symptom pattern
  2. Root cause: a subroutine runs only when it is called
  3. Worked example: DS1 stuck at 37 with the Copy 0 inside an uncalled subroutine
  4. Fixing it in the main program
  5. Keeping the subroutine and fixing the call instead
  6. Verifying the fix
  7. Rules that prevent a repeat
  8. Questions asked

A DS register that refuses to reset in a CLICK PLC is almost never an instruction problem. It is a scan-participation problem: the reset rung lives inside a subroutine that the main program is not calling, and rungs in an uncalled subroutine do not execute, so the register holds whatever the last scanned rung left in it. The fix is to move the reset Copy of constant 0 into the main program, placed after any rung that increments the register, or to guarantee the subroutine is called every scan.

The symptom pattern #

Check your program against this list. If most of these match, the diagnosis below applies:

  • The reset instruction writes 0 to a DS address such as DS1, and it sits inside a subroutine rather than the main ladder program.
  • Online monitoring shows the reset contact turning ON, but the destination register never changes.
  • Forcing the value to 0 from the data view works, and the register re-accumulates as expected until the next reset attempt.
  • Moving the same rung into the main program makes the reset work immediately.

If a rung behaves differently in the main program than in a subroutine, the instruction is fine; it is simply never executed.

Root cause: a subroutine runs only when it is called #

Ladder rungs in a CLICK PLC subroutine are not part of the cyclic main-program scan. They execute only during a scan in which the main program calls that routine. If the call condition is false, if the call rung was never added, or if the call itself is buried in another unscanned block, every rung in the subroutine is skipped. Skipped means frozen, not reset:

  • Output coils in the routine hold their last written state; they are not driven OFF.
  • Timers in the routine do not accumulate; they hold their last accumulated value.
  • DS, DD and DF data registers written in the routine hold the last written value.
  • Math and Copy destinations stay unchanged until some other scanned rung writes them.

This matches the observed behavior exactly. The increment logic runs elsewhere, moves the register, and the reset inside the unscanned routine never gets a turn.

A second contributor makes chasing this harder than it needs to be: a Math instruction evaluates an expression and stores the result, while a Copy instruction moves a source into a destination. For writing the literal constant 0 into one integer register, Copy is the more deterministic choice. It has no expression to evaluate and reads in the ladder as an unambiguous forced store. Swapping Math for Copy removes evaluation ambiguity while you fix the scan problem.

Worked example: DS1 stuck at 37 with the Copy 0 inside an uncalled subroutine #

Inputs, each illustrative except the scan rule, which is documented CLICK program flow:

  • DS1 holds the last accumulated value, 37, written by an increment rung in the main program.
  • The reset rung, a Copy of constant 0 into DS1, sits in a subroutine.
  • The call to that subroutine is gated by a mode bit that is FALSE during reset, so the routine is called on 0 of the scans in which the reset contact is ON.

The rule in words: rungs execute only when scanned, and a register changes value only when some scanned rung writes it. The number of updates the reset performs equals the number of scans the subroutine executes during the reset condition, which is 0, so DS1 keeps its value of 37. The increment rung in the main program is scanned on every cycle, so any new counts still land in DS1, which is why the register moves up but never returns to 0.

The decision: any reset of a DS register must run in the main program, or in a routine the main program calls unconditionally. In this case, delete the Copy from the subroutine and add it to the main program after the increment rung. With the reset contact held ON, the register reads 0 after the scan, which you confirm in the data view within one scan time.

Fixing it in the main program #

The recommended repair is to move the reset out of the subroutine:

  1. Back up the current project file before editing.
  2. Locate the reset rung in the subroutine and note its contact addresses and destination register, for example DS1.
  3. Delete or disable that rung in the subroutine.
  4. In the main program, add a rung with the reset contact driving a Copy instruction: constant source 0, destination DS1, single-register copy.
  5. Place that rung after any rung that increments or otherwise writes the register.
  6. Compile, transfer the project into the PLC, and put the CPU in RUN.

Rung order matters because CLICK executes top to bottom, left to right, and the last write in a scan wins. If the increment rung sits above the reset rung, the register reads 0 at the end of the scan. If the reset sits above the increment and both conditions are true in the same scan, the register reads 1. Place the reset after the accumulate logic whenever you want a true zero visible during a held reset.

Keeping the subroutine and fixing the call instead #

If the logic must stay modular, the call itself must be scanned whenever the reset needs to act:

  • Confirm the main program contains a call instruction targeting the routine.
  • Verify the call rung's enabling condition. A mode bit, a step bit, or a normally closed contact that is false by default means the routine never runs.
  • Confirm the call is not itself inside another unscanned subroutine; nested calls inherit the parent's scan condition.
  • Either call the routine unconditionally every scan, or gate it with a condition guaranteed true whenever a reset can occur.

The same execution rule explains related faults you may meet elsewhere: a ControlLogix main routine configured for scanned ladder solves the same class of problem on a different platform by letting you choose which routines the controller scans each cycle. Addressing, not scanning, is behind cases such as why a Modbus write to a CLICK PLC DS1 register needs address 0, and a complete worked CLICK reset application is in setting up a CLICK PLC 4-20 mA pressure trip with a relay output.

One safety note: never place interlock, alarm-clear or safety-related logic in a conditionally called routine. Those rungs must be evaluated on every scan so their outputs are deterministic; keep them in the main program.

Verifying the fix #

  • Online, add the DS register and the reset control bit to the data view. Drive the increment condition and confirm the register climbs; turn the reset bit ON and confirm it reaches 0 within one scan.
  • If the display flickers back to a nonzero value, the increment rung executes after the reset rung, so re-check the rung order.
  • Cycle CPU power and confirm the power-up value matches your intent. In a default CLICK project the DS address type is configured retentive, so registers restore their stored value rather than clearing; adjust the retentive range in the software if that is not what the application needs.
  • If the reset must fire once per button press, drive the Copy from a rising-edge contact so a held button does not pin the register at 0 and mask incoming counts.

Rules that prevent a repeat #

  • Write each DS register from as few rungs as possible; multiple writers across the main program and subroutines make the final value scan-order dependent.
  • Keep resets and interlocks in the main program so they are evaluated every scan.
  • Use Copy for constant loads and Math for expressions.
  • Call subroutines unconditionally unless frozen state is exactly what you intend.
  • Document which routine owns each DS address so the question of who wrote the value last is answerable without online tracing.

Questions asked

Are CLICK PLC DS registers retentive through a power cycle?

Yes, by default. In a default CLICK project the DS, DD, DH, DF, C, CT and TXT address types are configured as retentive, so a DS register restores its stored value when the CPU powers up rather than clearing. If you need the register to come up at 0, check the retentive-range configuration in the CLICK programming software for your CPU and move that address into the non-retentive range, or clear it with a first-scan rung.

Should I use a Math instruction or a Copy instruction to write 0 to DS1?

For writing a constant into one integer register, a Copy instruction with a constant source is the simpler and more deterministic choice. A Copy reads unambiguously in the ladder as force this value into this address, with no expression evaluation to trace. Reserve the Math instruction for expressions such as an increment, and use Copy whenever the intent is just to store a fixed value.

How can I prove a CLICK PLC subroutine is not being scanned?

Add a scratch rung inside the suspect subroutine that copies a known constant, for example 1234, into an unused register. Run the PLC and watch that register in the data view. If the register never changes, the routine is not being called and the diagnosis is confirmed independently of the reset logic. Then check the call rung in the main program for a false-by-default condition, a mode bit, or a call nested inside another unscanned routine.

Keep reading

  • Troubleshooting

    Fix ctrlX PLC license invalid exceptions on download

    The CmpApp invalid-license-metrics exception has two separate causes: a missing CODESYS IO-Link entitlement, shown by a demo-mode line in the log, or a known symbol-configuration bug cleared by Online > Reset Origin before the download. No Data Layer access license exists to buy.

    PLC programming

  • How-to

    How to compare two CLICK PLC programs for differences

    CLICK Programming Software has no built-in project compare, and the vendor has said none exists in the current release. The working method is to upload each machine's running program as a dated baseline, compare hardware, field assignments, configuration and logic in six passes, classify every mismatch, and load one merged program only after every difference has an owner.

    PLC programming

  • Troubleshooting

    PLC-5 not visible in RSLinx after processor replacement

    A replacement PLC-5 stays invisible in RSLinx because the 1785-ENET sidecar answers the network on its own while the processor waits for an application that configures the Ethernet channel 3A. Leave the non-isolated serial port disconnected until the cable is checked, bring the processor up over serial DF1 or DH+, download the saved program, and the Ethernet path returns.

    PLC programming