Share this

Design and Implementation of a Building Constant Pressure Variable Frequency Water Supply Monitoring System Based on CAN Bus

2026-04-06 03:49:36 · · #1

Abstract: This paper proposes a fuzzy PID algorithm control system for a water supply system using an 89C51 microcontroller as the controller. Furthermore, a low-level control network constructed using CAN bus technology is utilized to communicate with a monitoring computer, enabling on-site data acquisition, transmission, and remote monitoring of the building's water supply equipment. Experiments show that the constant pressure variable frequency water supply monitoring system achieves good control and monitoring results.

Keywords: Fuzzy PID; CAN bus; 89C51; Remote monitoring

1 Introduction

Traditional water supply systems largely rely on manual parameter adjustments for control, with critical parameters still recorded manually at set intervals. Water demand is time-varying; during peak periods, network pressure falls below standard levels, causing water outages in high-rise buildings. Conversely, during off-peak periods, pressure frequently exceeds limits, increasing the risk of pipe bursts and significant energy waste. Furthermore, traditional building electromechanical control equipment operates independently, lacking network communication capabilities and hindering off-site or remote monitoring. This paper proposes a constant-pressure water supply system using a fuzzy PID algorithm with Smith predictive compensation and frequency converter control. This system offers advantages such as economical operation, high reliability, and significant energy savings. The underlying control network, constructed using CAN fieldbus technology, employs a distributed structure and decentralized control principle, offering ease of use and expansion. It effectively meets the real-time and reliability requirements of building monitoring systems for remote monitoring.

The building water supply system adopts a control scheme of "general-purpose frequency converter + microcontroller (including PID controller) + power frequency/frequency conversion switching". The field controller can complete the data acquisition of field pipeline pressure feedback value, input of pressure setpoint, fuzzy PID regulation calculation, and finally send the control quantity to the frequency converter to control the speed of the water pump motor to achieve constant pressure water supply; at the same time, it can receive commands from other CAN nodes (mainly the host monitoring computer) or actively send its own data to the CAN bus for the host monitoring computer to receive, realizing human-machine interaction function.

2. System Hardware Design

2.1 Hardware Design of a CAN Bus-Based Remote Monitoring Building Automation System

CAN (Controller Area Network) bus is a serial communication local area network that supports distributed real-time control systems. Its signal transmission uses a short frame structure, with each frame containing 8 effective bytes, resulting in short transmission time and a low probability of interference. Due to its high performance, high reliability, and real-time capabilities, it has been widely used for data communication between detection and actuator mechanisms in control systems. The CAN bus conforms to the ISO 11898 standard, with a maximum transmission rate of 1MB/s (maximum transmission distance of 40m) and a maximum transmission distance of 10km (transmission rate approximately 5kbps).

The CAN bus-based remote monitoring building automation system consists of a computer and various intelligent nodes, as shown in Figure 1. The computer is equipped with a high-performance, cost-effective PCI-9820 non-intelligent two-channel CAN interface card. This product uses a standard PCI interface, allowing the computer to easily connect to the CAN bus and achieve CAN 2.0B protocol (compatible with CAN 2.0A) communication. The PCI-9820 interface card features two logically independent CAN interfaces, making development and application more convenient and flexible: each channel is opto-isolated, protecting the computer from ground loop damage and enhancing the system's reliability in harsh environments.


Figure 1. Schematic diagram of building water supply system


Figure 2. Block diagram of the field controller for the water supply system.



Unlike DCS control systems, this system's topology does not have all lower-level machines centered around the upper-level machine. Instead, all nodes are connected to the bus as "equal entities," with the upper-level computer merely acting as an equal intelligent node in the CAN bus.

2.2 Hardware Design of the Field Controller for the Building Water Supply System

The building constant pressure water supply system can be divided into five parts: CPU module, human-machine interface module (including keyboard input and LED display circuit), A/D and D/A conversion module, DI/DO module, and CAN communication module, as shown in Figure 2.

