Casting head cutting and grinding NC program generation method and system

By using pre-set NC code generation and visual workpiece pose recognition technology, the casting gating and grinding program is automatically generated, solving the problems of long processing time and unstable quality in complex casting processing, and realizing efficient and safe automated production.

CN121704352APending Publication Date: 2026-03-20Liupanshan Laboratory
View PDF 0 Cites 0 Cited by

Patent Information

Application Number
CN202511914030.8
Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
Filing Date
2025-12-18
Publication Date
2026-03-20

AI Technical Summary

Technical Problem

In the existing technology, the cutting and grinding of the gating and riser of complex castings relies on manual operation or semi-automatic equipment, which results in long processing preparation time, inability to adapt to the needs of multi-variety and small-batch production, unstable processing quality, and safety hazards and high labor costs.

Method used

By employing pre-set NC code generation, visual workpiece pose recognition, and online NC code correction technologies, the machine tool reference coordinate system is obtained, workpiece installation pose errors are identified, and the NC code is updated using a coordinate transformation matrix, thereby achieving automated generation of casting gating and grinding.

Benefits of technology

It shortens the processing preparation time, improves the automation level and overall efficiency of complex casting gating and grinding, ensures the stability and consistency of processing quality, and reduces safety risks and labor costs.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN121704352A_ABST
    Figure CN121704352A_ABST
Patent Text Reader

Abstract

The invention discloses a casting head cutting and grinding NC program generation method and system, and relates to the technical field of intelligent control, and the specific steps are as follows: obtaining a machine tool reference coordinate system, associating a feeding motion coordinate axis, a workpiece pose axis and a cutter pose axis with a set axis of a machine tool control system based on the machine tool reference coordinate system, and according to a casting three-dimensional mathematical model, generating a casting head cutting and grinding NC program; defining key parameters by taking a process step as a unit, and generating an initial preset NC code covering the whole process characteristics; based on the obtained point cloud data of the workpiece in the current working step, the installation pose error of the installed workpiece is recognized, and a coordinate transformation matrix T from a workpiece coordinate system to a machine tool reference coordinate system is solved; and converting the coordinate of the key reference point on the mounting workpiece to the reference coordinate system of the machine tool by using the coordinate transformation matrix T, and updating the initial preset NC code based on the converted coordinate of the key reference point. The machining preparation time is shortened, and the automation degree and the overall efficiency of cutting and grinding of the casting head of the complex casting are improved.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] This invention relates to the field of intelligent control technology, and more specifically to a method and system for generating NC programs for grinding and cutting gating risers in castings. Background Technology

[0002] Currently, the cutting and grinding of complex casting gatings and risers mainly relies on manual operation or semi-automated equipment, with operators relying on their experience. CNC machine tools, as key equipment for automated cutting, depend on precise NC code, which defines the tool's trajectory in the machine tool coordinate system. In actual production, due to the complex and diverse shapes of castings, varying gating and riser characteristics, and large dimensional deviations, coupled with casting process errors leading to differences between the actual shape of the blank and the digital model, and the lack of a consistent machining positioning datum, the actual position of the workpiece after clamping is difficult to precisely match the theoretical model. To generate usable machining programs, the current common method is to first position and clamp the workpiece, and then adjust and generate the NC code through on-site teaching combined with manual programming.

[0003] However, existing teaching and manual programming methods not only have excessively long preparation times, making them unsuitable for flexible production demands involving multiple varieties and small batches, but also suffer from unstable processing quality, poor product consistency, and even processing defects such as overcutting or undercutting due to the difficulty in accurately compensating for deviations between the actual workpiece mounting position and the theoretical model. Furthermore, the labor-intensive operation also brings safety hazards and high labor costs.

[0004] Therefore, how to quickly and automatically generate NC programs that can adapt to the actual installation position of the workpiece and accurately compensate for casting deviations is a problem that urgently needs to be solved by those skilled in the art. Summary of the Invention

[0005] In view of this, the present invention provides a method for generating NC programs for cutting and grinding the gating gates of castings, which overcomes the above-mentioned defects.

