STPWATCH: Stop watch
The STPWATCH (FB410) block determines the time difference between an increasing slope at start input and a decreasing slope at stop input.
Functionality
The block determines the time difference between an increasing slope at start input [Stt] and a decreasing slope at stop input [Stp]. The time difference is available for further processing after the measurement at output [Out]. Output [Out] always contains the last valid measured value for time.
Furthermore, output [TiEld] is available indicating the currently accrued time. This output primarily is used for testing during commissioning.
The entire functionality can be disabled at input [EnFnct]: If [EnFnct] = 0 (No), no new time measurement is carried out.
Output value [Out] is saved remanent, an old value is thus available after startup.
Special cases:
- With [EnFnct] = 0 (No), all current time measurements are reset. [Stt] and [Stp] are ignored.
- Further [Stt] pulses during the active time measurement reset time measurement and restart it; the stopped measured is invalid.
- Further [Stp] pulses during a measurement break are ignored.
- Output [Out] contains a new value only when the measurement is complete, i.e. [EnFnct] was 1 (Yes) during the entire measurement and a [Stt] pulse was first available and then a [Stp] pulse.
- Output [TiEld] is active as soon as measurement starts, i.e. also for incomplete measurements. If no measurement is active, [TiEld] = 0.
- If an increasing slope occurs simultaneously at [Stt] and [Stp], the stop input is processed before the start input within the same cycle. Thus, the current measurement is ended and becomes valid, and a new measurement starts.
Example for a time-related process of input and output signals:

Explanation:
- Start pulse 1 is invalid, as [EnFnct] = 0 (No).
- Start pulse 2 is valid, stop pulse 1 is also valid. This results in a valid measurement Meas.1. The time value of Meas.1 is assumed in [Out].
- Stop pulse 2 is ignored, as it is in a measurement pause.
- Start pulse 3 is valid, but not followed by a stop pulse. Measurement Meas.2 is invalid, but the value is not assumed in [Out].
- Start pulse 4 is valid. It stops measurement Meas.2 and starts Meas.3. Stop pulse 3 is valid. Measurement Meas.3 is valid, and the value is assumed in [Out].
- Start pulse 5 is valid, but is interrupted by a stop by [EnFnct] = 0 (No). Measurement Meas.2 is invalid, and the value is not assumed in [Out].
- Start pulse 6 and stop pulse 4 are invalid, as [EnFnct] = 0 (No).
- Start pulse 7 and stop pulse 5 are valid and result in valid measurement 5, assumed in [Out].
- Start pulse 8 and stop pulse 6 arrive at the same time, but are first evaluated as stop pulse and then as start pulse. The stop pulse is ignored, as no previous start occurred. The start pulse starts measurement Meas.6. This measurement is completed by stop pulse 7 arriving at the same time as start pulse 9. Measurement 6 is valid, and is assumed in [Out].
- Measurement Meas.7 is started at the same time. This measurement is completed by stop pulse 8 arriving at the same time as start pulse 10. Measurement 7 is valid, and is assumed in [Out].
- Measurement Meas.8 is started at the same time. This measurement is interrupted by [EnFnct] = 0 (No) and is invalid.
Inputs
Pin | E | Description |
EnFnct | p | Enable function. 1 (Yes): The function is enabled. 0 (No): The function is disabled. |
Stt | pa | Start. |
Stp | pa | Stop |
Outputs
Pin | E | Description |
Out | fx | Output. |
TiEld | a | Elapsed time. |
Input values
Pin | Description | Data type | Default value | E.g. Engineering unit or Text group | Min. | Max. |
EnFnct | Enable function. | Boolean | 1 (Yes) | No, Yes |
|
|
Stt | Start. | Boolean | 0 (No) | No, Yes |
|
|
Stp | Stop | Boolean | 0 (No) | No, Yes |
|
|
Output values
Pin | Description | Data type | Default value | E.g. Engineering unit or Text group | Min. | Max. |
Out | Output. | Time | T#0D_0H_0M_0S_0MS | T#0D_0H_0M_0S_0MS |
|
|
TiEld | Elapsed time. | Time | T#0D_0H_0M_0S_0MS | T#0D_0H_0M_0S_0MS |
|
|
Application
The start and stop inputs allow for measuring runtimes between two different events, e.g. damper runtime between end switch "closed" and "open", or pause time of a pump between switch-off and the next switch-on (stop time with two buttons).
If the time between two identical events must be measured, e.g. the time between two switch-on events, this can be implemented by sending the event to both the stop input and the start input (timer with 1 button).
Process response
The block is processed with the values at the inputs from the third process cycle onward, as the values at the inputs are considered valid only then. [TiEld] = 0 is issued during the first two process cycles.
From the first process cycle, the remanently saved value is issued at [Out].
Troubleshooting
Standard (see General rules and information).