0 Introduction Ordinary electric valves are a type of universal actuator, widely used in industrial process control as an important actuator, playing an irreplaceable role. The valve electric actuator, powered by a motor, drives a mechanical reduction gear to transmit power to the valve, achieving the final opening and closing of the valve; it is the core component of an electric valve. In recent years, domestic electric valve manufacturers have gradually mastered core technologies such as mechanical transmission and manufacturing through the introduction and absorption of advanced international technologies and cooperation with internationally renowned companies such as Limitorque and Rotork. Coupled with price advantages, they have achieved a dominant position in the domestic market. With the improvement of industrial automation, especially the emergence of fieldbus technology, electric valves with only local operation and simple point-to-point control functions are increasingly unable to meet market needs. Major foreign companies have launched fieldbus electric valve products, but these are expensive. Therefore, improving the automation level of electric valves in China, upgrading domestic electric valve products, launching their own fieldbus products, enhancing product competitiveness, consolidating the domestic market, and gradually participating in international competition are of great significance in today's WTO accession era. Fieldbus is a digital, serial, multi-point communication data bus used for communication between field devices in manufacturing or process areas and automatic control devices in control rooms. It is also known as an open, digital, multi-point communication low-level control network. The emergence of fieldbus provides a fully distributed solution for industrial automation, improving the intelligence and autonomy of field devices and facilitating system installation and maintenance. There are many types of fieldbuses; there are as many as 13 international standard fieldbuses. Among them, CAN bus has become a hot topic in domestic fieldbus development due to its support for multi-master mode, excellent short frame transmission performance, extremely high reliability, non-destructive bus-priority arbitration, chip support from many semiconductor manufacturers such as Intel, Philips, and Motorola, as well as relatively simple development methods and low development costs. This paper studies a valve control system based on CAN bus, which applies microcontroller technology and CAN technology to a domestically produced general-purpose electric valve, forming a valve remote control system together with an industrial control computer. 1 Overall Design of Valve Remote Control System General-purpose valves do not have high requirements for control accuracy and are relatively simple to operate, with only three states: open, closed, and stopped. Typically, operators control valves on-site by manipulating the valve controller, with the valve opening degree indicated by a pointer-type instrument. For safety, the controller includes a shutdown function in case of valve failure; however, fault diagnosis relies heavily on operator experience and may even require opening the valve cover for inspection, causing maintenance inconvenience. This paper proposes a remote valve control system with two levels: upper and lower control. Besides retaining the original on-site operation functions, operators can also remotely operate the valves via a host computer. The host computer provides a user-friendly human-machine interface, supports simple configuration of different valves in the system, and uses database technology to manage the status and fault information of each valve during system operation, facilitating system maintenance. In addition to a fieldbus interface for communication with the lower control unit, the host computer should also have an Ethernet interface for information exchange with external systems. The lower control unit, while retaining as much of the original electric actuator electrical structure as possible, introduces microcontroller technology to form an embedded control system. This system supports both on-site operation and remote control from the host computer, which can be switched via a field switch. The lower-level control system incorporates detection circuits and a fieldbus interface, enabling the collection of a large amount of fault information during valve operation. The microcontroller controls the valve's opening and closing according to the valve opening value set on-site or by the host computer, and also responds to data requests from the host computer, uploading valve operation information to it. The host and lower-level systems are connected via a fieldbus, with clearly defined roles, forming a true fully distributed fieldbus control system (FCS). Based on the above analysis, this paper adopts a two-level system structure of centralized management and distributed control, as shown in Figure 1. Figure 1: Simplified structure of the CAN bus valve control system. The host computer uses an industrial control computer, which, in addition to the functions mentioned above, also includes functions such as operation information statistics printing and system alarms. The lower-level system is a control unit with a microcontroller at its core, embedded in the valve, working together with the valve's electrical control components to achieve control functions. The system communication uses the CAN bus. The CAN bus protocol is simple, consisting only of the physical layer and data link layer. Users can define their own application layer. Shielded twisted-pair cable can be used as the transmission medium. Signal transmission uses a short frame structure, with each frame containing 8 effective bytes, resulting in short transmission time and low probability of interference. The bus communication rate can reach up to 1Mbps/40m, and the direct transmission distance can reach up to 10km/5Kbps. Up to 110 devices can be connected to the bus. When a node experiences a serious error, it can automatically disconnect from the bus. There is a wealth of literature on CAN bus technology, which will not be detailed here. The CAN bus is used in the remote valve control system mentioned in this paper because the valve control function logic is simple and the information volume is small, combined with considerations such as the CAN bus data transmission speed, ease of development, technical support, and cost. 2. Host Computer Design The system's host computer hardware uses an Advantech IPC-6718V industrial computer, paired with an Advantech PCL-841 dual-port CAN interface card. This provides stable performance and significantly shortens the system development cycle. The host computer software is designed using VB610 to facilitate the implementation of various monitoring functions required by users. The host computer software includes several parts, such as a system security module, a system communication parameter setting module, a database module, and a valve control module. Figure 2 shows the relationship between the various software modules of the host computer. As can be seen from the figure, the host computer software not only implements valve control functions but also fully considers the system security and database operations required by control software. Among them, the valve control module is the core of the host computer software. Figure 2: Host Computer Software Module Relationship Diagram. The main function of the host computer software is to monitor the status of each valve in the entire system and provide users with remote control operations for the valves in the field. After the host computer software starts, it first initializes the system and then enters the system monitoring operation mode. If it is the first application, configuration is required after initialization according to the specific system conditions. In the operation mode, the host computer and the lower-level valve control unit exchange information in a question-and-answer manner. The host computer analyzes the various status and fault information returned by each valve, refreshes the corresponding data in the database, and refreshes the corresponding parts on the main monitoring interface. Because the main monitoring interface displays numerous valves, it can only show the basic operating status (start, stop, fault) and opening degree of each valve. To view detailed operating information for a specific valve, users can click the valve icon on the interface to switch to the individual valve monitoring interface. This interface provides basic information such as the valve's current opening degree and on/off status, as well as alarm and fault information such as motor phase loss, over-limit operation, and motor overheating. Figure 3 illustrates the software flow of this process. To improve response speed during remote control, the host computer incorporates a remote control function for individual valves within the system. In this mode, the user transmits the required valve opening degree to the corresponding lower-level device via the CAN bus. The lower-level device then controls the valve's start and stop, transmitting the entire operating status to the host computer in real time. In practical applications, if different valves in the system require联动 (interlocking/coordination), this can also be achieved through host computer programming. 3. Lower-Level Machine Design The valve's operation is controlled by a lower-level machine embedded within the valve. Upon receiving a command specifying the opening degree, the lower-level machine analyzes the valve's current operating status and various states. If the valve is in a permissible operating state, the lower-level machine issues the analyzed command (open or close). When the valve reaches the specified opening degree, it executes a shutdown operation. The lower-level machine design will be described in detail below from both hardware and software perspectives. 3.1 Lower-Level Machine Hardware Design The lower-level machine is a single-chip microcomputer control system with "autonomous" capabilities. It adds fault signal acquisition and a CAN bus interface for external communication to the existing electrical control circuit. The lower-level machine circuit can be structurally and functionally divided into a main control unit module, a power monitoring module, a data acquisition and control interface module, a human-machine interface module, and a bus communication module. Their relationships are shown in Figure 4. ① Main Control Unit Module The main control module is the core of the entire lower-level machine, consisting of a minimum single-chip microcomputer system. It coordinates the work of the other four modules to complete the lower-level machine's control functions. Considering the number of valve operation and fault information collection points and the complexity of system development, this system selected the PHILIP MCS51 series microcontroller 80C552. It features 256 bytes of readable and writable RAM, five 8-bit I/O ports, one 8-bit input port, two 16-bit timers/counters, one 16-bit timer with a configuration capture/compare module, 15 interrupt sources, two interrupt priorities, eight 10-bit A/D converters, two pulse width modulation outputs, two serial ports (asynchronous serial port and I2C bus port), and an integrated watchdog timer. ② Power Monitoring Module: During valve operation, the main power circuit may fail for various reasons. Users require that the monitoring section of the lower-level system continue to operate briefly under these circumstances and promptly upload the fault information to the upper-level monitoring system so that operators can detect and resolve it early. Therefore, this paper designs a power monitoring module in the lower-level controller to monitor the valve's power supply status and switch between the main power supply and backup power supply. The circuit structure is shown in Figure 5. When the main power circuit fails, the backup power supply only powers the microcontroller system. Since the microcontroller system operates in power-saving mode with low power consumption at this time, ordinary dry-cell batteries or rechargeable batteries are used as the backup power supply. Experiments have shown that the backup power supply can operate for more than 12 hours when the main power circuit fails, which fully meets the needs of maintenance. ③ Data Acquisition and Control Interface Module This part is the input and output section of the lower-level control system. It mainly completes the acquisition of various alarm signals and valve opening degrees, and controls the valve opening, closing, and stopping. Its structure is shown in Figure 6. In the data acquisition circuit, in addition to acquiring basic operating status, a large number of signal acquisition points are added, such as motor phase loss, torque over-limit, motor overheating, fuse failure, limit switch in position, and emergency braking status, improving the monitoring capability of the lower-level machine. Most of the acquired and control signals in the valve are high-voltage signals. To protect the microcontroller system from interference, an isolation design is used in the circuit, increasing the system's reliability. Figure 6 Input/Output Circuit Structure ④ The human-machine interface module (HMI) allows for remote control of the valve via the host computer, as well as on-site control via a handheld device. This handheld device is the HMI module in the lower-level machine. It consists of a keyboard and a digital tube display circuit. The handheld device utilizes I2C bus technology. The keyboard circuit uses the PCF8574 input/output expansion chip with an I2C interface, and the display circuit uses the SAA1064 digital tube display driver chip with an I2C interface. The 80C552 microcontroller itself integrates an I2C bus interface, facilitating the system's hardware and software design. The hardware structure of the handheld device is shown in Figure 7. Furthermore, the I2C bus supports hot-swapping, greatly simplifying the use of the handheld device, allowing users to install and remove it without interfering with the normal operation of the valve. Figure 7 Human-Machine Interface Circuit Principle ⑤ Communication Function Module The communication circuit is the CAN bus interface section in the lower-level machine, and is the core component providing remote valve control functionality. It consists of a CAN controller SJA1000, a CAN driver 82C250, and an opto-isolation circuit, as shown in Figure 8. Due to the need for opto-isolation, the module uses a DC-DC power supply module. To improve the versatility of the communication module and meet the needs of different applications, a microswitch is also designed in the lower-level machine to set different communication baud rates and address selection for different valves. Figure 8 Communication Function Circuit Structure 3.2 Lower-Level Machine Software Design The lower-level machine software is written in C51 language, which greatly improves the readability and portability of the program. The lower-level machine software mainly completes the acquisition of valve status and faults, valve opening acquisition, execution of valve switching and stopping actions, and communication functions. Due to space limitations, only the main control program and the CAN bus communication interrupt service program are introduced below. ① Design of the Main Program The main work of the lower-level machine software is to acquire valve signals, control valve movement, and respond to requests or commands from the upper-level machine. After initialization, the lower-level computer system enters the main program loop. To accurately acquire valve opening degree and avoid false alarms, simple digital filtering is performed on the input signals. After comprehensive analysis of these signals, the lower-level computer controls the valve's opening, closing, and stopping actions according to the opening degree requirements. The lower-level computer has two control modes: local control and remote control, which can be distinguished by a local switch. In both control modes, the lower-level computer can upload operating data according to the requirements of the upper-level computer. The difference is that in local control, the operator uses a handheld device to control the valve on-site, and the upper-level computer can only monitor the lower-level computer, not control it. In remote control, the lower-level computer controls the valve by analyzing the commands from the upper-level computer. The lower-level computer main program software flowchart is shown in Figure 9. Figure 9 Lower-level computer software flowchart ② Design of CAN interrupt service program When the upper-level computer sends a data request or command to the lower-level computer, the lower-level computer will enter the CAN interrupt service program. After entering the CAN interrupt service routine, the context is first saved, then the SJA1000 interrupt register is read, the type of interrupt is analyzed, and the corresponding flag is set. If it is a receive interrupt, the receive data flag is set and the data is read, then the buffer is released, and finally the context is restored, and the interrupt returns. The CAN interrupt service routine is shown in Figure 10. Figure 10 CAN Interrupt Service Subroutine Flowchart. Because the lower-level machine needs to be embedded in the valve's electrical assembly cavity, electromagnetic interference is severe. Various software and hardware anti-interference designs were adopted in the design, which will not be detailed here due to space limitations. 4 Conclusion The technologies mentioned in this article have been applied to the QT, OOM, SMC, and ZA series electric valves produced by Tianjin Valve Company, making them electric valves with remote control and fault diagnosis functions. The remote valve control system composed of these valves has been in actual operation for nearly a year, with good performance, meeting design requirements, and passing the expert appraisal organized by the Tianjin Science and Technology Commission. Currently, pilot production of the product is being prepared, and the standardization of the application layer protocol is being accelerated, striving to launch electric valve products that meet DEVICENET requirements as soon as possible. It is believed that the introduction of these products to the market will drive the development of fieldbus actuators in my country.