[0006] To achieve the above objectives, the present invention adopts the following technical solution: A method for generating an NC program for grinding and cutting gating risers in castings, comprising the following steps: Step 1: Obtain the machine tool reference coordinate system. Based on the machine tool reference coordinate system, associate the feed motion coordinate axis, workpiece posture axis, tool posture axis with the set axis of the machine tool control system. According to the three-dimensional digital model of the casting, define and associate key parameters including riser number, riser shape, riser size, machining process, process parameters, initial installation position of the workpiece, position of the workpiece in the current step and tool posture, and key reference points, based on the process step as a unit, and generate initial preset NC code covering all process features. Step 2: Based on the point cloud data of the current workpiece, identify the installation pose error of the current workpiece and solve the coordinate transformation matrix T from the coordinate system of the current workpiece to the reference coordinate system of the machine tool. Step 3: Using the coordinate transformation matrix T, transform the coordinates of the key reference points on the workpiece in the current step to the machine tool reference coordinate system, and update the initial preset NC code based on the transformed key reference point coordinates to generate the final NC code.

[0007] Optionally, step 1 specifically includes: Step 11: Associate the feed motion coordinate axis, the workpiece posture axis, and the tool posture axis with the set axes of the machine tool control system; Step 12: Using the process step as a unit, number each riser of the casting according to the three-dimensional digital model of the casting, assign the riser number to the corresponding riser, select the processing technology for each riser based on the riser size, and set the process step name based on the riser number and the processing technology. Step 13: Set process parameters, including cutting feed speed Fc, grinding feed speed Fg, and tool feed / retraction speed Fis; Step 14: Obtain the orientation of the workpiece in the current step, and calculate the rotation angle of the workpiece's pose axis based on the initial installation orientation of the workpiece. Step 15: Obtain the tool posture of the current step, and calculate the rotation angle of the tool posture axis based on the initial default tool posture; Step 16: Set the riser shape of each riser to the position of the key reference point required for the current step execution. The key reference point includes the start and end points of the linear feed, the start and end points of the circular interpolation, the center and radius of the circle. Step 17: Repeat steps 11 to 16 until the key parameter definitions for all work steps are completed; Step 18: Set the sequence of steps with the goal of minimizing the number of tool changes and workpiece pose changes; Step 19: Generate the initial preset NC code based on the predefined NC code snippet, the process sequence, and the key parameters.

[0008] Optionally, the specific steps for selecting the processing technology in step 12 are as follows: Determine whether the processing technology selected for each riser is cutting. If so, select the cutting mode based on the relationship between the riser size and the preset threshold.

[0009] Optionally, the predefined NC code snippets in step 19 include at least: program initialization code snippet, tool selection code snippet, workpiece indexing code snippet, spindle start code snippet, spindle stop code snippet, tool feed code snippet, machining feed code snippet, tool retraction code snippet, and program end code snippet.

[0010] Optionally, the application principle of the tool selection code snippet is as follows: The cutting tool code and the grinding tool code are constructed based on the spindle, A-axis angle and tool posture angle, respectively. Based on the differences in the machining processes of adjacent steps, the cutting tool code or the grinding tool code is selected to control the motion of the feed axis and the tool posture axis.

[0011] Optionally, the specific steps for tool switching are as follows: Move the current spindle to a safe tool change position; Execute the tool change command to switch the current spindle to the spindle corresponding to the tool required for the next step, and adjust the position and pose data of the spindle and tool after the change.

[0012] A casting gating and riser cutting NC program generation system includes: The preset NC code generation module is used to obtain the machine tool reference coordinate system. Based on the machine tool reference coordinate system, the feed motion coordinate axis, workpiece posture axis, tool posture axis and the set axis of the machine tool control system are associated. According to the three-dimensional digital model of the casting, the module defines and associates key parameters including riser number, riser shape, riser size, machining process, process parameters, initial installation position of workpiece, position of workpiece and tool posture of current step, and key reference points, based on the process step. The module generates initial preset NC code covering all process features. The installation pose recognition module is used to identify the installation pose error of the current workpiece based on the acquired point cloud data of the current workpiece, and to solve the coordinate transformation matrix T from the coordinate system of the current workpiece to the machine tool reference coordinate system. The preset NC code correction module is used to transform the coordinates of the key reference points on the workpiece in the current step to the machine tool reference coordinate system using the coordinate transformation matrix T, and update the initial preset NC code based on the transformed key reference point coordinates to generate the final NC code.

