Abstract: This paper introduces the design of an embedded CNC system with a 32-bit CPU as the controller, including system hardware design and software design. The system uses Samsung's low-power S3C4510 as the core and has functions such as data storage, Ethernet communication, and LCD display. The system has the characteristics of low power consumption, low price, small size and can be integrated into the CNC machine tool operating table, which is the future trend of economical CNC machine tool development. Keywords: CNC system, embedded, UDP/IP protocol 1. Introduction Computer numerical control system is the foundation of advanced manufacturing technology and has received widespread attention at home and abroad, and its development is relatively fast. Nowadays, most computer numerical control systems are based on PC. Although PC-based CNC systems are powerful, they have the following disadvantages: (1) PC-based CNC systems require the bundled sale of industrial computers, resulting in resource waste and increased costs. (2) The hardware structure of PC-based CNC systems is very complex, which leads to a decrease in the overall reliability of the system. (3) The software operating systems of PC-based CNC systems mainly include DOS and Windows. The DOS operating system is too rudimentary, making it very difficult or impossible to implement many functions, such as network and USB functions; while the Windows operating system is too large and cumbersome, with extremely poor real-time performance and copyright issues with Microsoft. (4) PC-based CNC systems require the design of I/O control cards based on the ISA/PCI bus and dedicated motion control cards, which complicates the hardware structure. With the rapid development of embedded systems, microcomputer technology and integrated circuits, high-performance 32-bit CPUs have become popular, and ARM technology is gradually penetrating into all aspects of our lives. It has fast execution speed and powerful functions, and can completely replace PCs in mid- and low-end CNC systems, gaining greater price and technical advantages. This paper aims to break away from the traditional PC-based CNC system and research and design a 32-bit embedded microcomputer CNC system based on ARM. The core processor of this CNC system uses the S3C4510 chip produced by Samsung. This chip is a cost-effective, high-performance 16/32-bit RISC microcontroller used in Ethernet-based systems. It incorporates a 16/32-bit ARM7TDMI RISC processor designed by ARM, a low-power, high-performance 16/32-bit processor. The network interface chip uses the Realtek RTL8201, a full-duplex Ethernet controller. Since the S3C4510B already has an on-chip MAC controller with an MII interface, and the RTL8201 also provides an MII interface, their corresponding pins can be directly connected. The signal output is connected to the hub via an RJ45 connector through a coupling isolation transformer. In addition, the chip includes two programmable 32-bit timers, 18 programmable I/O ports, and two DMA channels. The timers can generate control pulses for the stepper motor, which are then amplified and output through the I/O ports to control the stepper motor. Furthermore, DMA technology can be used to improve access efficiency during the large-scale G-code access process, while freeing the CPU from busy access work to process data and control the motor. This greatly improves the performance and operating efficiency of the CNC system. 2. System Functions The system functional structure diagram is shown in Figure 1. The computer uses CAD software to generate machining G-code, which is downloaded to the motion controller's massive SDRAM memory via network cable. The machine can then be controlled online or run offline. The network download speed can reach 100 Mbit/s, so the communication speed is very fast. The communication protocol used is UDP/IP. Because data transmission in this system is far less complex than on the Internet, and the amount of data transmitted is relatively small, even if data errors or loss occur, the cost of retransmission is not significant. Therefore, the cumbersome TCP/IP protocol is avoided by using the User Datagram Protocol (UDP). This not only greatly simplifies programming but also significantly improves data transmission efficiency. The motion controller is responsible for reading the machining G code from the data storage, translating the machining G code, and outputting control pulses to the motor after processing by the motion control algorithm (circular interpolation), thereby controlling the operation of the motor during the engraving process and achieving the effect of three-axis linkage. It should be noted that the motor is prone to step loss when it suddenly accelerates or decelerates, which affects the accuracy of motion control. To avoid this situation, the motor should be controlled by acceleration and deceleration with uniform acceleration. 3. System Hardware Design The hardware design of this system is divided into several functional modules: parameter input module, parameter output module, LCD display module, keyboard input module, data communication module, data storage module, program storage module and a JTAG debugging interface. (1) Input module: The forward and reverse limit and emergency stop signals of the X, Y and Z axes of the engraving machine are input to the EPLD logic circuit through the opto-isolation module, which outputs control signals to control the stop of the engraving machine. The zero position signal of the engraving machine is read back by the CPU through 74LS16244. (2) Output module: The motor rotation direction and pulse parameter signals are output to drive the motor to operate through ULN2803. (3) LCD display module: Displays the current cutting tool position and spindle speed, etc. (4) Keyboard input module: Sets X, Y, and Z axis parameters for power on/off, spindle speed, and manual tool setting. (5) Data communication module: Downloads machining G-code generated by the PC. (6) Data storage module: Stores the downloaded machining G-code and data during operation. (7) Program storage module: Stores the running software. (8) JTAG debugging interface: Performs cross-debugging of the program through the JTAG boundary scan interface. The reason why Samsung's S3C4510B chip was chosen to build this system is because it has the following two advantages: First, it has a 100Mbps Ethernet controller and provides an MII interface. This makes its network interface and programming very simple and convenient, and the communication speed is fast (traditional 8/16-bit processors can only reach 10 Mbps); Second, it supports large-capacity SDRAM (which is much cheaper than DRAM), which is very useful for reducing costs. 4. System software design The system software adopts a front/back mode. The flowchart of the motion controller system software is shown in Figure 2. The system continuously runs subroutines for LCD display, key handling, G-code reading and translation, and control algorithm processing in the foreground. Background subroutines, such as communication and key interrupt subroutines, respond to corresponding hardware interrupts (e.g., Ethernet receive interrupt, key interrupt). After executing the interrupt service routine, the system returns to the original breakpoint and continues executing the foreground program. The communication program has a higher priority than the key interrupt. The interpolation algorithm processing subroutine is crucial. The tool cannot move strictly along the required curve; it can only approximate the required machining curve along a broken line. This process, where the coordinates of each intermediate point are calculated by the CNC system from the known coordinates of the workpiece's motion trajectory (seven points), the endpoint coordinates, and the curve equation of the contour trajectory, and the coordinates of the intermediate points are "inserted" or "filled in," is called "interpolation." The method by which the CNC system calculates the coordinates of each intermediate point is called the "interpolation algorithm." This system implements three-axis linkage digital integral linear interpolation and digital integral circular interpolation, and performs acceleration and deceleration control during the interpolation process to improve interpolation quality and accuracy. In the interpolation process, feed pulses are continuously sent to each coordinate axis, driving the motors of each axis to rotate. Each pulse moves the table by one basic length unit. The number of pulses sent to each axis determines the relative movement distance, while the pulse frequency represents the speed of the axis. Acceleration and deceleration control is achieved by realizing the change in pulse frequency of each axis from low to high and back to low within a machining code segment. 5. Summary The author's innovation lies in breaking through the traditional serial communication method of CNC machine tools, realizing Ethernet communication between the upper and lower computers through the UDP/IP protocol. This changes the current CNC system mode that mostly uses PCs as platforms, with all control functions and algorithms completed by a 32-bit lower computer controller. This simplifies user operation and saves investment, representing the future trend of economical CNC machine tool development. References: [1] Ma Zhongmei, Ma Guangyun, Xu Yinghui, et al. ARM Embedded Processor Architecture and Application Fundamentals. Beijing University of Aeronautics and Astronautics Press, 2002. [2] Yang Houchuan, Liang Wei. Machine Tool CNC System and Application. Peking University Press, 2005. [3] Wang Tianmiao. Embedded System Design and Example Development. Tsinghua University Press, 2003. [4] Lin Lizhi, et al.. Windows-based TCP/IP Programming. Tsinghua University Press, 2002. [5] Zhou Ligong, et al.. ARM Microcontroller Fundamentals and Practice. Beijing University of Aeronautics and Astronautics Press, 2003. [6] Wang Xi. Control of Stepper Motor Turntable. Microcomputer Information. Electronic Industry Press, 1984.