Design of Measurement and Control Module for CNC System Based on CAN Bus
2026-04-06 06:20:13··#1
Abstract: Computer network control systems can effectively utilize remote material and intellectual resources, establish online shared resource libraries, and realize computer integrated manufacturing systems. This paper utilizes advanced fieldbus control technology, selects CAN bus as the underlying distributed control technology, and designs and develops a CAN bus-based CNC system underlying measurement and control module, enabling faster information interaction between local devices. Keywords: Measurement and control module, CAN, DSP 1 Introduction A computer network system that uses a computer or microcontroller to communicate with various field devices through one or more bus methods and to perform necessary control on the field devices through the bus is called a low-level measurement and control communication network system, or simply low-level measurement and control network. This paper focuses on CNC systems and proposes a CAN bus-based CNC system underlying measurement and control network, where the field devices are CNC machine tools and other CNC equipment. 2 Basic Working Principle of CAN Bus The topology of the CAN bus is a typical serial bus structure. In the CAN bus, one node sends information and multiple nodes receive information; however, the CAN bus uses a broadcast access method for information storage. The CAN bus communication protocol supports a message-based working mode. In other words, adding or removing node devices will not affect the network's operation, making it ideal for control systems that require speed, reliability, and simplicity. CAN bus data communication offers outstanding reliability, real-time performance, and flexibility. CAN employs CRC checksum and provides corresponding error handling functions, ensuring the reliability of data communication. To clearly illustrate the working principle of the remote control instrument for CNC systems, we represent it in the form of a structural block diagram, as shown in Figure 1. The input signal comes from the photoelectric encoder of the CNC machine tool motor encoder, and the output signal can be used to drive servo motors or control other required signals. Below is its working principle: [align=center] Figure 1: Working principle diagram of a remote measurement and control instrument for a CNC system based on a CAN bus[/align] The pulse output signal from the servo motor encoder enters the input terminal of the measurement and control instrument, and then passes through a counter for filtering, frequency multiplication, phase detection, and counting. The microprocessor performs some simple processing on the acquired data and forwards it to the buffer of the CAN controller. When the time is right, the CAN controller further sends the data to the CAN transceiver (driver). Finally, the CAN transceiver forwards the data to the CAN bus, the transceiver of the main CAN node, and the CAN controller. The main CAN node acts as a gateway, retrieving data from the lower-level CAN nodes for further complex analysis and processing by itself or others. Conversely, data from above can be transmitted down to the lower-level CAN nodes through the CAN gateway in the same way. This is how the lower and middle layers exchange data. The lower-level CAN nodes can also receive information from the main CAN node and transmit commands to the corresponding interface circuits and servo systems through the output signal channel to control the CNC equipment. 3 Design and Development of a DSP-Based CAN Measurement and Control Instrument The microprocessor used in this paper is the TMS320LF2407 manufactured by TI. The system block diagram of the DSP-based CAN measurement and control instrument is shown in Figure 2: [align=center] Figure 2 System Block Diagram of a DSP-Based CAN Measurement and Control Instrument[/align] The CPU used in the DSP is the TI 2000 series TMS320LF2407, the opto-isolation is implemented using a 6N137, and the CAN driver is implemented using a PCA820C250. Because the TMS320LF2407 has a built-in CAN controller, no additional controller is needed here. 3.1 Hardware Design of the Measurement and Control Module The intelligent node consists of three main parts: signal acquisition, signal processing, and signal transmission. The structure of the entire intelligent node varies depending on the peripheral interfaces of the selected microprocessor chip. The TMS320LF2407 used in this system has abundant peripheral interfaces, so the entire intelligent node structure is simple and the system has extremely high reliability. The intelligent node circuit based on the TMS320LF2407 includes the following parts: power supply circuit, clock reset circuit, CAN bus interface circuit, signal conditioning section, and external storage circuit. Its structural block diagram is shown in Figure 3: [align=center] Figure 3 Overall Structure Diagram of Intelligent Node[/align] Since the TMS320LF2407 has an embedded CAN module, it can be connected to the CAN bus through a single CAN driver. To enhance the anti-interference capability of the CAN bus nodes, CANTX and CANRX are not directly connected to the TXD and RXD of the CAN driver 82C250, but are electrically isolated through a high-speed optocoupler 6N137 before being connected to the 82C250. This effectively achieves electrical isolation between the CAN nodes on the bus, avoiding mutual electrical interference. In this system, the 3.3V, 5V, and 5V-CAN power supplies used by the 6N137 are mutually isolated, ensuring the electrical isolation function of the optocoupler. The interface between the 82C250 and the CAN bus also adopts certain safety and anti-interference measures. The CANH and CANL pins of the 82C250 are each connected to the CAN bus via a 5-ohm resistor. The resistors limit the current and protect the 82C250 from overcurrent surges. Two 30pF capacitors are connected in parallel between CANH and CANL and ground to filter high-frequency interference on the bus and provide some electromagnetic radiation protection. Additionally, a surge protector is connected between each of the two CAN bus inputs and ground. When transient interference occurs between the input and ground, the surge protector discharges, providing some protection. 3.2 Clock and Reset Circuit Design 3.2.1 Clock Circuit Design This paper uses a 6MHz crystal oscillator. The crystal oscillator output is directly connected to the X2 pin, and the X1 pin of the DSP is left floating. In the program design, the internal clock phase-locked loop of the DSP is set to a 4x frequency multiplication, so the CPU's operating clock can reach 24MHz. 3.2.2 Reset Circuit Design A simple circuit combining power-on reset and button reset was used in the design. At the instant of power-on, the capacitor acts as a short circuit, and capacitor C16 acts as a short circuit, at which point RST is low, resetting the chip. After this period, the capacitor voltage reaches 2V, ending the reset process and the chip enters the normal operating area. When K1 is pressed, RST is directly connected to ground, and the chip performs a reset. Therefore, the operator can reset the system at any time as needed. 3.3 Power Supply Circuit Design The TM3S20LF2407A operates at 0.33V, while the crystal oscillator, optocoupler 6N137, and CAN driver used in the design are all SV powered. Therefore, the application system based on the TMS320LF2407A is a mixed voltage system, requiring voltage conversion. The system uses TI's G57333Q voltage converter chip to convert the 0.33V voltage for the DSP. 3.4 External Storage Circuit Design The TMS320LF2407 chip has an on-chip 4K program/data RAM and 32K FLASH program memory. The chip's built-in data and program memory already meet the requirements of this monitoring system, so no additional data and program memory is needed in the actual application hardware design. However, for the initial circuit design, a 64K static random access memory (SRAM) is designed for convenient online debugging, which is used by both the program and data during online debugging. 3.5 Signal Conditioning Circuit Design The signals from the sensors are all voltage or current signals. An amplifier circuit and a filter circuit are designed on this intelligent node to amplify and filter the initial signals. To ensure measurement accuracy, an instrumentation amplifier AD6523 is used for signals with high accuracy requirements. For signals with lower accuracy requirements, the inexpensive LM324 is used for amplification. The AD623 can operate in single-supply mode, with a supply voltage range of 3V-12V; the DS623 can also operate in dual-supply mode, with a voltage range of ±5V to ±6V. In this intelligent node, the power supply circuit only provides 3.3V and 5V voltages, and the DSP's operating voltage is 3.3V, so a single power supply is used. To decouple, a 10μF capacitor is added near the power supply pin. 4. Software Design of the Measurement and Control Instrument The software of the intelligent node includes a system initialization module, a data acquisition module, a data processing module, and a system transmission module. The initialization module performs the following tasks: clearing the registers used according to the chip's functions and characteristics, initializing the program FLASH area and data RAM area, setting interrupt ports, etc., to prepare for the main program's operation; it also checks and protects the system power supply, and uses its built-in watchdog timer to monitor the hardware operation of the DSP chip's resources. After the DSP chip is running normally, the main program of the data acquisition software begins execution. The default configuration parameters are used to allocate channel resources, memory resources, and bus resources for the data acquisition card system. The data acquisition module starts the LS7266R1 to acquire one frame of data using a timer soft interrupt in the EMA interrupt (event management interrupt); simultaneously, the data processing module processes the data from each channel of the previously acquired frame. Data transmission is accomplished via the CAN bus, so the data transmission module must perform CAN bus communication functions. The following two sections will detail the design of the data acquisition, processing, and transmission modules based on the characteristics of the TMS320LF2407. The CAN communication software has two main functions: packaging data from the smart node into valid CAN information frames and sending them to the target node; and receiving valid data frames from the CAN bus and restoring the information frames back to the original data for the CPU to perform further operations. The packaging and restoration of data frames are handled by the CAN controller within the DSP. In the communication software, only the corresponding registers in the CAN controller need to be set. The TMS320LF2407's CAN controller is a complete CAN controller. The entire software flow is shown in Figure 4: [align=center] Figure 4 Software Flowchart[/align] [align=center] Figure 5 CAN Bus Communication Flowchart[/align] With the support of the CAN controller, the design of the CAN communication software becomes simple and clear. The design philosophy of the CAN communication software in this system is as follows: Data transmission from this system to other nodes is designed as a function. When the system sends data, this function is called to send the data to the CAN bus. Data reception is achieved via interrupt. When the CAN controller receives data, it sends an interrupt response signal to the microcontroller, which then reads the received data in the interrupt routine. The flowchart of the entire system's CAN bus communication software management is shown in Figure 5. The innovation of this paper lies in the design of a CAN bus-based CNC system's underlying measurement and control module, which tests the motion accuracy of CNC machine tools. It achieves communication with various field devices and enables necessary control of these devices via the bus, making information exchange between local devices faster. References: [1] Kuan Ming. CAN bus principle and application system design [M]. Beijing: Beijing University of Aeronautics and Astronautics Press, 1996 [2] Zhang Xin, Wang Bing, Xu Jianmin. Design and implementation of network-based remote general monitoring system [J]. Computer Engineering and Applications, 2002, 38 (8): 223-225 [3] Guo Jianfeng. Ethernet intelligent controller based on ARM microprocessor [J]. Manufacturing Automation, 2004, 26 (3): 75-78 [4] Li Jianbo, Jiang Nianping, Zhao Qingxiao. Design and research of air conditioning measurement and control system based on fieldbus [J]. Microcomputer Information, 2007, 6-1: 39-40 Author Introduction: Sun Jian (1964.08-), male, from Xingyang, Henan, experimentalist, graduated from the Computer Science and Technology major of Zhongyuan University of Technology, research direction: computer and multimedia voice, bus control system