The CPU module uses the AT89C51 microcontroller chip from Atmel, which has 4KB of on-chip FLASH ROM. To improve system reliability, the MAX1232 chip, which features voltage monitoring and an integrated watchdog timer, is used to effectively prevent program crashes. In the A/D and D/A conversion modules, the signal input circuit primarily converts the pressure transmitter's current (4-20mA) output signal into a 0-5V analog voltage signal via an RCV420 current-to-voltage converter chip. This signal is then converted into a digital signal by an ADC0809 analog-to-digital converter. Similarly, after processing by the CPU's fuzzy PID algorithm, the signal is converted into a 0-10V voltage signal by an AD558 digital-to-analog converter to control the inverter's output speed.

This design uses an 8255 microcontroller for I/O expansion. Port A of the 8255 is used for ID settings in CAN network communication; Port B is used for digital input, such as external water level detection, which is input to Port B via optocoupler; Port C is used for digital output, controlling contactor groups to different on/off states. Control information from the microcontroller is output from Port C of the 8255, and through driver and relay isolation, controls the contactor's action, generating corresponding control signals.


Figure 3. Circuit diagram of CAN communication module for water supply system



In the hardware circuit design for CAN bus communication, a CAN bus interface circuit consisting of a PHILIPS independent CAN communication controller SJA1000 and a CAN bus interface TJA1040 is used, as shown in Figure 3. The transmission and reception of CAN bus nodes are controlled by pre-setting acceptance codes and acceptance mask codes, allowing intelligent nodes to control which data or commands they receive from the bus. The SJA1000 is controlled by an 89C51 microcontroller via an 8-bit address-data multiplexed bus and read/write control signals. The SJA1000's interrupt request signal INT is connected to the 89C51's external interrupt input INT0, allowing the CAN communication controller to transmit data with the microcontroller via interrupts. The SJA1000's transmit output TX0 and receive inputs RX0 and RX1 are isolated by a high-speed integrated optocoupler 6N137 and then connected to the CAN bus interface chip TJA1040. The photosensitive device in the 6N137 uses a photodiode, which can meet the requirements of high-speed digital signal transmission, achieving isolated transmission between the CAN bus and the nodes, thus improving the safety and reliability of the node device.

3. Software Design of Building Variable Frequency Constant Pressure Water Supply Monitoring System

3.1 Software Design of Building Variable Frequency Constant Pressure Water Supply System Controller


Figure 4 shows the structure of the parameter self-tuning fuzzy control PID controller.



Fuzzy control is a computer-based digital control system grounded in fuzzy set theory, fuzzy linguistic variables, and fuzzy logic inference. A fuzzy controller consists of three parts: fuzzification, fuzzy inference, and defuzzification. Since a constant pressure water supply speed regulation system comprises multiple components such as pumps, motors, and frequency converters, the entire system involves numerous parameters, some of which change during system operation. The pump's operating characteristics exhibit strong nonlinearity; changes in pipeline head and electrical load and its characteristics will alter the pump's operating point, thus changing the system parameters. For such a controlled object, conventional PID controllers struggle to guarantee optimal control performance under all operating conditions. This paper employs a parameter-self-tuning fuzzy PID algorithm, using the error e and error change rate ec as inputs, which can satisfy the requirements of deviation e and error change rate ec at different times. The self-tuning principle of parameter-autotuning fuzzy PID control is to first find the fuzzy relationship between the controller's three parameters KP, KI, and KD and the deviation e and the rate of change of deviation ec. During operation, by continuously detecting e and ec and using them as inputs to the controller, the controller adjusts the three parameters online according to fuzzy control rules to meet the different requirements of e and ec on the controller parameters, thereby enabling the controlled object to have good dynamic and static performance. The requirement for PID parameter self-tuning, achieved by modifying the PID parameters using fuzzy control rules, constitutes the parameter-autotuning fuzzy PID control system. The structure of the parameter-autotuning fuzzy PID controller is shown in Figure 4.

