ServiceCounter

ServiceCounter (FB)

FUNCTION_BLOCK ServiceCounter

Short description

Signaling of maintenance

Representation

Interfaces

Inputs

Outputs

Name
Data type
Value range
Initial value
Function

dLastService

DATE

Date of the last maintenance

dNextService

DATE

Date when the next maintenance is due

xAlarm1

BOOL

Indication that maintenance is due soon

xAlarm2

BOOL

Indication that maintenance is due today

xAlarm3

BOOL

Indication that maintenance was already due

diServiceInDay

DINT

Indication of in how many days the next maintenance is due

diServiceSinceDay

DINT

Days since the last maintenance

Setpoints / parameters

Name
Data type
Value range
Initial value
Function

iAlarm1

INT

(0-diServiceInterval)…0

-10

Alarm threshold 1 in days (maintenance is due soon)

iAlarm3

INT

0…diServiceInterval

10

Alarm threshold 3 in days (maintenance was already due)

diServiceInterval

UINT

1…1825

365

Maintenance interval (in days)

xReset

BOOL

FALSE

Reset maintenance day counter

xEn

BOOL

TRUE

Enable outputs xAlarm1 to 3

Function description

General

This function block provides functionalities for signaling maintenance intervals and for resetting the counter after maintenance has been performed. The three signaling outputs can be temporarily disabled. The number of days until the next maintenance (maintenance interval) can be freely set. The number of days since the last maintenance is calculated and displayed.

Outputs xAlarm1, xAlarm2 and xAlarm3

With the setpoint / parameter xEn equal to FALSE the outputs are xAlarm1, xAlarm2 and xAlarm3 temporarily deactivated. When the next service interval expires, the setpoint / parameter is reset to the initial value TRUE. The output xAlarm1 will be TRUE when the next maintenance date is reached in less than iAlarm1 days. Because the period is before the maintenance date, the value is negative to be entered. The output xAlarm2 is TRUE when maintenance is due today (diServcieInDay <= 0). The output xAlarm3 is TRUE when the next maintenance date was at least iAlarm3 days ago. The three outputs are reset to FALSE when the maintenance day counter is reset with the setpoint / parameter xReset . The variable dLastService is overwritten with the current date.

Setpoints / parameters iAlarm1, iAlarm3 and diServiceInterval

The setpoints / parameters are provided with input limits according to the following table:

Setpoint / Parameter
Minimum value
Maximum value
Note

diServiceInterval

0

5 * diServiceInterval

Service interval

iAlarm1

(0-diServiceInterval)

0

Threshold for output xAlarm1

iAlarm2

iAlarm1

iAlarm3

Threshold for output xAlarm2

iAlarm3

iAlarm2

diServiceInterval

Threshold for output xAlarm3

The setpoint / parameter iAlarm2 cannot be changed by the user.

The setpoints / parameters are checked cyclically and limited to the corresponding limits if necessary. Any change to one setpoint / parameter can therefore cause a change to another setpoint / parameter.

circle-info

Prerequisite for the use of the ServiceCounter function block

The use of the TimeRead2 function block is required for correct operation.

CODESYS

InOut:

Scope
Name
Type
Initial

Input Const

xEn

BOOL

TRUE

Input Const

xReset

BOOL

FALSE

Input Const

diServiceInterval

UINT

365

Input Const

iAlarm3

INT

10

Input Const

iAlarm1

INT

-10

Output

dLastService

DATE

Output

dNextService

DATE

Output

xAlarm1

BOOL

Output

xAlarm2

BOOL

Output

xAlarm3

BOOL

Output

diServiceInDay

DINT

Output

diServiceSinceDay

DINT

Last updated