[0013] As can be seen from the above technical solution, compared with the prior art, the present invention discloses a method and system for generating NC programs for grinding and cutting gating of castings. By integrating preset NC code generation, visual workpiece pose recognition and online NC code correction technology, the automatic generation of NC programs for grinding and cutting gating of complex castings under specific machine tool configurations is realized, which shortens the processing preparation time and improves the automation level and overall efficiency of grinding and cutting gating of complex castings. Attached Figure Description

[0014] To more clearly illustrate the technical solutions in the embodiments of the present invention or the prior art, the drawings used in the description of the embodiments or the prior art will be briefly introduced below. Obviously, the drawings described below are only embodiments of the present invention. For those skilled in the art, other drawings can be obtained based on the provided drawings without creative effort.

[0015] Figure 1 This is a schematic diagram of the overall method provided by the present invention; Figure 2 A schematic diagram of the NC basic code generation method for a single process step provided by the present invention. Detailed Implementation

[0016] The technical solutions of the embodiments of the present invention will be clearly and completely described below with reference to the accompanying drawings. Obviously, the described embodiments are only some embodiments of the present invention, and not all embodiments. Based on the embodiments of the present invention, all other embodiments obtained by those skilled in the art without creative effort are within the scope of protection of the present invention.

[0017] This invention discloses a method for generating NC programs for cutting and grinding the gating system of castings, including preset NC code generation, vision-based workpiece mounting posture recognition, and preset NC code correction. The specific steps are as follows: Step 1: Obtain the machine tool reference coordinate system. Based on the machine tool reference coordinate system, associate the feed motion coordinate axis, workpiece posture axis, tool posture axis with the set axis of the machine tool control system. According to the three-dimensional digital model of the casting, define and associate key parameters including riser number, riser shape, riser size, machining process, process parameters, initial installation position of the workpiece, position of the workpiece in the current step and tool posture, and key reference points, based on the process step as the unit, and generate initial preset NC code covering all process features. Step 2: Based on the point cloud data of the current workpiece, identify the installation pose error of the current workpiece and solve the coordinate transformation matrix T from the coordinate system of the current workpiece to the reference coordinate system of the machine tool. Step 3: Using the coordinate transformation matrix T, transform the coordinates of the key reference points on the workpiece in the current step to the machine tool reference coordinate system, and update the initial preset NC code based on the transformed key reference point coordinates to generate the final NC code.

[0018] In one embodiment, step 1 specifically includes: Step 11: Associate the feed motion coordinate axis and the tool attitude axis with the set axes of the machine tool control system; Step 12: Using the process step as a unit, number each riser in the casting according to the three-dimensional digital model of the casting, assign the riser number to the corresponding riser, select the processing technology for each riser based on the riser size, and set the process step name based on the riser number and processing technology. Step 13: Set the process parameters, including cutting feed speed Fc, grinding feed speed Fg, and tool feed / retraction speed Fis; Step 14: Obtain the orientation of the workpiece in the current step, and calculate the rotation angle of the workpiece's pose axis C-axis (motion coordinate axis) based on the initial installation orientation of the workpiece; Step 15: Obtain the tool posture of the current step and calculate the tool posture axis rotation angle based on the initial default tool posture; Step 16: Based on the riser shape of each riser, set the positions of the key reference points required for the current step execution. The key reference points include the start and end points of the linear feed, the start and end points of the circular interpolation, and the center and radius of the circle. Step 17: Repeat steps 11 to 16 until the key parameter definitions for all work steps are completed; Step 18: Set the sequence of steps with the goal of minimizing the number of tool changes and workpiece pose changes; Step 19: Generate initial preset NC code based on predefined NC code snippets, the set work step sequence, and key parameters.

