Abstract: A teaching-type five-axis linkage micro CNC milling machine was designed to meet the practical experimental requirements of college students. This milling machine adopts a swivel-head rotary table mechanical structure, enabling movement in three-dimensional space and rotation along the A and B axes, realizing the five-axis linkage design concept. Based on this, a motion control system for the five-axis linkage micro CNC milling machine based on an ARM microcontroller was developed. This CNC system adopts a "PC + ARM microcontroller" design. The host computer uses Delphi programming software to compile NC documents, calculate tool compensation, and communicate with the slave computer. The slave computer is composed of an ARM microcontroller with an STM32 chip as its core, mainly responsible for communication with the host computer, interpolation calculation, and motor position control. Due to its high stability, strong safety and reliability, and high cost-effectiveness, this CNC system is very suitable for college student experiments.
Keywords: five-axis linkage; embedded system; CNC system; Delphi programming; ARM microcontroller; STM32
Foreword
Motion control in high-speed CNC machining is crucial for improving machining quality and efficiency. While CNC machine tool experiments have become increasingly common in university engineering training centers, the equipment is often large, expensive machine tools or machining centers. Students typically only have hands-on experience, rarely having the opportunity to truly grasp the principles of CNC technology through practical training. Therefore, this paper develops a five-axis micro CNC milling machine structure and control system. This CNC milling machine is a comprehensive experimental project integrating teaching, experimentation, and research. Its content covers the structural design of the CNC milling machine, the design, installation, and debugging of the CNC system hardware, the development of the system software, and the electrical control of the machine tool. Furthermore, this CNC system is simple to operate, low in cost, and widely applicable. It not only facilitates teaching but also helps students develop better hands-on skills, making it significant in the field of education.
1. Structural Design of a Five-Axis Micro CNC Milling Machine
A five-axis linkage micro CNC milling machine consists of translation along the X, Y, and Z axes and rotation about any two of these axes. It can be basically divided into three types: double-swivel head type, double-rotary table type, and swivel head-rotary table type. The five-axis CNC milling machine designed in this paper adopts a swivel head-rotary table structure, as shown in Figure 1 (overall dimensions 400mm × 300mm × 600mm), namely, translation along the X, Y, and Z axes, oscillation about the Y-axis (B), and rotation about the X-axis (A). The newly designed five-axis linkage micro CNC milling machine can realize the machining of complex curved surfaces and can meet the experimental requirements of college students.
Figure 1. Structure diagram of a five-axis micro CNC milling machine
1.1 Linear Motion Module
The linear motion unit mainly consists of: lead screw and nut pairs, gear and rack pairs, and synchronous toothed belts. The designed teaching-type five-axis micro CNC machine tool features a compact structure. The X and Y axes of the milling machine use ball screw drives to ensure transmission accuracy, while the Z-axis uses a self-locking trapezoidal lead screw to prevent the spindle head from shifting downwards due to its own weight. Since the Z-axis motor and lead screw are not on the same axis, a synchronous belt drive with a 1:1 transmission ratio is used between the Z-axis motor shaft and the lead screw shaft to ensure transmission accuracy. All axes are driven by stepper motors.
1.2 Rotary Motion Module
Common rotary motion units in five-axis micro CNC milling machines include bevel gear drives, worm gear drives, and spur gear drives. Worm gear drives are chosen because they can meet the requirements of large reduction ratios and improve machining accuracy. Therefore, the rotary and oscillating axes of the designed CNC milling machine all use worm gear drives with a transmission ratio of 1:30, and the stroke of each rotary axis is -90° to 90°. Since stepper motors cannot self-lock after power failure, a single-start worm with a helix angle smaller than the contact friction angle of the worm gear is selected to achieve self-locking of the rotary axes. A rotary encoder with a resolution of 3600 pulses is used to control the angle of each rotary axis with a control accuracy of 0.1°, and each rotary axis is driven by a stepper motor.
2. Overall Design of CNC Milling Machine Control System
The overall design of the five-axis micro CNC milling machine control system is shown in Figure 2. The system mainly consists of two parts: system hardware and system software. The core of the system hardware is an ARM microcontroller. The microcontroller's independent I/O ports control the stepper motor drivers of each axis, thereby achieving precise rotation of each axis motor. PWM control is used to achieve stepless speed regulation of the spindle's brushless DC motor. The ARM microcontroller's independent I/O ports can realize digital input of limit switches and encoders, thus avoiding dangers caused by overtravel of each axis of the milling machine and ensuring the precise angle of rotation of each axis.
Figure 2 Overall design of the control system of the five-axis micro CNC milling machine
The system software consists of a host computer program and a slave computer program. The host computer program, written in Delphi, primarily handles non-real-time tasks such as reading and saving NC files, tool compensation, and decoding. The slave computer program mainly handles decoding and interpolation, limit switch and encoder control, etc., with interrupt service routines ensuring its real-time performance. In the communication module, real-time communication between the host and slave computers is achieved by setting the same baud rate and other parameters.
b
Currently, the most widely used control systems for CNC machine tools are mainly divided into two types: microcontroller control systems and motion control card control systems. While motion control cards can meet the data processing needs of micro CNC milling machines, their high cost and inconvenience (requiring the insertion of specific cards into the computer host) do not meet the requirements of ease of operation and cost-effectiveness in this project. Microcontroller control systems, on the other hand, possess strong data processing capabilities, are simple to program, and are easy to maintain. Therefore, a microcontroller was chosen as the core hardware of the micro CNC milling machine system.
3.1 Selection of Microcontroller Chips
The selected microcontroller is an ARM series microcontroller with the STM32F103RET6 as its core chip, used as the control system. This microcontroller has a large data storage capacity, strong processing power, and incorporates an embedded operating system, increasing its developability and meeting the control requirements of a micro numerical control system. The STM32F103RET6 microprocessor is a 32-bit Cortex-M3 core processor with built-in high-speed memory (including 512KB of flash memory and 64KB of internal memory).
The SRAM (Structured Array of Machines) can meet the needs of program storage and cached operation of CNC systems.
The microcontroller has 64 GPIO ports, and 51 independent I/O ports that can be used for control, which can meet the control of 5 stepper motors, 1 brushless DC motor, 6 photoelectric limit switches and 2 digital encoders of a micro CNC milling machine.
The microcontroller's independent I/O port outputs a pulse frequency of 50MHz, which can meet the speed requirements of stepper motors and brushless DC motors.
3.2 CNC System Hardware Circuit Design
To meet the functional requirements of this CNC system, a dedicated microcontroller control circuit for CNC milling machines based on the STM32F103RET6 chip was designed. This microcontroller circuit mainly consists of a power supply module, a driver module, a limit and encoder module, and a communication module. The system hardware circuit wiring diagram of the five-axis micro CNC milling machine is shown in Figure 3.
Figure 3 Wiring diagram of CNC system hardware circuit
In the design of the microcontroller, an external +5V power supply and USB are used simultaneously to power the microcontroller, ensuring the voltage and current requirements for its operation. The microcontroller communicates with the host computer via a serial port. For the design of the five-axis micro CNC milling machine, considering safety, photoelectric limit switches are required for each linear motion axis, and photoelectric encoders are required for the rotary axes. This ensures that the micro CNC milling machine does not experience collisions or other dangerous actions during operation, protecting both the machine tool and the operator.
The microcontroller provides direction and pulse signals to the motor driver through an independent I/O interface to drive the motor to rotate.
4. CNC Milling Machine Control System Software Design
The software design of the control system has a significant impact on the accuracy and stability of CNC milling machines. Based on the functional requirements and structural analysis of the micro CNC milling machine control system, its control system software mainly includes the following functional modules: user interface operation module, tool radius compensation calculation module, upper and lower computer communication module, decoding and interpolation module, and other modules. The software flowchart of the five-axis micro CNC milling machine is shown in Figure 4.
Figure 4. Software flowchart of the milling machine
User interface module: Enables user input of CNC G-codes, parameter settings, real-time coordinate display, and machining program management. The main software interface of the five-axis micro CNC milling machine is shown in Figure 5.
Figure 5. Software interface of the micro CNC milling machine
Tool radius compensation calculation module: This module reads tool compensation parameters to perform document compensation calculations and generates G-code after tool compensation, preparing for milling machine machining. Upper and lower computer communication module: This module enables data transfer between the PC and the microcontroller. On one hand, it transmits the upper computer's G-code program, switch status, and other data to the microcontroller to control the milling machine motor driver; on the other hand, it monitors the microcontroller's data operation status, allowing the PC to maintain real-time monitoring of the CNC milling machine's status. Decoding and interpolation module: This module decodes and analyzes the program transmitted from the upper computer, determines the milling machine's operating mode, feed rate, and other parameters, calculates the intersection coordinates, and performs interpolation calculations to determine the milling machine's running trajectory. Other modules: These modules primarily process and analyze collected signals from photoelectric limit switches, digital encoders, and emergency stop switches to ensure the milling machine's stroke and safe operation.
5. Conclusion
A teaching-type five-axis micro CNC milling machine was designed to meet the experimental requirements of university students. This micro CNC milling machine is fully functional and can completely satisfy the machining of complex curved surfaces. The motion units of the five-axis micro CNC milling machine were designed to ensure its motion accuracy and stability. Finally, the control system of the micro CNC milling machine was studied, using a microcontroller as the core. The control of the CNC milling machine is achieved by controlling five stepper motor drivers and a spindle servo drive, and the various modules of the control system were designed. Experiments show that the five-axis micro CNC milling machine with a microcontroller as the control system has high accuracy and stability.