StopWatchExt

StopWatchExt (FB)

FUNCTION_BLOCK StopWatchExt

Short description

Measurement of time intervals with plus/minus input and reset capability. Display of the total time (tElapsed) and the total time before the last measurement (tMeasured).

Representation

Interfaces

Inputs

Name
Data type
Value range
Initial value
Function

xUp

BOOL

Enable increase of the measured time

xDown

BOOL

Enable decrease of the measured time

xReset

BOOL

Reset of the stopwatch

Outputs

Name
Data type
Value range
Initial value
Function

tMeasured

TIME

0 days

0 … 10 days

Measured time before the last measurement

tElapsed

TIME

0 … 10 days

Measured duration since the last reset

xTimeError

BOOL

Indication of a stopwatch error

Function description

General

This function block is used to measure individual time intervals. The counter value is increased if the input xUp is active. The counter value is decreased if the input xDown is active. The input xUp has priority over the input xDown. The sum of the measured time intervals is shown at the output tElapsed . The sum of the measured time intervals before the last measurement is shown at the output tMeasured . The sum of the measured time intervals may be a maximum of 14400 minutes (= 10 days) and a minimum of 0 minutes. Any rising edge on the reset input (xReset = FALSE / TRUE) resets the outputs tElapsed and tMeasured to FALSE regardless of the other states. If measurement is not enabled (xUp = FALSE and xDown = FALSE) the outputs tElapsed and tMeasured are not changed.

Different reactions to an edge at the reset input xReset

Input xUp = TRUE: Each edge on the reset input resets the outputs tElapsed and tMeasured to 0. Afterwards the counter value immediately begins to increase continuously again. Input xDown = TRUE: Each edge on the reset input resets the outputs tElapsed and tMeasured to 0. The counter value does not change. The error indication xTimeError is activated as long as the input xDown remains TRUE in this state.

Error indication xTimeError

It is used to indicate functional errors (xTimeError = TRUE).

Status

xTimeError

no malfunction

FALSE

Measured time greater than / equal to 14400 minutes

TRUE

Measured time less than 1 ms and input xDown = TRUE

TRUE

CODESYS

InOut:

Scope
Name
Type

Input

xUp

BOOL

Input

xDown

BOOL

Input

xReset

BOOL

Output

tMeasured

TIME

Output

tElapsed

TIME

Output

xTimeError

BOOL

Last updated