ServiceCounter
ServiceCounter (FB)
FUNCTION_BLOCK ServiceCounter
Short description
Signaling of maintenance
Representation

Interfaces
Inputs
Outputs
dLastService
DATE
Date of the last maintenance
dNextService
DATE
Due date of the next maintenance
xAlarm1
BOOL
Display that maintenance is due soon
xAlarm2
BOOL
Display that maintenance is due today
xAlarm3
BOOL
Display that maintenance was already due
diServiceInDay
DINT
Display of how many days until the next maintenance is due
diServiceSinceDay
DINT
Days since the last maintenance
Setpoints / Parameters
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 the outputs xAlarm1 to 3
Function description
General
This function block provides functions for signaling maintenance intervals or for resetting the counter after maintenance has been carried out. The three outputs for signaling can be temporarily deactivated. 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 set to FALSE, the outputs xAlarm1, xAlarm2 and xAlarm3 are temporarily deactivated. When the next service interval expires, the setpoint / parameter is reset to the initial value TRUE. The output xAlarm1 will be TRUE if the next maintenance date is reached in less than iAlarm1 days. Since the period lies before the maintenance date, the value is to be entered as negative . The output xAlarm2 will be TRUE if maintenance is due today (diServcieInDay <= 0). The output xAlarm3 will be TRUE if the next maintenance date is already at least iAlarm3 days in the past. The three outputs are set back to FALSE again when the maintenance day counter is reset with the setpoint / parameter xReset . In doing so, the variable dLastService is assigned the current date.
Setpoints / Parameters iAlarm1, iAlarm3 and diServiceInterval
The setpoints / parameters are provided with input limits according to the following table:
diServiceInterval
0
5 * diServiceInterval
Service interval
iAlarm1
(0-diServiceInterval)
0
Threshold value for output xAlarm1
iAlarm2
iAlarm1
iAlarm3
Threshold value for output xAlarm2
iAlarm3
iAlarm2
diServiceInterval
Threshold value for output xAlarm3
The setpoint / parameter iAlarm2 cannot be changed by the user.
The setpoints / parameters are checked cyclically and, if necessary, limited to the corresponding limit values. Any change to a setpoint / parameter can therefore cause a change to another setpoint / parameter.
CODESYS
InOut:
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

