CounterMonitoring

CounterMonitoring (FB)

FUNCTION_BLOCK CounterMonitoring

Short description

Monitoring of a counter reading and generation of a fault message Typical application: Monitoring a water meter for exceeding a maximum consumption during a monitoring interval

Representation

Interfaces

Inputs

Name
Data type
Value range
Initial value
Function

xEn

BOOL

FALSE

Enable / disable the counter monitoring (TRUE = enabled)

rCounterValue

REAL

0.0

Current absolute counter value (e.g. meter for water volume)

xResetAlarm

BOOL

FALSE

Reset of the output 'xAlarm' (on each rising edge)

Outputs

Name
Data type
Value range
Initial value
Function

xAlarm

BOOL

FALSE

Fault message - counter monitoring (FALSE = off, TRUE = on)

tMonIntervall

TIME

Duration of a monitoring interval

tRemainIntervall

TIME

Remaining time in the monitoring interval

rConsumMax

REAL

Maximum consumption in the monitoring interval

rConsumIntervall

REAL

Current consumption in the monitoring interval

rConsumRemain

REAL

Remaining consumption in the monitoring interval before the alarm is triggered

Setpoints / parameters

Name
Data type
Value range
Initial value
Function

udiMonIntervall

UDINT

24

Duration of a monitoring interval (0 … 4294967295)

tMinIntervall

TIME

T#0s

Absolute minimum duration of a monitoring interval

tMaxIntervall

TIME

T#7D

Absolute maximum duration of a monitoring interval

eScaleIntervall

eTime

eTime.Hour

Scaling of the duration 'udiMonIntervall'

rConsumLimit

REAL

10.0

Limit value for consumption in the monitoring interval

Function description

General

This function block is used to monitor a media consumption (water, electricity, etc.) (input 'rCounterValue') during the configurable monitoring interval 'tMonIntervall'. If the consumption exceeds the maximum value for the monitoring interval 'rConsumLimit', an alarm ('xAlarm' = TRUE) is triggered. It can be reset by a rising edge on the input 'xResetAlarm'.

Monitoring

The cyclic monitoring interval starts if all of the following conditions are met simultaneously:

  1. 'xEn' = TRUE

  2. 'rConsumLimit' > 0.0

  3. 'tMonIntervall' >= T#60s

The cyclic monitoring interval is terminated if at least one of these conditions is no longer met. At the start of each monitoring interval the current counter value 'rCounterValue' is stored as the start value. During the monitoring interval the difference between the current counter value and the start value is continuously calculated (rConsumIntervall). The output xAlarm is activated (= TRUE) whenever this difference exceeds the threshold rConsumLimit. The output xAlarm is reset (= FALSE) by each rising edge at the input 'xResetAlarm'. The setting of the duration 'tMonIntervall' is made by the set values 'udiMonIntervall' (absolute numeric value) in combination with 'eScaleIntervall' (scaling) taking into account 'tMinIntervall' (absolute minimum) and 'tMaxIntervall' (absolute maximum).

Indicators

The following outputs are available to display the current operating status:

  1. xAlarm Fault message - counter monitoring (FALSE = off, TRUE = on)

  2. tMonIntervall Duration of a monitoring interval

  3. tRemainIntervall Remaining time in the monitoring interval

  4. rConsumMax Maximum consumption in the monitoring interval (identical to rConsumLimit)

  5. rConsumIntervall Current consumption in the monitoring interval (only consumptions >= 0.0 are displayed)

  6. rConsumRemain Remaining consumption in the monitoring interval before the alarm is triggered (only consumptions >= 0.0 are displayed)

Locking of the block (xEn = FALSE)

These outputs take the following fixed states:

  1. xAlarm FALSE

  2. tMonIntervall T#0s

  3. tRemainIntervall T#0s

  4. rConsumMax 0.0

  5. rConsumIntervall 0.0

  6. rConsumRemain 0.0

CODESYS

InOut:

Scope
Name
Type
Initial

Input

xEn

BOOL

TRUE

Input

rCounterValue

REAL

0.0

Input

xResetAlarm

BOOL

FALSE

Input Const

rConsumLimit

REAL

10.0

Input Const

eScaleIntervall

eTime

eTime.Hour

Input Const

tMaxIntervall

TIME

TIME#10080m0s0ms

Input Const

tMinIntervall

TIME

TIME#0ms

Input Const

udiMonIntervall

UDINT

24

Output

xAlarm

BOOL

Output

tMonIntervall

TIME

Output

tRemainIntervall

TIME

Output

rConsumMax

REAL

Output

rConsumIntervall

REAL

Output

rConsumRemain

REAL

Last updated