[0019] In one embodiment, step 11 specifically involves: when obtaining the machine tool reference coordinate system, the machine tool configuration is first selected. This embodiment targets two configurations: vertical cutting and grinding machine tool and gantry cutting and grinding machine tool. Based on the machine tool coordinate system setting, the coordinate axis of the cutting and grinding feed motion (i.e., the feed motion coordinate axis) and the attitude axis of the cutting tool (i.e., the tool attitude axis) are associated with the set axes in the machine tool control system.

[0020] In one embodiment, step 12 is the process step setting, specifically: for a certain type of casting, a riser serial number is generated based on a 3D digital model, and the riser serial number is associated with its dimensional parameters. The processing technology for the riser is selected as: cutting / grinding. There are two cutting modes for the cutting process: cutting mode 2 is selected when the minimum cross-sectional size of the riser is greater than or equal to a threshold, and cutting mode 1 is selected when it is less than the threshold. The angle of the integrated cutter head rotation axis A (tool switching axis) of the specified process is associated with the selection result. The process step name is set as: Process i: Riser k + Process.

[0021] In one embodiment, the workpiece orientation in step 15 is as follows: determine the workpiece orientation in the current step, and confirm the C-axis rotation angle based on the initial installation orientation of the workpiece.

[0022] In one embodiment, the setting of key reference points for the step execution in step 16 involves setting the positions of key reference points necessary for the execution of the step, including: the starting point S (xS, yS, zS) and ending point E (xE, yE, zE) for linear feed, and the starting point CS (xCS, yCS, zCS), ending point CE (xCE, yCE, zCE), center position CC (xCC, yCC, zCC), and radius Ri for circular interpolation.

[0023] In one embodiment, the step sequence setting in step 18 aims to minimize the combined number of tool switching times and workpiece pose switching times.

[0024] In one embodiment, the predefined NC code segments in step 19 are: based on the cutting and grinding process and machine tool configuration, design nine commonly used NC code segments for gating and grinding, including program initialization code segment, tool selection code segment, workpiece indexing code segment, spindle start code segment, spindle stop code segment, tool feed code segment, machining feed code segment, tool retraction code segment, and program end code segment, specifically: (1) Program initialization code snippet: G90# Absolute value programming; G00 Xx0 Yy0 Zz0 A0.00 B0.00 AA0.00 BB0.00 C0.00# Quick positioning, (x0, y0, z0) are the defined safe tool change positions. In the initial position, the tool, attitude, and rotary table are all in the default positions. (2) Tool selection code snippet: Based on the machining processes selected between two adjacent steps, if both are cutting or both are grinding, no tool change is needed. If the former is cutting and the latter is grinding, the tool will switch from cutting to grinding; if the former is grinding and the latter is cutting, the tool will switch from grinding to cutting. A specific code snippet is as follows: Cutting tool (spindle 1, A-axis angle θA is 90°, tool posture θAA): Xx0 Yy0 Zz0 AθA AAθAA BB0.00 C0.00#Safe tool change position, initial position; Switch to grinding tool (spindle 2, A-axis angle θA is 180°, tool posture θBB): Xx0 Yy0 Zz0 AθA AA0.00 BBθBB C0.00#Safe tool change position, initial position; Workpiece indexing code snippet Adjust the workpiece to the position required for the current machining step. θC is related to the initial position of the current machining step.

