free quality report for PLCopenXML exports

Rules / real-to-time-mul

REAL_TO_TIME(x) * 1000 truncates the setpoint: 2.7 s becomes 2 s

REAL_TO_TIME treats the number as milliseconds and drops the fraction during conversion. A multiply after it scales a value that is already damaged. Multiply before converting: REAL_TO_TIME(x * 1000.0).

Severity: Warning Rule id: real-to-time-mul REAL_TO_TIME(...)*N truncates the setpoint

What the rule checks

REAL_TO_TIME treats the number as milliseconds and truncates the fraction before conversion, so fractional time setpoints are lost. Multiply before REAL_TO_TIME.

What it does to the plant

The operator adjusts a time setpoint and the machine runs a rounded-down value: pulses, pauses and delays are shorter than set.

Example

Bad: the rule fires
PROGRAM PulseVAR    rPulseSec : REAL := 2.7;    tPulse : TIME;END_VARtPulse := REAL_TO_TIME(rPulseSec) * 1000;
Fixed: the rule is silent
PROGRAM PulseVAR    rPulseSec : REAL := 2.7;    tPulse : TIME;END_VARtPulse := REAL_TO_TIME(rPulseSec * 1000.0);

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. Multiply BEFORE the conversion: T := REAL_TO_TIME(sec * 1000.0);
  2. Or: T := DINT_TO_TIME(REAL_TO_DINT(sec * 1000.0));
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

In-depth article

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