CounterMonitoring

CounterMonitoring (FB)

FUNCTION_BLOCK CounterMonitoring

Short description

Monitoring of a counter value 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 of 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 every 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 minimal duration of a monitoring interval

tMaxIntervall

TIME

T#7D

Absolute maximal 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 adjustable 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 at the input ‘xResetAlarm’.\

Monitoring

The cyclic monitoring interval starts if all 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 limit ‘rConsumLimit’. The output ‘xAlarm’ is reset ( = FALSE ) by any rising edge at the input ‘xResetAlarm’. The setting of the duration ‘tMonIntervall’ is determined by the set value ‘udiMonIntervall’ (absolute numeric value) in combination with ‘eScaleIntervall’ (scaling) with consideration of ‘tMinIntervall’ (absolute minimum) and ‘tMaxIntervall’ (absolute maximum). \

Displays

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 shown)\

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

\

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