Publish the required PLC timer quantity as an integer with an explicit unit, then format it as a duration rather than a time of day. Distinguish preset, elapsed and remaining values, and define rounding, completion and invalid-data behavior before commissioning the display.
Publish the timer as an integer with an explicit unit, then format that duration into hours, minutes and seconds. If your display software documents a duration format that accepts the PLC representation directly, you can use it. Otherwise, converting the value in the PLC gives you a clear interface that is easier to inspect.
First decide whether the screen should show the preset, elapsed time or remaining time. Correct formatting cannot fix a tag connected to the wrong quantity. Keep presentation calculations separate from the logic that controls the machine.
Choose which timer quantity to display
A timer does not have one universally meaningful “current value.” Its preset and live timing values describe different things.
| Display label | Quantity needed | Expected behavior during an active interval |
|---|---|---|
| Set duration | Preset used for that interval | Usually stays fixed unless the application changes it |
| Elapsed | Time accumulated during the interval | Increases while timing is active |
| Remaining | Time still outstanding | Decreases toward zero |
Inspect the timer instruction and its documented outputs before creating the display tag. A tag connected to the preset can stay unchanged even while the timer operates correctly.
Do not assume that every timer exposes both elapsed and remaining values. Where the instruction's behavior supports it, you can calculate remaining time as the preset minus elapsed time, limited to a minimum of zero. Both inputs must use the same unit and describe the same timing interval.
If the application allows the preset to change during timing, establish whether the calculation needs the current preset or the preset captured when that interval began. That choice belongs to the machine's timing definition, not to the screen formatter.
Decode the timer representation before formatting it
S5TIME encodes a duration using a time-base selection and a binary-coded decimal magnitude. Binary-coded decimal stores decimal digits separately. Treating the whole encoded word as an ordinary integer therefore does not convert it into seconds or milliseconds.
Use the controller's documented conversion instruction or routine. Confirm all three parts of its definition:
- The input representation it accepts.
- The output data type it produces.
- The engineering unit of the result.
A conversion that returns milliseconds and one that returns seconds can both be correct, but they produce different integers for the same duration. The display must know which one it receives.
Keep this decoding separate from presentation arithmetic. First obtain a meaningful duration, such as elapsed_ms. Then split that duration into display fields. This separation lets you inspect the converted number without wondering whether an hours-and-minutes expression is hiding an error.
Check several durations that exercise different time bases supported by the timer. A conversion that appears correct for one preset is not enough to establish that the encoded representation is being interpreted properly.
Publish a tag with an explicit unit
A dedicated integer tag makes the interface easier to maintain. Names such as remaining_ms and elapsed_s explain more than timer_value.
A DINT is commonly a signed 32-bit integer, but confirm the definitions used by the controller and display driver. Select a unit and data type that can represent the longest required interval without overflow. Milliseconds preserve subsecond information but consume the integer range faster than seconds.
For the display connection, match:
- The PLC address and complete integer width.
- Signed or unsigned interpretation.
- Word order where the communication driver requires it.
- Scaling and engineering units.
Start with an unscaled numeric field labeled with its unit. Compare it with the converted PLC tag before adding duration formatting. Small values can look plausible even when a wider integer is mapped incorrectly, so include a larger representative value in the check.
Update the presentation tag while the underlying timer changes. A conversion executed only at the start of an interval publishes a snapshot, not a live duration. Implement any PLC changes through the normal engineering review and commissioning process.
Split total seconds into display fields
A duration is not a time of day. Using a clock or date formatter can introduce unwanted wrapping at a day boundary or apply calendar rules that have no meaning for a machine interval.
Once you have nonnegative whole seconds, calculate the fields with integer arithmetic:
hours = total_seconds div 3600minutes = (total_seconds mod 3600) div 60seconds = total_seconds mod 60
Here, div means integer division and mod means the remainder after division. These are mathematical expressions, not syntax for a particular controller or display package.
Pad the minute and second fields to two digits. Let the hour field grow to the required width rather than wrapping it at 24.
| Total whole seconds | Formatted duration |
|---|---|
| 59 | 0:00:59 |
| 60 | 0:01:00 |
| 3,599 | 0:59:59 |
| 3,600 | 1:00:00 |
| 90,061 | 25:01:01 |
For example, 3,661,000 milliseconds is 3,661 seconds because there are 1,000 milliseconds in a second. The formatted result is 1:01:01.
Do the arithmetic in the display application only if its documented expression functions support the required operations and formatting. Otherwise, calculate the fields in the PLC. If you publish separate fields, use a coherent update or snapshot so the screen does not combine values from different timer updates.
Choose a rounding rule for whole seconds
When the PLC publishes milliseconds, decide how fractional seconds become whole seconds. Do not leave that behavior to an unexplained numeric format.
For elapsed time, truncating a nonnegative value is often useful:
total_seconds = floor(elapsed_ms / 1000)
An elapsed value of 1,200 milliseconds then displays as one second.
For a countdown, rounding upward can better express that some time remains:
total_seconds = ceil(remaining_ms / 1000)
A remaining value of 200 milliseconds then displays as one second rather than zero. At an actual remaining value of zero, it displays zero.
These are presentation choices. Use the rule that matches the intended meaning, document it, and apply it consistently. If you round elapsed downward and remaining upward, do not expect the two displayed integers to behave like independently rounded measurements.
Screen acquisition and rendering also introduce delay. Whole-second formatting does not establish the exact instant at which the machine's timer completes. Where the numbers appear to lag, distinguish formatting from factory screen update delay before changing the arithmetic.
Define inactive, complete and invalid states
A number without a state label can be misleading. Zero might mean no time has elapsed, the countdown has finished, the timer has been reset, or a communication value is missing.
Define the display behavior for each relevant state:
- Inactive: Show an explicit inactive label and the value appropriate to the timer instruction.
- Timing: Show the live quantity with a clear Elapsed or Remaining label.
- Paused or interrupted: Show that state only if the control logic actually defines it. Some timers reset instead of pausing.
- Complete: Use the PLC's completion status rather than inferring completion solely from a rounded number.
- Invalid or stale: Mark the value unavailable or stale instead of silently presenting an old reading as current.
Do not clamp an unexpected negative duration to zero without considering why it occurred. If negative values are invalid for this interface, flag them as invalid so a mapping or calculation error remains visible.
A displayed zero is not permission to restart equipment or enter a hazardous area. Keep the distinction between an informational factory status display and an operator HMI. Timer formatting must not replace machine interlocks or safety functions.
Check the complete duration display
Check the numeric conversion, formatting and state handling separately. That makes a wrong result easier to locate.
Compare the converted PLC integer with the display's raw numeric field while the value is stationary. Then observe a controlled timing interval and confirm that elapsed increases or remaining decreases as intended. Use approved commissioning conditions rather than changing production timing merely to exercise the display.
Include these boundary cases in the display check:
- Zero, and a positive duration below one second if milliseconds are published.
- The transition between 59 seconds and one minute.
- The transition between 59 minutes, 59 seconds and one hour.
- More than 24 hours if the application requires it.
- Reset, interruption and completion according to the timer instruction.
- Loss of valid data and restoration of a current reading.
For a factory board, retain the quantity label and an understandable format such as Remaining 1:01:01. A bare 1:01 can mean one hour and one minute or one minute and one second. The finished display should make the timer's meaning clear without requiring you to inspect its tag definition.
Questions
Can a display read S5TIME directly?
Only when the display software explicitly supports that representation and documents how it interprets it. S5TIME includes a time base and a binary-coded decimal magnitude. Reading its encoded word as an ordinary integer does not produce a duration in seconds. A documented PLC conversion to a unit-tagged integer is an alternative.
Should the PLC publish milliseconds or seconds?
Publish milliseconds when you need subsecond information or want the display to choose its rounding policy. Whole seconds can simplify an interface that needs no finer detail. In either case, identify the unit in the tag definition and confirm that the selected integer type covers the longest required duration.
Why does a countdown display zero before the timer finishes?
Truncating a positive remaining value below one second produces zero whole seconds. Rounding upward keeps that positive remainder visible as one second. Use the PLC's completion status to indicate that timing has finished, rather than treating a rounded display value as the completion signal.
How do you prevent a duration from wrapping after 24 hours?
Use arithmetic on total duration rather than a time-of-day formatter. Calculate total hours without applying a 24-hour remainder, then calculate minutes and seconds from the remaining seconds. Allow enough space for the largest expected hour value and check that the underlying integer cannot overflow.
Planning information, not legal or engineering advice. Rules differ by place: check codes and permits with your local authority and your licensed trades.