Residual-Based Leak Detection and Severity Monitoring Using a PLC-Embedded Neural Observer for a Coupled-Tank System

Residual-Based Leak Detection and Severity Monitoring Using a PLC-Embedded Neural Observer for a Coupled-Tank System

S. Mangkalajan | T. Sangsuwan* | W. Koodtalang | W. Wongsaroj | N. Thong-un | A. Pongmanee

Department of Instrumentation and Electrical Energy Engineering, Faculty of Engineering, King Mongkut’s University of Technology North Bangkok, Bangkok 10800, Thailand

Center of Excellence on Instrumentation Technology and Automation, King Mongkut’s University of Technology North Bangkok, Bangkok 10800, Thailand

School of Electrical and Computer Engineering, Institute of Engineering, Suranaree University of Technology, Nakhon Ratchasima 30000, Thailand

Corresponding Author Email: 
thaksin.s@eng.kmutnb.ac.th
Page: 
2621-2640
|
DOI: 
https://doi.org/10.18280/jesa.590916
Received: 
7 July 2026
|
Revised: 
16 September 2026
|
Accepted: 
22 September 2026
|
Available online: 
30 September 2026
| Citation

© 2026 The authors. This article is published by IIETA and is licensed under the CC BY 4.0 license (http://creativecommons.org/licenses/by/4.0/).

OPEN ACCESS

Abstract: 

This study presents a residual-monitoring framework resident in a programmable logic controller (PLC) for leak detection, location indication, and severity assessment in a cascade-controlled coupled-tank process. A compact 4–6–4–2 multilayer perceptron (MLP) with 68 trainable parameters was trained offline using leak-free data and deployed in a Siemens S7-1200 PLC to estimate nominal upper- and lower-tank levels. Cascade proportional–integral (PI) control ran every 50 ms, while neural monitoring operated every 500 ms. The selected MLP required only 0.84 ms mean and 0.92 ms maximum inference time, providing ample computational margin. Measured–predicted residuals were processed using exponential moving average (EMA) filtering, adaptive baseline thresholds, stable-condition verification, and persistence confirmation. Calibrated two-channel residual signatures indicated leak location, while operating-region-dependent boundaries classified severity as Small, Medium, or Large. Independent test data yielded upper- and lower-tank root mean square error (RMSE) values of 0.1618 and 0.1612 cm. Experiments at 13 and 17 cm comprised 140 trials. Binary detection achieved 92.86% accuracy, 92.50% sensitivity, and 95.00% specificity. Among 111 confirmed leaks, conditional location and severity accuracies were 92.79% and 90.99%. End-to-end location and severity accuracies over all 120 leak trials were 85.83% and 84.17%, while 82.50% received both correct labels. The exact seven-class accuracy was 84.29%. Mean true-positive alarm delays were 4.57 ± 0.71 s at 17 cm and 4.83 ± 0.84 s at 13 cm.

Keywords: 

coupled-tank system, leak detection, neural observer, programmable logic controller, residual monitoring

1. Introduction

Leakage remains a persistent concern in industrial fluid systems, water-distribution networks, storage facilities, and process plants because it can compromise operational reliability, increase maintenance demand, cause environmental losses, and reduce process efficiency [1-4]. In particular, even minor leakage may progressively increase energy demand, disturb normal operating behavior, and create subtle deviations that are difficult to distinguish during on-line operation [5, 6]. Therefore, timely leak detection is important for limiting fluid losses, supporting safe and reliable plant operation, and reducing the risk of unplanned maintenance or production interruptions [6-8].

Within this context, coupled-tank systems (CTS) are widely used as representative benchmark processes in liquid-level control and fault-diagnosis studies because they exhibit nonlinear flow behavior, inter-tank coupling, disturbance sensitivity, and multivariable interactions that resemble practical fluid processes [9-12]. More specifically, these characteristics are relevant to interconnected liquid-storage and transfer applications in wastewater treatment, chemical processing, food processing, and related industries [12]. However, parameter variations and hydraulic disturbances can adversely affect level regulation and closed-loop stability, making reliable fault monitoring particularly important [12, 13]. Accordingly, leak-flow estimation and fault diagnosis have been investigated to improve monitoring performance and support safe operation of coupled liquid processes [14, 15].

From an implementation perspective, programmable logic controllers (PLCs) are widely used in industrial automation because of their robustness, modularity, deterministic cyclic execution, and reliable operation in industrial environments [16]. PLC-based systems are commonly employed for process control, liquid-level regulation, communication-enabled monitoring, and real-time implementation [17, 18]. Algorithms deployed on PLCs must comply with scan-cycle timing and limited memory and computational resources [19, 20]. In response to these implementation constraints, recent studies have demonstrated the feasibility of PLC- and edge-PLC-based fault diagnosis and embedded neural-network inference for nonlinear processes [20-22]. These developments motivate implementing lightweight leak-monitoring functions directly within the industrial control layer.

From a diagnostic perspective, conventional leak-detection methods commonly use pressure and flow measurements, model-based estimation, acoustic sensing, and decision-rule-based monitoring [23-25]. Pressure- and acoustic-signal-based methods can provide sensitive indications of leakage, particularly for small fault conditions [23, 25]. However, their practical application may be affected by measurement noise, non-stationary signals, signal-processing requirements, and additional sensing infrastructure [25, 26]. In addition, variations in operating conditions and production loads can reduce the reliability of fixed decision rules and complicate leak detection under transient conditions [27, 28]. To address these limitations, machine-learning (ML) and AI techniques have increasingly been applied to leak detection, classification, localization, and leak-size estimation. Artificial neural network (ANN)-based approaches have been used for pipeline leak diagnosis [29], while support vector machine (SVM)-based methods have been reported for leak detection in cylindrical storage tanks [30]. Long short-term memory–fully convolutional networks (LSTM–FCNs) have been developed using high-frequency pressure measurements for water-network leakage diagnosis [31], and physics-informed neural networks have been applied to multiphase leak detection, localization, and size estimation [32]. Convolutional neural network (CNN)-based methods have also been investigated for pipeline leak detection and localization [33]. Moreover, hybrid deep-learning approaches combining wavelet denoising with LSTM-transformer models [34] or acoustic-emission signals with CNN-LSTM architectures [35] have demonstrated the value of temporal and time-frequency information. In addition to these deep-learning approaches, time-domain statistical features [36] and acoustic-emission analysis [37] have likewise been used to enhance leak-sensitive signal representation. Related work has also investigated neural-network-based dynamic threshold generation for fault detection in interacting-tank processes [38].

Despite these advances, applying data-driven leak diagnosis to CTS remains challenging because nonlinear inter-tank flow, parameter sensitivity, measurement uncertainty, and operating variations complicate accurate state estimation [9-13]. In this context, observer- and residual-based approaches address this issue by comparing measured process outputs with estimated system behavior. High-gain observer theory has been extensively studied for nonlinear state estimation [39], whereas extended Kalman filtering, dual-observer schemes, and neuro-fuzzy Kalman-filtering methods have been applied to leakage and fault diagnosis in fluid and pipeline systems [40-42]. At the implementation level, ANN-based fault diagnosis has also been demonstrated on a real level-control system connected through an industrial fieldbus network [43]. However, the reported studies pursue different objectives and impose different implementation burdens. Recent coupled-tank and liquid-level studies emphasize control, fault estimation, or laboratory diagnosis [14, 15], whereas PLC and edge-PLC studies establish that embedded intelligent functions are feasible but do not integrate the complete leak-monitoring chain considered here [20-22]. Deep models using pressure or acoustic data offer strong pattern recognition but typically require labelled fault datasets and an external or dedicated inference path [29, 31-35]. Classical nonlinear observers retain a clear physical interpretation but require explicit hydraulic models, reliable parameters, and observer tuning [39-42]. Therefore, the unresolved system-automation gap is the integration of resource-bounded PLC-resident nominal prediction, residual generation, transient-aware confirmation, location indication, severity assessment, and operator visualization while the same controller continues deterministic closed-loop operation.

To address this gap, this paper proposes a residual-based leak detection and severity monitoring framework using a PLC-embedded neural observer for a coupled-tank system. Specifically, a compact multilayer perceptron (MLP) is trained offline using normal operating data and deployed as PLC-resident structured control language (SCL) logic to predict the upper- and lower-tank levels during operation. These predictions provide reference values for identifying deviations from normal system behavior. Subsequently, leak-sensitive residuals are obtained from the differences between measured and predicted levels. The decision logic combines exponential moving average (EMA) filtering, baseline-derived thresholds, stable operating-condition verification, and temporal confirmation to improve robustness against measurement noise and transient changes. These measures help distinguish persistent leak-related deviations from temporary operating fluctuations. Following leak confirmation, residual magnitude is used to classify leak severity, while a calibrated signature formed from the signed and magnitude residual channels provides an upper- or lower-tank location indication. Importantly, the complete monitoring function operates concurrently with cascade proportional–integral (PI) control, analog signal acquisition, and human–machine interface (HMI)-based alarm handling rather than as an external post-processing module. This arrangement allows leak monitoring to be integrated directly into the existing PLC control environment. Accordingly, the main contributions of this work are summarized as follows:

(1) Development and PLC deployment of a compact leak-free-data MLP observer for real-time prediction of coupled-tank levels under explicit execution and memory constraints.

(2) Integration of nominal prediction, residual filtering, adaptive baseline thresholds, stable-condition verification, and temporal confirmation as an auditable PLC-resident monitoring chain.

(3) Co-scheduling of cascade control at 50 ms and leak monitoring at 500 ms within the same PLC, with HMI-based diagnostic outputs and no external inference computer.

(4) Integrated detection, upper/lower location indication, and physically calibrated Small/Medium/Large severity assessment within one lightweight automation module.

(5) Experimental validation on a physical coupled-tank system using separate calibration and repeated-event datasets, with conditional and end-to-end metrics reported explicitly.

The remainder of this paper is organized as follows. Section 2 presents the experimental platform, the PLC implementation, and the neural observer in detail. Section 3 describes the residual-based monitoring method. Section 4 reports the experimental results and the performance evaluation, while Section 5 concludes the study and outlines future work.

2. System Description and PLC-Based Neural Observer Design

2.1 Coupled-tank system description

For experimental validation, a real-time Quanser coupled-tank system was used to investigate nonlinear level dynamics, hydraulic coupling, and leak-monitoring performance. As shown in Figure 1, the platform includes vertically connected upper and lower tanks, a variable-speed pump, level sensors, a Siemens S7-1200 PLC, an HMI, an SM1234 analog input/output (I/O) module, and a VoltPAQ-X1 signal-conditioning interface. Water is pumped to the upper tank and then flows to the lower tank through the interconnecting path, producing coupled nonlinear behavior. Both tank levels are continuously measured and transmitted to the PLC.

Figure 1. Real-time Quanser coupled-tank systems (CTS) experimental platform

Within this platform, the PLC performs cascade PI control, signal acquisition, neural-observer inference, residual evaluation, and leak-monitoring logic. The HMI displays the measured and estimated levels, control variables, residuals, and alarm states. Dedicated upper- and lower-tank leak ports were used to introduce controlled disturbances and assess the ability of the proposed PLC-resident framework to distinguish persistent leakage from normal closed-loop operation. From an automation perspective, control and diagnostic functions are executed as separate PLC tasks while using common process signals. The 50 ms control loop remains solely responsible for pump actuation, whereas the 500 ms monitoring task updates residuals, alarm status, leak location, and severity for HMI supervision. Hence, diagnostic processing does not interfere with the control action. Moreover, all monitoring calculations are performed within the PLC, avoiding reliance on external asynchronous computation.

2.2 PLC-based residual monitoring architecture

Figure 2 illustrates the PLC-based architecture used to integrate cascade-level control, neural-level prediction, and residual-based leak monitoring for the coupled-tank platform described in Section 2.1. The Siemens S7-1200 PLC performs two coordinated functions: a cascade PI control layer for closed-loop level regulation and a residual monitoring layer for leak assessment. Importantly, the monitoring function operates in parallel with the control task and does not modify the underlying control structure. The coupled-tank process operates in continuous time, where ${{h}_{u}}$(t) and ${{h}_{l}}$(t) denote the upper- and lower-tank liquid levels, respectively. After signal conditioning and analog acquisition, the level measurements are sampled by the PLC and represented in discrete time as

${{h}_{u}}\left( k \right)={{h}_{u}}\left( k{{T}_{s}} \right)$                           (1)

${{h}_{l}}\left( k \right)={{h}_{l}}\left( k{{T}_{s}} \right)$                               (2)

where, Ts is the sampling period and k is the discrete-time index. The PLC-generated pump command ui(k) is converted through the analog output interface to drive the pump. Accordingly, the hydraulic behavior of the coupled-tank process can be expressed using mass-balance relationships:

 ${{A}_{u}}\frac{d{{h}_{u}}\left( t \right)}{dt}={{q}_{p}}\left( t \right)-{{q}_{ul}}\left( t \right)-{{q}_{Lu}}\left( t \right)$                    (3)

${{A}_{l}}\frac{d{{h}_{l}}\left( t \right)}{dt}={{q}_{ul}}\left( t \right)-{{q}_{o}}\left( t \right)-{{q}_{Ll}}\left( t \right)$                          (4)

where, Au and Al are the cross-sectional areas of the upper and lower tanks, respectively; qp(t) is the pump inflow; qul(t) is the inter-tank flow; and qo(t) is the lower-tank outlet flow. The terms qLu(t) and qLl(t) represent leak flows from the upper and lower tanks. For gravity-driven flow through a small leak opening, the leak flows are represented by

${{q}_{Lu}}\left( t \right)={{C}_{d}}{{a}_{Lu}}\sqrt{2g{{h}_{u}}\left( t \right)}$                     (5)

${{q}_{Ll}}\left( t \right)={{C}_{d}}{{a}_{Ll}}\sqrt{2g{{h}_{l}}\left( t \right)}$                               (6)

where, Cd is the discharge coefficient, g is the gravitational acceleration, and aLu and aLl are the equivalent leak areas. Under normal operation, these terms are negligible. By contrast, when a controlled leak is introduced, the additional level-dependent outflow changes the nominal hydraulic response and causes deviations between the measured and predicted tank levels. In the cascade PI layer, the outer loop regulates the lower-tank level according to the reference hsp(k). The outer-loop error is given by

${{e}_{o}}\left( k \right)={{h}_{sp}}\left( k \right)-{{h}_{l}}\left( k \right)$                        (7)

The outer PI controller generates the intermediate reference uo(k) for the upper tank. The inner-loop error is then calculated as

${{e}_{i}}\left( k \right)={{u}_{o}}\left( k \right)-{{h}_{u}}\left( k \right)$                    (8)

The inner PI controller produces the pump command ui(k). This cascade arrangement regulates the lower-tank level while accounting for the coupled hydraulic response of the upper tank. Meanwhile, the residual-monitoring layer receives buffered process and control variables from the PLC. To ensure causal execution and temporal alignment, the neural observer uses closed-loop variables from the preceding monitoring instant. The observer input vector is therefore defined as:

$x\left( k-1 \right)={{\left[ {{e}_{o}}\left( k-1 \right){{e}_{i}}\left( k-1 \right){{u}_{o}}\left( k-1 \right){{u}_{i}}\left( k-1 \right) \right]}^{T}}$                     (9)

Figure 2. PLC-based residual monitoring architecture for the coupled-tank system

After normalization using the stored training parameters, the delayed input vector is processed by the PLC-embedded MLP to generate the one-step-ahead nominal tank-level estimates at the current monitoring instant:

$\hat{h}\left( k|k-1 \right)={{f}_{MLP}}\left( x\left( k-1 \right)\text{; }\!\!\Theta\!\!\text{ } \right)$                (10)

where, Θ denotes the stored MLP weights and biases. The notation $\hat{h}$(k|k–1) indicates that the tank levels at monitoring instant k are predicted using information available at instant k−1. For compactness, $\hat{h}$(k|k–1) is denoted by $\hat{h}$(k) hereafter. The observer output is expressed as:

$\hat{h}(k)=\left[\hat{h}_u(k) \hat{h}_l(k)\right]^T$                      (11)

where, ${{\hat{h}}_{u}}\left( k \right)$ and ${{\hat{h}}_{l}}\left( k \right)$ are the predicted upper- and lower-tank levels, respectively. The detailed MLP structure, model selection, training procedure, and PLC deployment are presented in Sections 2.3–2.5. Based on these estimates, the measured and predicted levels are compared to generate the residual vector:

$r\left( k \right)=h\left( k \right)-\hat{h}\left( k|k-1 \right)$                                  (12)

where

$h\left( k \right)={{\left[ {{h}_{u}}\left( k \right){{h}_{l}}\left( k \right) \right]}^{T}}$                        (13)

and

$r\left( k \right)={{\left[ {{r}_{u}}\left( k \right){{r}_{l}}\left( k \right) \right]}^{T}}$                     (14)

Thus, the individual residuals are obtained as

$r_u(k)=h_u(k)-\hat{h}_u(k \mid k-1)$                  (15)

  ${{r}_{l}}\left( k \right)={{h}_{l}}( k )-{{\hat{{h}}\,}_{l}}\left( k|k-1 \right)$                (16)

where, ru(k) and rl(k) are the residuals associated with the upper and lower tanks, respectively. During leak-free operation, the MLP estimates both tank levels with limited mismatch, whereas leakage introduces sustained residual deviations through additional outflow. The monitoring logic therefore evaluates filtered residuals against baseline thresholds under stable conditions and confirms persistent exceedance over a prescribed interval. After confirmation, residual magnitude determines severity, while the calibrated two-channel signature indicates the leak location on the HMI.

2.3 Lightweight multilayer perceptron neural observer design

The neural observer is implemented as a lightweight MLP to estimate the nominal upper- and lower-tank levels during closed-loop operation. Instead of directly classifying leaks, it generates nominal level estimates for residual calculation. A compact architecture is adopted to preserve deterministic PLC execution alongside signal acquisition, cascade PI control, residual processing, and HMI communication. As shown in Figure 3, the network comprises an input layer, two hidden layers, and an output layer, with the general configuration expressed as

$M:{{n}_{x}}-{{n}_{h1}}-{{n}_{h2}}-{{n}_{y}}$                   (17)

where, nx, nh1, nh2, and ny denote the numbers of neurons in the input, first hidden, second hidden, and output layers, respectively. In this work, nx = 4 corresponds to the closed-loop variables {eo(k–1), ei(k–1), uo(k–1), ui(k–1)}, whereas ny = 2 represents the predicted upper- and lower-tank levels. The hidden-layer dimensions are evaluated during the offline model-selection procedure in Section 2.4. Within this formulation, for each network layer, the pre-activation vector and layer output are calculated as

 ${{z}^{\left( j \right)}}\left( k \right)={{W}^{\left( j \right)}}{{a}^{\left( j-1 \right)}}\left( k \right)+{{b}^{\left( j \right)}}$                  (18)

${{a}^{\left( j \right)}}\left( k \right)=\phi \left( {{z}^{\left( j \right)}}\left( k \right) \right)$                (19)

where, W(j) and b(j) are the weight matrix and bias vector of layer j, respectively. The vector z(j)(k) represents the weighted-sum, or pre-activation, vector formed from the output of the preceding layer.

Figure 3. Lightweight multilayer perceptron (MLP) neural observer architecture

The vector a(j)(k) denotes the output of layer j, and ϕ(⋅) is the activation function. Hyperbolic tangent activation is applied in the hidden layers to represent the nonlinear relation between the closed-loop variables and the coupled-tank levels. The input to the first hidden layer is defined as:

${{a}^{\left( 0 \right)}}\left( k \right)={{x}_{n}}\left( k \right)$                 (20)

where, xn(k) is the normalized observer input. Each input variable is normalized using the statistics obtained from the normal training data:

${{x}_{n,i}}\left( k \right)=\frac{{{x}_{i}}\left( k \right)-{{\mu }_{x,i}}}{{{\sigma }_{x,i}}},i\in \left\{ 1,...{{n}_{x}} \right\}$                    (21)

where, xi(k) is the i-th input variable, while μx,i and σx,i are its corresponding mean and standard deviation. Because the observer performs continuous level estimation, the output layer uses a linear activation function. The normalized predicted-level vector is obtained as:

${{\hat{h}}_{n}}\left( k \right)={{W}^{\left( 3 \right)}}{{a}^{\left( 2 \right)}}\left( k \right)+{{b}^{\left( 3 \right)}}$                   (22)

where, W(3) and b(3) are the output-layer weights and biases. The predicted values are then converted to physical level units as:

${{\hat{h}}_{i}}\left( k \right)={{\hat{h}}_{n,i}}\left( k \right){{\sigma }_{h,i}}+{{\mu }_{h,i}},i\in \left\{ u,~l \right\}$                         (23)

where, μh,i and σh,i are the output normalization parameters for the corresponding tank level. Accordingly, the total number of trainable parameters is:

${{N}_{p}}=\left( {{n}_{x}}+1 \right){{n}_{h1}}+\left( {{n}_{h1}}+1 \right){{n}_{h2}}+\left( {{n}_{h2}}+1 \right){{n}_{y}}$                (24)

Based on these considerations, the final architecture was selected based on prediction accuracy, nominal residual variation, parameter count, and PLC implementation feasibility. The resulting estimates, ${{\hat{h}}_{u}}\left( k \right)$ and ${{\hat{h}}_{l}}\left( k \right)$, were then used for residual generation and subsequent leak detection, location indication, and severity classification.

2.4 Offline training and model selection

Offline training was performed using leak-free closed-loop data collected from the physical Quanser CTS. The lower-tank reference alternated between 13 and 17 cm every 200 s for 10 cycles. PLC variables were logged via Modbus TCP at 250 ms and downsampled to the 500-ms monitoring interval. Each input–target pair consisted of x(k−1) and h(k), separated by one monitoring interval. To preserve temporal separation and prevent data leakage, complete set-point segments were divided into training, validation, and test sets in proportions of approximately 70%, 15%, and 15%, respectively. Moreover, inputs and targets were standardized using statistics obtained exclusively from the training set. All models used tanh hidden layers, a linear output layer, Adam optimization (η = 0.001, L2 = 10−4), a batch size of 512, and 200 training epochs. The validation set was used for architecture selection, whereas the test set was reserved for final evaluation.

For architecture comparison, four lightweight MLP configurations were considered: 4–4–4–2, 4–6–4–2, 4–6–6–2, and 4–8–8–2. These structures provided increasing representation capacity while remaining suitable for PLC implementation. Their performance was assessed using root mean square error (RMSE), mean absolute error (MAE), residual standard deviation (SD), coefficient of determination, parameter count, multiply–accumulate (MAC) count, nominal-trial alarm flags, false alarm rate (FAR) and PLC execution time.

$RMS{{E}_{i}}=\sqrt{\frac{1}{N}\mathop{\sum }_{k=1}^{N}{{\left( {{h}_{i}}\left( k \right)-{{{\hat{h}}}_{i}}\left( k \right) \right)}^{2}}}$                 (25)

$MA{{E}_{i}}=\frac{1}{N}\mathop{\sum }_{k=1}^{N}\left| {{h}_{i}}\left( k \right)-{{{\hat{h}}}_{i}}\left( k \right) \right|$                     (26)

${{\sigma }_{r,i}}=\sqrt{\frac{1}{N-1}\mathop{\sum }_{k=1}^{N}{{\left( {{r}_{i}}\left( k \right)-{{{\bar{r}}}_{i}} \right)}^{2}}}$                   (27)

$R_{i}^{2}=1-\frac{\mathop{\sum }_{k=1}^{N}{{\left( {{h}_{i}}\left( k \right)-{{{\hat{h}}}_{i}}\left( k \right) \right)}^{2}}}{\mathop{\sum }_{k=1}^{N}{{\left( {{h}_{i}}\left( k \right)-{{{\bar{h}}}_{i}} \right)}^{2}}}$                          (28)

where, i ∈ {u, l}, N is the number of testing samples, hi(k) and ${{\hat{h}}_{i}}\left( k \right)$ are the measured and predicted levels, respectively, ri(k) is the residual, ${{\bar{r}}_{i}}$ is the mean residual, and ${{\bar{h}}_{i}}$ is the mean measured level. RMSE and MAE characterize the magnitude of the prediction error, whereas σr,i describes the dispersion of the nominal residual and is therefore relevant to threshold stability and leak sensitivity. The coefficient $R_{i}^{2}$ indicates how well the estimated trajectory follows the measured level over the evaluated operating range. Accordingly, the observer architecture was selected by considering prediction accuracy, nominal residual behavior, model size, and practical PLC deployment requirements rather than relying on a single performance index.

Table 1. Validation performance and PLC-oriented screening of candidate multilayer perceptron (MLP) observers

(a) Prediction performance

Model

Structure

Parameters

RMSEu

(cm)

RMSEl

(cm)

MAEu

(cm)

MAEl

(cm)

sr,u

(cm)

sr,l

(cm)

$R_{u}^{2}$

$R_{l}^{2}$

MLP-1

4–4–4–2

50

0.228127

0.232573

0.121108

0.114612

0.244950

0.253841

0.980136

0.985299

MLP-2

4–6–4–2

68

0.162588

0.160264

0.065678

0.067562

0.161564

0.152640

0.992199

0.990798

MLP-3

4–6–6–2

86

0.187706

0.140030

0.114662

0.064343

0.173697

0.138392

0.989603

0.992975

MLP-4

4–8–8–2

130

0.226297

0.137595

0.107930

0.049567

0.219289

0.133816

0.984889

0.993217

(b) PLC-oriented implementation screening

Model

MACs

Normal Flags

FAR (%)

Inference Mean/Max (ms)

Selection

MLP-1

40

0/20

0.0

0.57/0.60

Not retained

MLP-2

56

0/20

0.0

0.84/0.92

Retained

MLP-3

72

0/20

0.0

0.99/1.04

Not retained

MLP-4

112

0/20

0.0

1.31/1.33

Not retained

Note: MACs = multiply–accumulates, FAR = false alarm rate.

Based on these evaluation criteria, Table 1(a) summarizes the validation results of the four candidate observers. MLP-2 achieved the lowest upper-tank RMSE, MAE, and residual standard deviation while maintaining competitive lower-tank performance. Its validation RMSE values were 0.163 and 0.160 cm for the upper and lower tanks, respectively, with $R_{u}^{2}~$= 0.992 and $R_{l}^{2}$ = 0.991. More specifically, compared with MLP-1, the addition of 18 parameters reduced the upper- and lower-tank RMSE values by approximately 28.7% and 31.1%, respectively. By comparison, although MLP-3 and MLP-4 slightly improved selected lower-tank metrics, they required 86 and 130 parameters without providing consistent gains across both outputs. MLP-2 was therefore selected as the most balanced architecture, combining improved nominal prediction and reduced residual variation with a compact 68-parameter structure suitable for PLC implementation and maintenance. After the architecture was fixed, MLP-2 was evaluated on the independent test set and achieved upper- and lower-tank RMSE values of 0.1618 and 0.1612 cm, respectively. Its trained weights, biases, and normalization parameters were subsequently exported for PLC deployment as described in Section 2.5.

Table 1(b) further presents the PLC-oriented screening of the four candidate observers. MAC counts were derived from the dense-layer dimensions, while inference times were measured on the PLC under identical execution conditions. No confirmed false alarms were observed in the 20 normal screening trials for any candidate. These nominal screening trials were separate from the 20 Normal trials included in the final 140-event performance evaluation. The measured mean/maximum inference times increased with network complexity, from 0.57/0.60 ms for MLP-1 to 1.31/1.33 ms for MLP-4, while remaining well below the 500 ms monitoring interval. MLP-2 required 56 MACs and achieved a measured inference time of 0.84/0.92 ms. Consequently, it offered the most balanced trade-off among prediction accuracy, residual stability, model complexity, and PLC execution cost, whereas the larger MLP-3 and MLP-4 increased computational burden without consistent improvement across both tank outputs.

2.5 Multi-rate PLC deployment and real-time prediction workflow

After offline training, the selected 4−6−4−2 MLP observer was deployed in the Siemens S7-1200 PLC using fixed weights, biases, and normalization parameters. The observer operated in inference mode only, without online adaptation. To preserve deterministic control execution, a multi-rate structure separated control and monitoring functions. Within this structure, the cascade PI controller ran every Tc = 50 ms for signal acquisition, engineering-unit conversion, control calculation, pump-command update, and variable buffering. In parallel, the observer and monitoring task ran every Tm = 500 ms using the latest buffered variables to perform MLP inference, predict both tank levels, and calculate the residuals.

At each monitoring cycle, the buffered closed-loop variables eo(k–1), ei(k–1), uo(k–1) and ui(k–1) were normalized using the parameters obtained from the training subset. The normalized vector was propagated through the embedded MLP using the stored weights and biases. The output values were then denormalized to obtain ${{\hat{h}}_{u}}\left( k \right)$ and ${{\hat{h}}_{l}}\left( k \right)$in physical level units. These predictions were compared with the measured tank levels to generate ru(k) and rl(k), which were subsequently processed by the residual-based leak-monitoring method described in Section 3.

Overall, Algorithm 1 summarizes the multi-rate PLC execution. The implementation used a Siemens SIMATIC S7-1200 CPU 1212C AC/DC/Rly. With the selected 68-parameter 4–6–4–2 MLP, the complete application occupied 239,533 bytes of load memory (11.42%) and 19,349 bytes of work memory (25.19%), leaving approximately 1.86 MB and 57.45 kB available, respectively. Direct runtime measurements on the PLC showed that the selected MLP required an average inference time of 0.84 ms, with a maximum of 0.92 ms. This execution time is substantially shorter than the 500 ms monitoring interval, indicating that neural inference imposes only a small computational burden within the multi-rate implementation. Even the largest candidate network evaluated in Table 1(b) required a maximum inference time of only 1.33 ms. These results confirm that the selected observer can be executed with substantial timing margin while the 50 ms cascade-control task and 500 ms monitoring task remain separately scheduled.

Algorithm 1. Multi-rate PLC execution of the embedded neural observer

1: Input: hsp (k), hu (k), hl (k)

2: Output: ui(k), ${{\hat{h}}_{u}}\left( k \right)$, ${{\hat{h}}_{l}}\left( k \right)$, ru(k), rl(k), FL(k), Loc(k), S(k), A(k)

3: Load cascade PI, MLP, and normalization parameters

4: Initialize control, observer, HMI and monitoring-decision variables

5: Set fast control task period Tc = 50 ms

6: Set monitoring task period Tm = 500 ms

7: Fast task (every Tc)

8: Acquire upper- and lower-tank level signals hu(kc), hl(kc)

9: Convert raw analog signals into engineering units

10: Compute outer-loop and inner-loop errors eo(kc), ei(kc)

11: Execute cascade PI control and update pump command ui(kc)

12: Send ui(kc) to the analog output module

13: Store the latest hsp, hu, hl, eo, ei, uo, and ui in the PLC data buffer

14: Monitoring task (every Tm)

15: Read the latest buffered hsp, hu, hl, eo, ei, uo, ui

16: Construct the delayed observer input vector \[x(k-1)={{\left[ {{e}_{0}}(k-1),\text{ }{{e}_{i}}(k-1),\text{ }{{u}_{o}}(k-1),\text{ }{{u}_{i}}(k-1) \right]}^{T}}\]

17: Normalize x(k–1) using the stored training parameters

18: Execute MLP forward propagation using stored W and b

19: Denormalize the MLP outputs to obtain the one-step-ahead

nominal estimates ${{\hat{h}}_{u}}\left( k|k-1 \right)$and ${{\hat{h}}_{l}}\left( k|k-1 \right)$

20: Compute residuals ru(k) and rl(k)

21: Execute Algorithm 2 using ru(k), rl(k), hsp (k), and ui(k)

22: Update HMI observer variables, alarm state, leak location, and severity levels..

3. Residual-Based Leak Monitoring

The PLC-embedded MLP observer provides nominal upper- and lower-tank level estimates during closed-loop operation. The monitoring layer converts measured–predicted deviations into residual features, suppresses short-term fluctuations, and confirms alarms only when abnormal responses persist under stable conditions. This supervisory logic operates independently of the cascade PI controller and does not modify the control command. Figure 4 summarizes the resulting monitoring sequence.

Figure 4. PLC-resident workflow for residual-based leak detection, location indication, and severity monitoring

3.1 Residual features and filtering

The signed residuals ru(k) and rl(k) are obtained from Eqs. (12)–(16). For subsequent decision making, two complementary residual representations are retained for each tank. Specifically, the magnitude residual is used for abnormality detection, whereas the signed residual is retained for subsequent location interpretation. The magnitude residual is defined as:

${{r}_{m,i}}\left( k \right)=\left| {{r}_{i}}\left( k \right) \right|,i\in \left\{ u,l \right\}$                    (29)

To suppress short-duration fluctuations, an EMA is then applied to reduce noise and isolated prediction mismatch:

${{r}_{f,i}}\left( k \right)=\alpha {{r}_{m,i}}\left( k \right)+\left( 1-\alpha  \right){{r}_{f,i}}\left( k-1 \right)$                        (30)

where, rf,i(k) is the filtered magnitude residual and α is the smoothing coefficient. In parallel, the signed residual is filtered as:

${{r}_{s,i}}\left( k \right)=\alpha {{r}_{i}}\left( k \right)+\left( 1-\alpha  \right){{r}_{s,i}}\left( k-1 \right)$                  (31)

where, rs,i(k) preserves the direction of the observer mismatch. Importantly, this additional signal is not used to trigger a leak alarm. It is retained only to support location indication after leak confirmation. From an implementation perspective, the two-filter form requires one stored state per channel and therefore remains suitable for cyclic PLC execution.

3.2 Adaptive baseline thresholding

Despite residual filtering, a fixed residual limit is vulnerable to drift in sensor noise, observer mismatch, and operating conditions. The decision boundary is therefore obtained from slowly varying baseline statistics. Let μb,i(k) and σb,i(k) denote the baseline mean and standard deviation of rf,i(k). During stable, non-alarm operation, the mean and variance are updated according to:

${{\mu }_{b,i}}\left( k \right)=\left( 1-\beta  \right){{\mu }_{b,i}}\left( k-1 \right)+\beta {{r}_{f,i}}\left( k \right)$                           (32)

$\sigma _{b,i}^{2}\left( k \right)= \left( 1-\beta  \right)\sigma _{b,i}^{2}\left( k-1 \right)+\beta {{\left[ {{r}_{f,i}}\left( k \right)-{{\mu }_{b,i}}\left( k \right) \right]}^{2}}$                (33)

where, β is selected substantially smaller than α so that the baseline follows gradual nominal changes without tracking short residual excursions. Based on these statistics, the channel threshold is then calculated as:

$T{{H}_{i}}\left( k \right)=\max \left\{ {{\mu }_{b,i}}\left( k \right)+{{K}_{\sigma }}{{\sigma }_{b,i}}\left( k \right),T{{H}_{min}} \right\}$                        (34)

where, Kσ controls the trade-off between sensitivity and false-alarm resistance and THmin prevents the threshold from collapsing under very low-noise conditions. To prevent baseline contamination, baseline updates are suspended whenever a channel is in candidate or confirmed alarm state. Consequently, a persistent leak-induced residual cannot be absorbed into the nominal baseline.

3.3 Stable-condition verification and leak confirmation

In addition to adaptive thresholding, the residual decision is disabled during substantial reference changes or rapid pump-command adjustment. For this purpose, the corresponding variations are

$\Delta {{h}_{sp}}\left( k \right)=\left| {{h}_{sp}}\left( k \right)-{{h}_{sp}}\left( k-1 \right) \right|$                        (35)

$\Delta {{u}_{i}}\left( k \right)=\left| {{u}_{i}}\left( k \right)-{{u}_{i}}\left( k-1 \right) \right|$                            (36)

and the stable-operation condition is expressed as

$St\left( k \right)=\left( \Delta {{h}_{sp}}\left( k \right)<{{\varepsilon }_{h}} \right)\wedge \left( \Delta {{u}_{i}}\left( k \right)<{{\varepsilon }_{u}} \right)$                     (37)

where, εh and εu are the setpoint and pump-command stability limits, respectively. Furthermore, a short warm-up interval is also imposed after PLC initialization or manual reset. Let Ready(k) = 1 only after the baseline has been collected for Tw seconds. Accordingly, a leak candidate is formed only when the monitoring layer is ready, the process is stable, and the relevant filtered magnitude residual exceeds its threshold:

${{C}_{i}}\left( k \right)=\text{Ready}\left( k \right)\wedge St\left( k \right)\wedge \left[ {{r}_{f,i}}\left( k \right)>T{{H}_{i}} \right]$                   (38)

Once a candidate condition is established, the confirmation timer accumulates only while Ci(k) remains true:

$T_{c, i}(k)=\left\{\begin{array}{cl}T_{c, i}(k-1)+T_m, & C_i(k)=1 \\ 0, & C_i(k)=0\end{array}\right.$                    (39)

where, Tm is the monitoring period. After the prescribed persistence interval, the channel decision and latched flag are then given by:

${{D}_{i}}\left( k \right)=\left\{ \begin{matrix}  1, & {{T}_{c,i}}\left( k \right)\ge {{T}_{\text{confirm}}}  \\   0, & \text{otherwise}  \\\end{matrix} \right.$                     (40)

$F{{L}_{i}}\left( k \right)=\left\{ \begin{matrix}   0, & \text{Reset}\left( k \right)=1  \\   F{{L}_{i}}\left( k-1 \right)\vee {{D}_{i}}\left( k \right), & \text{otherwise}  \\\end{matrix} \right.$                 (41)

Taken together, this combination of stability gating, baseline freezing, and persistence confirmation rejects transient residual peaks while preserving sensitivity to sustained deviations. Finally, the overall leak condition is obtained as:

$FL\left( k \right)=F{{L}_{u}}\left( k \right)\vee F{{L}_{l}}\left( k \right)$                  (42)

3.4 Calibrated location indication and severity classification

Following leak confirmation, because the tanks are hydraulically coupled, a leak at one tank can affect both residual channels. Consequently, a location decision based on a single residual magnitude is not sufficiently reliable across all operating conditions. To address this ambiguity, the location module uses a calibrated residual signature collected during controlled-leak tests. Specifically, for each operating region g, defined from the reference-level band, the signature vector is formed as:

$q\left( k \right)={{\left[ {{r}_{s,u}}\left( k \right),{{r}_{s,l}}\left( k \right),{{r}_{f,u}}\left( k \right),~{{r}_{f,l}}\left( k \right) \right]}^{T}}$                  (43)

Based on the controlled-leak data, offline calibration stores the mean signatures cU,g and cL,g for upper- and lower-tank leak conditions, together with a diagonal scaling matrix Wg derived from the corresponding feature variation. At each confirmed event, the squared distances to the two location signatures are

${{d}_{j}}\left( k \right)={{\left[ q\left( k \right)-{{c}_{j,g}} \right]}^{T}}{{W}_{g}}\left[ q\left( k \right)-{{c}_{j,g}} \right],j\in \left\{ U,L \right\}$                               (44)

Accordingly, the location output is defined as:

$Loc\left( k \right)=\left\{ \begin{matrix}   Upper, & {{d}_{U}}\left( k \right)\le {{d}_{L}}\left( k \right)  \\   Lower, & {{d}_{U}}\left( k \right)>{{d}_{L}}\left( k \right)  \\ \end{matrix} \right.,FL\left( k \right)=1$                       (45)

For FL(k) = 1, the leak location is assigned to the calibrated prototype producing the smaller scaled distance. Under the present experimental conditions, this nearest-signature decision is appropriate because the experiments consider mutually exclusive upper- and lower-tank leaks. Algorithm 3 summarizes the procedure. In parallel with location indication, severity is evaluated only after confirmation. For this purpose, the severity metric is the largest filtered residual among confirmed channels.

${{r}_{sev}}\left( k \right)=\max \left\{ {{r}_{f,i}}\left( k \right){{|}_{F{{L}_{i}}=1}},i\in \left\{ u,l \right\} \right\}$                       (46)

The severity boundaries are stored by location and operating region because controlled-leak responses may vary with the reference level. Let THS,ℓ,g and THM,ℓ,g denote the calibrated Small-to-Medium and Medium-to-Large boundaries for location class ℓ and region g. The severity state is then

$S\left( k \right)=\left\{ \begin{matrix}   \begin{matrix}   Normal,  \\   Small,  \\\end{matrix} & \begin{matrix}   FL\left( k \right)=0  \\   {{r}_{sev}}\left( k \right)\text{T}{{\text{H}}_{S,\ell ,g}}  \\\end{matrix}  \\   \begin{matrix}   Medium,  \\   \text{Large},  \\\end{matrix} & \begin{matrix}   \text{T}{{\text{H}}_{S,\ell ,g}}\le {{r}_{sev}}\left( k \right)\text{T}{{\text{H}}_{M,\ell ,g}}  \\   {{r}_{sev}}\left( k \right)\ge \text{T}{{\text{H}}_{M,\ell ,g}}  \\\end{matrix}  \\\end{matrix} \right.$                      (47)

where, ℓ is the indicated location. Finally, the operator-oriented alarm vector is:

$A\left( k \right)={{\left[ FL\left( k \right)Loc\left( k \right)S\left( k \right) \right]}^{T}}$                      (48)

Algorithm 2. PLC residual-monitoring sequence

1: Input: ru(k), rl(k), hsp(k), ui(k), Reset(k)

2: Output: FL(k), Loc(k), S(k), A(k)

3: Update Ready(k) after the warm-up duration Tw

4: Evaluate stable St(k) from Eqs. (35)–(37)

5: for each tank I ∈ {u, l} do

6: rm,i(k) ← |ri(k)|

7: Update rf,i(k) and rs,i(k) using Eqs. (30)–(31).

8: if Ready(k) Ù St(k) Ù ~ FLi(k −1) Ù rf,i(k) ≤ THi(k −1) then

9: Update mb,i(k) and sb,i(k) using Eqs. (32)–(33)

10: else

11: Hold the baseline statistics

12: end if

13: Compute TH,i(k) using Eq. (34)

14: Set Ci(k) using Eq. (38) and update Tc,i(k) using Eq. (39).

15: Set Di(k) using Eq. (40) and update FLi(k) using Eq. (41)

16: end for

17: FL(k) ← FLu(k) Ú FLl(k)

18: Loc(k) ← Algorithm 3: LocationClass(FL(k), q(k), g(k))

19: S(k) ← Algorithm 4: SeverityClass(FL(k), Loc(k), rsev(k), g(k))

20: A(k) ← [FL(k), Loc(k), S(k)]T and update HMI tags

Algorithm 3. Calibrated location indication

1: Input: FL(k), q(k), g(k), cU,g, cL,g, Wg

2: Output: Loc(k).

3: if FL(k) = 0 then

4: Loc(k) ← Normal

5: else

6: Compute dU(k) and dL(k) using Eq. (44)

7: if dU(k) £ dL(k) then

8: Loc(k) ← Upper

9: else

10: Loc(k) ← Lower

11: end if

12: end if

Algorithm 4. Severity classification

1: Input: FL(k), Loc(k), rf,u(k), rf,l(k), g(k), calibrated severity table.

2: Output: S(k).

3: if FL(k) = 0 then

4: S(k) ← Normal

5: else

6: rsev(k) ← max{rf,i(k)|FLi(k) = 1}

7: Read THS,ℓ,g and THM,ℓ,g using Loc(k) and g(k).

8: if rsev(k) < THS,ℓ,g then

9: S(k) ← Small

10: else if rsev(k) < THM,ℓ,g then

11: S(k) ← Medium

12: else

13: S(k) ← Large

14: end if

15: end if

For operator interpretation, the HMI displays filtered residuals, adaptive thresholds, stability status, confirmation timers, and channel flags. Algorithm 2 executes the complete monitoring sequence, while Algorithms 3 and 4 perform location indication and severity classification, respectively. Severity classes were defined from measured leak outflow rather than universal safety limits. Across the tested operating regions, Small, Medium, and Large leaks corresponded to approximately 0.054–0.062 L/min, 0.081–0.092 L/min and 0.107–0.123 L/min, respectively. Small events support routine trending and planned inspection, Medium events warrant higher maintenance priority, and Large events require prompt operator assessment and plant-specific corrective action. These labels are diagnostic rather than safety-interlock commands and should be recalibrated when the vessel, liquid, sensing configuration, or operating range changes.

4. Experimental Results and Performance Evaluation

To evaluate the complete PLC-resident framework, the proposed monitoring scheme was assessed on the physical Quanser coupled-tank platform. The Siemens S7-1200 PLC executed cascade PI control at Tc = 50 ms and performed neural estimation, residual analysis, alarm confirmation, leak-location indication, and severity assessment at Tm = 500 ms. Meanwhile, process data were recorded through Modbus TCP at 250 ms for subsequent metric calculation and figure preparation. Importantly, all control and leak-decision functions were completed online in the PLC.

4.1 Experimental setup and leak-test conditions

The test bench comprised the Quanser coupled-tank process, VoltPAQ-X1 interface, Siemens S7-1200 PLC, SM1234 analog I/O module, and HMI. For real-time supervision, Figure 5 shows the monitoring interface used to display measured and estimated levels, residual signals, thresholds, alarm status, indicated leak location, and severity class.

Figure 5. Real-time PLC monitoring human–machine interface (HMI)

Prior to validation, the selected 4–6–4–2 MLP was trained on leak-free 13–17 cm data, after which its weights, biases, and normalization parameters were fixed in the PLC. Subsequently, tests were conducted at lower-tank setpoints of 13 and 17 cm, representing two calibrated hydraulic operating regions. The reported performance is therefore bounded to these setpoints, the stated controller and sensor configuration, and one controlled leak at a time. Accordingly, the results should not be extrapolated as evidence of unchanged accuracy over the full tank range. Controlled upper- and lower-tank leaks were introduced using the grooved plug in Figure 6, with Small (S), Medium (M), and Large (L) conditions defined by 2, 3, and 4 screw turns, respectively. Each test comprised nominal operation, leak initiation, and sustained leakage. Table 2 summarizes the leak classes and measured flow ranges, while Table 3 lists the PLC monitoring parameters. Section 4.7 states the data and recalibration required for other operating regions.

Figure 6. Adjustable grooved leak plug

Table 2. Leak conditions and measured leak-flow ranges

Label

Leak Location

Severity

Screw Rotation (turns)

Measured Leak Flow (L/min)

0

–

Normal

0

0.00

1

Upper tank

Small

2

0.055–0.062

2

Upper tank

Medium

3

0.081–0.091

3

Upper tank

Large

4

0.107–0.120

4

Lower tank

Small

2

0.054–0.062

5

Lower tank

Medium

3

0.081–0.092

6

Lower tank

Large

4

0.108–0.123

Table 3. Common PLC monitoring and decision parameters.

Parameter

Description

Value

Tc

Cascade PI task period

50 ms

Tm

Observer and monitoring task period

500 ms

Tlog

Modbus TCP logging interval

250 ms

a

EMA smoothing coefficient

0.2

b

Baseline adaptation gain

0.002

Ks

Adaptive-threshold multiplier

4.0

THmin

Minimum residual threshold

0.1 cm

εh

Setpoint-change limit for stable-condition verification

0.02 cm

εu

Pump-command-change limit for stable-condition verification

0.1%

Tw

Baseline warm-up duration before monitoring is enabled

40 s

Tconfirm

Alarm confirmation time

2.0 s

g(k)

Operating-region index selected from the lower-tank reference

13 or 17 cm

For hydraulic characterization, leak-flow ranges in Table 2 were obtained from QL = 60ΔV/Δt. Each leak condition was repeated three times at 13 and 17 cm for hydraulic analysis and calibration of the residual signatures and severity boundaries. To maintain separation between calibration and testing, these trials were excluded from the event-level dataset, in which each of the seven classes was tested ten times per operating point. With Tm = 500 ms, Tconfirm = 2.0 s corresponded to four consecutive monitoring cycles. Notably, Tlog was used only for data recording, while g(k) was selected from hsp ∈ {13, 17} cm.

4.2 Nominal observer tracking and transient rejection

To examine nominal tracking under transient operation, Figure 7 presents a representative leak-free reference change from 17 to 13 cm. This case was selected because it produced the larger closed-loop deviation and therefore provided a demanding assessment of nominal prediction and transient rejection. As shown in Figure 7(a), the upper- and lower-tank levels responded at different rates because of cascade control and hydraulic coupling, while the PLC estimates, ${{{\hat{h}}}_{{u}}}( {k} )$ and ${{{\hat{h}}}_{{l}}}({k})$, reproduced the main trends and converged toward the new operating condition. Despite this agreement, temporary measured–predicted deviations occurred during the rapid response, particularly in the upper-tank channel.

(a) level tracking

(b) stable-condition verification

Figure 7. Representative nominal 17-to-13 cm transition

More importantly, Figure 7(b) shows how stable-condition verification prevented these nominal deviations from triggering false alarms. Immediately after the setpoint change, |∣Δhsp∣ exceeded εh, while the control action caused repeated ∣Δui∣ excursions beyond εu. Consequently, St(k) became false, and residual-based decisions were inhibited throughout the transient interval. Monitoring was considered continuously stable only after approximately 50.5 s, when both conditions remained satisfied.

For clarity, the shaded regions in Figure 7 indicate the initial stable period, rejected transient interval, and restored stable condition. Taken together, the results show that reference-induced level and residual excursions were rejected as normal closed-loop transients rather than interpreted as leakage. Once stability was restored, residual evaluation and baseline adaptation resumed, while EMA filtering and persistence confirmation further suppressed short-duration threshold crossings. Similarly, the reverse 13-to-17 cm transition exhibited comparable behavior; however, the 17-to-13 cm case is presented because it produced the larger transient deviation. The 17-to-13 cm and reverse 13-to-17 cm steps provided the available sudden-reference tests, producing both controller action and residual excursions. During these transients, the stability gate suspended alarm accumulation and baseline adaptation until the setpoint and pump-command variations returned within their limits. Normal sensor noise was inherently included in the baseline statistics, whereas no additional noise injection or independent pump-voltage disturbance was applied. Therefore, robustness to prescribed noise levels, pump degradation, supply disturbances, and simultaneous setpoint/leak events remains outside the present validation scope.

4.3 Closed-loop hydraulic responses under controlled leakage

Following the nominal transient assessment, Figures 8 and 9 present representative measured-level responses at hsp= 17 cm. For comparison across operating regions, the same seven operating conditions were also tested at 13 cm. However, only the 17 cm results are shown to avoid repetitive figures. Nevertheless, results from both operating points are used subsequently for residual calibration and performance evaluation. The leak was introduced at approximately 17 s while the cascade PI controller remained active. During the initial nominal interval, before leak initiation, all measured responses remained within narrow nominal bands. After leak initiation, Figure 8 shows that an upper-tank leak directly reduced hu because the additional outflow occurred before the inter-tank flow path. The reduction increased with leak severity. In contrast, a lower-tank leak reduced the regulated lower-tank level and caused the outer PI controller to increase the upper-tank reference and pump command. Consequently, hu increased above its nominal value. Thus, the opposing response directions result from the disturbance location and the compensating action of the cascade controller. Consistent with the upper-tank behavior, Figure 9 shows the corresponding lower-tank responses. A lower-tank leak directly reduced hl below the reference before the controller restored the required inter-tank inflow. Conversely, for an upper-tank leak, the controller compensated for the upstream loss by increasing the pump command. Under the applied controller tuning, this compensation produced a temporary positive deviation in hl before the level returned toward its reference. For both leak locations, larger screw openings resulted in greater deviations and stronger recovery actions.

Figure 8. Upper-tank level responses under controlled leakage at hsp = 17 cm

Figure 9. Lower-tank level responses under controlled leakage at hsp = 17 cm

To quantify these responses, for each condition, RMSE, integral absolute error (IAE) and maximum absolute deviation were averaged over three post-leak trials using the unfiltered 250 ms data. Across the evaluated conditions, as shown in Figure 10, all indices increased with leak severity. Lower-tank leaks produced the largest hu deviations because the outer PI controller increased the upstream level to compensate for the loss, whereas hl deviations remained smaller due to direct level regulation.

Figure 10. Measured-level deviation indices under controlled leakage at hsp= 17 cm

Although the leak conditions appear distinguishable in Figures 8 and 9, the measured levels alone do not provide a robust online alarm variable. These figures compare synchronized experiments with a known leak-onset time and an available leak-free reference, whereas the PLC observes only the current process trajectory. Moreover, the nominal reference transition in Section 4.2 produces level excursions that may exceed those associated with a Small leak. In addition, feedback compensation can also restore hl close to its reference despite persistent leakage. Consequently, a fixed threshold applied directly to hu or hl would be sensitive to the operating point, normal transients, hydraulic coupling, and controller action.

To overcome these limitations, the MLP observer is used to estimate the nominal upper- and lower-tank levels, ${{\hat{h}}_{u}}$ and ${{\hat{h}}_{l}}$, from the closed-loop variables eo, ei, uo, and ui. Accordingly, these estimates represent the expected leak-free behavior of the controlled process. The residuals ${{r}_{u}}={{h}_{u}}-{{\hat{h}}_{u}}$ and ${{r}_{l}}={{h}_{l}}-{{\hat{h}}_{l}}$ then quantify the deviation of the measured levels from their nominal predictions. Therefore, compared with direct thresholding of hu and hl, the residuals provide a more consistent basis for transient rejection, adaptive thresholding, leak-location indication, and severity classification at both 13 and 17 cm.

4.4 Residual responses, leak separability and threshold calibration

Following the measured-level responses in Section 4.3, the observer residuals were examined as leak-sensitive features for the PLC decision layer. For illustration, Figures 11 and 12 show representative responses at hsp = 17 cm. The thin traces denote the raw signed residuals ru and rl, whereas the thicker traces represent the corresponding EMA-filtered residuals rs,u and rs,l. Under nominal conditions, before leak initiation, both channels remained near their nominal baselines. After leak initiation, the filtered signals developed sustained responses whose magnitudes increased from Small to Medium and Large conditions. For decision purposes, the signed residuals were retained for location interpretation, whereas leak detection and severity assessment used the filtered magnitude residuals rf,u, rf,l and rsev defined in Eqs. (30) and (46). In particular, upper-tank leaks produced a negative upper residual and a dominant positive lower residual, whereas lower-tank leaks showed the opposite pattern. Accordingly, because hydraulic coupling and cascade-controller compensation affected both channels, leak location was determined from the combined residual directions and relative magnitudes rather than from the largest residual alone.

Figure 11. PLC-generated raw and signed exponential moving average (EMA) residual responses for upper-tank leaks at hsp = 17 cm

Figure 12. PLC-generated raw and signed exponential moving average (EMA) residual responses for lower-tank leaks at hsp = 17 cm

Based on these residual patterns, Table 4 summarizes the calibrated location signatures and severity boundaries for the 13 and 17 cm operating regions. For each region g ∈ {13, 17}, the six leak classes: Upper-S, Upper-M, Upper-L, Lower-S, Lower-M, and Lower-L, were repeated three times, yielding 18 calibration events. Importantly, these trials were conducted separately from the event-level performance dataset.

For each calibration event e, the EMA-filtered residual features were evaluated over a steady post-confirmation interval. Specifically, the interval was selected after alarm confirmation, while stable operation was maintained and the residuals showed no sustained growth or decay. Because settling behavior varied among leak conditions, the interval was determined separately for each event; however, the same procedure and number of consecutive samples were used throughout. Accordingly, the event signature was calculated as

${{\bar{q}}_{e}}=\frac{1}{{{N}_{e}}}\mathop{\sum }_{k={{k}_{1,e}}}^{{{k}_{2,e}}}{{\left[ {{r}_{s,u}}\left( k \right){{r}_{s,l}}\left( k \right){{r}_{f,u}}\left( k \right){{r}_{f,l}}\left( k \right) \right]}^{T}}$                  (49)

where, k1,e and k2,e define the steady post-confirmation interval and Ne = k2,e − k1,e +1 is the number of monitoring samples in that interval.

Table 4. Calibrated residual-signature parameters and severity boundaries at 13 and 17 cm

Calibration Parameter

Calibrated Parameter Vector

THS,ℓ,g (cm)

THM,ℓ,g (cm)

cU,13

[−0.2975,

0.5151,

0.3040,

0.5151]T

2.48

3.34

cL,13

[−0.0008,

−0.5596,

0.0721,

0.5597]T

0.68

0.86

diag(W13)

[33.5168,

33.5168,

53.4445,

53.4445]T

-

-

cU,17

[0.0181,

1.3694,

0.1709,

1.3694]T

2.75

3.70

cL,17

[0.0708,

−0.0309,

0.2145,

0.1067]T

0.77

0.99

diag(W17)

[144.8806,

1.6077,

560.5375,

1.9238]T

-

-

After event-level signatures were obtained, the prototype vectors cU,g and cL,g were obtained by averaging the event signatures of the corresponding upper- and lower-tank calibration trials within operating region g. To avoid class imbalance, the three severity classes and their three repetitions were assigned equal weight. Thus, each prototype represented the overall residual response of its corresponding leak location rather than that of a single severity condition. Initially, equal nominal importance was assigned to the four residual features. Subsequently, differences in their natural variation were accounted for using the diagonal inverse-variance scaling matrix

${{W}_{g}}=diag\left[ \frac{1}{\sigma _{1,g}^{2}},~\frac{1}{\sigma _{2,g}^{2}},~\frac{1}{\sigma _{3,g}^{2}},~\frac{1}{\sigma _{4,g}^{2}} \right]$                     (50) 

where, $\text{ }\!\!\sigma\!\!\text{ }_{\text{j,g}}^{\text{2}}$ denotes the variance of feature j obtained from the calibration event signatures in operating region g. As a result, this normalization prevents features with greater dispersion from disproportionately influencing the signature-distance calculation without manually emphasizing a particular residual channel.

For each calibration event, the peak value of rsev(k) was extracted over the selected steady interval. The representative severity residual psev,c,ℓ,g was calculated as the arithmetic mean of the three event peaks for severity class c ∈ {S, M, L}, leak location ℓ ∈ {U, L}, and operating region g ∈ {13, 17}. Finally, the severity boundaries were defined as the midpoints between adjacent representative class values:

$\text{T}{{\text{H}}_{S,\ell ,g}}=\frac{{{p}_{\text{sev},S,\ell ,g}}+{{p}_{sev,M,\ell ,g}}}{2}$                  (51)

$\text{T}{{\text{H}}_{M,\ell ,g}}=\frac{{{p}_{sev,M,\ell ,g}}+{{p}_{sev,L,\ell ,g}}}{2}$                (52)

To ensure an unbiased evaluation, all prototype vectors, scaling matrices, and severity boundaries were obtained exclusively from the calibration trials and were fixed before the 140 repeated event-level tests. Therefore, no calibration parameter was adjusted using the test confusion matrices or alarm-delay results.

4.5 Representative PLC detection sequences and repeated-event performance

After fixing all calibration parameters, the PLC monitoring framework was evaluated at hsp = 13 and 17 cm using ten trials for each of seven classes, giving 70 trials per operating point and 140 trials in total. Throughout each trial, neural inference, residual processing, threshold evaluation, confirmation timing, location indication, and severity classification were executed online in the PLC. Figures 13 and 14 present four representative detection sequences. In these figures, the green, yellow, and red regions indicate normal, candidate, and confirmed leak states, respectively. Specifically, the alarm delay consists of the threshold-crossing time, tcross, followed by Tconfirm = 2.0 s. At 17 cm, the Lower-M and Upper-L leaks were confirmed after 4.5 and 4.0 s, while at 13 cm, the Lower-L and Upper-S leaks were detected after 5.0 and 4.0 s. Overall, persistent residual deviations were confirmed within a few seconds while cascade control remained active. Beyond these representative cases, Table 5 reports the class-level results and PLC alarm delays. Delay statistics were calculated from correctly classified location–severity events, while an additional summary used all true-positive detections to avoid conditioning the overall delay on classification success. Across all true-positive detections, the mean alarm delay was 4.57 ± 0.71 s at 17 cm and 4.83 ± 0.84 s at 13 cm, based on 56 and 55 confirmed events, respectively. By comparison, the 99 events with correct location and severity labels yielded 4.46 ± 0.57 s and 4.80 ± 0.73 s. Thus, restricting the analysis to exactly classified events introduced only limited delay-selection bias. As expected, larger leaks were detected faster because their residuals developed more rapidly, whereas lower-tank leaks at 13 cm generally required longer detection due to the lower hydraulic head and cascade-controller compensation. To summarize the overall classification performance, Figure 15 presents the seven-class confusion matrices. Across both operating points, 111 of 120 leak trials were confirmed, while 19 of 20 Normal trials remained alarm-free. Accordingly, leak sensitivity, specificity, and binary accuracy were 92.50%, 95.00%, and 92.86%, respectively. Among the confirmed leaks, 103 were assigned to the correct tank and 101 to the correct severity class, giving conditional location and severity accuracies of 92.79% and 90.99%. For end-to-end evaluation, the nine missed leaks were counted as failures, resulting in location and severity accuracies of 103/120 = 85.83% and 101/120 = 84.17%. Moreover, 99/120 = 82.50% received both correct labels. Finally, including the 19 correctly identified Normal trials, the exact seven-class accuracy was 118/140 = 84.29%.

(a) lower-tank medium leak

(b) upper-tank large leak

Figure 13. Representative PLC detection sequences at hsp = 17 cm

(a) lower-tank large leak

(b) upper-tank small leak

Figure 14. Representative PLC detection sequences at hsp = 13 cm

Table 5. Event-level detection and classification counts with associated PLC alarm delays

Leak Condition

Correct Class at 17 cm

Delay at 17 cm, Mean ± SD (s)

Correct Class at 13 cm

Delay at 13 cm, Mean ± SD (s)

Upper-S

8/10

4.62 ± 0.35

8/10

4.75 ± 0.46

Upper-M

8/10

4.25 ± 0.27

8/10

4.50 ± 0.38

Upper-L

10/10

4.00 ± 0.33

9/10

4.11 ± 0.33

Lower-S

9/10

5.33 ± 0.35

8/10

5.00 ± 0.38

Lower-M

7/10

4.50 ± 0.41

8/10

5.50 ± 0.38

Lower-L

8/10

4.06 ± 0.32

8/10

5.00 ± 0.38

Confirmed leaks

56/60

4.57 ± 0.71

55/60

4.83 ± 0.84

Exact-class events

50/60

4.46 ± 0.57

49/60

4.80 ± 0.73

(a) hsp = 17 cm

(b) hsp = 13 cm

Figure 15. Seven-class confusion matrices obtained from repeated PLC leak tests

The reported metrics use different denominators. Conditional location and severity accuracies are based on the 111 detected leaks, whereas end-to-end metrics include all 120 leak trials and treat the nine missed detections as failures, reducing the corresponding accuracies by 6.96 and 6.82 percentage points. Moreover, most remaining errors occurred for weaker Small/Medium leaks and at 13 cm, where residual separation was reduced by lower hydraulic head and cascade compensation. The exact seven-class metric is more stringent because a prediction is counted as correct only when the Normal/leak decision and, for leak cases, both location and severity match the applied class.

4.6 Discussion and comparison with representative diagnosis approaches

As a baseline comparison, measurement- and threshold-based monitoring provides a simple and computationally inexpensive solution for leak indication [23-25, 38]. However, the results in Figures 7-9 show that direct thresholds applied to tank levels, control errors, or controller outputs are not invariant under the present closed-loop conditions. Specifically, nominal reference changes produce temporary level excursions, whereas cascade PI compensation can return the regulated lower-tank level toward its reference despite sustained leakage. Moreover, hydraulic coupling also causes upper- and lower-tank leaks to influence both measured channels. Therefore, a threshold selected for weak-leak sensitivity may become susceptible to normal transients, while a wider threshold may fail to detect small residual changes.

To mitigate these effects, the proposed framework addresses this limitation by separating nominal-response estimation from alarm evaluation. Within this framework, the MLP observer generates the expected leak-free trajectories from eo(k–1), ei(k–1), uo(k–1), and ui(k–1), and the PLC rule layer evaluates the remaining measured–predicted mismatch. Subsequently, EMA filtering and adaptive baseline thresholds reduce noise and nominal drift, while stable-condition verification and confirmation timing suppress short transient crossings. After confirmation, the calibrated two-channel residual signature is used for location indication, and the filtered residual magnitude is compared with operating-region-dependent severity boundaries. The repeated experiments achieved a binary leak/no-leak accuracy of 92.86%. Among confirmed leaks, the conditional location and severity accuracies were 92.79% and 90.99%, respectively. When evaluated over all 120 leak trials, including unconfirmed events as failures, the corresponding end-to-end accuracies were 85.83% and 84.17%, while 82.50% received both correct location and severity labels.

The proposed approach also differs from direct data-driven classifiers. Edge-PLC and embedded ANN studies have demonstrated that learned models can operate close to the industrial control layer [20-22], while ANN and deep-learning methods can capture complex leak patterns from labeled pressure, acoustic, or time-series data [29, 31-35]. In comparison, as summarized in Table 6, these approaches offer strong pattern-recognition capability but generally require representative fault datasets and provide less transparent alarm decisions. In the present framework, the neural network is used only to reconstruct the nominal leak-free response, whereas detection, confirmation, location, and severity assessment remain within explicit PLC logic. As a result, this separation reduces dependence on extensive labeled leak data and allows the thresholds, timers, residual signatures, and severity boundaries to be inspected through the PLC program and HMI. Table 6 also contrasts the proposed framework with nonlinear observer-based diagnosis. High-gain observers provide an established basis for nonlinear state estimation [39], whereas Kalman-filter, dual-observer, and neuro-fuzzy observer methods support model-based residual generation, fault estimation, and uncertainty treatment [40-42]. These approaches provide strong theoretical interpretation but generally require an explicit process model, reliable hydraulic parameters, and additional observer or covariance tuning. In contrast, the proposed neural observer reduces this modeling burden by learning the nominal closed-loop response from experimental data while retaining the measured-versus-predicted residual interpretation commonly used in observer-based diagnosis.

Table 6. Positioning against representative leak- and fault-diagnosis approaches

Approach

Research Object

Input Signals

Detection Method

PLC Deployment

Main Limitation

Measurement/threshold [23-25, 38]

Pipelines and interacting tanks

Pressure, flow, acoustic, or level

Fixed/dynamic signal threshold

Simple PLC logic is possible. Often a separate monitor

Sensitive to operating transitions, coupling, and feedback compensation

High-gain nonlinear observer [39]

Nonlinear tank/fluid process

Plant input, measured states, and model parameters

Model-based state estimation and residuals

Possible, subject to model and execution complexity

Requires an explicit process model and observer-gain design

Kalman, dual, neuro-fuzzy observers [40-42]

Pipeline and fluid systems

Pressure/flow/state measurements plus model data

State/residual estimation with covariance or auxiliary observers

Usually host/edge implementation; PLC feasibility is case dependent

Higher modelling, parameter, covariance, and tuning burden

Direct ML diagnosis [20, 29, 31-35]

Pipelines, water networks, and industrial faults

Labelled pressure, acoustic, image, or time-series data

ANN/SVM/CNN/LSTM classification or localization

Some edge-PLC demonstrations; many are standalone pipelines

Needs representative fault data. Decisions can be opaque or computationally heavy

Proposed framework

Cascade-controlled coupled-tank process

eₒ(k–1), eᵢ(k–1), uₒ(k–1), uᵢ(k–1) and measured tank levels

Leak-free MLP nominal observer plus explicit residual rules

Fully PLC-resident with controller, timing logic, and HMI outputs

Calibration is operating-region dependent; validated for single leaks at 13 and 17 cm

From an implementation perspective, the multi-rate structure separates the 50 ms cascade-control task from the 500 ms monitoring task, while the 250 ms Modbus TCP stream is used only for data logging and figure preparation. For a fair comparison, the parameters and decision thresholds of the two baseline methods were determined from the available nominal/calibration data and were fixed before evaluation on the 140 repeated-event trials. No threshold was adjusted using the final test results. All three strategies were implemented using PLC-compatible logic and evaluated under the same experimental conditions. Within this architecture, Table 7 compares the proposed method with two PLC-compatible baseline methods using results from the same 140 experimental trials conducted on the physical coupled-tank testbed. Direct level-deviation thresholding has the lowest computational cost but yields the lowest binary accuracy and the highest false-alarm rate. Using MLP-2 with a fixed residual threshold improves detection performance, whereas the proposed adaptive residual logic further reduces false alarms and achieves the highest binary accuracy with only a modest increase in execution time.

Table 7. Same-dataset comparison of PLC-compatible leak-detection strategies

Method

Binary Accuracy (%)

False-Alarm Rate (%)

Mean Alarm Delay (s)

Execution Per Monitoring Cycle (ms)

Direct level-deviation threshold

81.43

15.0

5.86 ± 1.42

0.03

Fixed residual threshold + MLP-2

88.57

10.0

4.42 ± 0.93

0.86

Proposed adaptive residual logic + MLP-2

92.86

5.0

4.70 ± 0.79

1.05

4.7 Scope, recalibration requirements, and limitations

The demonstrated scope is limited to the 13 and 17 cm operating points, fixed cascade-controller settings, the installed sensors and pump, water as the working fluid and single upper- or lower-tank leaks within the measured flow ranges of Table 2. Because the observer is trained on nominal closed-loop behavior, its validity depends on representative leak-free data. Accordingly, performance after changes in operating range, sensors, pump dynamics, controller tuning, or under simultaneous leaks has not been established.

For deployment beyond the calibrated conditions, a structured recalibration is required. First, leak-free data should be collected over the intended operating regions and reference transitions. Next, normalization parameters, prediction errors, and nominal residual distributions should be re-evaluated using temporally separated validation data. Region-specific baseline statistics and minimum thresholds should then be established from alarm-free operation. Subsequently, representative controlled leaks should be used to update the location signatures and severity boundaries. Finally, all parameters should be fixed before independent repeated-event validation. This procedure should be repeated after any material change in the hydraulic or control configuration.

In addition, the present location rule assumes a single dominant leak. Simultaneous leaks may produce mixed residual signatures and therefore require an uncertainty-aware decision state rather than a forced Upper/Lower label. Future validation should also consider sensor-health monitoring, controlled noise and pump disturbances, gradual leak development, and combined setpoint–leak events.

5. Conclusions and Future Work

This study developed a PLC-resident leak-monitoring framework that combines nominal neural prediction with transparent residual-based decision logic for a cascade-controlled coupled-tank process. In particular, the selected 4–6–4–2 MLP was trained exclusively on leak-free closed-loop data and deployed in a Siemens S7-1200 PLC as a nominal level observer. Rather than using the neural network as a direct fault classifier, the framework retained explicit filtering, adaptive thresholding, stability verification, persistence confirmation, location indication, and severity classification within the PLC program. Accordingly, this separation provides an interpretable monitoring structure while reducing dependence on extensively labeled leak datasets.

Experimental results at 13 and 17 cm support the feasibility of the approach under the evaluated conditions. Across 140 repeated trials, the binary leak/no-leak accuracy was 92.86%, while the exact seven-class accuracy was 84.29%. When missed detections were treated as failures, the end-to-end location and severity accuracies were 85.83% and 84.17%, respectively. Moreover, mean true-positive alarm delays remained below 5 s at both operating levels. From an engineering perspective, these results indicate that measured–predicted residuals can reveal persistent hydraulic changes that may be partially masked by cascade-controller compensation. In addition, the longer delays observed for some lower-tank leaks at 13 cm show that detection performance depends on hydraulic head, disturbance location, and closed-loop response rather than on leak size alone.

At the implementation level, the multi-rate structure demonstrated that neural inference and residual monitoring can coexist with deterministic PLC control. Cascade PI control remained in the 50 ms task, whereas observer inference and leak decisions were executed every 500 ms. The selected 4–6–4–2 MLP required only 0.84 ms mean inference time, with a maximum of 0.92 ms on the PLC. This execution time was substantially below the 500 ms monitoring interval, confirming sufficient computational margin for real-time deployment. Consequently, the framework should be interpreted as a practical proof of feasibility for lightweight PLC-based monitoring rather than as a universally calibrated solution. Nevertheless, its current performance is supported only for the two evaluated operating regions, fixed controller settings, the tested sensor configuration, and mutually exclusive upper- or lower-tank leaks. Therefore, deployment over different operating ranges would require representative nominal data together with recalibration or scheduling of the residual signatures and severity boundaries.

Looking ahead, future work should evaluate wider reference ranges, different controller tunings, external hydraulic disturbances, sensor drift, and gradual leak development. In particular, simultaneous or spatially ambiguous leaks will require an uncertainty-aware location mechanism capable of representing mixed residual signatures. Furthermore, adaptive operating-region scheduling, online severity recalibration, confidence measures for ambiguous decisions, and direct leak-rate estimation should be investigated before extending the method to larger and more complex industrial fluid systems.

Acknowledgment

The authors acknowledge the Faculty of Engineering, King Mongkut’s University of Technology North Bangkok (KMUTNB), along with the Department of Instrumentation and Electrical Energy Engineering and CEITA (Prachinburi campus), for their support. This work was funded by the Faculty of Engineering, KMUTNB, under Grant ENG-67-016.

Nomenclature

Au

cross-sectional area of the upper tank, cm²

Al

cross-sectional area of the lower tank, cm²

A(k)

operator-oriented alarm vector containing leak flag, location, and severity

AUS, AUM, AUL

upper-tank Small, Medium, and Large leak alarm outputs

ALS, ALM, ALL

lower-tank Small, Medium, and Large leak alarm outputs

aLu

equivalent upper-tank leak-opening area, cm²

aLl

equivalent lower-tank leak-opening area, cm²

a(j) (k)

output vector of neural-network layer j

b(j)

bias vector of neural-network layer j

Cd

discharge coefficient

Ci(k)

leak-candidate condition for residual channel i

cU,g

calibrated mean residual-signature vector for an upper-tank leak in operating region g

cL,g

calibrated mean residual-signature vector for a lower-tank leak in operating region g

dU(k)

scaled squared distance to the calibrated upper-tank leak signature

dL(k)

scaled squared distance to the calibrated lower-tank leak signature

Di(k)

confirmed decision for residual channel i

eo(k)

outer-loop control error, hsp(k) − hl(k), cm

ei(k)

inner-loop control error, uo(k) − hu(k), PLC engineering unit

fMLP(·)

nonlinear mapping implemented by the MLP observer

FLi(k)

latched leak flag for residual channel i

FL(k)

overall leak flag

g

gravitational acceleration in the hydraulic model, cm·s⁻²

g(k)

operating-region index selected from the reference-level band

hu(t)

continuous-time upper-tank liquid level, cm

hl(t)

continuous-time lower-tank liquid level, cm

hu(k)

sampled upper-tank liquid level, cm

hl(k)

sampled lower-tank liquid level, cm

hsp(k)

lower-tank level reference or setpoint, cm

hl,ref

lower-tank reference level shown in the experimental figures, cm

${\hat{h}}$u(k)

MLP-predicted nominal upper-tank level, cm

$\hat{h}$l(k)

MLP-predicted nominal lower-tank level, cm

$\hat{h}$n,u(k)

normalized predicted upper-tank level

$\hat{h}$n,l(k)

normalized predicted lower-tank level

h(k)

measured tank-level vector [hu(k), hl(k)]ᵀ, cm

${\hat{h}}$(k)

predicted nominal tank-level vector [$\hat{h}$u(k), $\hat{h}$l(k)]ᵀ, cm

$\bar{h}$i

mean measured level of tank i, cm

i

tank or residual-channel index, i ∈ {u, l}

j

neural-network layer index or location-signature index, depending on context

k

discrete-time monitoring index

kc

fast control-task sample index

Kσ

adaptive-threshold standard-deviation multiplier

Loc(k)

leak-location output: Normal, Upper, or Lower

M

MLP structure designation nx–nh1–nh2–ny

N

number of samples used for metric calculation

Np

total number of MLP weights and biases

nx

number of MLP input neurons

nh1

number of neurons in the first hidden layer

nh2

number of neurons in the second hidden layer

ny

number of MLP output neurons

psev,c,ℓ,g

representative peak severity residual averaged over the three calibration events for severity class c, leak location ℓ, and operating region g, cm

qp(t)

pump inflow to the upper tank, cm³·s⁻¹

qul(t)

inter-tank flow from the upper tank to the lower tank, cm³·s⁻¹

qo(t)

normal outlet flow from the lower tank, cm³·s⁻¹

qLu(t)

upper-tank leak flow, cm³·s⁻¹

qLl(t)

lower-tank leak flow, cm³·s⁻¹

QL

experimentally measured leak-flow rate, L·min⁻¹

q(k)

residual-signature vector [rs,u, rs,l, rf,u, rf,l]ᵀ, cm

ru(k)

signed upper-tank residual, hu(k) − $\hat{h}$u(k), cm

rl(k)

signed lower-tank residual, hl(k) − $\hat{h}$l(k), cm

r(k)

residual vector [ru(k), rl(k)]ᵀ, cm

rm,i(k)

magnitude residual |ri(k)|, cm

rf,i(k)

EMA-filtered magnitude residual, cm

rs,i(k)

EMA-filtered signed residual, cm

rsev(k)

severity residual selected as the largest filtered residual among the confirmed channels, cm

$\bar{r}$i

mean residual of tank channel i, cm

$R_{i}^{2}$

coefficient of determination for tank i

Ready(k)

monitoring-readiness state after baseline warm-up

Reset(k)

manual or PLC reset command

S(k)

severity output: Normal, Small, Medium, or Large

St(k)

stable-operating-condition state

t

continuous time, s

tcross

time from leak introduction until the filtered residual crosses its threshold, s

Δtdet

total alarm delay from leak introduction to confirmed alarm, s

Ts

PLC signal-sampling period in the discrete-time representation, s

Tc

cascade PI control-task period, ms

Tm

neural-observer and residual-monitoring task period, ms

Tlog

Modbus TCP logging interval, ms

Tw

baseline warm-up duration before monitoring is enabled, s

Tconfirm

required persistence time for leak confirmation, s

Tc,i(k)

accumulated confirmation time for residual channel i, s

THi(k)

adaptive detection threshold for residual channel i, cm

THmin

minimum allowable residual threshold, cm

THS,ℓ,g

calibrated Small-to-Medium severity boundary for location ℓ and operating region g, cm

THM,ℓ,g

calibrated Medium-to-Large severity boundary for location ℓ and operating region g, cm

uo(k)

outer PI controller output and intermediate upper-tank reference, PLC engineering unit

ui(k)

inner PI controller output and pump command, PLC engineering unit

W(j)

weight matrix of neural-network layer j

Wg

diagonal scaling matrix for signature comparison in operating region g

xi(k)

i-th unnormalized MLP input variable, variable-dependent units

xn,i(k)

i-th normalized MLP input variable

x(k)

MLP input vector [eo, ei, uo, ui]ᵀ, mixed PLC units

xn(k)

normalized MLP input vector

z(j)(k)

pre-activation vector of neural-network layer j

Greek symbols

α

EMA smoothing coefficient for magnitude and signed residuals

β

baseline-statistics adaptation gain

Δhsp(k)

absolute change in the lower-tank setpoint, cm

Δui(k)

absolute change in the pump command, PLC engineering unit

ΔV

collected leak-water volume used for flow measurement, L

Δt

collection interval used for leak-flow measurement, s

εh

setpoint-change limit for stable-condition verification, cm

εu

pump-command-change limit for stable-condition verification, PLC engineering unit

η

Adam learning rate

Θ

complete set of trained MLP weights and biases

μx,i

training-set mean of MLP input i, variable-dependent units

σx,i

training-set standard deviation of MLP input i, variable-dependent units

μh,i

training-set mean of output level i, cm

σh,i

training-set standard deviation of output level i, cm

μb,i(k)

adaptive baseline mean of the filtered magnitude residual, cm

σb,i(k)

adaptive baseline standard deviation of the filtered magnitude residual, cm

σr,i

standard deviation of the nominal residual for tank i, cm

ϕ(·)

hidden-layer activation function

ℓ

indicated leak-location class, ℓ ∈ {U, L}

Subscripts

u

upper tank or upper residual channel

l

lower tank or lower residual channel

o

outer cascade-control loop or lower-tank outlet, depending on context

i

inner cascade-control loop or generic tank-channel index

p

pump

ul

upper-to-lower inter-tank path

Lu

upper-tank leakage

Ll

lower-tank leakage

m

residual magnitude

f

filtered magnitude residual

s

filtered signed residual

b

adaptive residual baseline

n

normalized variable

sp

setpoint

sev

severity-related residual

S

small severity or Small-to-Medium boundary

M

medium severity or Medium-to-Large boundary

L

large severity or lower-tank location, depending on context

U

upper-tank location

g

operating region

c

severity class, c ∈ {S, M, L}

ℓ

leak-location class

Superscripts and notation

(j)

neural-network layer number

T

matrix or vector transpose

$\hat{h}$

estimated or MLP-predicted value

$\bar{x}$

sample mean

Δx

change between consecutive samples

Abbreviations

AI

Artificial intelligence

ANN

Artificial neural network

CNN

Convolutional neural network

CPU

Central processing unit

CTS

Coupled-tank system

EMA

Exponential moving average

FAR

False alarm rate

HMI

Human–machine interface

I/O

Input/output

IAE

Integral absolute error

LSTM

Long short-term memory

LSTM–FCN

Long short-term memory–fully convolutional network

MAE

Mean absolute error

ML

Machine learning

MLP

Multilayer perceptron

PI

Proportional–integral

PLC

Programmable logic controller

RMSE

Root mean square error

SCL

Structured control language

SD

Standard deviation

SVM

Support vector machine

  References

[1] Farah, E., Shahrour, I. (2024). Water leak detection: A comprehensive review of methods, challenges, and future directions. Water, 16(20): 2975. https://doi.org/10.3390/w16202975

[2] Zuñiga-Uribe, M., Rojas-Galván, R., Álvarez-Alvarado, J.M., Aviles, M., Pérez-Soto, G.I., Pérez-Moreno, V. (2026). Artificial intelligence in water distribution networks: A systematic review of models, input variables, databases, and output strategies for leak detection. Smart Cities, 9(3): 45. https://doi.org/10.3390/smartcities9030045 

[3] Abdulshaheed, A., Mustapha, F., Ghavamian, A. (2017). A pressure-based method for monitoring leaks in a pipe distribution system: A review. Renewable and Sustainable Energy Reviews, 69: 902-911. https://doi.org/10.1016/j.rser.2016.08.024 

[4] Bhattacharjee, K., Banerji, A.K., Alam, M.H., Das, C. (2025). Leakage detection in pipeline systems using machine learning. Asian Journal of Civil Engineering, 26(6): 2465-2473. https://doi.org/10.1007/s42107-025-01320-z

[5] Fan, X., Zhang, X., Yu, X. (2021). Machine learning model and strategy for fast and accurate detection of leaks in water supply network. Journal of Infrastructure Preservation and Resilience, 2(1): 10. https://doi.org/10.1186/s43065-021-00021-6

[6] Titova, T., Kosturkov, R., Nachev, V. (2026). Diagnosis and localization of leaks in industrial compressed air systems using the dynamic time warping (DTW) time series analysis method. Applied Sciences, 16(10): 4913. https://doi.org/10.3390/app16104913

[7] Sousa, A.L., Brochado, A.F., Rocha, E., Andrade-Campos, A. (2026). A state-of-the-art review of scientific, industrial, and commercial developments in water leakage management for water supply systems. Water Research, 299: 125853. https://doi.org/10.1016/j.watres.2026.125853

[8] Wang, N., Du, W., Liu, H., et al. (2025). Fine-grained leakage detection for water supply pipelines based on CNN and selective state-space models. Water, 17(8): 1115. https://doi.org/10.3390/w17081115

[9] Mrugalski, M., Luzar, M., Pazera, M., Witczak, M., Aubrun, C. (2016). Neural network-based robust actuator fault diagnosis for a non-linear multi-tank system. ISA Transactions, 61: 318-328. https://doi.org/10.1016/j.isatra.2016.01.002

[10] KR, A.G., Mahapatra, S. (2024). Improving precision and robustness in level control of coupled tank systems: A tree seed optimization and μ-analysis approach. Results in Control and Optimization, 15: 100410. https://doi.org/10.1016/j.rico.2024.100410

[11] Mary, A.H., Miry, A.H., Miry, M.H. (2022). ANFIS based reinforcement learning strategy for control a nonlinear coupled tanks system. Journal of Electrical Engineering & Technology, 17(3): 1921-1929. https://doi.org/10.1007/s42835-021-00753-1

[12] Meng, X., Yu, H., Xu, T., Wu, H. (2020). Disturbance observer and L 2-gain-based state error feedback linearization control for the quadruple-tank liquid-level system. Energies, 13(20): 5500. https://doi.org/10.3390/en13205500

[13] Phothongkum, K., Kuntanapreeda, S. (2025). Stability-constrained reinforcement learning for level control of nonlinear coupled tank system: An experimental study. Neural Computing and Applications, 37(6): 4277-4290. https://doi.org/10.1007/s00521-024-10852-5

[14] Workneh, H., Raptis, I. (2025). A comprehensive experimental liquid-level control system for advancing fault diagnosis research innovation: Data, models, and procedures. Advanced Control for Applications: Engineering and Industrial Systems, 7(2): e70011. https://doi.org/10.1002/adc2.70011

[15] Torres-Ruvalcaba, H., Muñoz-Vázquez, A.J., Sánchez-Torres, J.D., Fernández-Anaya, G. (2026). Robust stabilization of a system of coupled tanks based on predefined-time leak-flow estimation. Measurement and Control. https://doi.org/10.1177/00202940261434356 

[16] Sehr, M.A., Lohstroh, M., Weber, M., et al. (2020). Programmable logic controllers in the context of industry 4.0. IEEE Transactions on Industrial Informatics, 17(5): 3523-3533. https://doi.org/10.1109/TII.2020.3007764 

[17] Al-Najari, B., Hen, C.K., Siaw Paw, J.K., Marhoon, A.F. (2025). Dynamic tuning of PLC-based built-in PID controller using PSO-MANFIS hybrid algorithm via OPC server. Automation, 6(4): 83. https://doi.org/10.3390/automation6040083

[18] Nazha, H.M., Youssef, A.M., Darwich, M.A., Ibrahim, T.A., Homsieh, H.E. (2025). A comparative study on fuzzy logic-based liquid level control systems with integrated industrial communication technology. Computation, 13(3): 60. https://doi.org/10.3390/computation13030060 

[19] Tarnawski, J., Kudełka, P., Korzeniowski, M. (2022). Advanced control with PLC—Code generator for aMPC controller implementation and cooperation with external computational server for dealing with multidimensionality, constraints and LMI based robustness. IEEE Access, 10: 10597-10617. https://doi.org/10.1109/ACCESS.2022.3142054 

[20] Liu, P., Zhang, Y., Wu, H., Fu, T. (2020). Optimization of edge-PLC-based fault diagnosis with random forest in industrial Internet of Things. IEEE Internet of Things Journal, 7(10): 9664-9674. https://doi.org/10.1109/JIOT.2020.2994200

[21] Koodtalang, W., Mangkalajan, S., Sangsuwan, T., Wongsaroj, W., Hansot, J., Thong-Un, N. (2026). Real time ANN-based fault detection in PLC controlled coupled-tank level systems. In 2026 23rd International Conference on Electrical Engineering/Electronics, Computer, Telecommunications and Information Technology (ECTI-CON), Chonburi, Thailand, pp. 19-24. https://doi.org/10.1109/ECTI-CON68836.2026.11609096

[22] Duymazlar, O., Engin, M., Engin, D. (2020). Embedded artificial neural network on PLCs to predict nonlinear system responses. In 2020 9th Mediterranean Conference on Embedded Computing (MECO), Budva, Montenegro, pp. 1-4. https://doi.org/10.1109/MECO49872.2020.9134167

[23] Navarro-Díaz, A., Delgado-Aguiñaga, J.A., Santos-Ruiz, I., Sánchez-Torres, J.D. (2024). Leak diagnosis in branched pipeline systems based on a robust differentiation scheme. IEEE Access, 12: 62162-62176. https://doi.org/10.1109/ACCESS.2024.3393976

[24] Abhulimen, K.E. (2026). Modelling and design of a pipeline network leak detection system. Flow Measurement and Instrumentation, 110: 103360. https://doi.org/10.1016/j.flowmeasinst.2026.103360

[25] Wang, S., Dong, L., Wang, J., Wang, H., Ji, C., Hong, J. (2020). Experiment study on small leak detection and diagnosis for propulsion system pipelines of sounding rocket. IEEE Access, 8: 8743-8753. https://doi.org/10.1109/ACCESS.2020.2964433

[26] Saleem, F., Ahmad, Z., Siddique, M.F., Umar, M., Kim, J.M. (2025). Acoustic emission-based pipeline leak detection and size identification using a customized one-dimensional DenseNet. Sensors, 25(4): 1112. https://doi.org/10.3390/s25041112

[27] Shi, J., Zhang, X., Zhang, H., Wang, Q., Yan, J., Xiao, L. (2024). Automated detection and diagnosis of leak fault considering volatility by graph deep probability learning. Applied Energy, 361: 122939. https://doi.org/10.1016/j.apenergy.2024.122939

[28] Shi, G., Wang, X., Zhang, J., Gao, X. (2025). High precision detection pipe bursts based on small sample diagnostic method. Sensors, 25(11): 3431. https://doi.org/10.3390/s25113431

[29] Pérez-Pérez, E.D.J., López-Estrada, F.R., Valencia-Palomo, G., Torres, L., Puig, V., Mina-Antonio, J.D. (2021). Leak diagnosis in pipelines using a combined artificial neural network approach. Control Engineering Practice, 107: 104677. https://doi.org/10.1016/j.conengprac.2020.104677

[30] Zheng, G., Chen, F., Liu, X., Liu, F., Ye, J. (2025). Orifice leak detection in atmospheric vertical cylindrical storage tanks based on SVM. Machines, 13(9): 839. https://doi.org/10.3390/machines13090839 

[31] Peng, S., Zeng, H., Wu, X., Zheng, G. (2025). Leakage break diagnosis for water distribution network using LSTM-FCN neural network based on high-frequency pressure data. Water, 17(12): 1823. https://doi.org/10.3390/w17121823

[32] Rahman, K.R., Khandakar, A., Barooah, A., Ayari, M.A., Rahman, M.A. (2026). Multiphase system leak detection, localization, and dimension estimation using multi-head physics informed neural network. Process Safety and Environmental Protection, 211: 108532. https://doi.org/10.1016/j.psep.2026.108532 

[33] Zhou, M., Yang, Y., Xu, Y., et al. (2021). A pipeline leak detection and localization approach based on ensemble TL1DCNN. IEEE Access, 9: 47565-47578. https://doi.org/10.1109/ACCESS.2021.3068292

[34] Ma, Y., Shang, Z., Zheng, J., et al. (2025). Research on leak detection and localization algorithm for oil and gas pipelines using wavelet denoising integrated with long short-term memory (LSTM)–transformer models. Sensors, 25(8): 2411. https://doi.org/10.3390/s25082411 

[35] Saleem, F., Ahmad, Z., Kim, J.M. (2024). Real-time pipeline leak detection: A hybrid deep learning approach using acoustic emission signals. Applied Sciences, 15(1): 185. https://doi.org/10.3390/app15010185

[36] Wang, F., Lin, W., Liu, Z., Wu, S., Qiu, X. (2017). Pipeline leak detection by using time-domain statistical features. IEEE Sensors Journal, 17(19): 6431-6442. https://doi.org/10.1109/JSEN.2017.2740220

[37] Sohaib, M., Islam, M., Kim, J., Jeon, D.C., Kim, J.M. (2019). Leakage detection of a spherical water storage tank in a chemical industry using acoustic emissions. Applied Sciences, 9(1): 196. https://doi.org/10.3390/app9010196

[38] Nagarajan, S., Karthikeyan, B., Sobana, S. (2017). Neural network based dynamic threshold generator for sensor failure detection in a three tank interacting level process. In 2017 Trends in Industrial Measurement and Automation (TIMA), Chennai, India, pp. 1-6. https://doi.org/10.1109/TIMA.2017.8064817 

[39] Khalil, H.K., Praly, L. (2014). High-gain observers in nonlinear feedback control. International Journal of Robust and Nonlinear Control, 24(6): 993-1015. https://doi.org/10.1002/rnc.3051

[40] Liu, Y., Guo, Q., Xie, W., Wang, S. (2025). Enhanced leak detection and localization in liquid pipelines using an improved extended Kalman filter. Processes, 13(5): 1447. https://doi.org/10.3390/pr13051447

[41] Xu, D., Jin, F., Zhou, F., Zhao, J., Wang, W. (2023). Active fault diagnosis based on dual-observer for leakage detection and estimation with adaptive auxiliary signal mechanism in industrial gas networks. IEEE Transactions on Instrumentation and Measurement, 73: 1-11. https://doi.org/10.1109/TIM.2023.3331394

[42] Pérez-Pérez, E.J., González-Baldizón, Y., Fragoso-Mandujano, J.A., Guzmán-Rabasa, J.A., Santos-Ruiz, I. (2024). Data-driven fault diagnosis in water pipelines based on neuro-fuzzy zonotopic Kalman filters. Mathematical and Computational Applications, 30(1): 2. https://doi.org/10.3390/mca30010002

[43] Fernandes, R.G., Silva, D.R., de Oliveira, L.A., Neto, A.D. (2007). Fault neural classifier applied to a level control real system. In 2007 IEEE International Symposium on Industrial Electronics, Vigo, Spain, pp. 1761-1766. https://doi.org/10.1109/ISIE.2007.4374872