[0025] G01 Xx0 Yy0 Zz0 AθA AAθAA BB0.00 CθC# Safe tool change position, workpiece indexing; (4) Spindle startup code snippet Spindle 1 Startup: M31# Spindle 1 rotates forward; M103# spindle speed 1 reached; M122# Spindle 1 spray is turned on; M51# Spindle 1 cooling is on; Spindle 2 Start: M06# Spindle 2 rotates forward; M120# spindle 2 spray is on; M53# Spindle 2 cooling is on; M107# Spindle 2 speed arrival detection; (5) Spindle stop code snippet Spindle 1 stopped: M33# Spindle 1 Stop; M106# Spindle 1 Zero Speed ​​Detection; M52# Spindle 1 cooling shut off; M121# Spindle 1 spray shut off; Spindle 2 Stop: M08# Spindle 2 Stop; M102# Spindle 2 Zero Speed ​​Detection; M54# Spindle 2 cooling off; M123# Spindle 2 spray shut off; Cut-in code snippet Feed from the safe tool change position to the feed position of this step at the set feed rate: F Fis; G01 Xx1 Yy1 Zz1 AθA AAθAA BB0.00 CθC# (x1, y1, z1) is the tool entry position; Machining feed code snippet Linear interpolation feed: F Fc / Fg# Grinding feed rate; G01 XxS YyS ZzS AθA AAθAA BB0.00 CθC# (xS, yS, zS) are the coordinates of the starting key reference point for this step; G01 XxE YyE ZzE AθA AAθAA BB0.00 CθC# (xE, yE, zE) are the coordinates of the critical reference point at the end of this step.

[0026] Circular interpolation feed: F Fc / Fg# Grinding feed rate; Circular interpolation identification clockwise / counterclockwise judgment: G01 XxCS Y yCS ZzCS AθA AAθAA BB0.00 CθC# (xCS, yCS, zCS) is the starting point of arc 1; G02 / G03 XxCE YyCE ZzCE RR1# (xCE, yCE, zCE) is the endpoint of arc 1, and R1 is the radius of arc 1.

[0027] Retracting the knife code snippet F Fis; G01 Xx4 Yy4 Zz4 AθA AAθAA BB0.00 CθC# (x4, y4, z4) Tool and workpiece separation coordinates; G00 Xx0 Yy0 Zz0 AθA AAθAA BB0.00 CθC# The tool separation point is quickly positioned to a safe tool change position.

[0028] (9) Code snippet for program termination Xx0 Yy0 Zz0 A0.00 B0.00 AA0.00 BB0.00 C0.00; M02# Program ended.

[0029] In one embodiment, the preset NC code generation process is as follows: Figure 2 As shown, key parameters such as step number, operation, riser number, workpiece pose, tool pose, and critical reference points are extracted from the defined steps. NC code for each step is generated sequentially from beginning to end according to the set step number, with program initialization and termination code snippets added at the beginning and end. The specific implementation process for generating the basic NC code for a single step is as follows: (1) Add a program initialization code snippet; (2) Read the process name of the process step, determine whether it is cutting or grinding, and select the tool; (3) Determine whether the current step is the same as the previous step. If they are the same, proceed directly to (5); if they are different, proceed to (4). (4) Add a spindle stop code snippet to stop the tool spindle of the previous step, perform zero speed detection, turn off spindle cooling, and turn off spindle bearing cooling and lubrication spray; (5) Add a tool selection code snippet to position the tool in the machining position; (6) Add a spindle start code snippet to start the tool spindle and perform speed detection, start spindle cooling, and start spindle bearing cooling and lubrication spray; (7) Add a rotation code snippet to adjust the riser to be cut and ground to the machining position using the rotary table; (8) Add a feed code snippet to feed from the safe tool change position to the starting position of the grinding step; (9) Based on the key parameters of the process step, determine whether the feed method of the process step is linear feed or circular feed; (10) Add a feed code snippet to complete the processing of this step; (11) Add a tool retraction code snippet to return the tool to the safe tool change position; (12) Read the sequence number of the next step and determine whether the step number is greater than the maximum value of the step number. If not, repeat (2) to (11). If it is greater than the maximum value of the step number, then proceed to (13). (13) Add a spindle stop code snippet; (14) Add the program end code snippet.

