Share this

Research and Development of Automatic Programming System for CNC Punch Presses Based on AutoCAD

2026-04-06 06:20:18 · · #1
Abstract: This paper proposes a modular design method based on AutoCAD and studies the key technologies for the development of an automatic programming system, including the acquisition of graphic data, selection of machining molds, optimization of machining paths, and generation of NC code, among other automatic programming processes. The overall structural scheme of the simulation module is studied, and two-dimensional dynamic simulation based on AutoCAD is realized. Practical production has proven that the automatic programming system for CNC punching machines based on AutoCAD can meet the needs of actual production and effectively improve the production efficiency and safety of CNC punching. Keywords: VisualLISP; CNC punching machine; automatic programming; machining simulation 1 Overview With the development of science and technology, CNC machine tools are increasingly widely used in the machinery manufacturing industry. In CNC machining systems, traditional manual NC code programming is not only inefficient but also prone to errors; while automatic programming using APT language, although concise in geometric definition statements and powerful in function, requires programmers to memorize the system's language and rules, and errors are difficult to detect. Foreign CNC punching machine graphic programming systems have been applied to actual industrial production, while China is still in the research stage in this area. This paper presents an in-depth study of the automatic programming system for CNC punch presses. The system was developed within the AutoCAD VisualLISP environment and successfully passed compatibility tests with multiple AutoCAD versions from 2000 to 2006. 2. Overall Structure of the Automatic Programming System The automatic programming system adopts a modular structure, consisting of six functional modules: the main automatic programming module, the graphic information processing module, the machining path determination and optimization module, the mold library and mold selection module, the post-processing module, and the graphic simulation module. The overall structure of the modular CNC punch press automatic programming system is shown in Figure 1. [align=center] Figure 1 Overall Structure of the Automatic Programming System[/align] The main function of the main automatic programming module is to call the machining path module and the mold library module, converting graphic information into machining path information and mold information, and generating toolpath files. This module can also directly call the post-processing module and the graphic simulation module to generate the NC code required for machining and perform graphic simulation. This module also includes file editing functions such as saving and editing toolpath files and NC code files. 3. Key Technologies for System Development 3.1 Graphic Information Processing To generate NC code, the computer must first recognize the graphics to be processed. The graphic information processing module extracts useful graphic information from the CAD drawing, such as the diameter and center of a circular hole, the side length and center of a square hole, the diameter and centerline arc of an oval hole, and the side length and geometric center of a rectangular hole. This information is then transmitted to the main program module. There are several methods for obtaining graphic information, such as importing DXF files or obtaining it through human-computer interaction. Since VisualLISP can directly manipulate selection sets, the latter method is more suitable and facilitates more convenient human-computer interaction operations such as setting the programming origin (workpiece coordinate system origin). 3.1.1 Obtaining Basic Parameters of the Circle Class In AutoLISP, obtaining the basic parameters of a circle through interactive operations is very easy. The following simple code snippet can obtain the main parameters of a circle: `(SETQ cir_data(ENTGET(CAR(ENTSEL"\nPlease select a circle:"))))`; Obtain graphic information through interactive operations: `(SETQ cir_pt(CDR(ASSOC 10cir_data)))`; Obtain the center coordinates from the graphic information: `(SETQ cir_r(CDR(ASSOC 40 cir_data)))`; Obtain the radius of the circle from the graphic information. 3.1.2 Obtaining Basic Parameters of the Rectangle Class The main parameters of the rectangle class are two side lengths and four vertices. The four vertices can be obtained using AutoLISP functions, and the side lengths can be determined by calculating the distance between two adjacent points. Obtaining the position of a point generally uses the `ASSOC` function, which searches for an element in the association table. If found, it returns the entry in the association table. If the number of points is large, a loop reading method is generally used; only one loop is needed to obtain the four vertices. (SETQ reg_data(ENTGET(CAR(ENTSEL"\nPlease select a rectangle:")))); Obtain graphic information through interactive operation (WHILE(SETQpt(ASSOCloreg data)); Set loop condition (SETQ reg-data(CDR(MEMBER pt reg-da-ta))); Delete the obtained points from the point table (SETQptb(CONS(CDR pt)ptb))); Store the obtained points in the variable ptb. When calculating the side length, the points are extracted from the point table variable ptb and directly obtained through the Distance function without distance calculation. 3.1.3 Obtaining the basic parameters of oval holes and straight holes The acquisition of the basic parameters of oval holes and straight holes involves the extraction of polyline data. In order to realize the automatic programming of graphics, both types of holes must be converted into polylines or Lwpolylines. The coordinates of each node and the convexity of the arc can be obtained by using the AutoLISP table processing function. The method is as follows: (SETQ pel_data(ENTGET(CAR(ENTSEL"\nPlease select a rectangle:")))) (SETQ ptl(CDR(ASSOCl0pel-ara))); Take the coordinates of the first node from pel_data and assign them to the variable pt1 (SETQ par(CDR(ASSOC42pel-ata))); Take the convexity of the first line segment from pel_data and assign it to the variable par The radius of the arc can be calculated from the convexity value and the coordinates of two adjacent nodes. The value of the radius R is determined by formula (1): R=(dist*par2+dist)/(2*par) (1) Where: R is the radius of the arc; dist is the distance between the two nodes; par is the absolute value of the convexity. The basic parameters of the oval hole class are mainly 4 radii and 4 centers. In fact, it is only necessary to calculate 4 of the centers to realize the programming function. With four centers, the start and end points of the circular arc punch can be determined. By analyzing and calculating the arc radius, the radius of the die and the required arc radius for the circular arc punch can be obtained. For a straight hole, obtaining the arc radii of the four vertices of its polyline allows us to determine the start, end, and length of the punch. The calculated arc radius is the radius of the die. 3.2 Automatic Selection of Machining Dies 3.2.1 Establishment of the Die Library For a specific tool, the following parameters are required: die number, shape, X-direction length, Y-direction length, and diameter. For circular dies, there are no X or Y-direction length parameters; for rectangular dies, there is no diameter parameter. Users can create and modify tools through a dialog box. Define variables m_dia as the die diameter, m_xlen as the die X-direction length, m_ylen as the die Y-direction length, m_shape as the die shape, and m_sym as the die number. The following code segment defines the tool information format. (list m_sym m_shape m_xlen m_ylen m_dia); The creation of the tool information table-based mold class establishes the tool storage format, meaning that tool information is stored in the tool library in a table format. Mold library management uses table operations to manage the mold library. 3.2.2 Automatic Selection of Machining Molds A typical CNC punching machine can have multiple molds, including both circular and rectangular molds. The holes to be processed can be divided into four categories: round holes, rectangular holes, oval holes, and straight holes. To facilitate the selection of graphics and the processing of different types of graphics, the system can assign different types of graphics to four different selection sets ss1, ss2, ss3, and ss4 through interactive operations. By setting the parameters of the SSGET function, errors in the assignment process can be avoided. The overall process of automatic mold selection by the system is shown in Figure 2. [align=center] Figure 2 Overall process of automatic mold selection by the system[/align] Mold matching requires the writing of a dedicated matching function, which automatically selects the appropriate mold from the established mold library for processing based on the different hole shapes. 3.3 Determination of Machining Path The determination of machining path is the determination of the stamping path of CNC punch press. The main design task is to determine how to determine the machining sequence, how to optimize the machining path to the shortest length, how to minimize the machining time, and how to adapt the program to various machining schemes. 3.3.1 Basic Principles of Machining Path The determination of machining path of CNC punch press mainly involves two basic principles: (1) Concentrate the same tool operation as much as possible. In CNC punching, in order to reduce the auxiliary time occupied by tool turning, the parts can be processed by concentrating the operations, and the same punching part on the surface of the part can be processed with the same die as much as possible. (2) Shortest tool path. For CNC equipment, every second is precious. The time required for the stamping process is relatively short, and the idle stroke of the die determines the processing efficiency. It is particularly important to arrange the idle stroke path reasonably. 3.3.2 Machining Path Optimization The problem of machining path optimization is finding the shortest traversal path for machining holes. For machining holes of the same size, path optimization can be classified as a complete NP problem. A typical example of a complete NP problem is the Peddler's Problem. The difference between the Peddler's Problem and the shortest traversal path problem studied in this paper is that the final node in the Peddler's Problem is the starting point, while the shortest traversal path does not require returning to the starting point. However, if an efficient algorithm can be used to solve the Peddler's Problem, an approximate algorithm for the shortest traversal path can be derived by analogy. A completely perfect algorithm for a complete NP problem does not exist because obtaining a result for a number of traversal points greater than 20 would take years or even decades. Approximate algorithms are generally used to replace optimal algorithms. Common algorithms include orthogonal path methods and nearest-point path methods. 3.4 Post-Processing The main function of the post-processing module is to convert toolpath files into NC code. Its function as an independent module is to generate NC code adaptable to different CNC systems through different post-processing steps, enhancing the system's versatility. 3.4.1 Design of Post-processing Module Post-processing modules are divided into two main categories: one is a dedicated post-processing module, and the other is a general post-processing module. According to the characteristics of the stamping CNC system, the general post-processing module is more suitable for this system. By formulating a standard format machine tool file, the standardized file of machine tool data is realized through the dialog box. When calling the standard machine tool file during NC code generation and graphic simulation, the corresponding CNC code information can be obtained. The CNC system C code setting interface is shown in Figure 3. [align=center] Figure 3 G code setting interface[/align] 3.4.2 NC Code Generation (1) NC Code Generation for Point Punching The C code for point punching is GOO, but in order to adapt to more CNC systems, the author creates a variable gcode_00 to represent the fast point positioning punching instruction. The system default code is GOO, and different CNC systems can be set in the post-processing settings of the automatic programming system. The center position coordinates of the tool are determined by the machining path module, and the tool information is determined by the mold selection module. (2) NC code generation for step punching Taking linear step punching as an example, the default G code for linear step punching is G69. Different CNC systems can still be set in the C code settings of the automatic programming system. The coordinates of the starting and ending positions of the step punch are determined by the machining path module, and the tool information is determined by the mold selection module. The length of the step punch is the distance between the starting and ending positions, which can be easily achieved using the Distance function. The determination of the step distance is divided into two cases: circular mold step punching and rectangular mold step punching. 3.4.3 Determination of step punch step distance When using a circular mold for step punching, uniform step punch tooth patterns will inevitably be produced. The larger the step distance, the more obvious the tooth patterns. The step distance of the circular mold step punch depends on the height of the step punch tooth patterns, that is, on the size of the step punch accuracy. The size of the tooth patterns determines the machining accuracy of the hole. Therefore, when designing the program, the accuracy requirement is taken as an input parameter and set in the step punch accuracy settings of the automatic programming system. The size of the step distance is calculated and determined by formula (2). p = 2(ds-s2)1/2 (2) Where: P is the step distance; d is the mold diameter; s is the tooth height. The step distance of a rectangular mold depends only on the length of the step punch and the size of the mold. The minimum number of step punches is obtained by dividing the distance between the start and end points of the step punch by the mold size in the step punch direction, rounding down, and adding one. Then, the value obtained by dividing the distance between the start and end points of the step punch by the number of step punches can be used as the step distance. Of course, in most CNC systems, the step distance of a rectangular mold can be any value smaller than the mold size in the step punch direction. In order to ensure the efficiency and effect of processing, a reasonable step value can be manually estimated and then set in the step punch accuracy setting of the automatic programming system. If the number of step punches obtained by dividing the distance between the start and end points of the step punch by this step distance is not an integer, the CNC system will automatically adjust the step to suit the processing. 4. Simulation of the Machining Process During CNC machining, whether the quality of the machined part meets the requirements, whether interference and collisions occur between the part and the tool, the tool and the fixture, or the tool and the machine tool table, whether the tool overcuts or undercuts the part, and whether the tool path and path mode are reasonable—all these problems that may occur in actual machining depend on the correctness of the CNC machining instruction set output by the automatic programming system. Based on the information provided by the NC code file, the machining trajectory is simulated and displayed on the screen for program verification and stamping process inspection. 4.1 Overall Structure of the Simulation System The simulation system should be able to complete error checking of the CNC program and dynamically simulate the movement of the CNC machine tool driving the tool and the machining process. Therefore, the simulation of the machining process generally consists of three parts: file processing, error checking, and simulation. Its overall structure is shown in Figure 4. [align=center] Figure 4 Overall Structure Diagram of the Simulation System[/align] 4.2 Translation of NC Code and Implementation of Simulation Once the data of the program segment is obtained, the provided values ​​can be used for simulation. Drawing on the screen does not equate to simulating the machining process. If you want to see all the graphics displayed on the screen and dynamically observe the machining sequence, you need to add some programming. Dynamic simulation can be achieved in two ways: First, by calling AutoCAD's internal "delay" command. This method is simple and quick, allowing you to arbitrarily set the generation time between two graphics, thus adjusting the simulation speed. The second method is to write a dynamic function, z_timer. The z_timer function takes the input punch press T-axis movement speed and the distance between two adjacent machining points calculated from the graphics to determine the required movement time, which is then delayed by the Delay function. This method has the advantages of: the total time matches the actual time, tool change time can be included for truly real-time simulation, and the time scaling ratio can be specified through a dialog box, allowing you to control the simulation speed proportionally. 5. Program Execution Example 5.1 Automatic Generation of NC Code The actual machining control board drawing is shown in Figure 5. [align=center]Figure 5 Electrical Control Board[/align] First, draw Figure 5 in AutoCAD at a 1:1 scale. Then check if the rectangular hole to be machined is a single piece. If the rectangular hole is drawn using multiple straight line segments, it needs to be converted into a polyline. Click the menu "CNC Machining" → "Machining Tool Pre-inspection" to check if there is a suitable machining tool in the tool magazine for the hole to be machined. After the check is completed, the system will prompt that there is no directly usable mold for the 60×20 rectangular hole. Therefore, the punch die can be specified as tool T316, i.e., a 13×13 square mold. However, to make the dynamic simulation clearer, tool T321, i.e., a 10×10 square mold, is selected. Click the menu "CNC Machining" → "NC Code Generation". In the pop-up dialog box, select the graphic to be machined according to the prompts and set the relevant parameters. Click OK to generate the corresponding NC code, as shown in Figure 6. [align=center]Figure 6 System-generated NC code file[/align] 5.2 Example of dynamic simulation of NC code First, perform error checking on the NC code file. After confirming that there are no lexical or syntactic errors, click "NC Machining" → "NC Simulation" to activate the NC simulation dialog box. Select the NC file to be simulated through the dialog box, set the stamping simulation speed, and click the OK button. The dialog box will close automatically, and dynamic simulation of the specified NC code file will begin on the current screen. The simulation effect is shown in Figure 7. Figure 7 shows the simulation result of the NC code file. The dotted line in the figure shows the center trajectory of the tool movement. [align=center]Figure 7 Simulation result[/align] 6 Conclusion This system has been successfully applied to an electrical control equipment factory in Shanxi. Practical production has proven that this system has the functions of automatic generation of NC code and dynamic simulation of graphics, and can also detect errors in existing NC code. The system automatically programs the part drawings, avoiding the tedious coordinate calculations of manual programming, and optimizes the machining path, thus improving production efficiency. Combined with the application of the graphic simulation module, it effectively reduces the occurrence of machining accidents and improves the safety of stamping.
Read next

CATDOLL 115CM Cici TPE (Natural Tone)

Height: 115cm Weight: 19.5kg Shoulder Width: 29cm Bust/Waist/Hip: 57/53/64cm Oral Depth: 3-5cm Vaginal Depth: 3-15cm An...

Articles 2026-02-22