A CNC comprehensive training system
Through finite element analysis and multi-body dynamics modeling, combined with CNC programs to solve the motion equation, the problem that traditional systems cannot accurately simulate tool motion trajectory is solved, high-precision tool motion trajectory simulation is achieved, and the accuracy of simulation results is improved.
Patent Information
- Application Number
- CN202510139211.1
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2025-02-08
- Publication Date
- 2025-05-09
- Estimated Expiration
- 2045-02-08
AI Technical Summary
When simulating the tool movement trajectory, the traditional CNC comprehensive training system has simple physical modeling methods and cannot accurately simulate the impact of complex factors on tool movement, resulting in a far different simulation results from the actual processing trajectory.
Finite element analysis and multi-body dynamics are used to model the tool, workpiece and machine tool system, combined with CNC programs to solve the motion equation, and homogeneous coordinate transformation and rotation matrix are used to determine the position of the tool in the workpiece system, and the continuous trajectory of the tool in the three-dimensional space is obtained.
High-precision simulation of tool motion trajectory is achieved, complex physical phenomena are taken into account, and the accuracy of simulation results is improved, making it closer to the actual processing process.
Smart Images

Figure CN119596840B_ABST
Abstract
Description
Technical Field
[0001] The invention relates to the technical field of computer-assisted teaching, and in particular to a numerical control comprehensive training system. Background Art
[0002] Computer-aided instruction is an important technology. In the teaching and practice of CNC technology, the traditional CNC comprehensive training system has many significant defects, the most critical of which is the serious lack of accurate simulation and effective analysis capabilities of tool motion trajectory.
[0003] In traditional systems, physical modeling methods are crude, relying only on simple geometric approximations to describe tools, workpieces, and machine tools, completely ignoring the impact of complex factors such as differences in material properties, dynamic changes in cutting forces, and elastic deformation of machine tool structures on tool motion. This makes the simulated tool trajectory far different from the actual trajectory in actual processing. It is difficult for students to master the accurate processing technology based on the simulation results during the training process, and enterprise technicians also lack reliable references when debugging programs and optimizing processes before processing, which greatly increases learning costs and production risks. In order to solve this technical problem, we provide a comprehensive CNC training system. Summary of the invention
[0004] The purpose of the present invention is to provide a numerical control comprehensive training system to solve the problems raised in the above background technology.
[0005] To achieve the above-mentioned purpose, a numerical control comprehensive training system is provided, which includes a physical modeling trajectory calculation unit, an environment construction trajectory rendering unit, and a program trajectory association interaction unit;
[0006] The physical modeling trajectory calculation unit uses finite element analysis and multi-body dynamics to model a system including a tool, a workpiece and a machine tool, and converts instructions into boundary and loading conditions according to a numerical control program, uses an implicit time integration algorithm to solve the system motion equation to calculate the motion parameters of the tool, and uses homogeneous coordinate transformation and rotation matrix to determine the position of the tool in the workpiece system when multiple axes are linked, and obtains a continuous trajectory of the tool in three-dimensional space;
[0007] The environment construction trajectory rendering unit is based on a rendering engine developed by a modern graphics API, uses Phong lighting and a cubic spline curve algorithm, and renders the smoothed tool trajectory through a shader program. The user can control the viewing angle through an input device, and uses a depth buffer and a ray casting algorithm to display the trajectory point information;
[0008] The program trajectory association interaction unit uses finite automaton theory to develop a numerical control program parser, constructs a program structure tree and associates program segments with trajectory segments, realizes two-way highlighting of codes and trajectories, and realizes trajectory modification and program update based on user operations.
[0009] As a further improvement of the technical solution, the physical modeling trajectory calculation unit includes a physical modeling module, and the specific steps of using finite element analysis in the physical modeling module to model a system including a tool, a workpiece and a machine tool are as follows:
[0010] Adaptive meshing technology is used to initially divide the model according to the complexity and material properties of the tool, workpiece and machine tool structure, and material parameters are assigned to different components through material database query;
[0011] Based on the principle of virtual work, the tool cutting force and machine tool constraint force are equivalent to nodal forces. Combined with the determined material constitutive relationship, the overall stiffness matrix and load vector are constructed to form a linear equation group. The Gaussian elimination method is used to solve the equation group and obtain the displacement of each node as the initial condition for subsequent dynamic analysis.
[0012] As a further improvement of the technical solution, the method of using multi-body dynamics in the physical modeling module to model the system including the tool, the workpiece and the machine tool is as follows:
[0013] The tool, workpiece and moving parts of the machine tool are regarded as rigid bodies, and the inertia tensor is determined according to their geometric shape and mass distribution. For the spindle, the inertia tensor is calculated by measuring its diameter, length and mass and combining the formula for calculating the inertia tensor of a rotating body. For the workbench, the inertia tensor relative to the center of mass is calculated using the parallel axis theorem.
[0014] By analyzing the actual kinematic chain of the machine tool, the types of kinematic pairs and constraints between the rigid bodies are determined, and the feed speed and spindle speed instructions given by the CNC program are converted into forces and torques on the corresponding rigid bodies;
[0015] For the spindle drive, the torque required is calculated based on the rotational speed and moment of inertia. For the table feed drive, the driving force is determined according to the feed speed and table mass using Newton's second law to match the model motion with the CNC program instructions.
[0016] As a further improvement of the technical solution, the physical modeling trajectory calculation unit includes a trajectory calculation module, in which the position of the tool in the workpiece system is determined by using homogeneous coordinate transformation and rotation matrix when multiple axes are linked, and the specific operation flow of obtaining the continuous trajectory of the tool in three-dimensional space is as follows:
[0017] Taking the fixed point of the machine bed as the origin, the machine coordinate system and the workpiece coordinate system are established according to the machine coordinate axis direction definition rules. Then the workpiece coordinate system is determined according to the clamping position of the workpiece on the machine tool, and the initial translation vector and rotation angle between the two are recorded.
[0018] For each motion instruction in the multi-axis linkage process, the coordinates of the tool in the machine tool coordinate system are converted into coordinates in the workpiece coordinate system. At the same time as the coordinate transformation, a rotation matrix is constructed according to the rotation angles of each axis of the machine tool to describe the posture of the tool in the workpiece coordinate system. The tool position and posture information are combined to obtain the continuous trajectory of the tool in three-dimensional space.
[0019] As a further improvement of the technical solution, the environment construction trajectory rendering unit is based on the developed rendering engine, further uses Phong lighting and cubic spline curve algorithm, and renders the smoothed tool trajectory through a shader program in a specific method as follows:
[0020] The original tool trajectory is smoothed, the original discrete tool trajectory point set is used as input, the cubic spline curve algorithm is used for smoothing operation, the cubic spline function is obtained, and the cubic spline function is discretized and converted into a set of new vertex coordinates, and then the normal vector is calculated according to the new vertex coordinates;
[0021] In the shader program, lighting is added to the rendered tool track, and the added lighting includes calculating ambient light, calculating diffuse light, and calculating specular light. The calculated ambient light is used to simulate uniform lighting from the surrounding environment in the scene, giving the tool track a basic brightness. The calculated diffuse light is used to simulate diffuse reflection of light on the surface of the tool track, generating lighting of different intensities according to different surface orientations. The calculated specular light is used to simulate the specular reflection effect of light on the surface of the tool track, generating highlights.
[0022] The intensities of ambient light, diffuse light, and specular light are added together to obtain the final light intensity, which is applied to the output color of the shader program. The trajectory data that has been converted and smoothed and combined with the lighting information is passed to the shader program. After receiving this information, the shader program calculates the final color based on the light intensity and applies it to the smoothed trajectory. The smooth tool trajectory with lighting effects is rendered to the screen through the rendering pipeline of the graphics API.
[0023] As a further improvement of the technical solution, the program trajectory association interaction unit includes a program parsing module, and the specific steps of developing a numerical control program parser using finite automaton theory in the program parsing module are as follows:
[0024] According to the grammar rules of CNC programs, the program parsing process is divided into the initial state, instruction reading state, parameter parsing state and program segment end state. Each state represents a specific link in the parsing process.
[0025] Among them, the CNC program is composed of letters, numbers and symbols. These characters are used as the input character set, and the transition conditions between states are determined according to the grammatical logic of the CNC program. The state transfer function is constructed based on this, and the CNC program is parsed through the state transfer function to identify the program structure.
[0026] As a further improvement of the present technical solution, the program trajectory association interaction unit includes an association interaction module, in which a program structure tree is constructed and program segments and trajectory segments are associated, and a method for realizing two-way highlighting of code and trajectory and trajectory modification and program update based on user operation is as follows:
[0027] The program segments identified by the program parser are used as nodes, and a tree structure is constructed according to the program logic relationship. The mapping relationship between the tool trajectory segment start point and end point index corresponding to the program segment execution is established by recording the tool trajectory segment start point and end point index corresponding to the program segment execution.
[0028] When the program is executed to a certain program segment, the corresponding tool trajectory segment is located and highlighted according to the mapping relationship. Conversely, when the user clicks on a tool trajectory segment, the associated program segment can also be found and highlighted, realizing a two-way association between code and trajectory.
[0029] When the user modifies the tool trajectory through the input device, the program parser backtracks the associated program segments according to the trajectory modification information and automatically updates the corresponding NC program parameters. Similarly, when the user modifies the NC program in the program editing interface, the program is re-parsed and the tool trajectory is updated in real time based on the new program structure and instructions.
[0030] As a further improvement of the technical solution, in the association interaction module, the user can control the viewing angle through the input device, and the specific operation of using the depth buffer and ray casting algorithm to display the track point information is as follows:
[0031] The user interacts with the rendering window through input devices to realize the perspective control. When the mouse moves, the observation matrix is rotated and translated using the functions based on the GLM math library according to the direction and distance of the mouse movement, changing the perspective direction and position of the user's observation of the tool trajectory. The keyboard keys are used to control the perspective zoom.
[0032] During the rendering process, the depth buffer mechanism is enabled, and the depth test is turned on through the function based on the GLM math library. In the rasterization stage, the rendering pipeline will display the occlusion relationship between the tool trajectory and other objects in the scene according to the depth value of each pixel, presenting a three-dimensional scene;
[0033] When the user hovers the mouse over the tool trajectory, the ray casting algorithm is started. Starting from the viewpoint position, a ray is emitted along the direction of the mouse. By cooperating with the geometric processing stage of the rendering pipeline, the intersection of the ray and the tool trajectory is determined. If there is an intersection, the shader program is used to draw the coordinate value of the trajectory point near the intersection and present it in text form.
[0034] Compared with the prior art, the present invention has the following beneficial effects:
[0035] In a comprehensive CNC training system, through high-precision physical modeling and trajectory calculation modules, advanced finite element analysis and multi-body dynamics algorithms are used to accurately calculate the tool motion trajectory, taking into account complex physical phenomena, avoiding the problem of large trajectory deviation caused by rough physical modeling in traditional systems, making the simulation results closer to actual processing and improving the reliability of the processing technology. The virtual environment construction and trajectory rendering module is based on a high-performance rendering engine developed based on modern graphics API. It uses Phong lighting and cubic spline curve algorithms to achieve realistic rendering of tool trajectories. Compared with traditional systems that only use simple lines to outline the trajectory, it provides a clearer and more intuitive visualization effect, allowing users to more easily observe trajectory details and features, which helps to better understand the processing process. The program trajectory association and interaction module uses a parser developed by finite automaton theory and innovative association and interaction technologies to achieve a close connection between program and trajectory, and improve the overall level of CNC technology teaching and practice. BRIEF DESCRIPTION OF THE DRAWINGS
[0036] Figure 1 It is an overall block diagram of the present invention.
[0037] The meaning of each number in the figure is:
[0038] 1. Physical modeling trajectory calculation unit; 11. Physical modeling module; 12. Trajectory calculation module; 2. Environment construction trajectory rendering unit; 3. Program trajectory association interaction unit; 31. Program parsing module; 32. Association interaction module. DETAILED DESCRIPTION
[0039] The following will be combined with the drawings in the embodiments of the present invention to clearly and completely describe the technical solutions in the embodiments of the present invention. Obviously, the described embodiments are only part of the embodiments of the present invention, not all of the embodiments. Based on the embodiments of the present invention, all other embodiments obtained by ordinary technicians in this field without creative work are within the scope of protection of the present invention.
[0040] The present invention provides a numerical control comprehensive training system, please refer to Figure 1 As shown, it includes a physical modeling trajectory calculation unit 1, an environment construction trajectory rendering unit 2, and a program trajectory association interaction unit 3;
[0041] The physical modeling trajectory calculation unit 1 uses finite element analysis and multi-body dynamics to model the system including the tool, workpiece and machine tool, and converts the instructions into boundary and loading conditions according to the CNC program. The implicit time integration algorithm is used to solve the system motion equation to calculate the motion parameters of the tool. When multiple axes are linked, the homogeneous coordinate transformation and rotation matrix are used to determine the position of the tool in the workpiece system to obtain the continuous trajectory of the tool in three-dimensional space.
[0042] The physical modeling trajectory calculation unit 1 includes a physical modeling module 11. The specific steps of using finite element analysis in the physical modeling module 11 to model a system including a tool, a workpiece and a machine tool are as follows:
[0043] Different parts have different geometric shapes and stress conditions, requiring different meshing strategies. For simple shapes and uniform materials, structured meshes can save computing resources while ensuring computational accuracy; for complex shapes and stress concentration areas, unstructured meshes and local encryption can better capture details and local effects. The advantage is that it can strike a balance between computational cost and computational accuracy, improving the efficiency and accuracy of finite element analysis.
[0044] Adaptive meshing technology is used to perform initial division of the model according to the complexity of the tool, workpiece and machine tool structure and material properties. For parts with simple geometric shapes and uniform material properties, such as workpieces with regular rectangular shapes, structured meshing methods can be used to divide them into hexahedral units of equal size. For tools with complex surfaces or irregular shapes, unstructured meshing is used, and the Delaunay triangulation algorithm can be used to generate triangular units. Local encryption is performed in key areas where stress is concentrated or the geometric shape changes drastically, such as the cutting edge of the tool and the corners of the machine tool.
[0045] Material parameters are assigned to different components through material database query. For common materials, such as 45 steel workpieces, their material properties, including elastic modulus, Poisson's ratio and density, are found from the material database. Accurate material parameters are the basis for finite element analysis. The mechanical properties of different materials will significantly affect the behavior of the system. Combining database and experimental methods can obtain accurate material parameters and improve the authenticity of modeling.
[0046] Based on the principle of virtual work, the cutting force of the tool is , Machine tool constraint Equivalent to the nodal force, according to the constitutive relation of the material, for linear elastic materials, its constitutive equation is , is stress, The element stiffness matrix can be derived as For a system composed of multiple units, the unit stiffness matrix is assembled to obtain the overall stiffness matrix , and the nodal forces are combined into a load vector , forming a linear system of equations The principle of virtual work provides a theoretical basis for finite element analysis. Converting actual external forces into nodal forces and establishing a set of equations are key steps in converting physical problems into mathematical problems for solution. Complex physical systems can be described by mathematical equations through a systematic approach, which makes it easier to solve.
[0047] Gaussian elimination method is used to solve the equations , for the linear system ,here , , , Gaussian elimination method transforms the augmented matrix into Transform it into an upper triangular matrix, and then back-substitute to solve it. Suppose that after the Gaussian elimination process, Transformed into an upper triangular matrix , then by back-substitution formula and ;in, , solving node displacements, Gaussian elimination method is a mature and effective method for solving linear equations. It has high accuracy and efficiency for solving medium-sized finite element equations. It can directly solve node displacements and provide accurate initial displacement conditions for subsequent dynamic analysis. The displacements of each node in the system are obtained. These displacements are an important basis for the subsequent analysis of tool motion trajectory, system deformation and stress distribution, and provide initial data for the dynamic behavior analysis of the system.
[0048] The method of using multi-body dynamics to model the system including the tool, workpiece and machine tool in the physical modeling module 11 is as follows:
[0049] The tool, workpiece and moving parts of the machine tool are regarded as rigid bodies, and the inertia tensor is determined according to their geometric shape and mass distribution. For the spindle, the inertia tensor is determined by measuring its diameter. ,length and quality , combined with the calculation formula of the inertia tensor of the rotating body, the calculation formula of the inertia tensor of the rotating body is: ;in , For a solid cylindrical spindle, the calculation of its inertia tensor can accurately describe its rotation characteristics.
[0050] For the workbench, its shape is approximately a cuboid, assuming that its length ,Width ,high and quality , first calculate its inertia tensor relative to its own center of mass, for the cuboid along Moment of inertia of the axis ; Then use the parallel axis theorem Compute the inertia tensor about the translation axis, where is the moment of inertia about the center of mass, It is the distance from the translation axis to the center of mass. For the workbench, this can accurately describe the moment of inertia characteristics during its translation.
[0051] Simplifying complex components into rigid bodies and calculating the inertia tensor can describe the actual physical components using the rigid body dynamics theory in multi-body dynamics, which is convenient for subsequent dynamic analysis. It can simplify the model while retaining key dynamic characteristics and reducing the amount of calculation. The calculated inertia tensor can accurately reflect the rotation and translation characteristics of the components, providing the necessary physical quantities for subsequent motion analysis.
[0052] By analyzing the actual kinematic chain of the machine tool, the types of kinematic pairs and constraints between the rigid bodies are determined. For the spindle and the worktable, since the spindle can rotate around its own axis and the worktable can translate in a certain direction, there is a rotation-translation coupling motion between them. The cylindrical pair constraint is used. This constraint limits other degrees of freedom except translation along the cylindrical axis and rotation around the axis. For the tool and the spindle, a fixed pair connection is usually used, which means that there is no relative motion between the tool and the spindle, which can be expressed by the constraint equation as follows: , , , , ,in Represented as location, Represents the rotation angle around each axis. Kinematic pairs and constraints are the key to the interaction between different components in a multi-body dynamic system. Accurately determining these conditions can truly reflect the actual motion constraints of the system. Through precise constraints, unnecessary degrees of freedom can be reduced, the complexity of the system can be reduced, and the model can be made more consistent with the kinematic characteristics of the actual machine tool system. The established multi-body dynamics model can accurately simulate the relative motion of the components in the actual machine tool system, avoid unrealistic motion, and improve the physical authenticity of the model.
[0053] According to the spindle speed given by the NC program Instructions, for spindle drive, based on speed and moment of inertia , calculate the required torque through the formula and apply it to the spindle, convert the speed command of the CNC program into the actual driving torque, make the movement of the model consistent with the program command, convert the control command into physical quantity, enable the model to move according to the program command, ensure the accuracy and controllability of the model movement, ensure that the spindle rotates according to the requirements of the CNC program in the simulation environment, and provide accurate power input for the dynamic analysis of the machining process.
[0054] For the table feed drive, according to the feed speed and workbench quality , use Newton's second law to determine the driving force, convert the feed speed instruction in the CNC program into the driving force of the worktable, ensure that the worktable moves at a predetermined speed, make the movement of the worktable meet the program requirements, provide accurate driving force calculation for the feed movement in the processing process, and let the worktable accurately perform the feed movement in the simulation system, which conforms to the motion laws in actual processing, and makes the motion simulation of the entire system more in line with the control of the CNC program.
[0055] The physical modeling trajectory calculation unit 1 includes a trajectory calculation module 12. When multiple axes are linked, the trajectory calculation module 12 uses homogeneous coordinate transformation and rotation matrix to determine the position of the tool in the workpiece system, and obtains the specific operation flow of the continuous trajectory of the tool in three-dimensional space as follows:
[0056] Taking the fixed point of the machine tool bed as the origin, the machine tool coordinate system is established according to the machine tool coordinate axis direction definition rules. The machine tool coordinate axis is determined according to the design and manufacturing standards of the machine tool. The workpiece coordinate system is then determined according to the clamping position of the workpiece on the machine tool and the processing technology requirements. The clamping position will affect the position of the workpiece coordinate system relative to the machine tool coordinate system. The origin position of the workpiece coordinate system is obtained by measuring the relative position relationship between the clamping reference and the origin of the machine tool coordinate system. At the same time, the initial translation vector and rotation angle between the two are recorded.
[0057] In multi-axis machining, it is necessary to clarify the position and posture of the tool in different coordinate systems. The machine tool coordinate system is the benchmark of the machine tool, and the workpiece coordinate system is the reference system for machining. The establishment of the two is the basis for coordinate transformation, which provides a clear reference framework for subsequent coordinate transformation and trajectory calculation, avoiding confusion of coordinate information in different reference systems.
[0058] For each motion instruction in the multi-axis linkage process, the coordinates of the tool in the machine tool coordinate system are converted to the coordinates in the workpiece coordinate system. In multi-axis linkage processing, the position of the tool relative to the machine tool and the workpiece will change continuously with the movement of each axis. The homogeneous coordinate transformation and rotation matrix can easily and accurately convert the position of the tool in the machine tool coordinate system to the workpiece coordinate system. The homogeneous coordinate transformation can uniformly handle translation and rotation operations, making the calculation of coordinate transformation more concise and systematic. The rotation matrix can accurately describe the rotation of the tool around different axes.
[0059] While transforming the homogeneous coordinates, a rotation matrix is constructed according to the rotation angles of the machine tool axes to describe the tool's posture in the workpiece coordinate system. The tool's posture is crucial to machining accuracy and surface quality. The rotation matrix can accurately describe the tool's directional changes in space, accurately represent the tool's spatial posture, and provide accurate tool direction information for complex surface machining during the machining process.
[0060] The tool position and posture information are combined to obtain the continuous trajectory of the tool in three-dimensional space. For each motion instruction in the multi-axis linkage processing process, the position and posture of the tool in the workpiece coordinate system are calculated through the above-mentioned coordinate transformation and rotation matrix, and these position and posture information are recorded in sequence to form a continuous trajectory sequence of the tool in three-dimensional space.
[0061] Generating continuous tool trajectories is the core of CNC machining trajectory planning. Only accurate and continuous trajectories can guide the machine tool to perform precise machining. Through the system's coordinate transformation and posture calculation, the trajectory information of the tool in the entire machining process can be completely generated.
[0062] The environment construction trajectory rendering unit 2 develops a rendering engine based on modern graphics API, uses Phong lighting and cubic spline curve algorithm, and renders the smoothed tool trajectory through a shader program. Users can control the viewing angle through input devices and use depth buffering and ray casting algorithms to display trajectory point information.
[0063] The specific method of rendering the smoothed tool trajectory through the shader program in the environment construction trajectory rendering unit 2 based on the developed rendering engine, further using Phong lighting and cubic spline curve algorithm, is as follows:
[0064] The original tool trajectory is smoothed and the original discrete tool trajectory point set is As input, the cubic spline algorithm is used for smoothing. , which is a piecewise cubic polynomial function, in each interval The above expression is ,in are the coefficients to be determined. To determine these coefficients, the following conditions need to be met:
[0065] The curve passes through each data point, that is ;
[0066] The curve has Continuity, that is and .
[0067] Solving the above conditions will form a linear equation system, which can be expressed in matrix form To indicate that It is composed of nodes and the matrix of endpoint conditions, is the inclusion coefficient The vector of Contains trajectory points Vector, solving this system of equations gives the cubic spline function The coefficient of .
[0068] Then for the cubic spline function Discretize it, Select within range Value, for the new vertex coordinates, calculate its normal vector. The original discrete tool trajectory may be in the shape of a broken line, which is not smooth enough. A smooth curve can be obtained through the cubic spline curve algorithm, which is more in line with the actual tool motion trajectory. The discretized new vertex coordinates and normal vectors provide a better data basis for subsequent lighting calculations, making the tool trajectory look more natural and smooth, avoiding sharp corners, and improving the quality of visualization.
[0069] In the shader program, the ambient light component is calculated using a formula based on the preset ambient light intensity and the ambient light reflectance coefficient of the material. The ambient light simulates the uniform lighting from all directions in the scene, providing basic brightness for objects and ensuring that objects are not completely dark when there is no other light. This provides basic lighting conditions for the scene, makes the rendering results more realistic, and avoids completely black areas on objects.
[0070] Calculate the diffuse light. According to the light source direction vector, the normal vector of the tool trajectory surface and the diffuse reflection coefficient of the material, use the formula to calculate the diffuse light component. The diffuse light simulates the reflection of light on a rough surface. Its intensity depends on the angle between the incident angle of the light and the surface normal vector, making the surface of the object present different brightness, simulating the change of lighting on the surface of the actual object. Different lighting effects can be displayed according to the surface orientation, making the tool trajectory three-dimensional and better reflecting its shape.
[0071] Calculate the specular light. According to the sight direction vector, the reflected light direction vector and the specular reflection coefficient of the material, use the formula to calculate the specular light component. Specular light simulates the reflection of light on a smooth surface, producing a highlight effect, making the object look more shiny, which conforms to the visual characteristics of materials such as metal cutting tools. You can add a highlight effect to the tool trajectory, making it look brighter and more metallic, improving the realism of the rendering.
[0072] The intensities of ambient light, diffuse light, and specular light are added together to obtain the final light intensity, and the final light intensity is applied to the output color of the shader program to obtain the final color. Comprehensive consideration of ambient light, diffuse light, and specular light can fully simulate the lighting effects in the real world and obtain more realistic lighting effects. Combining different types of lighting makes the rendered tool trajectory more consistent with the visual effects under actual lighting, thereby improving the quality and realism of the rendering.
[0073] The trajectory data that has been converted and smoothed and combined with lighting information, including vertex coordinates, normal vectors and final colors, is passed to the shader program. After receiving this information, the shader program calculates the final color based on the light intensity and applies it to the smoothed trajectory. The smoothed tool trajectory with lighting effects is rendered to the screen through the rendering pipeline of the graphics API. The rendering pipeline includes vertex processing, rasterization, and fragment processing stages, which convert vertex data into pixels on the screen and apply color information.
[0074] The rendering pipeline of the graphics API can efficiently convert the calculated data into images on the screen to achieve visualization. The advantage is that by using the powerful functions of the graphics API, the parallel computing capabilities of the GPU can be fully utilized to quickly render high-quality images, and the tool trajectory can be displayed on the screen in the form of a smooth curve with realistic lighting effects, making it convenient for users to observe the details and shape of the tool trajectory, thereby improving the visualization effect and user experience of the CNC comprehensive training system.
[0075] The program trajectory association interaction unit 3 uses the finite automaton theory to develop a CNC program parser, construct a program structure tree and associate program segments with trajectory segments, realize two-way highlighting of codes and trajectories, and trajectory modification and program update based on user operations.
[0076] The program trajectory association interaction unit 3 includes a program analysis module 31. The specific steps of developing a numerical control program analyzer using finite automaton theory in the program analysis module 31 are as follows:
[0077] According to the grammatical rules of CNC programs, the program parsing process is divided into the initial state , instruction read status , parameter parsing status and the end status of the program segment ,Each state represents a specific link in the parsing process. NC programs are composed of letters, numbers and ,symbols. These characters are taken as input character sets. These ,character sets cover the basic elements of NC programs and are the ,basic input of the parsing program.
[0078] According to the grammatical logic of the CNC program, the transfer conditions between states are determined. According to the grammatical logic of the CNC program, the state transfer conditions are determined, which enables the parser to perform correct state transfer according to the order and type of input characters, which conforms to the grammatical structure of the program. A state transfer table or a state transfer diagram can be used to represent the state transfer function. The state transfer table is a matrix, in which rows represent the current state, columns represent input characters, and elements in the table represent the state after the transfer. The state transfer table or state transfer diagram can intuitively represent the state transfer function, which is easy to understand and implement, and clearly shows the transfer relationship between states. It is easy to design and maintain the parsing logic, which is convenient for developers to implement the logic of the parser and helps to visually check the parsing process.
[0079] The NC program is parsed through the state transfer function to identify the program structure and start from the initial state. At the beginning, the CNC program is read character by character. According to the current state and the read characters, the next state is determined through the state transfer function. At the same time, the program content is processed according to the state. In the parameter parsing state, the currently read instruction is recorded. In the program, the read number is stored as the parameter of the instruction. In the process, the information of the current program segment is sorted, and the parsed program segment information is stored or processed.
[0080] The parsing process is driven by the state transfer function to ensure that the parsing of the program follows the grammatical structure of the CNC program. The state transfer mechanism of the finite automaton is used to accurately and efficiently parse the program to avoid complex logical judgments. The CNC program can be accurately decomposed into different program segments and instructions, and the corresponding parameters can be parsed to provide accurate program structure information for subsequent program structure analysis and the association between the program and the trajectory, providing an important program parsing foundation for the operation of the entire CNC comprehensive training system.
[0081] The program track association interaction unit 3 includes an association interaction module 32, in which a program structure tree is constructed and program segments and track segments are associated, and a method for realizing two-way highlighting of code and track and track modification and program update based on user operation is as follows:
[0082] The program segments identified by the program parser are used as nodes, and a tree structure is constructed according to the program logic relationship. By recording the starting point and end point indexes of the tool trajectory segment corresponding to the execution of the program segment, a mapping relationship between the two is established, and the program and trajectory are linked. The correspondence between program execution and tool trajectory is clarified, which facilitates quick search and association between the program and trajectory, provides a basis for two-way highlighting and modification operations, realizes the accurate correspondence between program segments and trajectory segments, and ensures that subsequent operations can accurately find the associated parts.
[0083] When the program executes to a certain program segment, the corresponding tool trajectory segment is located according to the mapping relationship and highlighted, allowing the user to intuitively see the corresponding tool trajectory when the program is executed, enhancing the user's understanding of the program execution process. When the user clicks on a certain tool trajectory segment, the corresponding program segment is reversely searched according to the stored mapping relationship, which is convenient for the user to understand the program from the trajectory perspective. When the user is interested in a certain trajectory, the corresponding program part can be quickly found. A two-way association display is provided, which enhances the user's understanding of the relationship between the program and the trajectory, allowing the user to understand the processing process from different angles.
[0084] When the user modifies the tool trajectory through the input device, the program parser is used to backtrack the associated program segments based on the trajectory modification information to maintain the consistency of the program and trajectory. The user's modification of the trajectory needs to be reflected in the program to ensure the correctness of the program control, enabling the user to flexibly modify the machining process and improving the interactivity and practicality of the system.
[0085] When the user modifies the CNC program in the program editing interface, the program is re-parsed and the tool trajectory is updated in real time based on the new program structure and instructions. This ensures that the tool trajectory can be updated in time after the program is modified, maintaining the consistency of the program and trajectory. This realizes instant updating of the tool trajectory after program modification, ensuring the synchronization and accuracy of the program and trajectory.
[0086] In the association interaction module 32, the user can control the viewing angle through the input device, and the specific operation of using the depth buffer and ray casting algorithm to display the track point information is as follows:
[0087] The user interacts with the rendering window through input devices to realize perspective control. When the mouse moves, the observation matrix is rotated and translated using functions based on the GLM math library according to the direction and distance of the mouse movement. The user needs to observe the tool trajectory from different angles and positions to better view the machining process and trajectory details. It provides a flexible perspective control method, enhances the user's observation ability of the three-dimensional scene, and allows the user to freely adjust the perspective to view different parts of the tool trajectory, thereby improving the user's visualization experience of the machining process.
[0088] The keyboard keys are used to control the perspective zoom. During the rendering process, the depth buffer mechanism is enabled, and the depth test is enabled through a function based on the GLM math library. The depth test is enabled using a function. During the rasterization stage of the rendering pipeline, the depth value of each pixel is recorded. When rendering a new pixel, the depth buffer compares the depth value of the new pixel with the stored depth value. If the depth value of the new pixel is smaller, the original pixel is overwritten.
[0089] In a three-dimensional scene, it is necessary to correctly display the occlusion relationship between the tool trajectory and other objects to avoid the wrong front-to-back display order, ensure that the rendered scene has the correct sense of spatial hierarchy, and make the rendering result more consistent with the actual three-dimensional spatial relationship.
[0090] When the user hovers the mouse over the tool trajectory, the ray casting algorithm is started, starting from the viewpoint position, a ray is emitted along the direction of the mouse, and then the ray cooperates with the geometric processing stage of the rendering pipeline to determine the intersection of the ray and the tool trajectory. If there is an intersection, the shader program is used to draw the coordinate value of the trajectory point near the intersection, and the coordinate information of the point is displayed in text form.
[0091] It provides users with more detailed information, making it easier for them to obtain specific coordinate values when observing the trajectory, helping them analyze and evaluate the machining process, enhancing their ability to obtain trajectory information, and improving the system's interactivity and information display capabilities. It allows users to easily obtain specific trajectory point coordinates when observing tool trajectories, helping them better understand the position of tool trajectories in three-dimensional space.
[0092] In the present invention, the tool, workpiece and machine tool system are modeled by the physical modeling trajectory calculation unit 1 using finite element analysis and multi-body dynamics, the motion equation is solved in combination with the numerical control program, the position of the tool in the workpiece system is determined during multi-axis linkage, and the accurate trajectory is obtained. The environment construction trajectory rendering unit 2 develops a rendering engine based on a modern graphics API, uses Phong lighting and cubic spline curve algorithms, and renders the smoothed tool trajectory through a shader program. The user can control the viewing angle and view the trajectory point information. The program trajectory association interaction unit 3 uses the finite automaton theory to develop a parser, constructs a program structure tree to associate program segments with trajectory segments, realizes two-way highlighting of code and trajectory, and trajectory modification and program update based on user operations, thereby improving the accuracy of numerical control training.
[0093] The above shows and describes the basic principles, main features and advantages of the present invention. Those skilled in the art should understand that the present invention is not limited by the above embodiments. The above embodiments and descriptions are only preferred examples of the present invention and are not intended to limit the present invention. Without departing from the spirit and scope of the present invention, the present invention may have various changes and improvements, which fall within the scope of the present invention. The scope of protection of the present invention is defined by the attached claims and their equivalents.
Claims
1. A CNC comprehensive training system, characterized in that: It includes a physical modeling trajectory calculation unit (1), an environment construction trajectory rendering unit (2), and a program trajectory association interaction unit (3); The physical modeling trajectory calculation unit (1) uses finite element analysis and multi-body dynamics to model a system including a tool, a workpiece and a machine tool. The physical modeling trajectory calculation unit (1) includes a physical modeling module (11). The physical modeling module (11) converts instructions into boundaries and loading conditions of a contact area between the tool and the workpiece according to a numerical control program, and uses an implicit time integration algorithm to solve the system motion equation to calculate the motion parameters of the tool. The method for using multi-body dynamics in the physical modeling module (11) to model a system including a tool, a workpiece and a machine tool is as follows: The tool, workpiece and moving parts of the machine tool are regarded as rigid bodies, and the inertia tensor is determined according to their geometric shape and mass distribution. For the spindle, the inertia tensor is calculated by measuring its diameter, length and mass and combining the formula for calculating the inertia tensor of a rotating body. For the workbench, the inertia tensor relative to the center of mass is calculated using the parallel axis theorem. By analyzing the actual kinematic chain of the machine tool, the types of kinematic pairs and constraints between the rigid bodies are determined, and the feed speed and spindle speed instructions given by the CNC program are converted into forces and torques on the corresponding rigid bodies; For spindle drive, the torque required is calculated based on the rotation speed and moment of inertia. For table feed drive, the driving force is determined according to the feed speed and table mass using Newton's second law, so that the model motion matches the NC program instructions. When multiple axes are linked, the position of the tool in the workpiece system is determined using homogeneous coordinate transformation and rotation matrix, and the continuous trajectory of the tool in three-dimensional space is obtained. The environment construction trajectory rendering unit (2) develops a rendering engine based on a modern graphics API, uses Phong lighting and a cubic spline curve algorithm, and renders the smoothed tool trajectory through a shader program. The user can control the viewing angle through an input device, and uses a depth buffer and a ray casting algorithm to display the trajectory point information. The environment construction trajectory rendering unit (2) is based on the developed rendering engine, further uses Phong lighting and a cubic spline curve algorithm, and renders the smoothed tool trajectory through a shader program. The specific method is as follows: The original tool trajectory is smoothed, the original discrete tool trajectory point set is used as input, the cubic spline curve algorithm is used for smoothing operation, the cubic spline function is obtained, and the cubic spline function is discretized and converted into a set of new vertex coordinates, and then the normal vector is calculated according to the new vertex coordinates; In the shader program, lighting is added to the rendered tool track, and the added lighting includes calculating ambient light, calculating diffuse light, and calculating specular light. The calculated ambient light is used to simulate uniform lighting from the surrounding environment in the scene, giving the tool track a basic brightness. The calculated diffuse light is used to simulate diffuse reflection of light on the surface of the tool track, generating lighting of different intensities according to different surface orientations. The calculated specular light is used to simulate the specular reflection effect of light on the surface of the tool track, generating highlights. The intensities of ambient light, diffuse light, and specular light are added together to obtain the final light intensity, which is applied to the output color of the shader program. The trajectory data that has been converted and smoothed and combined with the light information is passed to the shader program. After receiving this information, the shader program calculates the final color based on the light intensity and applies it to the smoothed trajectory. The smoothed tool trajectory with the light effect is rendered to the screen through the rendering pipeline of the graphics API. The program trajectory association interaction unit (3) uses finite automaton theory to develop a numerical control program parser, construct a program structure tree and associate program segments with trajectory segments, thereby realizing two-way highlighting of codes and trajectories, and trajectory modification and program update based on user operations.
2. A numerical control comprehensive training system according to claim 1, characterized in that: The physical modeling trajectory calculation unit (1) comprises a physical modeling module (11), wherein the specific steps of using finite element analysis in the physical modeling module (11) to model a system including a tool, a workpiece and a machine tool are as follows: Adaptive meshing technology is used to initially divide the model according to the complexity and material properties of the tool, workpiece and machine tool structure, and material parameters are assigned to different components through material database query; Based on the principle of virtual work, the tool cutting force and machine tool constraint force are equivalent to nodal forces. Combined with the determined material constitutive relationship, the overall stiffness matrix and load vector are constructed to form a linear equation group. The Gaussian elimination method is used to solve the equation group and obtain the displacement of each node as the initial condition for subsequent dynamic analysis.
3. A numerical control comprehensive training system according to claim 1, characterized in that: The physical modeling trajectory calculation unit (1) comprises a trajectory calculation module (12), wherein the trajectory calculation module (12) uses homogeneous coordinate transformation and rotation matrix to determine the position of the tool in the workpiece system when multiple axes are linked, and the specific operation flow of obtaining the continuous trajectory of the tool in three-dimensional space is as follows: Taking the fixed point of the machine bed as the origin, the machine coordinate system and the workpiece coordinate system are established according to the machine coordinate axis direction definition rules. Then the workpiece coordinate system is determined according to the clamping position of the workpiece on the machine tool, and the initial translation vector and rotation angle between the two are recorded. For each motion instruction in the multi-axis linkage process, the coordinates of the tool in the machine tool coordinate system are converted into coordinates in the workpiece coordinate system. At the same time as the coordinate transformation, a rotation matrix is constructed according to the rotation angles of each axis of the machine tool to describe the posture of the tool in the workpiece coordinate system. The tool position and posture information are combined to obtain the continuous trajectory of the tool in three-dimensional space.
4. The CNC comprehensive training system according to claim 1, characterized in that: The program trajectory association interaction unit (3) comprises a program analysis module (31). The specific steps of developing a numerical control program analyzer using finite automaton theory in the program analysis module (31) are as follows: According to the grammar rules of CNC programs, the program parsing process is divided into the initial state, instruction reading state, parameter parsing state and program segment end state. Each state represents a specific link in the parsing process. Among them, the CNC program is composed of letters, numbers and symbols. These characters are used as the input character set, and the transition conditions between states are determined according to the grammatical logic of the CNC program. The state transfer function is constructed based on this, and the CNC program is parsed through the state transfer function to identify the program structure.
5. A numerical control comprehensive training system according to claim 4, characterized in that: The program trajectory association interaction unit (3) comprises an association interaction module (32), in which a program structure tree is constructed and program segments and trajectory segments are associated, and a method for realizing two-way highlighting of code and trajectory and trajectory modification and program update based on user operation is as follows: The program segments identified by the program parser are used as nodes, and a tree structure is constructed according to the program logic relationship. The mapping relationship between the tool trajectory segment start point and end point index corresponding to the program segment execution is established by recording the tool trajectory segment start point and end point index corresponding to the program segment execution. When the program is executed to a certain program segment, the corresponding tool trajectory segment is located and highlighted according to the mapping relationship. Conversely, when the user clicks on a tool trajectory segment, the associated program segment can also be found and highlighted, realizing a two-way association between code and trajectory. When the user modifies the tool trajectory through the input device, the program parser backtracks the associated program segments according to the trajectory modification information and automatically updates the corresponding NC program parameters. Similarly, when the user modifies the NC program in the program editing interface, the program is re-parsed and the tool trajectory is updated in real time based on the new program structure and instructions.
6. A numerical control comprehensive training system according to claim 5, characterized in that: In the association interaction module (32), the user can control the viewing angle through the input device, and the specific operation of using the depth buffer and ray casting algorithm to display the track point information is as follows: The user interacts with the rendering window through input devices to realize the perspective control. When the mouse moves, the observation matrix is rotated and translated using the functions based on the GLM math library according to the direction and distance of the mouse movement, changing the perspective direction and position of the user's observation of the tool trajectory. The keyboard keys are used to control the perspective zoom. During the rendering process, the depth buffer mechanism is enabled, and the depth test is turned on through the function based on the GLM math library. In the rasterization stage, the rendering pipeline will display the occlusion relationship between the tool trajectory and other objects in the scene according to the depth value of each pixel, presenting a three-dimensional scene; When the user hovers the mouse over the tool trajectory, the ray casting algorithm is started. Starting from the viewpoint position, a ray is emitted along the direction of the mouse. By cooperating with the geometric processing stage of the rendering pipeline, the intersection of the ray and the tool trajectory is determined. If there is an intersection, the shader program is used to draw the coordinate value of the trajectory point near the intersection and present it in text form.
Citation Information
Patent Citations
OpenGL-based three-dimensional simulation method and system for multi-channel numerical control system
CN112462691A