Show machine elapsed run time on an HMI display

6 min read · Published November 9, 2026

Do the timing in the PLC: feed the run contact into a timer or a once-per-second add on a retained 32-bit total, and point the panel's numeric display at that tag. The panel's own counter and its alarm log work as fallbacks: the counter counts time blindly, and the alarm log answers only after the event.

Show elapsed run time by accumulating the on-time in the PLC and pointing a numeric display object at that value. The controller sees the run signal every scan, so it can time the machine exactly; the panel's job is to show the number.

The panel can also time things on its own, two ways. Its built-in counter object ticks on an interval you set. Its alarm log records when a signal was set and cleared, and the difference between the two timestamps is the interval. Both are fallbacks: the counter never sees the machine, and the log answers only after the event. This page compares the three ways, gives the retention and overflow numbers to design with, and ends with the decision for each case.

Decide what the number means

Three different numbers get called "elapsed time", and each needs different logic:

  • Current on-period. Start timing when the run signal turns on, stop or clear it when the signal turns off. This answers "how long has it been running?"
  • Cumulative on-time. Add every on-period to one retained total, with a reset that only maintenance can reach. This answers "how many hours has this machine actually run?"
  • After-the-fact interval. Read timestamps and subtract. This answers "how long did yesterday's run last?"

Confirm with the process owner which of the three they want before you write any logic, because a display of the wrong period still looks plausible.

The three ways side by side

Way What it shows What you configure The limit
PLC timer or accumulator, shown on a numeric display Live current interval, or a lifetime total that survives power cuts Run contact into a timer or a once-per-second add on a retained tag; display format and units Needs a controller program change; the timer's millisecond value must be mapped to an integer tag for display
Panel's built-in counter object Time since the counter started counting Increment interval, minimum count, maximum count, repeat after rollover Its settings contain no run-signal input, so it counts wall time whether the machine runs or sits stopped
Alarm log Each on-period, after it ends The run contact or control relay configured as an alarm Read the set and cleared timestamps and subtract; the live screen shows nothing until the period is over

Where each wins is easy to state. The PLC route wins for every live number and every total that must survive a power cycle. The counter wins only when the controller program is frozen and you need a rough time-on-screen figure for a trial or a demonstration. The alarm log wins when the question is historical and the machine already logs alarms, so the data exists at no extra cost.

Build it in the PLC

Take the run signal from a control-rated contact, such as the contactor's auxiliary contact. Never tap a safety circuit to feed a display total.

For the current on-period, use the standard on-delay timer. IEC 61131-3 defines the timer family and a TIME type with 1 ms resolution, so the elapsed value is an integer of milliseconds while the input is on.

For cumulative on-time, add each period to a retained tag. The same standard defines retained-variable marking, and that marking is what carries a value through a power cycle, so mark the total retentive in the controller. Size the tag for the job: a signed 32-bit count of milliseconds overflows at 2,147,483,647 ms, which is 596.5 h of accumulated on-time, so milliseconds are for short intervals. A signed 32-bit count of seconds overflows at 2,147,483,647 s, about 68 years, and that is the right unit for a lifetime total. A once-per-second pulse contact in series with the run bit adds one count for every second the machine runs; this running-total technique is the same one used to roll a live shift total into a month total.

The display side is a numeric display object pointed at the tag. A timer's TIME value needs an explicit mapping for display: map the PLC TIME tag to a 32-bit integer tag and the panel shows the raw milliseconds, 5000 for 5 s. Label the object with its units, keep operators read-only, and match the format to the tag; displaying HH:MM:SS time on a numeric object covers the formatting. If your controller already holds a production count and you only need to scale it, showing motor run hours from a PLC counter covers that variant.

When the counter object is the only option

Sometimes the controller program cannot be touched: a validated machine, a rental rig, a trial cell. Then the panel's counter object does the timing. Its documented settings are the time between count increments, the minimum count, the maximum count, and whether it repeats by rolling over to the minimum at the maximum, as rollover counters do. Set the increment interval to the display step you want and expect the count to wrap when repeat is on.

