Stopwatch
The Stopwatch node measures elapsed time and provides two different operating modes, defined by the Trigger policy property:
- Switch — the Stopwatch counts while the Input connector is equal to 1 and pauses when it returns to 0.
- Toggle — the Stopwatch starts on the first rising edge received on Input and uses each following rising edge to calculate a new partial time.
When the Reset connector is equal to 1, the node stops counting and sends 0 to both Partial time and Total time.
Counting can start again only after Reset returns to 0.
The unit of measure used for the calculated times is defined by the Time UoM property.
Behaviour of Stopwatch with Trigger policy Switch
Behaviour of Stopwatch with Trigger policy Toggle
Connectors
| Connector | Type | Description |
|---|---|---|
| Input | Input | Controls the Stopwatch according to the selected Trigger policy. |
| Reset | Input | Stops the Stopwatch and resets both time outputs to 0 while active. |
| Partial time | Output | Returns the elapsed time for the most recent measured interval. |
| Total time | Output | Returns the total accumulated counted time. |
Main properties
| Property | Description |
|---|---|
| Trigger policy | Defines how the Input connector controls the Stopwatch. Available modes are Switch and Toggle. |
| Time UoM | Defines the unit of measure used by the Stopwatch for Partial time and Total time. |
Operation
The Stopwatch measures elapsed time and provides:
- the duration of the most recently completed interval on Partial time;
- the total accumulated elapsed time on Total time.
The exact behaviour depends on the selected Trigger policy.
The unit used for both outputs is defined by the Time UoM property.
Trigger policy - Switch
With:
Trigger policy = Switch
the Input connector directly controls whether the Stopwatch is counting or paused.
The behaviour is:
- when Input = 1, the Stopwatch starts or resumes counting;
- when Input = 0, the Stopwatch pauses;
- every time the Stopwatch pauses, Partial time is updated with the duration of the last active interval;
- Total time is updated with the total accumulated counted time.
Conceptually:
Input = 1 → Counting
Input = 0 → Pause and update outputs
In Switch mode, the Stopwatch measures the amount of time during which Input remains equal to 1.
Switch mode example
Assume:
Time UoM = Seconds
and the following sequence:
- Input = 1 for 10 seconds;
- Input = 0;
- Input = 1 for another 5 seconds;
- Input = 0.
After the first pause:
Partial time = 10
Total time = 10
After the second pause:
Partial time = 5
Total time = 15
Since Time UoM is set to Seconds, these values represent seconds.
Trigger policy - Toggle
With:
Trigger policy = Toggle
the Stopwatch reacts to rising edges on the Input connector.
A rising edge corresponds to:
0 → 1
The behaviour is:
- the first rising edge starts the Stopwatch;
- every following rising edge closes the current partial interval;
- the elapsed time between the current rising edge and the previous rising edge is sent to Partial time;
- the total elapsed time since the Stopwatch started is sent to Total time.
Conceptually:
First rising edge → Start
Next rising edge → Update Partial time and Total time
In Toggle mode, the time intervals are measured between consecutive rising edges on the Input connector.
Toggle mode example
Assume:
Time UoM = Seconds
and that the Stopwatch receives rising edges at:
- 10:00:00
- 10:00:12
- 10:00:20
The first rising edge starts the measurement.
At the second rising edge:
Partial time = 12
Total time = 12
At the third rising edge:
Partial time = 8
Total time = 20
The output values are expressed according to the configured Time UoM.
Partial time
The Partial time output represents the duration of the most recently completed measurement interval.
Its meaning depends on the selected Trigger policy.
With Switch:
Partial time = duration for which Input remained equal to 1 before returning to 0
With Toggle:
Partial time = time elapsed between two consecutive rising edges
The value is expressed in the unit selected through Time UoM.
Total time
The Total time output represents the total accumulated measured time.
With Switch, it corresponds to the sum of all intervals during which Input was equal to 1.
For example:
10 + 5 + 20 = 35
results in:
Total time = 35
The actual unit depends on the configured Time UoM.
With Toggle, Total time represents the total elapsed time accumulated from the start through the successive rising-edge intervals.
Time UoM
The Time UoM property defines the unit of measure used by the Stopwatch when calculating and returning elapsed time.
The selected unit is applied to both:
- Partial time
- Total time
For example, when:
Time UoM = Seconds
the values returned by Partial time and Total time are expressed in seconds.
Choose the Time UoM according to the time scale required by the logic that receives the Stopwatch outputs.
Reset
The Reset input immediately stops the Stopwatch.
When:
Reset = 1
the node:
- stops counting;
- sends 0 to Partial time;
- sends 0 to Total time;
- remains stopped while Reset stays equal to 1.
The Stopwatch can start counting again only after:
Reset = 0
While Reset = 1, the Stopwatch cannot start a new measurement.
Example - Reset during counting
Suppose the Stopwatch has already measured:
Total time = 45
If:
Reset = 1
the node immediately sets:
Partial time = 0
Total time = 0
and stops the current measurement.
After Reset returns to 0, the Stopwatch is ready to start a new measurement according to the selected Trigger policy.
Typical applications
The Stopwatch node is useful whenever elapsed time must be measured inside a logic scheme.
Typical applications include:
- measuring device operating time;
- measuring the duration of an active condition;
- recording machine cycle times;
- measuring occupancy durations;
- comparing partial operating intervals;
- accumulating total active time;
- measuring time between repeated events.
Verification through simulation
The Stopwatch can be tested using the Logic Module simulation tools.
A typical test procedure is the following:
- connect a digital signal to Input;
- connect a digital signal to Reset;
- configure the desired Time UoM;
- select Switch as Trigger policy;
- set Input = 1 and let the Stopwatch count for a few seconds;
- set Input = 0;
- verify the values of Partial time and Total time;
- verify that both values are expressed according to the configured Time UoM;
- repeat the sequence and verify that Partial time reports the last interval while Total time accumulates the measured time;
- switch the Trigger policy to Toggle;
- generate a first rising edge and verify that the Stopwatch starts;
- generate additional rising edges and verify the update of Partial time and Total time;
- set Reset = 1 and verify that both outputs immediately return to 0;
- return Reset to 0 and verify that a new measurement can be started.
Configuration notes
- Switch mode measures the duration of the periods during which Input = 1.
- Toggle mode measures the time between consecutive rising edges.
- Partial time always refers to the most recently completed interval.
- Total time represents the accumulated measured time.
- Time UoM defines the unit of measure used for both Partial time and Total time.
- In Toggle mode, the first rising edge starts the Stopwatch and does not yet produce a completed partial interval.
- Reset immediately stops the measurement and clears both time outputs.
- Reset must return to 0 before counting can start again.

