Rules / fb-preset-missing
Timer has no PT preset anywhere: the output comes at once
A preset can be set as a call argument, by assigning t.PT := ..., or as an initial value in the declaration. If none exists, PT is zero and there is no delay. Unlike timer-zero-pt, the zero is not written here, it is forgotten.
Severity: Critical
Rule id: fb-preset-missing
The instance has no preset anywhere
What the rule checks
A preset, PT on a timer and PV on a counter, can be set in three ways: as a call argument, by assigning the field t.PT := …, or as an initial value in the declaration. If it is set nowhere, PT stays at zero and the output appears in the same scan in which the input went up. The code looks right: the call is there, the output is read, the delay is not. It differs from timer-zero-pt in that there the zero is written explicitly, while here the preset is simply missing, which is harder to spot by eye.
What it does to the plant
The intended delay is missing, and reading the code does not reveal it because the call and the output are both there.
Example
FUNCTION_BLOCK FB_DelayVAR_INPUT xCmd : BOOL;END_VARVAR_OUTPUT xOut : BOOL;END_VARVAR tmrOn : TON;END_VARtmrOn(IN := xCmd);xOut := tmrOn.Q;
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
- Set the preset in the call:
t(IN := v, PT := T#5S);so it is visible next to the run condition. - If the preset comes from the HMI, assign the field before the call and make sure the variable is not left at zero on first start.
Upload a PLCopen XML or CODESYS .export file: the report is free and the code is not stored.
The same linter without uploading a file: command line and GitHub Action.
Related rules
2026-11-26