Abstract: This paper briefly describes the general characteristics of computer real-time control and distributed control systems (DCS), and takes the control system of a certain type of underwater robot as an example to introduce in detail the specific implementation of a small real-time DCS system.
Keywords: Real-time control; Distributed control system; Two-port memory; Serial communication
1 Introduction
Since the 1970s, distributed control systems with microcomputers at their core have integrated the latest achievements of modern technology: computer, communication, and automation control technology (referred to as 3C technology) into a distributed control system. It adopts the basic design concept of decentralized danger and decentralized control, while centralized operation and management, and a multi-level hierarchical structure, which enables it to meet the requirements of various complex real-time control.
Real-time control is an important and highly promising aspect of computer applications, primarily characterized by real-time performance and multitasking. Real-time performance means that control actions must begin and complete within a specified timeframe, with signals sent sequentially. Multitasking refers to the presence of multiple independent and/or semi-independent tasks within the system, simultaneously processing different signals and controlling different devices and processes. The control system of a certain type of underwater robot is a typical real-time control problem, requiring the system to complete information acquisition from various sensors, control calculations, thrust allocation, and control command distribution within one cycle (0.5 seconds). To address this, a small distributed control system was designed, the structure of which is shown in Figure 1.
2. System Workflow
As shown in Figure 1, the three microcontrollers underwater are mainly responsible for data acquisition. After processing, the data is transmitted to the host computer (dynamic positioning control host) via serial port. Two sonar solvers independently process the underwater acoustic signals fed back by Doppler velocimetry sonar and positioning altimeter sonar, and then send the required robot speed and position attitude information to the host computer via RS-485 serial port. The host computer performs control calculations based on this feedback information, and then sends control commands to the microcontrollers, which control the various actuators.
Figure 1. Simplified structural diagram of the control system of a certain type of underwater robot
3. System Function Implementation
3.1 Hardware Design
Based on the design concept of distributed control and centralized management, and combined with the actual situation of the project, a three-level control system was designed, with the dynamic positioning control host as the management computer, two sonar solvers and a master microcontroller as the monitoring computer, and two slave microcontrollers as the direct controllers. The master and slave microcontrollers are both 80C196KC.
In selecting sensing devices, intelligent sensors with strong anti-interference capabilities were chosen as much as possible. However, considering the budget of the preliminary research project, some conventional sensors were also used. Furthermore, due to the numerous external sensors on the robot and the limited space within the cabin, this paper references the concept of field-based information processing in fieldbus control systems by placing a microcontroller externally on the robot to process the sensor data before uploading it to the main microcontroller. Experiments show that this approach not only alleviates the workload of the main microcontroller and realizes the design concept of a distributed system, but also reduces common-mode interference on signal transmission lines.
The control system's actuators mainly consist of five propulsion motors, a rudder, and a pitch adjustment device. The pitch adjustment device uses a 24V torque motor to move a slider, thus adjusting the underwater robot's pitch. It is connected to the parallel port of the microcontroller after passing through a high-performance opto-isolation chip. During the underwater robot's movement, the propulsion motor speeds may need to be changed at any time to obtain different propulsive forces, and variable frequency speed control is the ideal way to achieve this. This system uses a Delta VFD-A/H type frequency converter, which can not only achieve various speed curves but also has comprehensive protection measures against overvoltage, overcurrent, and overheating. The frequency converter interfaces with the control system via an RS485 serial port, and a single CPU can connect to up to 32 frequency converters.
3.2 System Communication
As shown in Figure 1, this control system is a typical multi-machine system. One of the key technologies and challenges of multi-machine systems is information sharing. The success of solving this challenge directly affects whether the control system can successfully achieve motion control of the underwater robot. Based on the actual situation of the control system and the requirements of the host computer for the follow-up of the actuators, this paper adopts a communication method that combines parallel and serial communication. These communication methods will be briefly introduced below.
3.2.1 Communication between Microcontroller 1 and Five Frequency Converters
The standard RS485 half-duplex serial communication method is adopted, as shown in Figure 2. Microcontroller 1 acts as the master, with a baud rate of 9600bps, odd parity, mode 3, and 11 bits for the following data: 8-bit character, 1-bit start bit, 1-bit stop bit, and 1-bit address/data bit. Since it is a point-to-multipoint communication, an address-based wake-up method is used, with the addresses of the five frequency converters ranging from $00 to $04.
Figure 2 shows the communication circuit between the microcontroller and the frequency converter.
Figure 3. Communication circuit between master and slave microcontrollers.
Since RS-485 is a half-duplex communication mode, the CPU can only operate in either transmit (or receive) mode at a time. Therefore, a transmit/receive switching program is included in microcontroller 1. During initialization, P2.6 and P2.7 are cleared to enable microcontroller 1's serial port to receive data only, using interrupt mode to receive inverter data. In the transmit program, P2.6 and P2.7 are first set to enable microcontroller 1's serial port to operate in transmit mode. After transmission is complete, P2.6 and P2.7 are cleared again. This achieves half-duplex communication between microcontroller 1 and the inverter.
3.2.2 Parallel Communication between Master Microcontroller and Slave Microcontroller 1
In the control system shown in Figure 1, the communication between the master microcontroller and the slave microcontroller 1 is not only large in terms of communication volume, but also requires the actuator to have as little lag as possible in order to realize the follow-up control system. Therefore, parallel communication is preferred. Among the many parallel communication methods available today, dual-port memory can achieve high-speed and reliable parallel communication with minimal software and hardware costs. Therefore, this paper uses dual-port RAM IDT7132 as the shared RAM of the master and slave microcontrollers to realize parallel communication, as shown in Figure 3 (note the positions of READYL and READYR in the figure) [3]. Due to the special structure of dual-port RAM, the two machines can exchange data conveniently and quickly, thereby greatly reducing the lag caused by communication and providing the possibility for realizing follow-up control. If a 2K×16-bit dual-port RAM is to be constructed, an IDT7142 can be added.
3.2.3 Serial communication between the main microcontroller and the dynamic positioning control host
The communication circuit diagram is similar to that in Figure 2, except that the RS485 two-wire communication mode has been changed to RS422 four-wire communication mode to improve the communication speed, and the transceiver has been changed from MAX485 to MAX490.
On the main microcontroller side, due to the large amount of information to be transmitted (a total of 107 characters), the data to be transmitted is divided into two groups in the program. Each group has a protocol header and a checksum. The group of data to be transmitted is determined by the different communication control characters of the host computer (55H and 66H respectively). On the host computer side, since the host computer needs to dynamically display the underwater robot's motion posture and receive return information from various devices, if an interrupt information reception method is used, conflicts will occur and information loss will result when each slave device sends information to the host computer at the same time. Therefore, the information transmission from each slave device to the host computer must follow the commands of the host computer, and the entire system operates at a unified rhythm. When the host computer is idle, it sends an enable command to the i-th slave device in sequence. Upon receiving the command, the i-th slave device immediately sends the information to be uploaded. If the host computer does not receive the command, it resends the enable command. At the same time, in order to improve the reliability of communication, the characters to be transmitted are split into 3xH forms on each side of the communication, and the transmitted data is summed to obtain the checksum. After receiving a set of data, the other side of the communication performs a summation check. If the checksum is incorrect, the set of data is discarded, and the system waits for the next set of data.
4. Conclusion
This paper designs a real-time distributed control system composed of a host PC, a slave PC, and a microcontroller. It employs a combination of intelligent sensors and conventional sensors for information acquisition, along with variable frequency speed control using a frequency converter, to achieve motion control of the underwater robot. The dynamic positioning control host has the longest communication time in the entire control system, approximately 0.2 seconds, which is still far less than the system's required cycle time (0.5 seconds), thus enabling real-time acquisition of the robot's position and attitude information. This underwater robot has completed heading control and depth-holding control experiments. The experimental results show that the distributed system has achieved real-time control, creating conditions for further research on underwater robots in my country.
References
[1] Bai Yan et al. Distributed Control Systems and Fieldbus Control Systems: Fundamentals, Evaluation, Design and Application [M]. China Electric Power Press, 2001.
[2] Zhang Yunsheng. Principles and Applications of Real-Time Control System Software Design [M]. National Defense Industry Press, 1998.
[3] Dou Zhenzhong. Practical Handbook of Microcontroller Peripheral Devices - Memory Volume [M]. Beijing University of Aeronautics and Astronautics Press, 1998.