Share this

Practice and Exploration of USB Interface Retrofitting for Economical CNC Machine Tools

2026-04-06 05:41:24 · · #1
To address the slow data transmission speed and communication contention issues caused by large data volumes in complex curved surfaces during CNC machining, this paper proposes a new interface—the USB interface—between the host computer and the CNC machine tool in the CNC system to transform economical CNC machine tools. The paper also demonstrates the corresponding hardware and software improvements. The method for implementing the USB interface on the CNC machine tool is described, and a USB driver for Windows is provided. The use of the USB interface significantly accelerates data transmission and improves the flexibility and versatility of configuring economical CNC systems with PCs, thereby expanding the network functionality of economical CNC machine tools and solving the data communication contention problem caused by slow transmission speeds in networked manufacturing. I. Problem Statement With the advent of the network era, the machinery manufacturing industry faces the challenge of adapting to networked manufacturing. Therefore, combining computer technology, network technology, and traditional control technology, with PCs as the main controller, has become an increasingly popular focus in the machinery manufacturing field. PC-based CNC can be divided into three types, which are introduced below. 1. NC Board Insertion Type: This type of CNC system refers to the core function boards of the CNC system being inserted into the expansion slot of the PC. The PC is responsible for user interface, file management, and communication functions, while the NC board is responsible for the machine tool's motion control and switching logic control. 2. Software CNC: Software CNC can be understood as using the concepts and methods of a PC to implement CNC functions. The main body of this CNC device is a PC, fully utilizing the PC's ever-increasing computing speed, expanding storage capacity, and continuously optimized operating system to achieve motion trajectory control and switching logic control in machine tool control. Currently, this approach still has many problems to be solved and remains in the laboratory research stage. 3. Embedding the PC Board into the CNC: This is a widely adopted CNC system. Connecting to the PC through the front-end interface on the CNC is a compromise, but it can inherit the existing mature CNC technology while gaining the flexibility and openness of the PC. The USB interface technology discussed in this article is based on this type of CNC system. This basic method of connecting CNC equipment to the host control computer is called DNC technology, which is one of the most fundamental application technologies in networked manufacturing. Early economic CNC systems in my country were mostly modified from single-board computers, requiring an external DNC interface board to achieve basic DNC (download NC program) functions, as shown in Figure 1. [align=center] Figure 1 Basic DNC communication interface of economic CNC system[/align] The communication method between the computer and the CNC machining equipment depends on the communication interface and communication protocol of the CNC system. The communication interfaces and communication protocols provided by the CNC system are as follows: (1) Recording interface, which is the communication interface of the old economic CNC system made in Japan. (2) Paper tape reader input interface and paper tape punching machine output interface. Early imported CNC systems usually have this interface, such as the FANUC 7M system. Newly developed CNC systems have basically eliminated this interface, but there are still a certain number of CNC machining equipment in Chinese enterprises that include this interface. (3) Asynchronous serial communication interface, such as RS232, R5422, R485, etc. This is the most common type of communication interface. Almost all newly developed CNC systems include this type of interface. It adopts communication protocols such as XON/XOFF, 3964R, and simplified 3964. (4) DNC interface, such as FANUC DNC2 interface. This type of interface can realize long-distance communication, has error feedback and online real-time modification functions, and is convenient for remote management. However, due to its complex structure, the communication software development is difficult and the price is high, so it is rarely introduced in my country. (5) Network communication interface, mainly including MAP interface, Ethernet interface and fieldbus interface. This type of interface has high communication speed and high reliability. Most newly developed open CNC systems have Ethernet interface options, but few CNC systems introduced in my country are equipped with network communication interfaces. (6) MAP network adopts MAP2.1 and MAP3.0 manufacturing automation protocols. It is currently the most widely used industrial network. It integrates broadband technology, bus technology and passive workstations to ensure error-free information transmission. However, when MAP is required to transmit NC programs synchronously with machining, it struggles to meet real-time requirements. This is because MAP employs a complete seven-layer protocol, resulting in high network access costs, low transmission efficiency, and poor real-time performance, making it unsuitable for networking CNC machining equipment. As the above analysis shows, the asynchronous serial communication interface RS232 is the most commonly used communication interface for CNC systems, and almost all CNC systems include this interface. Similarly, the DNC interface board in Figure 1 also uses the RS232 interface. In today's rapidly evolving computer technology landscape, the RS232 interface is being replaced by a new USB interface in computer applications. From keyboards and mice to printers and scanners, numerous USB-based peripherals have replaced devices that previously used RS232 interfaces. Could such a new USB interface technology also be adopted in CNC systems? In DNC communication systems, when multiple CNC machining machines are simultaneously processing a complex part, the NC program may be too large for the CNC system's memory to store. In such cases, DNC transmission may be necessary, potentially causing the CNC machining machine to pause processing due to a temporary lack of the NC program. This phenomenon is known as "communication contention." Communication competition often has serious consequences in actual production. For example, a pause in the horizontal machining of automotive body panel stamping dies can cause local "focusing" of the body panel, which directly affects the quality of the stamped parts. The factors that cause communication competition are roughly as follows : (1) The number of CNC machining equipment participating in the network, m. The more the number, the greater the possibility of communication competition. (2) Fieldbus transmission rate, transmission efficiency C, and node switching service time t. Transmission efficiency refers to the proportion of the number of effective bytes transmitted to the total number of bytes transmitted. (3) The communication propagation rate vi and transmission efficiency ei (i=1~m) of each CNC machining equipment. vi is usually 9600b/s, but the precision machining of complex surfaces and cavities requires a value of more than 19200b/s. (4) The CNC system program consumption rate pi, i.e. the number of bits of the program executed by the CNC system per second. pi fluctuates greatly, but each system has a relatively definite maximum pi value. (5) The size of the CNC system communication data buffer BUFFER, Qi. (6) The size of the data buffer BUFFER of each DNC communication front-end unit, Si. Si is the quantity that needs to be optimized. By establishing a mathematical model, we can obtain: From equation (1), we know that the upper limit of the data buffer S of the DNC communication front-end unit is related to Q, v, c, and p: the larger Q, v, and c are, the smaller P is, and the larger the upper limit of S is. The lower limit of S is also related to m and t: the smaller m and t are, the smaller the lower limit of S is. Equation (2) shows the maximum number of DNC communication systems that can connect the same CNC machining equipment without communication contention: the larger v and c are, the smaller p and t are, and the larger m is. If the number of CNC machining equipment connected to the DNC communication system does not satisfy equation (2), then the system will definitely experience communication contention. At this time, we can only reduce the consumption rate p of the machining program by reducing the feed speed of all or some CNC machining equipment, or use a higher transmission rate, i.e., increase v. Therefore, using a USB bus and interface with a higher transmission rate can solve the communication contention problem in the DNC communication system. II. Technical Analysis The advantages of the USB interface over the RS232 interface are: (1) The USB bus provides three different data transmission rates: 1.5Mb/s low-speed data transmission, 12Mb/s full-speed data transmission, and 480Mb/s high-speed data transmission (USB 2.0 supports), while the RS232 rate is only 20kb/s at most. USB has a significant advantage in high-speed data transmission when processing curved surfaces with large curvature changes. (2) Theoretically, USB can support up to 127 peripherals. Compared with the point-to-point connection of RS232, a system using the USB interface can potentially enable one PC to control multiple NCs, thereby greatly improving efficiency, reducing costs, facilitating control, and making it more conducive to collaborative manufacturing. (3) The effective connection distance of USB is 5m, which can be extended through a hub, up to 5 levels, reaching a distance of 30m, while the maximum distance of RS232 during data transmission is only 15m. Icron has developed the Extreme USB technology, which can extend USB devices to distances of 500 to 2000m. (4) Another significant feature of USB is its support for hot-swapping, which is very suitable for environments where production layout adjustments are frequent. Imagine that when it is necessary to add or remove NC or when the NC malfunctions and needs to be shut down for maintenance, the equipment can be directly connected to the system, which will greatly reduce the production adjustment time. (5) USB also has the characteristics of low price, ease of use, and good fault tolerance in data transmission. From the above analysis, it is not difficult to see that the use of USB interface in CNC system has many conveniences and is a technological improvement compared to RS232 interface. We further propose a convenient mode of small and medium-sized processing and manufacturing network, as shown in Figure 2. [align=center] Figure 2 Network topology structure after adopting USB interface[/align] III. Technical transformation method Transforming the RS232 interface on the economical CNC system into a USB interface requires both software and hardware aspects. 1. Hardware transformation On the PC side, most mainstream models nowadays support USB interface, and some high-end PCs even support USB 2.0. For PCs that do not support USB, the solution can be to insert a USB expansion card into the motherboard. The key transformation is in the DNC interface board. One approach is to use a USB/RS232 converter, the structure of which is shown in Figure 3. [align=center]Figure 3: Structure of a USB/RS232 Converter[/align] A USB/RS232 converter generally consists of a USB interface module, a UART interface module, a data buffer, and a protocol control unit. The USB interface module primarily provides connection to the USB bus, implementing all the functions of a typical USB device and connecting to the USB port on the PC. The UART interface implements all the functions of a standard RS232 interface and connects to the RS232 interface of the DNC interface board. The protocol control unit receives commands from the USB interface and configures the UART interface (configuring communication baud rate, data bits, parity bits, start/stop bits, flow control signals, etc.). The data buffer is used to temporarily store data during data transmission between the two parties. Another modification method is to directly modify the DNC interface board by adding a USB module. Figure 4 shows the modified hardware structure. [align=center]Figure 4: Structure of the Modified DNC Interface Board[/align] Here, SIE is the serial interface engine, the core module of the USB interface. If the CPU includes a USB interface, the CPU connects directly to the SIE core module responsible for implementing the main functions required by the USB protocol. Otherwise, the CPU needs to connect to the SIE through a serial bus, such as I2C or data address line I/O port. There is a fundamental difference between the two hardware modifications in the implementation of the USB interface: the USB chip used in the former USB/RS232 converter is a USB interface chip, which in terms of hardware structure only includes chips such as USB serial interface engine (SIE), FIFO memory, transceiver and voltage regulator; the latter is a microprocessor (MPU) with a built-in USB unit, that is, the chip includes an enhanced version of the 8051 core, which can be connected to the original CPU through I/O, and can even directly drive stepper motors to complete CNC tasks. 2. Software design (1) USB/RS232 This structure can be used directly without the need to develop a separate driver. (2) For direct modification of the DNC interface board, the firmware development of EZ-USB can be carried out using the Keil C Compiler tool in Cypress Lab, a Cypress USB emulator software. This application was developed by Cypress Semiconductor to support the development of USB chipsets. By compiling the corresponding program, the compiled file can be directly burned into the EEPROM, thus completing the firmware design of USB. Alternatively, CYASM assembly language can be used, which is a compiler program with only 38 simplified instructions. The compiled hexadecimal format file (.hex) can also be burned into the EEPROM for use. Its main functions are to control the EZ-USB chip to accept and process the requests of the USB driver (11 types of USB 1.1 standard requests, such as requesting device descriptors, requesting or setting device status, requesting device settings, requesting or setting device interfaces); control the EZ-USB chip to accept the control instructions of the application; control the data acquisition of the A/D module; and store data through EZ-USB and upload it to the PC in real time. (3) Compiling USB drivers under Windows system The USB bus supports hot plugging. When Windows detects a new USB peripheral, one thing it must do is to find out which device driver application software should be used to communicate with the device, and then load the selected driver. This is the job of Windows Device Manager. Device Manager uses classes, device installers, and INF files to find this match. When Windows enumerates new USB devices, Device Manager compares the data in all INF files (device vendor and product IDs, also known as VID and HD, as well as manufacturer, vendor name, and descriptor, etc.) with the information obtained from the device descriptor during enumeration. After finding a match, the Windows system registry saves information about all installed devices. All USB devices will be listed at the location HKEY_LOCAL_MACHINE\Enum\USB. Because Windows 98 provides USBD (USB system driver), and USBD provides users with directly supported USB DI, when writing USB drivers, users only need to configure URBs (USB Request Blocks) that meet USB requirements and send them through USB DI to control USB devices. A device driver is a software component that ensures that applications can access hardware devices. A device driver allows applications to avoid knowing the details of physical connections, signals, and protocols required to communicate with a device. Applications can communicate with device drivers using a set of functions supported by the operating system. The API functions for reading and writing USB devices are CreateFile, Device Io Control, or Read File and Write File. All device-related driver operations are compiled into a DLL and provided to the application. The application does not need to know the details of operating the device, only the interface functions of the DLL. Below is an example of a basic USB device operation function. CreateFile(TEXT("\\\\.\\Ez-USB"), GENERIC_READ, FILE_SHARE_READ|FILE_SHARE_WRITE, NULL, OPEN_EXISTING, FILE_FLAG_OVERLAPPED, NULL) The first parameter is the name of the device to be opened; the second and third parameters are the authorized read/write and shared modes, respectively; the fourth parameter is the security attribute, usually NULL; the fifth parameter is the opening mode (for USB devices, this should be opening an existing one); the sixth parameter is the asynchronous interleaving mode; the seventh parameter is the template file, which is not needed here. The function returns a device pointer. Device Io Control(hUSB, (DWORD)wFuncNum, (PVOID)pParam, (DWORD)dwSize,NULL,0,&Returned,NULL) USB is the device pointer obtained through CreatFile; wFunHum is the device operation code, which can be found in the standard code provided by CYPRESS or USBD; pParam is the pointer to the request data buffer for the operation; dwSize is the size of the data buffer, followed by two parameters: the pointer and size of the output data receive buffer for the operation, which are generally NULL and 0 respectively; Returned is the operation return pointer; the last parameter is for asynchronous operations and can be NULL. Before use, define the request data buffer. After obtaining the device pointer, you can use the corresponding operation code to operate the USB device. The above device driver and upper-layer application software have been tested and verified under VC6.0. IV. Summary Through the above software and hardware modifications, a new interface—the USB interface—is provided between the economical CNC and the PC. This transformation helps improve the flexibility and versatility of configuring economical CNC systems with PCs. We can even use a single PC to control all the NCs on a small production line. This not only significantly reduces installation and configuration time, lowers failure rates, and reduces the number of operators, but also allows for parallel manufacturing in conjunction with relevant software, maximizing NC utilization. Furthermore, it expands the network functionality of the economical CNC system, enabling networked manufacturing through PC connection to the Internet/Intranet.
Read next

CATDOLL Qiu Soft Silicone Head

You can choose the skin tone, eye color, and wig, or upgrade to implanted hair. Soft silicone heads come with a functio...

Articles 2026-02-22