Research on the Application of CAN Bus in Mechatronics
2026-04-06 07:28:46··#1
Abstract: Taking the detection and control of various parameters in the control system of a hydraulic integrated test bench as an example, this paper introduces the application of CAN bus in mechatronics. The paper describes the design of the CAN interface circuit, the initialization process of the SJA1000 CAN controller, and the design of the hydraulic integrated test bench control system. Keywords: CAN bus; hydraulic; SJA1000 0. Introduction In traditional hydraulic control systems, mechanical means are mainly used for system control. However, using traditional mechanical methods to control the hydraulic system increases the overall system size, complexity, and maintenance difficulty. With the development of computer technology, fieldbus technology, and artificial intelligence, increasingly complex hydraulic control systems have a promising future. Based on these characteristics, this test bench uses CAN bus technology to achieve real-time control for hydraulic hose pulse pressure testing, applying pulse pressure to the test piece to test the hose's lifespan. 1. Design of CAN Interface Circuit The CAN bus node interface circuit is shown in Figure 1. The P89LPC932 is a single-chip packaged high-performance, low-power microcontroller with on-chip 8K Flash. Its instruction execution time is only 2 to 4 clock cycles, 6 times that of a standard 80C51 device. The P89LPC932 microcontroller integrates a series of distinctive functional components, including a byte-based I2C bus, SPI interface, UART communication interface, real-time clock, EEPROM, A/D converter, ISP/IAP in-circuit programming, and remote programming. It offers 24-26 available I/O ports. Operating at low voltage (3V), this microcontroller performs well in battery-powered portable systems. Its integrated system-level functions make it suitable for applications requiring high integration and low cost, significantly reducing component count and board area while meeting diverse performance requirements. The SJA1000 is an independent CAN communication controller supporting CAN2.0A and CAN2.0B, compatible with the PCA82C200 CAN controller, and a replacement for the PCA82C200. It also features a new operating mode (PeliCAN), enabling the SJA1000 to support the CAN2.0B protocol with many new features. The SJA1000 integrates the physical layer and data link layer functions of the CAN protocol, enabling framing of communication data. This controller features a multi-master architecture, bus access priority, and hardware filtering. The PC82C250 is a CAN bus transceiver, serving as the interface between the CAN controller and the physical bus. It provides drive transmission capability to the bus, differential transmission capability to the CAN controller, and differential reception capability to the CAN controller. It has strong resistance to transient interference and bus protection capabilities; it offers three different operating modes: high-speed, slope control, and standby. Power loss at a node on the bus will not affect the bus. High-speed applications up to 1 Mbps can be achieved within 40 m, and a maximum of 110 nodes can be connected. 2. Test Bench System Design 2.1 System Overall Principle Block Diagram Due to the need to detect and control numerous parameters, the test bench is modularized to reduce overall system complexity, improving reliability, maintainability, and scalability. Each module forms a closed-loop subsystem, connected to the host via a CAN bus. Data from each module is transmitted to the host via the CAN bus. The master unit is responsible for monitoring each slave unit, issuing commands to the slave units, receiving and processing the detection data transmitted from the slave units, and displaying data information and pressure waveforms. The CAN interface circuit is responsible for serial communication between the nodes. The overall system principle block diagram is shown in Figure 2. 2.2 Master System Pressure Control The master system pressure control is shown in Figure 3. The working process of this subsystem is as follows: The main oil pump (one-way fixed displacement hydraulic pump) injects hydraulic oil into the left chamber of the intensifier through the high-speed switching valve and the three-position four-way electro-hydraulic directional valve. The microcontroller detects the pressure in the left chamber of the intensifier in real time through the pressure sensor. When the pressure in the left chamber of the intensifier reaches the predetermined value, the microcontroller closes the high-speed switching valve and switches the electro-hydraulic directional valve to maintain the pressure in the left chamber of the intensifier for a given time; then it switches the electro-hydraulic directional valve again to return the hydraulic oil in the left chamber of the intensifier to the master system oil sump. This applies a cycle of pulse pressure to the test piece. By controlling the high-speed switching valve and the electro-hydraulic directional valve through the microcontroller, a pulse pressure of a certain frequency can be applied to the test piece. Simultaneously, the microcontroller transmits the detected pressure value to the host computer via the CAN bus to display the pressure waveform, based on the host computer's command. 2.3 Main System Oil Temperature Control During operation, the hydraulic oil in the main system continuously circulates, inevitably leading to an increase in oil temperature. Excessive oil temperature reduces the service life of the test bench and may even cause accidents; excessively low oil temperature affects the test bench's performance. The main system oil temperature control principle is shown in Figure 4. The microcontroller monitors the oil pool temperature in real time using a temperature sensor to control the cooling device and sends the temperature value to the host computer for display; if the temperature exceeds a predetermined value, an alarm is triggered. 2.4 High-Temperature System Control To ensure that the pressure generated by the hydraulic oil in the test specimen's hose reaches a given value within a given time, allowing the hose to withstand the specified high temperature and pressure, a high-temperature oil pump (one-way quantitative hydraulic pump) must supplement the required pressure and temperature. The high-temperature system pressure supplementation control principle is shown in Figure 5. The microcontroller sends the detected pressure value of the test specimen to the host computer and displays its waveform. The high-temperature system oil temperature control principle is similar to Figure 4, only the cooling device is replaced with a heating device. The heating device can only be started after the high-temperature oil pump is started. 3. SJA1000 CAN Controller Initialization Process During CAN bus communication, the current module sends the acquired data to the bus for the host to use and receives data frames sent to it from the bus, storing them in a buffer. After power-on or reset, the SJA1000 CAN controller must be initialized (see Figure 6). After power-on, the CAN controller enters reset mode after receiving a reset pulse on its (/RST) pin. Before configuring the various configuration registers of the SJA1000, the master controller checks whether the SJA1000 has entered reset mode by reading the reset/request flag. To avoid discrepancies between the microcontroller's power-on reset time and the SJA1000's reset time, the microcontroller waits for the SJA1000 to complete its power-on reset before configuring the SJA1000 configuration registers. Registers containing configuration information can only be written to in reset mode. In the SJA1000 initialization program, in reset mode, the main controller needs to configure the following registers: (1) Mode register (select the application operation mode only in PeliCAN mode) Receive filter mode Self-test mode Listen mode (2) Clock divider register Use BasicCAN or PeliCAN mode CLKOUT pin can be used CAN input comparator is skipped TX1 output is dedicated to receive interrupt output (3) Receive code and receive mask register Define the receive code of the message to be received Define the receive mask for comparison with the bits related to the receive code (4) Output control register Define the configuration of CAN output pins TX0 and TX1 After configuring these configuration information into the SJA1000 configuration register, the SJA1000 enters the operation mode by clearing the reset mode/request. It is essential to ensure that the reset flag is truly deleted and that the operation mode is entered before CAN bus communication is performed. This can be achieved by reading the flag. The reset mode/request flag cannot be cleared when the hardware reset is in a suspended state, i.e., when the (/RST) pin of the CAN controller is low. 4. Conclusion The CAN bus, with its high performance, high reliability, low cost, and unique design, is increasingly valued and is recognized as one of the most promising buses. The CAN bus technology was applied to industrial field control, and hardware circuits and software were designed and put into practical use. References [1] Wu Kuanming. CAN Bus Principles and Application System Design [2] Philips Semiconductor. Application Notes and Development Tools for 80C51 Microcontrollers