[0030] In one embodiment, a method for identifying the pose error of complex casting installation based on scanned point cloud data is used to solve the coordinate transformation matrix T from the workpiece coordinate system to the machine tool reference coordinate system in the current step. The specific steps are as follows: Step 21: Set up a standard block on the worktable and mark its pose relative to the machine tool reference coordinate system; Step 22: Mount the casting to be cut and ground on the worktable; Step 23: Use a 3D laser scanning camera to simultaneously scan the casting to be cut and ground and the standard block to obtain point cloud data containing the casting to be cut and ground and the standard block; Step 24: In the point cloud data processing software, select no fewer than three non-coplanar points from the workpiece in the current step, denoted as vector P; Step 25: In the point cloud data processing software, obtain the coordinate values ​​Pw of the data point P in the workpiece coordinate system of the current step, and the coordinate values ​​Pc of the data point in the standard block coordinate system.

[0031] Step 26: Based on the above two sets of coordinates, use the SVD method to solve for the rotation matrix and translation vector of the workpiece coordinate system in the current step relative to the standard block coordinate system; Step 27: Based on the rotation matrix transformation formula, calculate the rotation angle of each axis of the current workpiece coordinate system relative to the standard block coordinate system, and then obtain the coordinate transformation matrix T of the current workpiece coordinate system relative to the machine tool reference coordinate system.

[0032] In one embodiment, the coordinates of the key reference points are transformed from the workpiece coordinate system of the current step to the machine tool reference coordinate system, and the transformed coordinate point values ​​are assigned to the corresponding key reference point variables in the preset NC code. Specifically: Step 31: In the collected point cloud data, obtain the coordinate value KW of the defined key reference point in the workpiece coordinate system of the current step; Step 32: Calculate the coordinate values ​​KR of the key reference point in the machine tool reference coordinate system. The calculation process is as follows: KR = T·KW.

[0033] This embodiment also discloses a casting gating and riser cutting NC program generation system, including: The preset NC code generation module is used to obtain the machine tool reference coordinate system. Based on the machine tool reference coordinate system, the feed motion coordinate axis, the tool posture axis and the set axis of the machine tool control system are associated. According to the three-dimensional digital model of the casting, the module defines and associates key parameters including riser number, riser shape, riser size, machining process, process parameters, initial installation position of the workpiece, position of the workpiece and tool posture in the current step, and key reference points, based on the process step, to generate initial preset NC code covering all process features. The installation pose recognition module is used to identify the installation pose error of the current workpiece based on the acquired point cloud data of the current workpiece, and to solve the coordinate transformation matrix T from the coordinate system of the current workpiece to the machine tool reference coordinate system. The preset NC code correction module is used to transform the coordinates of key reference points on the workpiece in the current step to the machine tool reference coordinate system using the coordinate transformation matrix T, and update the initial preset NC code based on the transformed key reference point coordinates to generate the final NC code.

[0034] The various embodiments in this specification are described in a progressive manner, with each embodiment focusing on its differences from other embodiments. Similar or identical parts between embodiments can be referred to interchangeably. For the apparatus disclosed in the embodiments, since they correspond to the methods disclosed in the embodiments, the description is relatively simple; relevant parts can be referred to the method section.

[0035] The above description of the disclosed embodiments enables those skilled in the art to make or use the invention. Various modifications to these embodiments will be readily apparent to those skilled in the art, and the general principles defined herein may be implemented in other embodiments without departing from the spirit or scope of the invention. Therefore, the invention is not to be limited to the embodiments shown herein, but is to be accorded the widest scope consistent with the principles and novel features disclosed herein.

Claims

1. A method for generating an NC program for grinding and cutting gating risers in castings, characterized in that, The specific steps are as follows: Step 1: Obtain the machine tool reference coordinate system. Based on the machine tool reference coordinate system, associate the feed motion coordinate axis, workpiece posture axis, tool posture axis with the set axis of the machine tool control system. According to the three-dimensional digital model of the casting, define and associate key parameters including riser number, riser shape, riser size, machining process, process parameters, initial installation position of the workpiece, position of the workpiece in the current step and tool posture, and key reference points, based on the process step as a unit, and generate initial preset NC code covering all process features. Step 2: Based on the point cloud data of the current workpiece, identify the installation pose error of the current workpiece and solve the coordinate transformation matrix T from the coordinate system of the current workpiece to the reference coordinate system of the machine tool. Step 3: Using the coordinate transformation matrix T, transform the coordinates of the key reference points on the workpiece in the current step to the machine tool reference coordinate system, and update the initial preset NC code based on the transformed key reference point coordinates to generate the final NC code.