Know what you bought. The counter counts the interval you gave it, and none of its settings reads the run signal, so its number answers "time since this screen started counting". That is the right answer only when the screen counts exactly while the machine runs. For real on-time, the number has to come from the controller.

Read it back from the alarm log

Configure the run contact or control relay as an alarm and the panel's log keeps a timestamp for the set and the clear of every period. Subtract the two for each event: a run logged set at 07:42 and cleared at 15:26 was 7 h 44 min of on-time.

This is a history view, and a good one, but the screen shows nothing live while the machine runs, and the log holds only the events that fit it. For keeping that history over weeks of set-and-clear patterns, a circular alarm event buffer with separate pointers is the storage pattern to copy. For the timestamp arithmetic itself, converting robot mode data timestamps to elapsed time walks through turning paired timestamps into intervals.

Example: a 20,000 hour gearbox total

Scenario. A conveyor drive gets rebuilt at 20,000 h of motor run time. The panel must show lifetime hours, the total must survive power cuts, the run signal is the contactor's auxiliary contact, and the machine accumulates 8 h of run time on a busy day.

First candidate: keep the total as the timer's millisecond value. Capacity is 2,147,483,647 ms = 596.5 h. At 8 h of run time per day, 596.5 / 8 = 74.6 calendar days to overflow. Rejected for a lifetime total.

Chosen design: a retained 32-bit tag of seconds, incremented once per second while the run bit is on. Capacity is 2,147,483,647 s = 2,147,483,647 / 86,400 = 24,855 days = 68.1 years of accumulated on-time. The rebuild threshold fits easily: 20,000 h x 3600 s/h = 72,000,000 s, about 3.4 percent of capacity. Display: a numeric object on the tag, scaled to hours, so a total of 3,600,000 s shows as 1,000.0 h.

Test it with the machine in a controlled state. Run two short on-periods and confirm the second adds to the first instead of replacing it. Then cut controller power mid-period and confirm the retained total comes back where it stopped.

The decision

Recommendation: accumulate the on-time in the PLC and display the controller's value. For a live current interval, run the run contact into a standard on-delay timer and map its millisecond TIME value to a 32-bit integer tag for a numeric display. For a lifetime total, add one count to a retained 32-bit tag of seconds per second the machine runs, and scale to hours on the display. Use the panel's counter object only when the controller program cannot be changed, and read its number as time since counting started. Use the alarm log when the question is historical: read the set and cleared timestamps per event and subtract.

If the same total also has to be readable from across the floor, that is a separate purchase: a shop-floor status screen showing the shift numbers as content, next to the panel that carries the live value.

Questions

Can the panel show run time if there is no PLC at all?

Only with the counter object, and then the number is time since the counter started counting, not machine on-time. A panel with no controller has no input that tells it the motor is running, so a true on-time total needs at least one run signal into a controller. If the machine has a spare control relay contact, the PLC route is a small program change plus one numeric display.

Why does my numeric display show a strange number instead of time?

Usually the data format. A timer's elapsed value is an integer of milliseconds, so if the display object is set to another type or width it prints a raw or garbled integer. Map the timer's TIME value to a 32-bit integer tag, set the display format and units to match, and check the number against a stopwatch over a minute of known run time.

How do I reset the total without losing it by accident?

Put the reset in the controller and behind the panel's user levels: a write action on a maintenance screen that moves zero into the retained total. Operators get a read-only numeric display and no reset control on the machine's home page. An unprotected reset write next to everyday controls is the usual way a lifetime total disappears.

Does the total survive a power cut?

Only when the tag is retentive. Mark the total tag retentive in the controller and the value returns through a power cycle; without that marking the timer restarts at zero. Where the controller keeps retained data in battery-backed memory, battery service life is typically quoted at up to five years under good conditions, so put the battery on the maintenance schedule.

Planning information, not legal or engineering advice. Rules differ by place: check codes and permits with your local authority and your licensed trades.

Keep reading

Build your signAsk for a quote