Share this

Embedded CNC System Based on ARM+FPGA

2026-04-06 10:25:55 · · #1
Abstract: This paper addresses some problems existing in current CNC systems and proposes an embedded CNC system based on ARM + FPGA architecture, using the μC/OS-Ⅱ real-time operating system. The hardware structure and software design of this system are described in detail. Keywords : ARM, FPGA, embedded CNC system, μC/OS-Ⅱ 1 Introduction Since the advent of the first CNC machine tool in 1952, with the continuous development of computer technology, CNC systems have undergone a development process from hardware CNC to computer numerical control (CNC). Initially, in hardware CNC systems, the input, calculation, interpolation, and control functions of the part program were all completed by hardware. The CNC system uses a computer as the core component of the numerical control system, which reduces the hardware circuit and improves the versatility and reliability of the system. However, there are still some problems with this type of system, such as resource waste, poor real-time performance of the operating system, and complex hardware structure. This paper introduces an embedded numerical control system based on PC with an "ARM+FPGA" structure. This system is a new generation of numerical control system for controlling fully digital stepper motors developed and produced for small and portable machine tools. The host computer PC is used for programming complex machining code, while the "ARM+FPGA" structure control system is used to realize the motion control function. Using ARM to develop the numerical control system can reduce hardware costs, enhance stability, and improve the scalability of the system. 2 System Hardware Design 2.1 Hardware Structure In the design of this system, the PC is used as the host computer and ARM+FPGA is used as the control core. The hardware structure of the system is shown in Figure 1. [align=center] Figure 1 System Hardware Structure[/align] In the host PC, CAD software is used to generate machining G code. The program code is serially transmitted to the SDRAM of the system via USB. The ARM reads the G code from the data memory, performs decoding, tool compensation calculation, and coarse interpolation[1]. The FPGA receives control commands from the ARM, reads data, completes the fine interpolation function, and outputs control pulses for the motor. In addition, in order to realize high-speed data exchange between the host PC and the controller, the system, in addition to serial communication, also uses USB interface communication and uses DMA to exchange data synchronously with the host PC. This method can enable the system to achieve higher communication speed. The system has 3 pulse direct drive stepper motors with a maximum frequency of 4MHz. 2.2 Chip Selection (1) ARM Microprocessor The system uses the 16/32-bit RISC embedded microprocessor S3C44B0X launched by SAMSUNG, with a maximum main frequency of 66MHz. The S3C44B0X uses the ARM7TDMI core, 0.25um process CMOS standard macro cells and memory compiler, and also provides a very rich set of built-in components, including 8K high-speed cache, external memory controller, 2-channel general DMA, 2-channel peripheral DMA, 2-channel UART with handshake protocol, 71 general I/O ports, 8-channel external interrupt sources, 8-channel 10-bit ADC and on-chip clock generator with PLL. By providing abundant on-chip resources, the peripheral circuits can be reduced, thus lowering the system cost. In addition, the chip also adopts low-voltage technology, which has a fast operation speed and low power consumption, making it very suitable for the design of CNC systems. (2) FPGA FPGA (Field Programmable Gate Array) is developed on the basis of logic devices such as PAL and GAL. It is a special ASIC chip with abundant logic resources and I/O pins. Users can reconfigure its internal logic modules and I/O modules to implement user logic. In addition, FPGA has the advantages of large scale, small size and high reliability, which meet the design requirements of CNC systems. This system uses Lattice's LFXP6C-3Q208C chip to implement interpolation operation. In the system, the FPGA receives control instructions and data information from the ARM and external RAM to perform interpolation operation, generate a pulse sequence to control the operation of the stepper motor, and send the pulse sequence to the stepper motor driver through the interface. In addition, the FPGA is connected to the spindle encoder, which can identify its output signal and count it. The counting result is stored in the register for the ARM to read. The FPGA also connects to the I/O interface via the ULN2083AC chip to perform various signal conversion and isolation functions. Figure 2 shows the peripheral connections of the FPGA. [align=center] Figure 2 Peripheral Connections of FPGA[/align] 2.3 Connection Methods for Pulse Output Signals There are two connection methods for pulse output signals: differential and single-ended. The single-ended method is suitable for some early stepper drivers where the anodes of the pulse and direction are connected together, but not for some stepper drivers where the cathodes of the pulse and direction are connected together. The differential method is suitable for stepper drivers with independent pulse and direction inputs and most servo drivers, and can achieve better anti-interference performance. This system uses the differential connection method, as shown in Figure 3. [align=center] Figure 3 Differential Connection of Pulse Output Signal[/align] 3 System Software Structure The system software structure is mainly divided into two parts: operating system software and CNC application software. Since the CNC system is a real-time multi-tasking system with high real-time requirements, in order to ensure the coordinated execution of various tasks, this system uses the μC/OS-Ⅱ real-time operating system as the software platform. 3.1 Introduction to μC/OS-II [2] μC/OS-II is a real-time operating system with open source code. It is a preemptive kernel that always prioritizes the highest-level task when it is ready to run. It is also a multi-task management system that can manage 64 tasks, of which 8 are reserved for the system. There are up to 56 user tasks, and each task has its own independent stack space. Most of the source code of μC/OS-II is written in C language, and only the parts related to the microprocessor are written in assembly language, so it has strong portability. However, since μC/OS-II can only read and write processor and registers through assembly language, some processor-related code needs to be completed in assembly language. 3.2 Porting of μC/OS-II To achieve normal operation of this operating system on the S3C44B0X microprocessor platform, it is necessary to modify the code related to the processor type [3]. The following is a brief introduction to the relevant files that need to be modified: (1) Modify the OS_CPU.H file: including the definition of data types and basic information related to the processor. (2) Modify the OS_CPU_C.C file: Write the stack structure function OSTaskStkInit() for initializing the task, which is called by the task creation function OSTaskCreate() or OSTaskCreateEXT(). For example, to create an interpolation task, use: OSTaskCreate(InterpTask, (void*)0, (void*)&InterpTask_Stack[STACKSIZE-1], InterpTask_Pri). In addition, five functions must be declared: task creation function OSTaskCreateHook(), task deletion function OSTaskDelHook(), task switching function OSTaskSwHook(), clock tick generation function OSTimeTickHook(), and statistics function OSTimeTickHook(). (3) Modify the OS_CPU_A.ASM file: Write four processor-related assembly language functions: OSStartHighRdy(), OSCtxSw(), OSIntCtxSw(), and OSTickISR(). 3.3 Application software design of CNC system According to the functions to be realized by the CNC system, the application software of the system can be divided into several modules: human-machine interface module, data processing module, interpolation module. The tasks of the human-machine interface module are completed by the PC, including the editing of CNC code, the setting of relevant parameters during the machining process, the setting of tool compensation parameters, etc. [4]. (1) Data processing module The data processing module mainly completes the decoding and tool compensation functions. Decoding is to translate the various workpiece contour information (such as starting point, straight line or arc, etc.), machining speed F and other auxiliary information (M, S, T) of the CNC code into a data form that the system can recognize according to a certain rule. Since when compiling the part machining program, only the contour shape of the part is generally considered, while the actual cutting control is based on the tool center, the data obtained after decoding cannot be directly used by the interpolation program. It must be converted into the parameters required for interpolation after trajectory calculation, tool length compensation and tool radius compensation. (2) Interpolation module The core task of the CNC system is interpolation. The accuracy of interpolation calculation affects the accuracy of the entire CNC system. The interpolation task involves calculating the coordinates of several intermediate points between the start and end points of the part contour based on the decoded data, according to the feed rate requirements. This coordinates are then converted into pulse data and sent to the stepper driver. This system uses pulse incremental interpolation, with a pulse output frequency error of less than 0.1%. The pulse output can be in single-pulse (pulse + direction) or double-pulse (pulse + pulse) mode. It can perform arbitrary 2-3 axis linear interpolation, arbitrary 2-axis circular interpolation, and continuous interpolation. [align=center] Figure 4 Flowchart of the first quadrant linear interpolation software using the point-by-point comparison method[/align] The following uses first quadrant linear interpolation as an example. Figure 4 shows the flowchart of the first quadrant linear interpolation software using the point-by-point comparison method. Where (xe, ye) are the coordinates of the end point of the line, and F is the deviation value after each linear interpolation calculation. When F ≥ 0, the machining point is on or above the machining line, so a pulse is generated in the positive x-axis direction. The stepper motor driver drives the x-axis stepper motor to advance by one step angle, and the new deviation F = F - ye is calculated. When F < 0, the machining point is below the line, so a pulse is generated in the positive y-axis direction. The stepper motor driver drives the y-axis stepper motor to advance by one step angle, and the new deviation F = F + xe is calculated. n is the endpoint determination; when the tool reaches the endpoint, interpolation stops. This system uses VHDL to implement interpolation algorithms. The following is a partial code snippet: ARCHITECTURE connect OF chabu IS BEGIN VERIABLE F:INTEGER:=0; n:INTEGER:=ABS(xe)+ABS(ye); xi,yi:INTEGER //(xi,yi) are the tool's machining point coordinates during interpolation. PROCESS(reset) //reset is the reset signal; after interpolation starts, it clears the deviation value F and (xi,yi) to zero. BEGIN returns the tool to the origin. F=0; …… END PROCESS; PROCESS(clk) //clk is the clock control signal; interpolation is performed when the rising edge of clk arrives. BEGIN WHILE(n>0) LOOP IF(F>=0) THEN cqx=1; //cqx, cqy are the output pulse signals for the x and y axes. cqy=0; F=F-ye; n=n-1; ELSE …… END IF; END LOOP; END PROCESS; END connect; 3.4 Data Exchange in the System During CNC machining, a large amount of data information needs to be transferred between modules of the CNC system. This function is mainly achieved through various buffer storage areas, as shown in Figure 5, which illustrates the data exchange process. First, the CNC machining program is read into the CNC machining program buffer. Characters are read one by one, decoded, and sent to the decoding result buffer. Then, after a series of interpolation preparations (including tool compensation calculation and speed processing), the result is sent to the interpolation buffer. When the interpolation program executes the interpolation operation, it reads the contents of the interpolation buffer storage area into the interpolation working storage area. Then, it uses the data from the interpolation working area to perform interpolation calculations and sends the result to the interpolation output register. [align=center] Figure 5 Data Exchange[/align] 4 Conclusion The embedded CNC system adopts ARM and FPGA hardware platforms, reducing the number of peripheral components in the system. It has advantages such as small size, high cost-effectiveness, and good stability. Furthermore, by utilizing the μC/OS-II real-time operating system as the development tool, the CNC system possesses excellent real-time performance, meeting the requirements of high-speed and high-precision machining, and effectively solving the problems existing in traditional CNC systems. Therefore, embedded CNC systems have broad development prospects. References: [1] Liu Yanxia, ​​Li Shufen. Embedded CNC system based on ARM[J]. Microcomputer Information. 2006, 22(35): 90-91, 96 [2] Labrosse Jean J. Translated by Shao Beibei, Embedded real-time operating system μC/OS-Ⅱ[M]. 2nd edition. Beijing: China Electric Power Press. 2003 [3] Wang Xiaoming, Wang Shuxin, Zhang Hongwei. Porting of real-time operating system μC/OS-Ⅱ on ARM[J]. Mechatronics. 2007, (1): 56-58 [4] Yang Daihua, Chen Zhihui. Development of CNC system based on real-time operating system μC/OS-Ⅱ[J]. Manufacturing Technology and Machine Tool. 2007, (12): 21-23 Author Introduction: First author: Zhu Xiaojie (1983-), female, from Wuxi, Jiangsu, master's student, major research direction: CNC system. Mailing Address: P.O. Box 119, Dingjiaqiao Campus, Nanjing University of Technology, No. 5 Xinmofan Road, Nanjing, 210009, China. Tel: +86 13675122764 E-mail: [email protected] Second Author: Shu Zhibing (1965-), male, from Nanjing, Jiangsu Province, Director of the Institute of Motion Control, Nanjing University of Technology. Main research areas: AC servo systems, DSP technology, fieldbus, CNC systems, motion control, mechatronics systems, etc. E-mail: [email protected]
Read next

CATDOLL 128CM Cici Silicone Doll

Height: 128 Silicone Weight: 21kg Shoulder Width: 30cm Bust/Waist/Hip: 57/52/63cm Oral Depth: N/A Vaginal Depth: 3-15cm...

Articles 2026-02-22
CATDOLL 138CM Ya TPE

CATDOLL 138CM Ya TPE

Articles
2026-02-22
CATDOLL Himari Hard Silicone Head

CATDOLL Himari Hard Silicone Head

Articles
2026-02-22