2. The method for generating an NC program for grinding and cutting the gating system of a casting according to claim 1, characterized in that, Step 1 is as follows: Step 11: Associate the feed motion coordinate axis, the workpiece posture axis, and the tool posture axis with the set axes of the machine tool control system; Step 12: Using the process step as a unit, number each riser of the casting according to the three-dimensional digital model of the casting, assign the riser number to the corresponding riser, select the processing technology for each riser based on the riser size, and set the process step name based on the riser number and the processing technology. Step 13: Set process parameters, including cutting feed speed Fc, grinding feed speed Fg, and tool feed / retraction speed Fis; Step 14: Obtain the orientation of the workpiece in the current step, and calculate the rotation angle of the workpiece's pose axis based on the initial installation orientation of the workpiece. Step 15: Obtain the tool posture of the current step, and calculate the rotation angle of the tool posture axis based on the initial default tool posture; Step 16: Based on the riser shape of each riser, set the position of the key reference point required for the current step execution. The key reference point includes the start and end points of the linear feed, the start and end points of the circular interpolation, the center and radius of the circle. Step 17: Repeat steps 11 to 16 until the key parameter definitions for all work steps are completed; Step 18: Set the sequence of steps with the goal of minimizing the number of tool changes and workpiece pose changes; Step 19: Generate the initial preset NC code based on the predefined NC code snippet, the process sequence, and the key parameters.

3. The method for generating an NC program for grinding and cutting the gating system of a casting according to claim 2, characterized in that, The specific steps for selecting the processing technology mentioned in step 12 are as follows: Determine whether the processing technology selected for each riser is cutting. If so, select the cutting mode based on the relationship between the riser size and the preset threshold.

4. The method for generating an NC program for grinding and cutting the gating system of a casting according to claim 2, characterized in that, The predefined NC code snippets mentioned in step 19 include at least the following: program initialization code snippet, tool selection code snippet, workpiece indexing code snippet, spindle start code snippet, spindle stop code snippet, tool feed code snippet, machining feed code snippet, tool retraction code snippet, and program end code snippet.

5. The method for generating an NC program for grinding and cutting the gating system of a casting according to claim 4, characterized in that, The principle behind the tool selection code snippet is as follows: The cutting tool code and the grinding tool code are constructed based on the spindle, A-axis angle and tool posture angle, respectively. Based on the differences in the machining processes of adjacent steps, the cutting tool code or the grinding tool code is selected to control the motion of the feed axis and the tool posture axis.

6. The method for generating an NC program for grinding and cutting the gating system of a casting according to claim 5, characterized in that, The specific steps for tool switching are as follows: Move the current spindle to a safe tool change position; Execute the tool change command to switch the current spindle to the spindle corresponding to the tool required for the next step, and adjust the position and pose data of the spindle and tool after the change.

7. A casting gating and grinding NC program generation system, characterized in that, include: The preset NC code generation module is used to obtain the machine tool reference coordinate system. Based on the machine tool reference coordinate system, the feed motion coordinate axis, workpiece posture axis, tool posture axis and the set axis of the machine tool control system are associated. According to the three-dimensional digital model of the casting, the module defines and associates key parameters including riser number, riser shape, riser size, machining process, process parameters, initial installation position of workpiece, position of workpiece and tool posture of current step, and key reference points, based on the process step. The module generates initial preset NC code covering all process features. The installation pose recognition module is used to identify the installation pose error of the current workpiece based on the acquired point cloud data of the current workpiece, and to solve the coordinate transformation matrix T from the coordinate system of the current workpiece to the machine tool reference coordinate system. The preset NC code correction module is used to transform the coordinates of the key reference points on the workpiece in the current step to the machine tool reference coordinate system using the coordinate transformation matrix T, and update the initial preset NC code based on the transformed key reference point coordinates to generate the final NC code.