Modular design of typical CNC milling machine control software
2026-04-06 04:49:25··#1
This article introduces a typical CNC milling machine, which mainly consists of a machine tool operation panel, three linear coordinate axes (X, Y, and Z), an upper spindle, and auxiliary functions such as hydraulic, lubrication, and cooling systems. The machine tool's electrical system includes a digital control system (CNC), a digital servo drive system, a spindle frequency converter, and a PLC input/output control system. This electrical system primarily handles human-machine interaction and controls the coordinate feed, spindle rotation, and hydraulic, lubrication, and cooling systems of the three-coordinate machine tool. The three coordinate axes of this machine tool utilize a HEIDEHAIN linear encoder with a closed-loop feedback mechanism. The spindle is an electric spindle controlled by a Schneider frequency converter. Considering the machine tool's structural characteristics, its electrical control system is equipped with the NUM1050 fully digital CNC system from NUM (France), and the servo drive is configured with the corresponding MDLUNUMDRIVE CNC servo drive system. The PLC control program for this three-coordinate machine tool is developed using the built-in PLC functions of the NUM1050 fully digital CNC system and a corresponding software platform. Therefore, the flexibility and maintainability of the PLC program are inextricably linked to the high performance of the NUM1050 CNC system. 1. NUM1050 CNC System The NUM1050 is an open and powerful digital control system, employing a 64-bit CPU 68040 for data processing and coordinate control, featuring high processing speed and high position control accuracy. The system includes: a graphical management CNC panel display and keyboard; memory for storing operating programs, PLC programs, and user files; powerful communication capabilities allowing the CNC to communicate with a host computer via RS232 serial port or network interface; an axis control board for controlling the movement of digital or analog axes; a built-in PLC managing the machine tool through input/output modules; and CNC software managing machining programs, machine tool data, computer trajectories and speeds, and monitoring the movement of the coordinate axes. 2. Features of the NUM1050 Built-in PLC: The PLC uses the input/output interfaces provided by the NUM system to exchange data with the outside world. Data in the storage area is refreshed through the PLC's scan cycle. The PLC reads data through the %I variable, while outputting data to the outside world is done through the %Q variable. The built-in PLC exchanges data with the NC through the exchange area, which contains the input/output data between the NC and the PLC. Data output from the NC to the PLC is read by the PLC from the exchange area through the %R variable. Data sent from the PLC to the NC is placed in the exchange area through the %W variable and read by the NC. The scan cycle is automatically executed by the system. Each byte and bit of all variables in %R and %W has a specific meaning, specifically provided to the PLC to control the operation of the NC and coordinate the actions between external devices and the NC. 3. Features of the NUM1050 PLC Program Structure: NUM CNC system PLC programming includes ladder diagrams, assembly language, and high-level languages (C language). All programs are designed using task modules and subroutine modules. The PLC program's task modules include: %INI, %TS0~4, %TF0~15, and %TH0~15. Subroutine modules %SP0~255 are also included; these subroutines can be called by task modules or between subroutines. The functions of each module are as follows: Initialization task %INI: Executed once each time the system powers on. Looping task %TS: The system first executes %TS0, then TS1~4 in sequence. The execution cycle of %TS0 is equal to each RTC (Real-Time Clock) cycle, i.e., 20ms. %TS1~4 execute once every 5 RTC cycles (100ms). Background task %TS has a lower priority than looping task %TS and interrupt task %TH, and can be used to wait for tasks. Background tasks can last for several RTC cycles and can be interrupted by looping tasks. Interrupt (real-time) task %TH is used for higher priority events without waiting for the RTC cycle to end. Interrupt (real-time) task %TH has a higher priority than looping task %TS and background task %TF. Error Message Table %9999.9: Machine Tool Error Message File. 4. Design and Implementation of the PLC Program for a Three-Coordinate CNC Gantry Milling Machine. The design of a PLC program relies heavily on a good software platform and hardware environment. The NUM1050 CNC system provides machine tool manufacturers with abundant software resources and powerful software development tools, such as PLCTOOL, SETTOOL, and PCTOOLKIT. These are all based on the WINDOWS platform, greatly facilitating the development of machine tool electrical control systems. PLCTOOL, in particular, allows for convenient programming using PLC ladder diagrams or the high-level language C, and features a rich instruction set, timer/counter units, a graphical interface, and flexible and convenient operation. The PLC program for this three-coordinate CNC gantry milling machine was developed and designed on the PLCTOOL software platform. Considering practical applications, this three-coordinate machine tool uses ladder diagram language to design the PLC program, which has the advantages of being intuitive, dynamically displayable, and easy to debug and maintain. Using the input/output modules and machine tool operation panel provided by the NUM1050 CNC system, the machine tool's motion and other functions can be controlled very conveniently, as the operation panel has programmable custom keys. The machine tool operation panel provided by the NUM system is connected to the system via fiber optic cable, improving reliability. Based on the characteristics of the NUM1050 PLC program structure, the various functions of this three-axis machine tool were assigned to different modules for control when designing the PLC program. Since this machine tool has no special interrupt tasks, the program design used the initialization task %INI, the cyclic task %TS, and the subroutine module %SP. The scan cycle of %TS0 is 20ms, so important subroutines are called in %TS0. Auxiliary functions of the machine tool, such as hydraulics, cooling, and lubrication, are controlled in task modules %TS1 to 3. The control of the machine tool's coordinates, spindle, and related parts is handled by the ladder diagram subroutine module %SP. The PLC program structure and module description of a three-axis CNC milling machine are as follows: %INI: Called by the system before other tasks are executed, executed only once when the PLC is powered on, not controlled by the PTC cycle, mainly for initializing some variables. %TS0: Calls a subroutine. %TS1: Controls the machine tool's auxiliary functions, guideway lubrication and hydraulic system. The guideway lubrication cycle is controlled by a timer in the PLC program. %TS2: Controls the machine tool's cooling system. Automatic and manual cooling can be selected on the machine tool's operation panel. %TS3: Controls the machine tool spindle's tool release and tool clamping. %SP0: Used to control the flashing of indicator lights on the machine tool's operation panel. Most of the custom buttons on the machine tool's operation panel provided by the NUM1050 system have indicator lights. When using functions that require special reminders, the buttons use flashing indicator lights for visibility, such as the machine tool fault reset button, tool change completion button, etc. %SP2: Controls the custom buttons on the machine tool's operation panel. The custom buttons on the operation panel must be programmed by the PLC to take effect, and the function of the buttons is defined according to the needs of the machine tool. According to user requirements, the operation panel of this three-axis CNC gantry milling machine is designed with functions such as machine start, cooling control, spindle start/stop, tool change completion, and machine fault reset. %SP3: Controls coordinate movement and coordinate limit safety checks. %SP4: M function decoding; this module defines the M06 function for tool change completion. %SP5: Controls coordinate axis servo enable. %SP6: This module controls all functions of the spindle, including spindle cooling, spindle lubrication, tool clamping, spindle motor, and spindle frequency converter. %SP20: Display control of machine fault information. When a machine fault occurs, the fault number and fault content need to be displayed on the display page in a timely manner. When multiple faults occur, the system can display them sequentially, with the display time for each fault set in this subroutine module. This module is called by other related modules. All functions and controls of this three-axis CNC gantry milling machine are implemented by the above modules, among which %SP2, %SP3, %SP5, and %SP6 are the core of the machine's PLC program. Designing the PLC program in a modular manner allows for individual debugging of each module, improving the efficiency of machine tool debugging. When problems arise during debugging, the source of the problem can be quickly identified. Furthermore, different functions of the machine tool are represented by different sub-modules, making the program structure clear at a glance. Individual debugging of each sub-module and the final electromechanical integration testing have proven the effectiveness of this PLC program design philosophy and method. 5. Conclusion After intensive debugging, this three-axis CNC gantry milling machine is operating normally, meeting the requirements, and has reached the acceptance standards. Practice has proven that the control software design of this coordinate measuring machine tool is successful, and some of the basic modules designed and developed also have good portability. With slight modifications, they can be used in the design of PLC ladder diagrams for typical CNC machine tools using the NUM1000 series CNC, laying a good foundation for the design of PLC control software for future CNC machine tools of the same series.