In water supply control, time lag negatively impacts system performance, especially when the time lag is significant. In water supply systems, time lag leads to poor dynamic performance. While fuzzy PID control greatly reduces the impact of parameter changes on control performance, it doesn't fundamentally solve the problem of large time lags. In designing a fuzzy PID controller for the water supply system, we introduced Smith predictive control, combining the two to design a Smith-compensated fuzzy PID controller, achieving good application results.


Figure 5. Flowchart of the main program of the system



The software design of the water supply system field controller can be broadly divided into three parts: initialization, including microcontroller initialization and CAN controller initialization; sampling, calculation, and control output of field water pressure; and data transmission and control commands and parameters from other nodes (including the host monitoring computer) as a CAN node. Specifically, the system software consists of three parts: the main program, the timer T0 interrupt program, and the external CAN communication INT0 interrupt program. The main program primarily handles system initialization, keyboard scanning, fuzzy PID calculation, and water level fault handling, as shown in Figure 5.

In this design, the Timer T0 interrupt is a crucial program for the field control of the water supply system, including modules such as pipeline pressure sampling, pipeline pressure display, median filtering, and CAN transmission subroutines. When Timer T0 operates in Mode 1, its maximum timing interval is 65.536ms, but a 1-second timing interval is achieved. The flowchart of the Timer T0 interrupt is shown in Figure 6. For remote monitoring, the pipeline pressure sampled by the field controller must be transmitted to the host computer via the communication bus. Simultaneously, the field controller should also receive control commands from the host computer, such as commands to stop the water pump in emergencies. Due to the real-time requirements of control information, this design uses the INT0 interrupt method for receiving information via CAN communication. The flowchart of the INT0 interrupt program is shown in Figure 7.


Figure 6. Flowchart of Timer T0 interrupt


Figure 7 Flowchart of CAN Interrupt Receive Program



3.2 Design of Monitoring Software for Building Variable Frequency Constant Pressure Water Supply System

The system's monitoring software is implemented using VC6.0. The overall software design tasks include determining the overall software structure, subsystems and module divisions, defining the interfaces between modules, evaluating the quality of module division, and performing data analysis.


Figure 8 Overall System Software Structure Diagram



Analysis. Based on the requirements and process of the overall software design, this design decomposes the system's information management and monitoring program into different modules according to their functions. The information management and monitoring software of the water supply automation computer control system mainly includes three parts: data acquisition and communication, equipment status control, and data management. The data acquisition and communication part collects data such as water level, pressure, flow rate, voltage, and current for recording, storage, and analysis, as well as communication with CAN. The equipment control part determines the current operating status of the system based on the collected data and can adjust the equipment's operating status by modifying operating parameters. The data management part is responsible for data statistics, querying, and printing output, as well as database backup and maintenance. The overall system software structure diagram is shown in Figure 8.

6. Conclusion

Through system testing and debugging, the design and implementation plan of this intelligent node has been proven successful. It can reliably operate and complete the required tasks, with control information processed on-site and the management layer implemented in the host computer. This demonstrates the high performance and high reliability of the CAN bus, achieving the goal of remote or centralized monitoring of building automation systems.

References:

[1] Wang Na. Building Automation System (BAS) and its design in intelligent buildings. Journal of Northwest Institute of Architectural Engineering, 1997, (2): 58-62.

[2] Yang Xianhui. Fieldbus Technology and Its Applications. Beijing: Tsinghua University Press, 1999: 135-230.

[3] Rao Yuntao, Zou Jijun, Zheng Yongyun. CAN Fieldbus Principles and Applications. Beijing: Beijing University of Aeronautics and Astronautics Press, 2003: 224-227.

[4] Liu Yongxin, Li Chungui. Microcontroller-controlled variable frequency speed regulation constant pressure water supply system. Journal of Guangxi Institute of Technology, 2001, 12(4): 10-12.

Read next

CATDOLL Ava Soft Silicone Head

You can choose the skin tone, eye color, and wig, or upgrade to implanted hair. Soft silicone heads come with a functio...

Articles 2026-02-22