Share this

Research and Implementation of Key Technologies for CNC Simulation

2026-04-06 08:32:56 · · #1
Abstract: The realism of the graphics and the refresh rate during the operation of the CNC simulation system are two important indicators for evaluating the quality of the system. The author studied and implemented the three-axis CNC milling simulation system from two aspects: the geometric representation of the workpiece model and the local drawing technology used in the simulation process. The system achieved ideal results in terms of the effect of realistic graphics and refresh rate. Keywords: CNC simulation, realistic graphics, local drawing, CAD/CAM 1 Introduction With the increasing complexity of mechanical parts manufacturing, the need for verification of the correctness of CNC code is becoming more and more urgent. The CNC simulation system uses computer graphics display technology to simulate the actual machining process and is one of the powerful tools for verifying the correctness of CNC machining programs [1]. There are relatively mature CNC machining simulation systems abroad, such as the Vericut system of CGTech in the United States [2]. Many domestic research institutions have also done a lot of research in this area and launched relatively mature CNC simulation systems. However, compared with similar products abroad, there is still a certain gap in the effect of simulation process animation. Therefore, in the research process, the authors drew on some existing results [3][4], improved the traditional Z-MAP method, and designed and implemented a three-axis CNC milling simulation system based on OpenGL template caching mechanism and local drawing algorithm with secondary determination of drawing range. 2 Improved Z-MAP method Assuming that the tool is parallel to the z-axis, the three-axis CNC milling process has two obvious characteristics [5]: 1) Only the upper surface of the workpiece is the machining surface; 2) A ray with any point on the bottom plane of the workpiece as the starting point and parallel to the z-axis has only one intersection point with the upper surface of the workpiece. It is under such conditions that it is possible to apply the Z-MAP method to the geometric representation of the workpiece model in the three-axis CNC milling simulation system. 2.1 Traditional Z-MAP method The Z-MAP method proposed by Hsu and Yang [6] is a special representation method based on discrete model. The basic idea of ​​this method is to assume the original workpiece model is a cuboid, and then discretize the rectangle obtained by projecting the cuboid onto the XOY plane into m×n uniformly distributed square grids with a certain precision. This allows the entire workpiece model to be discretized into a set of m×n small cuboids, each with a square as its base. After introducing the Z-MAP method to establish the geometric representation of the workpiece, the geometric representation of the actual cutting process of the tool is approximately represented as a process of continuous updating (reducing) of the height of the discrete small cuboids. Therefore, this method is figuratively called the "grass-cutting method." 2.2 Improved Z-MAP Method During the research process, the authors used the Z-MAP method to establish the geometric representation of the workpiece and found that this method still has shortcomings. The workpiece model established based on the Z-MAP method is merely a collection of small cuboid units of different heights. This severely disrupts the geometric continuity of the upper surface of the workpiece model, especially when the discretization precision is low, making it difficult to express the local surface features of the upper surface of the workpiece during the cutting process. Therefore, the authors improved upon the traditional Z-MAP method, designing an improved Z-MAP method. The algorithm is as follows: 1) After discretizing the bottom plane of the workpiece model into a series of square grids with a certain discretization accuracy, a series of z-direction line segments can be obtained with each grid point as the starting point and the top surface of the workpiece model as the ending point; 2) The triangular grid surface formed by connecting the intersection points of all z-direction line segments with the upper surface of the workpiece model according to certain rules can be regarded as an approximate representation of the workpiece model. 3. Local Rendering Technology During CNC simulation, changes in the shape characteristics of the workpiece model only occur in the local area of ​​the current cutting segment, while other scenes remain unchanged. If only the local area of ​​the current cutting segment is locally rendered, the amount of data involved in hidden surface removal, lighting, and graphics generation will be greatly reduced, ultimately improving the graphics refresh rate and achieving an animation display effect of at least 24 frames per second. In the process of researching CNC simulation, the author designed and implemented a local drawing method for workpiece models based on the Z-MAP method in complex scenarios. The basic process is as follows: 1) Determine the display area Q of the tool motion envelope of the cutting segment on the screen in the device coordinate system; 2) In the world coordinate system, initially select a rectangular area F of the workpiece model on the lowest cutting plane. F is the smallest area where the graphic display result overlaps with Q; 3) Accurately exclude the parts of the rectangular area F that do not overlap with Q on the lowest cutting plane, and finally accurately determine the local area R; 4) Use template caching technology to display the selected local drawing area R in the screen display area Q. 3.1 Determination of the Tool Motion Envelope of the Cutting Segment The process of determining the local drawing range of the triangular mesh surface of the workpiece model in the world coordinate system is essentially to seek the maximum triangular mesh range that may be occluded by the tool motion envelope of a certain cutting segment in the workpiece model space; and the determination of the local drawing area of ​​the graphics in the device coordinate system is also to seek the maximum graphic display range of the tool motion envelope of a certain cutting segment. Determining the precise tool motion envelope requires considering the influence of tool type, especially since the composition of the ball end mill's envelope is quite complex. However, in actual model determination, the model can be appropriately simplified for the following two reasons: 1) Since the world coordinate system and equipment coordinate system define the largest local region or range, any type of tool is simplified to a cuboid model; 2) In actual cutting, the change in workpiece shape is limited to a local range within a certain cutting segment, and the upper surface of the workpiece represents the maximum range of change in the height direction. Based on the above analysis, determining the tool motion envelope of the cutting segment is essentially determining the vertex positions of the tool motion envelope. As shown in Figure 3-1, determining the six surfaces of the tool motion envelope sequentially based on the coordinates of these eight vertices determines the tool motion envelope, and the determination of the tool motion envelope is the foundation of the local rendering algorithm. [align=center] Figure 3-1 Tool motion envelope in the cutting section[/align] 3.2 Determination of the local drawing area in the world coordinate system The purpose of determining the local drawing area of ​​the triangular mesh surface on the upper surface of the workpiece model in the world coordinate system is to find the maximum range that may be occluded by the tool motion envelope. In order to reflect the principle of "maximum range", the authors introduced the concept of "lowest cutting plane" in the algorithm design. The definition of "lowest cutting plane" is as follows: [align=center] Figure 3-2 Schematic diagram of the determination of the local drawing area[/align] Where Z[sub]MIN[/sub] refers to the minimum value of the z coordinate of the vertex of the triangular mesh surface on the upper surface of the workpiece model after all cutting processes are completed. Moreover, there is a clear rule in the workpiece model space: for the triangular mesh surface part that is not occluded by the tool motion envelope on the "lowest cutting plane", although in reality the triangular mesh surface in this area is often higher than the "lowest cutting plane", in this case, these areas are absolutely impossible to be occluded by the tool motion envelope. Therefore, this part of the area can be ignored during local drawing. As shown in Figure 3-2, the plane defined by the four white straight lines is the "lowest cutting plane," and the black cuboid is the tool motion envelope. To determine the local drawing area, the simplest method is to sequentially determine whether the imaginary display graphics of each grid line parallel to the X (or Y) direction intersect with the imaginary display graphics of the tool motion envelope. If they intersect, the intersection interval between each grid line and the tool motion envelope display graphics is precisely determined, and the set of all intersection intervals is the local drawing area. However, this method suffers from high computational cost and low efficiency. Therefore, the authors adopted two stages: preliminary selection and final selection, to improve computational efficiency. The purpose of preliminary selection is to determine the smallest rectangular area where the workpiece's upper surface and the tool motion envelope have an occlusion relationship. The rectangular area enclosed by the four thick white lines shown in Figure 3-2 is the preliminary selection result. The purpose of final selection is to exclude areas within the initially selected rectangular area that absolutely do not have an occlusion relationship. The remaining area is the region that needs to be redrawn due to potential occlusion relationships. The white area within the tool motion envelope shown in Figure 3-2 is the final selection result. 3.3 Determination of the local drawing area of ​​the screen graphics Based on the obtained tool motion envelope, it can be determined that the area changed on the screen is only within the tool motion envelope, while the area outside the tool motion envelope will not change. Therefore, the authors used the template buffer mechanism provided by OpenGL to limit the drawing range of the screen in the research and implementation process. The template buffer provided by OpenGL restricts the drawing to certain parts of the screen. The template buffer can keep the graphics of certain parts of the screen unchanged, while other parts can still be displayed normally [7]. In the simulation of three-axis CNC milling, the local drawing area can only be in the tool motion envelope of the current cutting segment. Therefore, the display area of ​​the tool motion envelope of the current cutting segment on the screen is set as the template. 3.4 Complete process of local drawing Step 1: Clear the template buffer; Step 2: Enable the depth buffer and template buffer to draw the tool motion envelope, and set the information in the color buffer to be unmodifiable, and do not display the drawn tool motion envelope, but set the information in the corresponding template buffer to 1; Step 3: Enable the depth buffer and draw a far plane; Step 4: Set the color buffer to be writable and draw the changed part of the workpiece model. In CNC machining graphics simulation, to ensure correct hidden surface removal in locally redrawn areas, the depth information of the workpiece model within the screen-defined area must be set to its maximum value. OpenGL does not provide a function to modify the depth information of local areas; therefore, the authors used a far plane drawing method to modify the depth information of the envelope determined by the workpiece model. Since this far plane is merely a medium for modifying the depth information, it does not need to be displayed on the screen. 4. Conclusion Based on the geometric representation of the workpiece model and local drawing techniques, the authors implemented a three-axis CNC milling simulation system. An experiment was conducted using a ball end mill with a radius of 4 to mill a semi-cylindrical part as an example. When the discrete accuracy of the workpiece model was 0.8, the number of vertices in the triangular mesh on the upper surface of the workpiece model was 187 × 300. The refresh rate using the global drawing method was (28.723 ± 1) frames per second, while the refresh rate using the local drawing method was (67.703 ± 1) frames per second. The resulting image is shown in Figure 4-1. When the discretization accuracy of the workpiece model is 0.5, the number of vertices of the triangular mesh on the upper surface of the workpiece model is 300×480. The refresh rate using the local rendering method is (10.264±1) frames per second, and the refresh rate using the local rendering method is (64.170±1) frames per second. The effect is shown in Figure 4-2. [align=center] Figure 4-1 Simulation effect when discretization accuracy is 0.8 Figure 4-2 Simulation effect when discretization accuracy is 0.5[/align] The innovation of this paper is that, based on the improvement of the traditional Z-MAP method, a three-axis CNC milling simulation system based on the OpenGL template caching mechanism and the local rendering algorithm with secondary determination of the drawing range was designed and implemented. The CNC code used in this system comes from the FANUC CNC machine tool of the CNC machining center of the School of Mechanical and Electrical Engineering of Zhengzhou University of Light Industry. The test environment is Pentium® 4 CPU 1.49GHZ, 512MB memory. The NC file is read directly to obtain the above test data. The application of this system will save about 500,000 yuan in development costs per year. References [1]. Ying Ke. Research on 3D graphics of CNC simulation based on OpenGL [J]. Microcomputer Information, 2006, 22 (9-1): 226-228. [2]. Cui Hongbin, Fang Yixiang, Zhang Jiayu et al. Fundamentals and Applications of Computer-Aided Design [M]. Beijing: Tsinghua University Press, 2002. [3]. Jiang Xiaofeng. Research on key technologies of CNC machining simulation [D]. Nanjing: Nanjing University of Aeronautics and Astronautics, 1999. [4]. Wu Tiejun, Zhou Laishui, Zhou Rurong. Real-time realistic graphics display of CNC simulation [J]. Journal of Computer-Aided Design and Graphics, 2000, 12 (4): 291-293. [5]. Luo Kun. Realization of CNC milling simulation by triangular discretization method [J]. Journal of Computer-Aided Design and Graphics, 2001, 13 (11): 1024-1028. [6]. Sang-Kyu Lee, Sung-Lim Ko. Development of simulation system for machining process using enhanced Z map model [J]. Journal of Materials Processing Technology, 2002, (130-131): 608-617. [7]. Mason Woo, Jackie Neider, Tom Davis, Dave Shreiner, Wu Bin, Duan Haibo, Xue Fengwu, translated. OpenGL Programming: The Definitive Guide (3rd Edition) [M]. Beijing: China Electric Power Press, 2003.
Read next

CATDOLL 108CM Bebe

Height: 108cm Weight: 14.5kg Shoulder Width: 26cm Bust/Waist/Hip: 51/47/59cm Oral Depth: 3-5cm Vaginal Depth: 3-13cm An...

Articles 2026-02-22