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 of 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 the stopwatch

Outputs

Name
Data type
Value range
Initial value
Function

tMeasured

TIME

0 days

0 … 10 days

Time measured before the last measurement

tElapsed

TIME

0 … 10 days

Time duration measured since the last reset

xTimeError

BOOL

Display 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 must be at most 14400 minutes (= 10 days) and at least 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 reaction to an edge on 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 increases again continuously. 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).

State

xTimeError

no malfunction

FALSE

Measurement time greater than / equal to 14400 minutes

TRUE

Measurement 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