Maintenance Inspector
Regular price
€450,00 EUR
Regular price
Sale price
€450,00 EUR
Unit price
per
Couldn't load pickup availability
Description
Maintenance_FB scales and filters a process value, automatically learns 10 maximum values over tick cycles, calculates an average from them, and monitors deviations during operation with regard to tolerance and time window. A sliding error FIFO (10 slots) and thresholds for warning and error ranges enable robust diagnostics. Latches, plaintext, and timestamps are managed in the diagnostic UDT.
Note: Module for process diagnostics/quality assurance. Not a safety-related function.
How it works
1) Scaling & Filtering
-
Scaling:
ValueRaw = ValueRaw_in * Gain + Offset
from#P.UDT_ChannelParams
. -
IIR filter: If
FilterTime > 0
, then simple 1st order filter withα = 1/8
:yFilt := yFilt + (ValueRaw - yFilt) * 0.125
; otherwiseValueFiltered = ValueRaw
. - Metadata:
ChannelName
andUnitText
are taken from the parameters in the diagnosis.
2) Reset
- Sets learning and error index to 1, empties arrays
LearnValues[1..10]
/ErrValues[1..10]
, clears counters and latches. - Diagnostic fields are specifically reset (ASCII text: Reset ), current measured values are retained;
LastErrorDT := NowDT
.
3) Learning (10 ticks)
-
Max-Sampler: While
#Learn
is active and at every#Tick
-High the maximum ofValueFiltered
is collected. -
Tick falling edge: If
NOT Tick AND Tick_old
the maximum value is written toLearnValues[LearnIndex]
;LearnIndex
is incremented. - After 10 entries the mean value is calculated (
MeanValue
),Learned := TRUE
, Status: Learning completed .
4) Error detection (online)
-
Deviation counter: If
|ValueFiltered - MeanValue| > Tolerance
, thenTimeOutCnt
++; otherwise set to 0. -
FIFO update on tick falling edge:
-
ErrValues[ErrIndex] := (TimeOutCnt ≥ ErrorWindow)
;ErrIndex
rotates from 1 to 10. -
ErrCount
= Number of TRUE inErrValues
. -
Error Latch: If
ErrCount ≥ ErrorThreshold
and not yet latched ⇒ErrorLatched := TRUE
,ErrorActive := TRUE
,ErrorCode := 1001
, Status: Error detected ,LastErrorDT := NowDT
.
-
5) Auto-reset in warning area
- Warning condition:
ErrCount > 0
andErrCount < ErrorThreshold
. - TON
WarnResetTime
: After expiration, FIFO, counters and latches are reset; Status: Warning area reset .
6) Status maintenance
- If
Learned = FALSE
⇒ Status: Learning active . - If
ErrorActive = TRUE
⇒ status remains Error detected . - Otherwise ⇒ Status: OK .
- Edge detection:
Tick_old := Tick
at cycle end.
Technical details
-
Inputs/Signals:
#ValueRaw
,#Tick
,#Reset
,#Learn
,#NowDT
. -
Parameters (
#P.UDT_ChannelParams
):Name
,UnitText
,Gain
,Offset
,FilterTime
,Tolerance
,ErrorWindow
,ErrorThreshold
,WarnResetTime
. -
Diagnostic UDT (
#D.KanalDiagnose
):ChannelName
,UnitText
,ValueRaw
,ValueFiltered
,MeanValue
,Learned
,ErrorActive
,ErrorCount
,ErrorCode
,StatusText
,LastErrorDT
. -
Internal variables:
yFilt
,LearnValues[1..10]
,ErrValues[1..10]
,LearnIndex
,ErrIndex
,ErrCount
,TimeOutCnt
,MaxValue
,MeanValue
,Tick_old
,ErrorLatched
,sum
,warnCond
,tonWarnReset
.
Diagnosis & plain texts
- Reset (reset performed)
- Training active (not yet 10 samples)
- Training completed (average calculated)
- Warning area reset (auto-reset)
-
Error detected (Latch active,
ErrorCode=1001
) - OK (operation without errors)
Possible applications
- Sensor/channel monitoring with learning-based reference value
- Detection of creeping drifts via FIFO windows
- HMI-friendly diagnostics including latch and timestamp
- Advance warning with automatic reset
compatibility
- Siemens TIA Portal V16 (S7-1200/1500), SCL
- Testable with PLCSIM
Scope of delivery
- SCL block ChannelDiag_LearnAvg_FB according to the above specification
- Parameterization UDT and diagnostic UDT (field assignments compatible with the code)
- Quick guide & integration notes
Support
- Adjusting window size, filter alpha and learning logic
- Extension to more samples or moving average
- HMI messages/language switching (ASCII/UTF-8)
- Trend/CSV logging of learning/online values