← All exercises

Run Hours

medium

Accumulate the run time of a BOOL input in seconds with a manual reset.

What it teaches

Use a timer to accumulate elapsed time, and an internal counter or DINT to roll TONR cycles into seconds (or use RTOR to retain ACC across enable drops). Teaches retentive timing, scan-time accumulation, and reset semantics.

Inputs and outputs

TagTypeDefaultDescription
In_RunBOOLSignal to track run time
In_ResetBOOLResets the accumulated time to 0
Out_RunSecondsDINTTotal accumulated run time in seconds

Required behavior

  • Accumulates elapsed time in seconds while In_Run is true.
  • Retains the accumulated time when In_Run goes false.
  • Resets the accumulated time to 0 when In_Reset is true.