Author Contributions
Conceptualization, B.Y. and S.S.; methodology, B.Y. and S.S.; software, B.Y.; validation, B.Y.; formal analysis, B.Y. and S.S.; investigation, B.Y.; resources, B.Y.; data curation, B.Y.; writing—original draft preparation, B.Y. and S.S.; writing—review and editing, B.Y. and S.S.; visualization, B.Y.; supervision, B.Y.; project administration, B.Y.; funding acquisition, B.Y. All authors have read and agreed to the published version of the manuscript.
Figure 1.
Closed loop flow diagram of CTS.
Figure 1.
Closed loop flow diagram of CTS.
Figure 2.
Layout of implemented CTS.
Figure 2.
Layout of implemented CTS.
Figure 3.
Electrical block diagram of CTS.
Figure 3.
Electrical block diagram of CTS.
Figure 4.
HC-SR04 ultrasonic level sensor assembled in a specially designed 3D printed case for installation on top of each tank. (a) Top view of the sensor assembly with the protection cover open; (b) Bottom view of the sensor with transmitter and receiver, facing the water surface in the tank.
Figure 4.
HC-SR04 ultrasonic level sensor assembled in a specially designed 3D printed case for installation on top of each tank. (a) Top view of the sensor assembly with the protection cover open; (b) Bottom view of the sensor with transmitter and receiver, facing the water surface in the tank.
Figure 5.
AF-E-400 electromagnetic flow meter.
Figure 5.
AF-E-400 electromagnetic flow meter.
Figure 6.
Specially designed ball valve assembly and servo motor. (a) Technical drawing of designed ball valve. (b) Front view of ball valve assembled in a 3D-printed casing under MG-996R servo motor.
Figure 6.
Specially designed ball valve assembly and servo motor. (a) Technical drawing of designed ball valve. (b) Front view of ball valve assembled in a 3D-printed casing under MG-996R servo motor.
Figure 7.
The electrical schematics of MG996R servo motor controller.
Figure 7.
The electrical schematics of MG996R servo motor controller.
Figure 8.
The implemented electronic interface card designed on STM32F746 evaluation board.
Figure 8.
The implemented electronic interface card designed on STM32F746 evaluation board.
Figure 9.
The designed embedded software flow chart.
Figure 9.
The designed embedded software flow chart.
Figure 10.
The designed GUI possessing control and observation panels.
Figure 10.
The designed GUI possessing control and observation panels.
Figure 11.
Membership functions: (a) error and change-in-error inputs; (b) motor PWM output.
Figure 11.
Membership functions: (a) error and change-in-error inputs; (b) motor PWM output.
Figure 12.
Degree-of-membership calculation flow chart.
Figure 12.
Degree-of-membership calculation flow chart.
Figure 13.
FLC stages flow chart.
Figure 13.
FLC stages flow chart.
Figure 14.
Curve fitting plot for input flow rate to PWM conversion.
Figure 14.
Curve fitting plot for input flow rate to PWM conversion.
Figure 15.
Flow charts of implemented control cycle, FLC, FL-based PID, and FL-based FLC.
Figure 15.
Flow charts of implemented control cycle, FLC, FL-based PID, and FL-based FLC.
Figure 16.
SISO model of CTS.
Figure 16.
SISO model of CTS.
Figure 17.
FLC control on CTS model.
Figure 17.
FLC control on CTS model.
Figure 18.
Simulations of FLC with (a) SP1; (b) SP2; (c) SP3; (d) SP4.
Figure 18.
Simulations of FLC with (a) SP1; (b) SP2; (c) SP3; (d) SP4.
Figure 19.
FL-based PID controller model.
Figure 19.
FL-based PID controller model.
Figure 20.
Simulations of FL-based PID controller with (a) SP1; (b) SP2; (c) SP3; (d) SP4.
Figure 20.
Simulations of FL-based PID controller with (a) SP1; (b) SP2; (c) SP3; (d) SP4.
Figure 21.
FL-based FLC model.
Figure 21.
FL-based FLC model.
Figure 22.
Simulations of FL-based FLC with (a) SP1; (b) SP2; (c) SP3; (d) SP4.
Figure 22.
Simulations of FL-based FLC with (a) SP1; (b) SP2; (c) SP3; (d) SP4.
Figure 23.
Test screenshots from GUI for FLC with (a) SP1; (b) SP2; (c) SP3; (d) SP4.
Figure 23.
Test screenshots from GUI for FLC with (a) SP1; (b) SP2; (c) SP3; (d) SP4.
Figure 24.
Test screenshots from GUI for FL-based PID controller with (a) SP1; (b) SP2; (c) SP3; (d) SP4.
Figure 24.
Test screenshots from GUI for FL-based PID controller with (a) SP1; (b) SP2; (c) SP3; (d) SP4.
Figure 25.
Test screenshots from GUI for FL-based FLC with (a) SP1; (b) SP2; (c) SP3; (d) SP4.
Figure 25.
Test screenshots from GUI for FL-based FLC with (a) SP1; (b) SP2; (c) SP3; (d) SP4.
Table 1.
GUI commands and parameters used for UART serial communication with CTS.
Table 1.
GUI commands and parameters used for UART serial communication with CTS.
Command | Parameter 1 | Parameter 2 | Parameter 3 | Explanation |
---|
Write (W) | P | 1 | pwm | set pump driver pwm ratio |
V | 1 | valve-1 | set valve-1 orifice ratio |
2 | valve-2 | set valve-2 orifice ratio |
3 | valve-3 | set valve-3 orifice ratio |
S | 1 | set point | write constant setpoint (step) |
Kp | PID-Kp | - | write PID coefficient Kp |
Ki | PID-Ki | - | write PID coefficient Ki |
Kd | PID-Kd | - | write PID coefficient Kd |
Read (R) | N | Cycle Cnt | - | read instantaneous control cycle |
P | pump | - | read pump pwm ratio |
L | levels | - | read both tank water levels |
V | valves | - | read all valve openings |
Control Mode (CM) | 0 | manual | - | switch to manual control mode |
1 | fuzzy | - | switch to fuzzy controller |
2 | FL + PID | - | switch to FL + PID controller |
3 | FL + fuzzy | - | switch to FL + fuzzy controller |
Control (C) | B | 0–1 | - | buzzer on/off |
R | 0–1 | - | relay on/off |
E | 0–1 | - | emergency on/off |
P | 0–1 | - | pump main power on/off |
S | 1–4 | - | switch setpoint profile |
Table 2.
FLC fuzzy associative matrix for CTS.
Table 2.
FLC fuzzy associative matrix for CTS.
e’ | | NL | NS | Z | PS | PL |
---|
| e |
---|
NL | L | L | L | L | M |
NS | L | L | L | M | M |
Z | L | M | M | M | H |
PS | M | M | M | H | H |
PL | M | M | H | H | H |
Table 3.
Simulated FLC performances.
Table 3.
Simulated FLC performances.
SP | Input Type | RMSE | MAE | MSE | Overshoot (m) | Settling Time (s) |
---|
SP1 | step input–1 | 0.06593 | 0.03815 | 4.346 × 10−3 | 0.0087 | 71.8 |
SP2 | step input–2 | 0.03992 | 0.02642 | 1.594 × 10−3 | 0.0113 | 37.2 |
SP3 | sinusoidal input–1 | 0.01383 | 0.01081 | 1.912 × 10−4 | 0.0095 | - |
SP4 | sinusoidal input–2 | 0.00689 | 0.00627 | 4.751 × 10−5 | 0.0077 | - |
Table 4.
Simulated FL-based PID controller performances.
Table 4.
Simulated FL-based PID controller performances.
SP | Input Type | RMSE | MAE | MSE | Overshoot (m) | Settling Time (s) |
---|
SP1 | step input–1 | 0.06161 | 0.03688 | 3.795 × 10−3 | 0 | 75.2 |
SP2 | step input–2 | 0.04274 | 0.02989 | 1.827 × 10−3 | 0 | 59.6 |
SP3 | sinusoidal input–1 | 0.01355 | 0.01103 | 1.835 × 10−4 | 0.0232 | - |
SP4 | sinusoidal input–2 | 0.00691 | 0.00518 | 4.773 × 10−5 | 0.0083 | - |
Table 5.
Simulated FL-based FLC performances.
Table 5.
Simulated FL-based FLC performances.
SP | Input Type | RMSE | MAE | MSE | Overshoot (m) | Settling Time (s) |
---|
SP1 | step input–1 | 0.059 | 0.03008 | 3.481 × 10−3 | 0 | 51.8 |
SP2 | step input–2 | 0.03698 | 0.02092 | 1.368 × 10−3 | 0 | 29.2 |
SP3 | sinusoidal input–1 | 5.43 × 10−3 | 4.372 × 10−3 | 2.949 × 10−5 | 0.0073 | - |
SP4 | sinusoidal input–2 | 2.918 × 10−3 | 1.653 × 10−3 | 8.517 × 10−6 | 0.0023 | - |
Table 6.
Comparisons of FLC, FL-based PID, and FL-based FLC simulations in terms of tracking errors.
Table 6.
Comparisons of FLC, FL-based PID, and FL-based FLC simulations in terms of tracking errors.
| FLC | FL-Based PID | FL-Based FLC |
---|
SP | RMSE | MAE | MSE | RMSE | MAE | MSE | RMSE | MAE | MSE |
---|
SP1 | 0.0659 | 0.0382 | 0.0043 | 0.0616 | 0.0369 | 0.0038 | 0.059 | 0.0301 | 0.0035 |
SP2 | 0.0399 | 0.0264 | 0.0016 | 0.0427 | 0.0299 | 0.0018 | 0.0370 | 0.0209 | 0.0014 |
SP3 | 0.0138 | 0.0108 | 1.9 × 10−4 | 0.0136 | 0.0110 | 1.8 × 10−4 | 0.0054 | 0.0044 | 2.9 × 10−5 |
SP4 | 0.0069 | 0.0063 | 4.8 × 10−5 | 0.0069 | 0.0052 | 4.8 × 10−5 | 0.0029 | 0.0017 | 8.5 × 10−6 |
Table 7.
Comparison of simulation results in terms of overshoot and settling time.
Table 7.
Comparison of simulation results in terms of overshoot and settling time.
| FLC | FL-Based PID | FL-Based FLC |
---|
SP | Overshoot (m) | Settling Time (s) | Overshoot (m) | Settling Time (s) | Overshoot (m) | Settling Time (s) |
---|
SP1 | 0.0087 | 71.8 | 0 | 75.2 | 0 | 51.8 |
SP2 | 0.0113 | 37.2 | 0 | 59.6 | 0 | 29.2 |
SP3 | 0.0095 | - | 0.0232 | - | 0.0073 | - |
SP4 | 0.0077 | - | 0.0083 | - | 0.0023 | - |
Table 8.
Experimental FLC performances.
Table 8.
Experimental FLC performances.
SP | Input Type | RMSE | MAE | MSE | Overshoot (m) | Settling Time (s) |
---|
SP1 | step input–1 | 0.06509 | 0.03559 | 4.236 × 10−3 | 0.011 | 64.2 |
SP2 | step input–2 | 0.03956 | 0.02513 | 1.564 × 10−3 | 0.021 | 28.6 |
SP3 | sinusoidal input–1 | 0.01423 | 0.01112 | 2.026 × 10−4 | 0.014 | - |
SP4 | sinusoidal input–2 | 0.00712 | 0.00639 | 5.067 × 10−5 | 0.009 | - |
Table 9.
Experimental FL-based PID controller performances.
Table 9.
Experimental FL-based PID controller performances.
SP | Input Type | RMSE | MAE | MSE | Overshoot (m) | Settling Time (s) |
---|
SP1 | step input–1 | 0.06722 | 0.03976 | 4.518 × 10−3 | 0 | 72.4 |
SP2 | step input–2 | 0.04452 | 0.03062 | 1.982 × 10−3 | 0 | 55.8 |
SP3 | sinusoidal input–1 | 0.01249 | 0.00983 | 1.560 × 10−4 | 0.013 | - |
SP4 | sinusoidal input–2 | 0.00476 | 0.00319 | 2.266 × 10−5 | 0.008 | - |
Table 10.
Experimental FL-based fuzzy logic controller performance in terms of overshoot, settling time, and tracking errors.
Table 10.
Experimental FL-based fuzzy logic controller performance in terms of overshoot, settling time, and tracking errors.
SP | Input Type | RMSE | MAE | MSE | Overshoot (m) | Settling Time (s) |
---|
SP1 | step input–1 | 0.06531 | 0.03487 | 4.265 × 10−3 | 0.003 | 54 |
SP2 | step input–2 | 0.04406 | 0.0281 | 1.942 × 10−3 | 0 | 24.8 |
SP3 | sinusoidal input–1 | 9.31 × 10−3 | 7.524 × 10−3 | 8.667 × 10−5 | 0.012 | - |
SP4 | sinusoidal input–2 | 4.02 × 10−3 | 2.863 × 10−3 | 1.616 × 10−5 | 0.004 | - |
Table 11.
Comparison of experimental results in terms of tracking errors.
Table 11.
Comparison of experimental results in terms of tracking errors.
| FLC | FL-Based PID | FL-Based FLC |
---|
SP | RMSE | MAE | MSE | RMSE | MAE | MSE | RMSE | MAE | MSE |
---|
SP1 | 0.0651 | 0.0356 | 0.0042 | 0.0672 | 0.0398 | 0.0045 | 0.0653 | 0.0349 | 0.0043 |
SP2 | 0.0396 | 0.0251 | 0.0016 | 0.0445 | 0.0306 | 0.002 | 0.0441 | 0.0281 | 0.0019 |
SP3 | 0.0142 | 0.0111 | 2.0 × 10−4 | 0.0125 | 0.0098 | 1.6 × 10−4 | 0.0093 | 0.0075 | 8.7 × 10−5 |
SP4 | 0.0071 | 0.0064 | 5.1 × 10−5 | 0.0047 | 0.0032 | 2.3 × 10−5 | 0.0040 | 0.0028 | 1.6 × 10−5 |
Table 12.
Comparison of experimental results in terms of overshoot and settling time.
Table 12.
Comparison of experimental results in terms of overshoot and settling time.
| FLC | FL-Based PID | FL-Based FLC |
---|
SP | Overshoot (m) | Settling Time (s) | Overshoot (m) | Settling Time (s) | Overshoot (m) | Settling Time (s) |
---|
SP1 | 0.011 | 64.2 | 0 | 72.4 | 0.003 | 54 |
SP2 | 0.021 | 28.6 | 0 | 55.8 | 0 | 24.8 |
SP3 | 0.014 | - | 0.013 | - | 0.012 | - |
SP4 | 0.009 | - | 0.008 | - | 0.004 | - |