← All exercises

Run Hours

medium

Totals a machine's run time as hours, minutes, and seconds, retaining the total through stops, with a manual reset.

What it teaches

The real hour meter: run one retentive timer continuously and bank a second each time its accumulator passes a moving 1000 ms target, then cascade the rollovers — seconds into minutes, minutes into hours. Self-resetting timers lose a little time at every rollover on real controllers; the free-running meter with a moving target is the drift-free production pattern.

Inputs and outputs

TagTypeDefaultDescription
In_RunBOOLSignal to track run time
In_ResetBOOLClears the accumulated total
Out_SecondsDINTSeconds portion of the total, 0-59
Out_MinutesDINTMinutes portion of the total, 0-59
Out_HoursDINTWhole hours of accumulated run time

Required behavior

  • Accumulates run time while In_Run is 1 and holds the total — including any partial second — while In_Run is 0.
  • Every full 1000 ms of accumulated run time advances the display by exactly one second — the meter never drifts.
  • Out_Seconds and Out_Minutes roll over at 60.
  • In_Reset clears the total to 0:00:00, including any partial second.