free quality report for PLCopenXML exports

Rules / fb-call-overwritten

Two calls of the same timer in a row with different inputs

A timer or edge detector instance holds one state. Two calls in a row in one branch make it see an input change within a single scan that never happened in the process: the second call overwrites the first.

Severity: Critical Rule id: fb-call-overwritten A second call to the instance overwrites the first

What the rule checks

A stateful FB instance, a timer or an edge detector, holds a single state. Two calls in a row within the same branch with different inputs mean that within one scan the timer sees an input change that never happened in the process: the second call immediately overwrites the state left by the first, while the code looks like two live calls. Two legitimate patterns are left alone. Calls in MUTUALLY EXCLUSIVE branches: start the timer in one branch, reset it via IN := FALSE in the other (seven times in our corpus). And a restart within one scan: t(IN := FALSE); t(IN := TRUE, PT := …);, where the first call clears ET and Q and the second starts counting afresh. The rule only fires when both calls sit on the same path, run in the same scan, and the first one is not a reset.

What it does to the plant

The timer never reaches its preset and the edge detector fires at the wrong moments.

Example

Bad: the rule fires
FUNCTION_BLOCK FB_DelayVAR_INPUT    xCmd : BOOL;END_VARVAR_OUTPUT    xOut : BOOL;END_VARVAR    tmrOn : TON;END_VARtmrOn(IN := xCmd, PT := T#5S);xOut := tmrOn.Q;tmrOn(IN := FALSE);
Fixed: the rule is silent
FUNCTION_BLOCK FB_DelayVAR_INPUT    xCmd : BOOL;END_VARVAR_OUTPUT    xOut : BOOL;END_VARVAR    tmrOn : TON;END_VARtmrOn(IN := xCmd, PT := T#5S);xOut := tmrOn.Q;

Both listings are run through the linter by an automated test: the rule fires on the first and stays silent on the second.

How to fix

  1. Keep a single call and make the input an expression: t(IN := a AND NOT b, PT := …);.
  2. If a reset is needed, put the calls in mutually exclusive branches so exactly one runs per scan.
Check your project

Upload a PLCopen XML or CODESYS .export file: the report is free and the code is not stored.

Local version on GitHub →

The same linter without uploading a file: command line and GitHub Action.

Related rules

2026-11-26

Processing happens in memory, and the uploaded code is not stored. The tool advises; code changes are up to the engineer (see what the linter can't see). What happens to your code → · Rule reference · Your code & privacy · Industry benchmark · Feedback · GitHub