Research on Open Drilling Machine CNC System Software
2026-04-06 04:48:00··#1
1. Introduction In today's rapidly developing computer technology, the transformation of CNC systems from traditional dedicated, closed systems to flexible, open CNC systems has become an inevitable trend. Compared with traditional closed CNC systems, open CNC systems have the following advantages: Scalability: The functions and scale (hardware or software modules) of the CNC system can be flexibly increased or decreased according to specific applications; Portability: The system's functional software is platform-independent and can run on hardware platforms provided by different vendors; Extensibility: Developers can effectively integrate their own software into the NC system to form their own dedicated system; Interoperability: Through standardized interfaces, communication, and interaction mechanisms, different functional modules can achieve interoperability and coordinated operation. Currently, the main form of open CNC systems is PC-based NC, that is, a motion controller with NC function is plugged into the PC bus to complete the NC core functions with high real-time requirements. This project uses the MPC08 motion controller from Stepper Electromechanical Co., Ltd., which is a general-purpose motion controller that meets the functional requirements of CNC systems and offers high cost performance. Based on the drilling machine's process, this project conducts research on the CNC system software. 2. System Overall Structure This CNC drilling machine system has eight axes: X, Y, and Z1, Z2, Z3, Z4, Z5, and Z6. The X and Y axes control positioning in two directions on the plane, while Z1, Z2, Z3, Z4, Z5, and Z6 control the feed rate during drilling. The X, Y, and Z axes can be linked for control. During machining, a machining file is created based on parameters such as the coordinates, diameter, and depth of the holes on the workpiece. The system then controls the machine tool to complete the drilling process according to this file. To control the eight axes of the machine tool, we use the MPC08 motion controller as the core of the system control, which is inserted into the PCI slot of a PC. The system hardware block diagram is as follows: The industrial PC acts as the main control computer to handle communication with the MPC08 controller and non-real-time tasks such as upper-level system operation, scheduling management, fault diagnosis, and parameter input. The MPC08 is an open, general-purpose motion controller. All instructions are immediate, suitable for high-speed, precise point-to-point motion on PCB drilling machines. It has sufficient dedicated and general-purpose I/O channels for machine tool control. The software provides a rich set of motion control functions for users to independently develop and build their required CNC systems on the Windows platform. We insert the MPC08 into the PC's PCI slot to control the entire system. The I/O and feedback system uses the MPC08's dedicated and general-purpose input and output channels to connect and control various machine tool electrical I/O signals. The drive and servo stepper motor units receive pulses and direction signals from the MPC08 to complete the required motion. The frequency converter and spindle rotation control section communicates with the frequency converter via the PC's serial port to control the spindle speed; this control is independent of the MPC08. 3. Software Structure Design To meet the requirements of scalability, portability, expandability, and interoperability, the software adopts a modular design approach and is developed using Visual C++ 6.0 on the Windows 2000 operating system. The software is divided into two main parts: the human-machine interface (HMI) and the system control. The overall module structure of the software is shown in the figure below: 1) HMI The HMI module mainly completes the status display of the entire CNC system and the input of required parameters. In addition, it should be user-friendly and easy to use. This program design utilizes the powerful functions of the CWnd and CButton classes in the MFC library, and uses the member functions of these two classes and their derived subclasses to construct a user-friendly and convenient interface. The interface includes the display of important parameters during the machining process, main function buttons, and the display of machining graphics. The parameter display includes the coordinates of each axis, working stroke, bottom dead center, tool code, diameter, offset, and the record of the number of holes machined, as well as the record of the tool magazine, etc.; the function buttons include start, return to origin, return to stop position, import file, tool parameters, tool management, machining parameters, etc. The tool parameters, tool management, and machining parameters buttons can also open other interfaces to complete system functions; the graphics display is located in the middle of the interface and is used to display the graphics of the machined PCB holes. During the machining process, it can also dynamically display the machining progress of a certain hole. 2) Machining File Function Module: The machining file function module decodes externally input machining files (Excellon format files commonly used in the PCB industry), converting the information in the machining file into the data format required by the control system. The software implementation involves interpreting each line of the file, placing the data for each tool node to be machined into a WORK_NODE structure, and placing the corresponding hole machining data under that tool into a RECORD_NODE structure within the WORK_NODE structure. Finally, each tool node is stored in a machining linked list gWorkList of type WORK_NODE. The data structures for WORK_NODE and RECORD_NODE are as follows: `typedef struct _WORK_NODE { int Type; // Tool type, int ToolNo; // Tool number T0, T1... double Diameter; // Diameter in mm double VelocityForZUp; // Lifting speed double VelocityForZDown; // Drilling speed in mm/min double Offset; // Allowable offset in mm int Rev; // Spindle speed in rpm/minute int MaxLife, HitCount; // Lifespan int ToolCurNo; // Tool magazine number of the current tool jia CRecordList *pList; // Hole coordinate linked list} WORK_NODE, *PWORK_NODE; typedef struct _RECORD_NODE { double x; // x-coordinate double y; // y-coordinate} RECORD_NODE, *PRECORD_NODE; 3)` This machining parameter management function manages various parameters during machine tool control, including machine axis parameters, system parameters, machining parameters, tool parameters, and machine coordinate parameters. For ease of management and use, all these parameters are stored as global variables within the program. Operations on these variables allow for the reading and modification of each parameter. Each parameter variable is a custom structure type. Axis parameters include enable, maximum speed, maximum acceleration, pulse equivalent, homing speed, homing direction, and backlash for each axis. System parameters include interpolation accuracy, position detection cycle, tool magazine coordinate position, depth detection depth, and depth detection speed. Machining parameters include feed rate, lift rate, working stroke, spindle speed, tool change method, and breakage detection range. Tool parameters include tool type, diameter, tool life, remaining tool life, and tool magazine number. Machine coordinate parameters include both absolute and relative coordinate parameters. All parameters, except for absolute and relative coordinate parameters, must be input by the user before machining. During machining, the machine moves according to these set data. Below is an example of a data structure for axis parameters: `typedef struct _AXIS_PARAM_SET { int Installed; // Whether the axis is installed: TRUE — Installed int Enable; // Whether the axis is valid int HomeDir; // Machine tool zeroing direction: 1 — Forward, -1 — Reverse, 0 — Invalid double Interval; // Backlash, p; double MaxSpeed; // Maximum speed (mm/min) (A) double AccelSpeed; // Maximum acceleration (mm/min︿2) 3600000 double PulseFactor; // Pulse equivalent (mm) long PulseUp; // Electronic gear numerator long PulseDown; // Electronic gear denominator long PulseDir; // Feedback direction int SRatio; // S-curve coefficient double HomeSpeed; // Zeroing speed double HomeCheckDis; // Zeroing detection length double HomeOffsetDis; // Distance traveled after zeroing double DepthCheckDis;` // Depth detection descent distance } AXIS_PARAM_SET, *PAXIS_PARAM_SET; 4) Motion and Tool Change Control Motion and tool change control is the core part of the drilling machine's motion, completing the drilling machine's hole machining (including start, positioning, drilling down, lifting), homing, returning to the stop position, and tool change actions. The code in this module is executed in a specially established motion control thread PubWorkThreadHandler (LPVOID pParam). a) Hole Machining When the user is ready to machine and presses the start machining button, the thread automatically reads the decoded data in the machining chain list gWorkList. Based on the known data information, the program sends motion commands to the MPC08 motion controller at the speed set by the machining parameter management module. The controller sends pulses to make the machine tool move quickly and position itself to the coordinates of the hole. Then, it performs hole machining at the given drilling speed and depth, and then lifts up at the given speed, while quickly positioning itself to the coordinates of the next hole to be machined. b) Accurate zeroing plays a crucial role in machine tool positioning and machining. This system's zeroing method utilizes the Z-pulse of the servo motor. When the zeroing button is pressed, the motion control thread of the program sends a zeroing command to the controller according to the corresponding steps, ensuring accurate zeroing of the machine tool. The designed zeroing steps are: each axis moves rapidly towards the origin → slows down upon encountering the origin switch → moves slowly in the opposite direction after slowing down → stops upon receiving the Z-pulse signal from the servo motor. The machine tool uses the stopping coordinates as its origin. A macro is defined for each step in the program to distinguish which step is being processed. c) Returning to the parking position: Pressing the return to the parking position button sends a command to move the X and Y axes of the machine tool to the parking position coordinates set in the machining parameter management module before machining. d) When machining PCB boards with a tool-changing drilling machine, different diameter holes need to be machined. This requires changing tools after machining one diameter hole to a tool of a different diameter. This system offers two tool changing methods: manual and automatic. Manual tool changing involves manually removing the old tool and replacing it with a new one after machining a hole of a certain diameter or when the tool's lifespan has expired, returning to the stop position, and then resuming machining. Manual tool changing is less efficient; modern machine tools generally use automatic tool changing. The tool changing process designed here is as follows: Z-axis homing – presser foot lifted – X-axis moved to the original tool magazine position – Y-axis moved to the original tool magazine position – Z-axis moved to the tool changing position – chuck opening and tool placement – delay – Z-axis homing – XY-axis returned to the stop position – check tool placement – Z-axis homing – returned to the stop position – X-axis moved to the target tool position – Y-axis moved to the target tool position – Z-axis moved to the tool changing position – chuck closing and tool removal – delay – Z-axis homing – returned to the stop position – check tool removal – Z-axis homing – XY-axis returned to the stop position – presser foot lowered. The software implementation of the tool changing is also completed step-by-step in the motion control thread, with each step, similar to the homing step, defined with a macro for differentiation. After the entire tool change process is completed, the machine tool continues to process the remaining holes. 5) Self-diagnosis and detection: The self-diagnosis module plays an important role in the debugging, detection, and status monitoring of the machine tool. Through this module, the user can detect the status of the machine tool's electrical signals at any time, including the signals input from the machine tool to the controller and the control signals output from the controller to the machine tool by the user. In the program, another auxiliary thread, PubMonitorThreadHandler, continuously queries the status register of the MPC08 controller and displays the following dialog box: 4 Application: This system utilizes the powerful functions of the MPC08 motion controller and is software-programmed under the guidance of modular thinking. It is ultimately effectively applied to the control system of a PCB drilling machine, with good running performance. It has also passed high-precision and speed machining tests in PCB CNC machine tools. When machining with a tool diameter of 0.1-0.3mm and a hole spacing of 0.5mm, the maximum speed of each axis and the number of holes drilled per minute all meet the expected requirements.