Research on PC-based Three-Axis Linkage CNC System
2026-04-06 06:00:18··#1
Preface: Due to the rapid development of computer technology and its standardization and openness, CNC technology has been upgraded. Many CNC system manufacturers are utilizing the rich hardware and software resources of PCs to develop a new generation of CNC systems with open architectures, namely PC-based modular, reconfigurable, and expandable CNC systems. Keywords: Three-axis linkage, CNC system, PC PC-based open CNC systems can be roughly divided into four types:PC-connected CNC type This type of system uses a common serial cable to connect an existing prototype CNC to a PC. This system is easy to implement, and the prototype CNC can be used almost without modification. Common software can also be used, but the prototype CNC cannot be made open, and the system's communication and response speeds are slow. PC-embedded CNC type This type of system integrates a PC into the CNC, with a dedicated bus connecting the PC and the CNC. The system has fast data transmission and rapid response, and the prototype CNC system can also be used without modification. However, it cannot directly utilize a general-purpose PC, limiting its openness. NC Embedded PC Type This type of system consists of a dedicated CNC card inserted into the expansion slot of a general-purpose PC. It ensures sufficient system performance, offers strong software versatility, and provides flexible programming. Fully Software-Based NC: This type of system handles all CNC functions via the PC, controlling servo drives and other components through a servo interface card installed in the PC's expansion slot. It offers good software versatility and flexible programming. However, real-time processing is difficult to implement, and ensuring system performance is challenging; additionally, prototype CNC resources are difficult to utilize. This system focuses on the design of an economical CNC machine tool control system, choosing the NC embedded PC type for open CNC system development research. The core of the control system is a PC + motion controller, with 4 controlled axes, 3 linked axes, and stepper motors as the drive elements. This system is implemented in C++ under Windows, and the software design employs an object-oriented approach. System Hardware Structure Motion Controller Selection: A motion controller utilizes a high-performance microprocessor (such as a DSP) and large-scale programmable devices to achieve multi-axis coordinated control of multiple motors. Specifically, it integrates the underlying software and hardware for motion control, enabling various speed and position control functions required for motor control. These functions can be easily accessed via a computer. This system uses a motion controller based on the MCX314 DSP motion control chip. The MCX314 chip, developed by NOVA Electronics Co., Ltd. of Japan, is a high-performance DSP motion control chip with a simple interface, convenient programming, and reliable operation. It can be widely used in motion control in CNC machine tools, robotics, and other fields. The chip can interface with an 8-bit or 16-bit data bus, and through command, data, and status registers, it achieves 4-axis 3-linkage motion control and real-time monitoring of position, speed, and acceleration. It supports linear, circular, and bit-based trajectory interpolation modes, with an output pulse frequency of up to 4MHz. Each axis has a servo feedback input terminal, 4 input points, and 8 output points, which can be independently set to constant speed, linear, or S-curve acceleration/deceleration control modes. It also has two 32-bit logic counters, a real position counter, and a status comparison register. The main functional structure of the MCX314 chip is shown in Figure 1. [IMG=MCX314 Functional Block Diagram]/uploadpic/THESIS/2007/12/2007121411245035903N.jpg[/IMG] Figure 1 MCX314 Functional Block Diagram I/O Interface Design The motion controller based on the MCX314 chip realizes information transmission between the PC and the motion device through the ISA bus. Each axis consists of a digital interface composed of pulse output signals, general output signals, direction limit signals, stop signals, and encoder input signals. The pulse output interface is directly connected to the stepper motor to control its movement; the encoder input interface receives feedback data from the encoder on the motor, realizing semi-closed-loop control. The motion controller occupies 16 consecutive ISA bus I/O address spaces, used for data reading and writing, instruction writing, and status register reading and writing. The hardware composition is shown in Figure 2. [IMG=Hardware Composition Block Diagram of Motion Controller]/uploadpic/THESIS/2007/12/20071214112517571515.jpg[/IMG] Figure 2 Hardware Composition Block Diagram of Motion Controller 2.3 System Hardware Working Principle The system consists of a PC, a standard keyboard, a mouse, and a CRT color monitor. The PC acts as the main controller, implementing functions such as human-machine interface management, NC file editing and preprocessing, and machining monitoring. Manual editing of NC files and input of operation commands are completed using the standard keyboard, while the CRT color monitor is used to display the two-dimensional trajectory dynamic display of the machining process through the human-machine interface. The motion controller uses the MCX314 chip as its core, controlling the MCX314 chip with 8-bit data. The clock frequency of the MCX314 is set externally. This system uses the default 16MHz frequency of the MCX314 as the clock signal. The ISA data line is connected to the MCX314 data line via a bidirectional driver, and the MCX314 internally determines which register the data is sent to. System Software Structure Software Platform Selection: Windows has advantages such as a user-friendly interface, relatively easy program development, and good program portability. It also features high-precision real-time response and a preemptive multitasking scheduling mechanism, making it a natural advantage for developing real-time multitasking systems. Windows has two features beneficial for CNC system implementation: First, it provides high-precision real-time response. This real-time function is interrupt-based, requiring no hardware interaction, and multiple real-time instances can be used simultaneously. The accuracy of the real-time response is very high, fully meeting the requirements of CNC technology. Second, it supports multithreading. Threads are a key feature of 32-bit operating systems, offering a series of advantages. For CNC systems, the most useful feature is its support for a preemptive multitasking mechanism, high real-time response speed, and no interference between threads. This facilitates the expansion and tailoring of functions. Implementing a CNC system under Windows can fully utilize these two advantages. Therefore, the Windows operating platform is the preferred software platform. Programming Language Platform Selection Programming language is closely related to software development and runtime efficiency. This system uses C++ and runs in the Borland C++ Builder environment. C++ Builder is an object-oriented visual programming platform used for rapid development of 32-bit Windows applications. Programming in C++ Builder allows for the creation of highly efficient Windows applications with minimal code overhead. Software Structure Implementation The system software is divided into two parts: one is the main control module, which includes modules for parameter configuration, program, machining, manual control, display, and graphics; the other is the motion controller based on the MCX314 chip. The main control module communicates with the MCX314, reads its register status values, and sends relevant control commands to the MCX314 according to the system status. The two parts are closely interconnected. After system startup, the configuration file is loaded according to the settings in the system configuration file. Then, the main control module is started, communicates with the MCX314, reads the chip's register parameters, and transmits the relevant values to the display module. **Program Module Call:** This module allows for editing CNC machining program segments or transferring files. **Machining Module Call:** This module decodes the selected CNC program and transmits the decoded instructions to the MCX314. The MCX314 motion controller then issues corresponding pulse commands to control the movement of each axis motor. **Manual Control Module Call:** In manual mode, pressing the manual control key for each axis sends pulse commands to the corresponding axis motor, causing it to move. **Graphics Module Call:** This module verifies the machining program's compliance with the drawing requirements before machining. Calling this function simulates the machining process on the screen. During machining, calling this module also displays the tool's trajectory graphically. **Motion Controller Software Design: ** The system uses C++ Builder to repackage the MCX314's instruction set. The expected actions are achieved through communication between the main control program and this repackaged motion controller program. This program module is encapsulated using C++ Builder, offering excellent openness. It consists of three parts: define.h, mcxfunc.c, and mcx314.c. For ease of description and programming, relevant variables are defined in the define.h file based on the functional meaning of the motion controller circuit, MCX314 registers, and instruction set. The program categorizes the bits in the status register into four types based on their meaning: axis motion status bits, axis stop status bits, axis error status bits, and interrupt source flag bits. These are used to define the code for reading and writing. For example: //Axis interrupt source flag #define STA_INT_PLS 0x01 //pulse #define STA_INT_PGCM 0x02 //P>=C- #define STA_INT_PLCM 0x04 //P =C+ #define STA_INT_CEND 0x20 //C-END #define STA_INT_CSTA 0x40 //C-STA #define STA_INT_DEND 0x80 //D-END This encapsulates the functions of the MCX314 motion controller, realizing three-axis linkage. It can read the status of each motion axis by calling the linear and circular interpolation functions provided by the software, realizing the motion control function of the CNC system. The provided working mode function allows switching between automatic and manual modes. The software's general input/output functions enable the CNC system to control the machine tool's cutting fluid, automatic tool post, and electric fixture, replacing the PLC control part of traditional CNC machine tools and saving hardware costs. Main Control Module Design The main control module of the system is mainly responsible for scheduling various functional modules, realizing system initialization, parameter management, CNC program editing, manual function implementation, machining status display, and communication with the MCX314. When the system starts, it calls the parameter configuration module to realize system initialization. Meanwhile, during system operation, users can access parameter management at any time to modify relevant system parameters. After system initialization, the display module will be activated to display the various functions of the CNC system in real time and respond to commands accordingly. In this system, we utilize a standard keyboard and define the functions of some keys, such as F7 for calling the machining module, F8 for calling the program module, F9 for the graphic simulation module, F10 for the display position module, F11 for manual mode, and F12 for the parameter setting module. Additionally, F1 to F6 are defined as switching keys for the sub-functions of each module. The principle block diagram is shown in Figure 3. [IMG=System Main Control Module Block Diagram]/uploadpic/THESIS/2007/12/20071214112523558823.jpg[/IMG] Figure 3 System Main Control Module Block Diagram Open Human-Machine Interface The user interface plays a crucial role as the human-machine interface. A good user interface can easily handle various frequently occurring interactive dialogues, and is simple to operate, improving efficiency. The system's display interface shows the current operating status of the machine tool, such as the machine tool's command position (i.e., logical position), actual position, feed rate, and coolant switch. During system operation, this function can be accessed by pressing the position key (set to F10 on the keyboard). Its operating interface is shown in Figure 4: [IMG=Display Interface]/uploadpic/THESIS/2007/12/2007121411253192691B.jpg[/IMG] Figure 4 Display Interface User Input/Output Interface This module implements user input and system output. The main function of user input is to allow the user to input CNC codes, issue control commands, and configure system parameters. The user-input codes use ISO standard CNC codes. Figure 5 shows the user program input and editing interface: [IMG=Editing Interface]/uploadpic/THESIS/2007/12/2007121411254082721A.jpg[/IMG] Figure 5 Parameter Setting Interface of the Editing Interface System This interface is used to set system and machine tool related parameters, such as the machine tool's mechanical travel, maximum feed rate, whether there is an encoder, whether soft limit is enabled and its value, and the X-axis programming mode (diameter programming or radius programming). By setting these values and storing them in the relevant configuration files, the system can call the previously saved configuration during initialization. During operation, if the relevant parameters change, the initialization program can be called immediately to make the changes. System Simulation Machining Interface This system establishes the thread TrdGraphic and uses the TCanvas class provided by the compiler as the base class to create a series of graphics classes, such as CShap (for creating the workpiece graphic) and CTool (for creating the tool graphic). During graphical simulation, the CNC machining program is read and a two-dimensional simulation machining graphic of the tool and workpiece is drawn on the screen. Users can zoom in and out to view the machining details. [IMG=Parameter Setting Interface]/uploadpic/THESIS/2007/12/2007121411254838260B.jpg[/IMG] Figure 6 Parameter Setting Interface [IMG=Simulation Machining Interface]/uploadpic/THESIS/2007/12/20071214112553300426.jpg[/IMG] Figure 7 Simulation Machining Interface Conclusion This CNC system has strong control functions, enabling three-axis linkage control, and can perform three-axis linear interpolation and circular interpolation of any two axes; it has a user-friendly human-machine interface. Adopting a Windows-style interface, users can quickly edit and process NC files without special training. It realizes the main control module, display, automatic machining, manual operation, parameter setting, simulation, and program editing functions of the CNC system. Open CNC systems, with their significant advantages, have become the future trend in CNC system development. Adopting a PC bus architecture and modular functionality provides an excellent platform for software development and functional expansion, giving CNC systems better versatility, flexibility, adaptability, and scalability, and greatly promoting their development towards intelligence and networking.