Share this

CAN bus-based dual-tank water control system

2026-04-06 05:10:13 · · #1
1 Introduction CAN (Control Area Network) was originally designed by Bosch in Germany for automotive monitoring and control systems. Due to its high performance, high reliability, and unique design, it has gained increasing attention. Currently, the CAN bus is the only international standard and is widely recognized as one of the most promising fieldbuses. CAN has the following main characteristics: (1) Multiple masters access the bus based on priority; (2) Non-destructive priority-based arbitration; (3) Multi-address transmission with receiver filtering; (4) Remote data request; (5) Configuration flexibility; (6) System-wide data compatibility; (7) Error detection and error messages; (8) Automatic retransmission of frames lost due to arbitration or corruption due to errors; (9) Identification of temporary errors and permanent fault nodes, and automatic disconnection of faulty nodes. Considering these advantages of the CAN bus, we designed a dual-tank water level control system based on the CAN bus. 2. System Overall Structure The dual-tank test bench consists of two water tanks, a frequency converter, a water level sensor, an AC motor, a water pump, and a distribution panel. The water level sensor measures the water level in the controlled tank, and the water pump pumps water from the supply tank. The system control aims to maintain the water level in the controlled tank at a given height, and to restore the water level to the given height when external disturbances or changes in the object's characteristics are applied. This system transforms ordinary transmitters, actuators, and PCs into intelligent nodes with CAN interfaces, and then organically connects them via a bus to form a complete control system. The overall structure of the control system is shown in Figure 1. [align=center] Figure 1 Overall Structure Diagram of the Dual-Tank Water Tank Control System[/align] The system's network topology adopts a bus structure, which can be divided into two layers: the field control layer and the process monitoring layer. 2.1 Field Control Layer The field control layer is the bottom layer of the system, consisting of transmitters or actuators with CAN interfaces. They communicate with each other via the CAN bus to complete all control work. Its basic working process is as follows: The transmitter transforms the value of the controlled variable into a standard signal. This signal undergoes A/D conversion and digital filtering within the CAN interface. The resulting digital signal is then transmitted to the corresponding CAN interface via the bus. Within this node, the signal is received and calculated according to the selected control algorithm (PID or fuzzy control). The calculation result is then converted to D/A, and the analog signal is amplified to drive the actuator. In this way, the entire control system can form a complete closed-loop control system according to certain control laws. 2.2 Process Monitoring Layer The process monitoring layer is the layer above the field control layer. It receives the required production process data transmitted from this layer and sends operation commands to this layer so that operators can monitor the entire production process. The process monitoring layer can be connected to Ethernet so that the management layer can directly and quickly obtain data from the production line, fully demonstrating the advantages of fully digital fieldbus. The process monitoring layer mainly consists of two parts: a CAN adapter and a host computer. One end of the CAN adapter is connected to the bus to complete communication with the CAN bus; the other end is connected to the host computer to complete communication with the host computer. Its main function is to transmit the operation signals and control parameters of the host computer to the designated CAN network node, and at the same time, transmit the data of the node to the host computer for further processing. This system exchanges data with the host computer through the RS232 serial port. Although this method has a low transmission speed, it is simple in structure, easy to implement and inexpensive. 3. Hardware design of the system As can be seen from the overall system structure diagram (Figure 1), the system hardware mainly includes 3 CAN smart stations: CAN communication adapter (#3 CAN smart station), smart sensor node (#1 CAN smart station) and smart actuator node (#2 CAN smart station). The design of each smart station is similar. The smart sensor node is used as an example for introduction below. Its hardware structure diagram is shown in Figure 2. [align=center] Figure 2 Hardware structure diagram of smart sensor node[/align] The CAN communication circuit is the focus of this introduction. This part of the circuit is mainly composed of the CAN protocol chip SJA1000, the CAN transceiver chip 82C250 and the opto-isolation circuit. (1) CAN controller The CAN controller is the core chip of CAN communication. Its main function is to implement the CAN bus protocol and interface with the microprocessor. The CAN controller used in this paper is the Philips SJA1000, which is an independent CAN controller that supports the CAN 2.0b protocol and can implement all functions of the CAN bus physical layer and data link layer. The SJA1000 has two working modes to choose from: basicCAN mode and Pelican mode. In this design, the Pelican mode is used, which has the following extensions on the basis of basicCAN mode: error counter for read/write access, programmable error alarm limit, most recent error code register, interrupt for each CAN bus error, support for hot-plugging, listen-only mode, and single-transmission capability. These added functions are very important for system optimization and error diagnosis. (2) CAN transceiver The CAN transceiver uses the PCA82C250, which is the interface between the CAN controller and the physical bus. It can improve the bus drive interference capability, increase the communication anti-interference capability, and protect the SJA1000 from damage. It can support up to 110 nodes and can work under harsh working conditions at a transmission rate of 1 Mbps. The 82C250 provides differential transmission capability to the bus and differential reception capability to the CAN controller. Its differential receiver has a wide common-mode rejection ratio and strong anti-electromagnetic interference capability. It has internal bus protection circuit and current limiting circuit, and has low current standby operation mode and slope control to reduce radio frequency interference. (3) Optocoupler The optocoupler is used to isolate the network and the internal system to improve its anti-interference performance. The hardware circuit diagram of the CAN communication part is shown in Figure 3. [align=center] Figure 3 CAN communication circuit schematic diagram[/align] 4 System software design The software of the CAN bus-based measurement and control system is divided into lower-level computer part and upper-level computer part. The lower-level computer software completes the functions of acquisition, control, and data transmission. It adopts a modular design method and mainly includes the following modules: general CAN communication module, control algorithm module, RS232 communication module, data acquisition and output module, self-test and fault handling module. The upper-level computer software mainly completes the configuration of the monitoring screen and communication with the adapter card. The software is written in different languages ​​according to different situations. The microcontroller part is written in C51 language and uses the Keil C51 integrated development environment. The configuration software uses "KingSCADA 6.5", which is a popular intelligent software package for building human-machine interfaces for industrial control objects. It supports Microsoft Windows 95/98/NT Chinese operating systems and can easily develop fully functional and user-friendly configuration software. The communication and scheduling software of the host computer is written in the high-level language Visual Basic 6.0. It supports object-oriented programming, has rich control resources, and can save a lot of development time. The design of the CAN communication module and the host computer communication program is described in detail below. 4.1 Design of the general CAN communication module The function of the general CAN communication module is to complete the initialization settings of the CAN controller; control the data exchange between nodes; detect the status of each node and the bus; and perform fault handling. Its program flowchart is shown in Figure 4. [align=center] Figure 4 Flowchart of the main program of the communication module[/align] 1) Initialization settings of the CAN controller The initialization of the CAN controller mainly completes the initialization settings of SJA1000, which is a key point and a difficult point in the design. After the system is powered on, the hardware is reset, or the main controller issues a reset command, the SJA1000 needs to be initialized to set important parameters such as its working mode, communication rate, output control method, identifier, and masking format. (2) Data transmission and reception submodule The data transmission and reception submodule mainly controls the transmission and reception of data from each node. The transmission of data from the SJA1000 CAN controller to the CAN bus is automatically completed by the CAN controller. The transmission program only needs to send the packaged data to the CAN's transmission buffer and then start the transmission command. The transmission program can use either polling or interrupt mode. Since the polling method is relatively simple, it will not be introduced here. For the interrupt mode, the transmission program is divided into two parts: one is the main program and the other is the interrupt service program. The main program is mainly used to control the transmission of information and to temporarily store the information to be transmitted in the temporary storage area when the transmission buffer is full; the interrupt transmission program is responsible for sending the temporary information in the temporary storage area. The transmission of information from the CAN bus to the CAN reception buffer is automatically completed by the CAN controller. The reception program only needs to read the information to be received from the reception buffer. The reception program can also use either polling or interrupt mode, and the complexity of the two is similar. 4.2 Design of the Host Computer Communication Program The host computer software design mainly includes two parts: the design of the monitoring interface software and the design of the communication software with the adapter. The monitoring interface uses the "KingSCADA" software package, and further development is performed for different system applications. The communication program is written in VB. The host computer's communication program is equivalent to an interface conversion program, exchanging data with the adapter's RS232 port on one side and with KingSCADA on the other, as shown in Figure 5. [align=center] Figure 5 Functional diagram of the host computer communication program[/align] Communication between VB and the adapter card is completed through the RS232 protocol, which can be easily implemented using the VB communication control MSComm. Communication between VB and KingSCADA is implemented through Dynamic Data Exchange (DDE). 5 Conclusion Fieldbus, due to its high reliability as a digital serial network and its low cost as a computer network, is highly favored and has been widely used in various measurement and control systems. CAN bus is a fieldbus that has developed rapidly among fieldbus technologies. Compared with other buses, the data communication of the bus has unique technical characteristics such as reliability, real-time performance and flexibility. It is a serial communication network that effectively supports distributed control or real-time control and is easy for users to carry out secondary development. Therefore, it is increasingly valued by various industrial manufacturers and has become one of the most promising fieldbuses. The dual-tank water level control system based on CAN bus introduced in this paper has been successfully applied in the system laboratory of the School of Motion Engineering of Wuhan University. The experiment proved that the system runs stably and has good real-time control performance. References [1] Wu Kuanming. CAN bus principle and application system design [M]. Beijing: Beijing University of Aeronautics and Astronautics Press, 1996. [2] Ma Zhongmei et al. C language application design of single-chip microcomputer [M]. Beijing: Beijing University of Aeronautics and Astronautics Press, 2003. [3] data sheet sja1000 [Z]. philips semiconductors.
Read next

CATDOLL Cici Hard Silicone Head

The head made from hard silicone does not have a usable oral cavity. You can choose the skin tone, eye color, and wig, ...

Articles 2026-02-22