A post-processing method and system for a right-angle milling head of a numerical control machine tool
Patent Information
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- HEFEI UNIV OF TECH
- Filing Date
- 2026-05-11
- Publication Date
- 2026-08-04
AI Technical Summary
[0004]为解决现有的数控机床后处理方法存在通用性差、效率低的技术问题,本发明提供一种用于数控机床直角铣削头的后处理方法及系统
1、该用于数控机床直角铣削头的后处理方法,其通过对旋转角度进行自动归一化、映射与约束校验,并利用模态指令状态机对G代码指令进行分类管理和冗余消除,同时自动识别钻孔循环特征并自适应计算循环参数,解决了现有的数控机床后处理器存在通用性差、效率低的技术问题,得到了自动生成坐标系指令以提高编程效率、自动校验角度以提高加工安全性、减少冗余代码以提高程序执行效率、以及自动处理特殊加工特征以提高通用性且减少人工干预的技术效果。
Smart Images

Figure CN122507014A_ABST
Abstract
Description
Technical Field
[0001] This invention relates to a post-processing method in the field of CNC machine tools, and more particularly to a post-processing method for a right-angle milling head of a CNC machine tool, and also to a post-processing system for a right-angle milling head of a CNC machine tool. Background Technology
[0002] In the field of CNC machining, three-axis vertical machining centers are widely used due to their simple structure and low cost. However, the spindle direction of this type of equipment is usually fixed in the vertical direction, which leads to problems such as tool interference, insufficient machining rigidity, and difficulty in guaranteeing accuracy when performing side machining or deep cavity machining. To solve these problems, right-angle milling heads are widely used as accessories in engineering to convert the vertical output of the spindle to horizontal output, thereby expanding machining capabilities without changing the machine tool structure. However, when using a right-angle milling head, the workpiece coordinate system must be offset and rotated accordingly to ensure that the tool path is consistent with the actual machining direction.
[0003] In existing technologies, it is usually necessary to manually add additional coordinate system instructions and coordinate rotation instructions to the CNC system and manually calculate the offset, which is complex and error-prone. In addition, existing post-processors have poor versatility, are usually tied to specific CAM systems, have high costs, and lack constraint verification of rotation angles, which can easily generate illegal instructions and cause machine tool errors. At the same time, the generated CNC programs contain a large number of redundant modal instructions, which reduces the program execution efficiency. For special machining features such as countersunk holes, there is also a lack of automatic processing capabilities, requiring manual intervention. Summary of the Invention
[0004] To address the technical problems of poor versatility and low efficiency in existing CNC machine tool post-processing methods, this invention provides a post-processing method and system for right-angle milling heads on CNC machine tools.
[0005] This invention is achieved using the following technical solution: a post-processing method for a right-angle milling head on a CNC machine tool, comprising the following steps: S1: Analyze the tool position data to obtain coordinate system offset, rotation angle, tool parameters and machining path segment data; S2: First, normalize the rotation angle and map it to a preset standard angle range. Then, perform constraint condition verification on the mapped rotation angle. If the verification fails, terminate the processing flow. S3: Based on the coordinate system offset and the verified rotation angle, automatically generate coordinate system G-code instructions for translation and rotation; S4: Traverse the processing path segment data and convert each path segment into corresponding motion control G-code instructions according to the path type; S5: Identify the drilling cycle type in the machining path, and automatically match or calculate the cycle parameters according to the feature type to generate the corresponding fixed cycle G-code instructions; S6: Using a preset state machine mechanism, all G-code instructions are classified by function and their modal states are tracked. The corresponding instructions are output to the final CNC program only when the modal state of the instruction changes.
[0006] This invention solves the technical problems of poor versatility and low efficiency of existing CNC machine tool post-processors by automatically normalizing, mapping, and verifying rotation angles, and by using a modal instruction state machine to classify, manage, and eliminate redundancy in G-code instructions. It also automatically identifies drilling cycle characteristics and adaptively calculates cycle parameters. The invention achieves the technical effects of automatically generating coordinate system instructions to improve programming efficiency, automatically verifying angles to improve machining safety, reducing redundant code to improve program execution efficiency, and automatically handling special machining features to improve versatility and reduce manual intervention.
[0007] As a further improvement to the above scheme, in step S2, the constraint verification includes the following steps: Verify whether the B-axis rotation angle is an integer multiple of a preset discrete precision, and verify whether the A-axis rotation angle is within a preset safety range; wherein, the B-axis is used to control the spindle azimuth angle of the right-angle milling head, and the A-axis is used to control the tool tilt angle of the right-angle milling head.
[0008] As a further improvement to the above scheme, in step S5, when the countersunk hole feature is identified and the machining depth parameter is missing in the tool position data, the machining depth is automatically calculated using geometric relationships based on the top diameter, bottom diameter and countersunk angle of the countersunk hole.
[0009] Furthermore, the formula for calculating the processing depth is: In the formula, For the depth of burrowing, The diameter of the conical inlet is... The diameter at the beginning of the cone surface. The vertex angle of the cone.
[0010] As a further improvement to the above scheme, in step S6, all G-code instructions are classified into at least the following categories: Motion command type, plane selection type, coordinate mode type, tool compensation type, feed mode type, and fixed cycle type; Each category has a corresponding current state variable, and the initial state is undefined. The state machine only outputs the instruction and updates the state when the parsed instruction is different from the current state of the corresponding category.
[0011] Furthermore, the fixed loop instruction adopts a block-level modal management mechanism, specifically as follows: Upon first encountering a fixed loop instruction, the fixed loop instruction is output and the current loop state is recorded; Before encountering a fixed loop cancellation command or switching to other types of loops, only the coordinate values of subsequent holes are output; When the fixed loop cancellation instruction is encountered, the corresponding instruction is forcibly output and the current loop state is reset to undefined.
[0012] As a further improvement to the above scheme, in step S4, when the processing path segment is an arc, the rotation direction of the arc is automatically determined by calculating the dot product of the starting vector and the ending vector of the corresponding arc path, and a corresponding clockwise or counterclockwise arc interpolation command is generated.
[0013] As a further improvement to the above scheme, in step S2, the rotation angle is normalized to the range of [-180°, 180°], and then, according to the interval to which the normalized angle value belongs, the normalized angle value is converted to the [0°, 360°] angle interval that the target system can recognize through a predefined mapping rule.
[0014] As a further improvement to the above solution, the post-processing method further includes the following steps: S7: Before outputting the final CNC program, perform formatting optimization on the instructions to be output: omit coordinate axis words that have not changed, merge continuous motion instructions with the same parameters, and control the feed rate and spindle speed instructions to be output only when the values change.
[0015] The present invention also provides a post-processing system for a right-angle milling head of a CNC machine tool, which applies any of the post-processing methods for a right-angle milling head of a CNC machine tool described above, the system comprising: The data parsing module is used to parse tool position data and obtain coordinate system offset, rotation angle, tool parameters and machining path segment data; The verification module is used to first normalize the rotation angle and map it to a preset standard angle range, and then verify the constraint conditions of the mapped rotation angle. If the verification fails, the processing flow is terminated. The coordinate system instruction generation module is used to automatically generate coordinate system G-code instructions for translation and rotation based on the coordinate system offset and the verified rotation angle. The motion control instruction generation module is used to traverse the processing path segment data and convert each path segment into corresponding motion control G-code instructions according to the path type. The fixed cycle generation module is used to identify the drilling cycle type in the machining path, and automatically match or calculate the cycle parameters according to the feature type to generate the corresponding fixed cycle G-code instructions. The instruction processing module is used to classify all G-code instructions by function and track their modal states using a preset state machine mechanism, and outputs the corresponding instruction to the final CNC program only when the modal state of the instruction changes.
[0016] Compared with existing CNC machine tool post-processing methods, the post-processing method and system of the present invention for right-angle milling heads of CNC machine tools have the following advantages: 1. This post-processing method for right-angle milling heads on CNC machine tools automatically normalizes, maps, and verifies the rotation angle, and uses a modal instruction state machine to classify, manage, and eliminate redundancy in G-code instructions. Simultaneously, it automatically identifies drilling cycle characteristics and adaptively calculates cycle parameters. This solves the technical problems of poor versatility and low efficiency in existing CNC machine tool post-processors, achieving the technical effects of automatically generating coordinate system instructions to improve programming efficiency, automatically verifying angles to improve machining safety, reducing redundant code to improve program execution efficiency, and automatically processing special machining features to improve versatility and reduce manual intervention.
[0017] 2. This post-processing method for right-angle milling heads on CNC machine tools automatically determines the rotation direction of the arc by calculating the dot product of the starting and ending vectors of the arc path. It eliminates the need for manual judgment or additional input of arc direction parameters, thereby improving the accuracy and automation of arc machining path conversion.
[0018] 3. The post-processing method for right-angle milling heads of CNC machine tools adopts a block-level modal management mechanism for fixed cycle instructions. During continuous hole machining, it automatically omits repeated fixed cycle instruction codes, outputs coordinate values only when the hole coordinates change, and automatically outputs a fixed cycle cancellation instruction at the end of the cycle. This further reduces program redundancy and improves the program execution efficiency of continuous hole machining.
[0019] 4. The post-processing method for right-angle milling heads of CNC machine tools can perform formatting optimization on instructions before outputting the CNC program. This includes omitting coordinate axis words that have not changed, merging continuous motion instructions with the same parameters, and outputting feed rate and spindle speed control instructions only when the values change. This effectively compresses the program size, reduces the communication load of the machine tool control system, and improves the readability and maintainability of the program.
[0020] 5. The post-processing system for right-angle milling heads of CNC machine tools has the same beneficial effects as the post-processing methods described above, and will not be elaborated further here. Attached Figure Description
[0021] Figure 1 This is a flowchart of a post-processing method for a right-angle milling head on a CNC machine tool according to Embodiment 1 of the present invention.
[0022] Figure 2 This is a cross-sectional view of the countersunk hole geometry in Embodiment 1 of the present invention.
[0023] Figure 3 This is a top view of the countersunk hole geometry in Embodiment 1 of the present invention. Detailed Implementation
[0024] To make the objectives, technical solutions, and advantages of this invention clearer, the invention will be further described in detail below with reference to the accompanying drawings and embodiments. It should be understood that the specific embodiments described herein are merely illustrative and not intended to limit the invention.
[0025] Example 1 Please see Figure 1 , Figure 2 as well as Figure 3 This embodiment provides a post-processing method for a right-angle milling head on a CNC machine tool. This post-processing method is a method that can automatically convert tool position data generated by a computer-aided manufacturing (CAM) system into a CNC program suitable for machining a right-angle milling head. The post-processing method includes the following steps S1-S6, and in some embodiments, step S7 may also be included.
[0026] S1: Parse the toolpath data to obtain coordinate system offset, rotation angle, tool parameters, and machining path segment data. In this embodiment, the toolpath data can be received by a parsing module, and the following parameters can be obtained through parsing: (1) Coordinate system parameters (used in steps S2, S3 and S4) offset_X, offset_Y, offset_Z (coordinate offsets), angle_A, angle_B (rotation angles), fixture_bias (fixture bias number). Purpose: Step S2: Angle normalization and mapping (using angle_B) Step S3: Angle constraint verification (using angle_A, angle_B) Step S4: Generate G117 / G118 (using offset_X / Y / Z, angle_A / B, fixture_bias) (2) Tool parameters Examples include tool_id (tool number), tool_length_offset (tool length compensation number H), tool_radius (tool radius), spindle_speed (spindle speed S), feed_rate (feed rate F), and coolant_flag (coolant status). parameter For steps Specific role tool_id S7 (Optimized Output: Tool Switch) Generate TxxM6 tool_length_offset S7 Generate G43Hxx spindle_speed S4 / 7 Output S value feed_rate S4 / 5 Controlling feed rate coolant_flag S7 Control M8 / M9 tool_radius (Optional extension) Can be used for G41 / G42 tool replacement
[0027] (3) Path segment parameters (used in steps S5, S6, and S7) point_start(X,Y,Z), point_end(X,Y,Z), center(cx,cy,cz), normal_vec(nx,ny,nz), tool_axis(ax,ay,az), path_type(LINE / ARC / HELIX / DRILL). parameter For point_start / end Straight line, fast movement center Circular interpolation normal_vec+tool_axis Determining the direction of the arc path_type Path classification
[0028] (4) Drilling cycle parameters cycle_type, top_z, feed_to, retract_plane, step_depth, dwell_time, csink_diameter, top_diameter, included_angle. parameter For cycle_type Match G81 / G82 / G83 feed_to Direct Z-Depth csink_* Automatic depth calculation dwell_time P parameters step_depth Q parameter
[0029] (5) Path segment data (straight lines, arcs, boreholes, etc.).
[0030] S2: First, normalize the rotation angle and map it to a preset standard angle range. Then, perform constraint verification on the mapped rotation angle. If the verification fails, the processing flow terminates. Specifically, the rotation angle can be normalized to the range of [-180°, 180°]. Then, based on the range to which the normalized angle value belongs, the normalized angle value is converted to the [0°, 360°] angle range recognizable by the target system using predefined mapping rules. A specific example of this step is given below.
[0031] (1) Angle normalization processing Let the input angle be b_original, which can be any angle value. First, normalize it to the range [-180°, 180°]. Specifically, take the modulo 360 of the original angle to map it to the interval [0, 360). For example: 400° → 40°, -50° → 310°. For angles greater than 180°, subtract 360° to convert them to negative angles. For example: 270° → -90°, 190° → -170°. For angles less than or equal to -180°, add 360° to pull them back to the (-180, 180) interval. For example: -180° → 180°, -200° → 160°. Finally, the result of b_norm will be limited to the (-180, 180) interval.
[0032] (2) Interval mapping rules The normalized angle b_norm is mapped to the target system angle new_b according to the following rules: when the angle is in the range (-180°, 90°), 270° is added to the angle. When the angle is in the range [90°, 180°], 90° is subtracted from the angle. Finally, the angle is restricted to the range [0, 360°].
[0033] (3) Explanation of the mapping principle The purpose of the above mapping is to convert rotation angles in different directions into equivalent attitude angles that the CNC system can recognize. Essentially, it involves performing an equivalent transformation of the spatial attitude to ensure consistent tool orientation while simultaneously meeting the system's angle expression specifications.
[0034] (4) Mapping example Example 1: Input: b_original=-90° Normalization: b_norm = -90° Interval: -180 < -90 < 90 → Satisfies the first condition Mapping: new_b = -90 + 270 = 180° Output: B180 Example 2: Input: b_original=90° Normalization: b_norm=90° Interval: 90 ≤ b_norm ≤ 180 → Second condition Mapping: new_b=90-90=0° Output: B0 Example 3: Input: b_original=180° Mapping: new_b = 180 - 90 = 90° Output: B90 Example 4 (360° span): Input: b_original=270° Normalization: b_norm = -90° Mapping: new_b=180° Output: B180 (5) Angle legality verification (related to Example 3) After mapping is complete, apply constraints to new_b: Calculate the remainder when new_b is divided by 5.
[0035] Whether it is not 0, that is, whether new_b is divisible by 5.
[0036] If the condition is true (new_b is not a multiple of 5), then the error logic will be executed.
[0037] (6) Alternative implementation methods In other implementations: the interval division rules can be adjusted according to different CNC systems; a lookup table method can be used to replace interval calculation; different angular accuracies (such as 1° or 10° step size) can be supported.
[0038] Finally, the modulo operation is used to convert it to [0°, 360°].
[0039] In this embodiment, the constraint verification includes the following steps: verifying whether the B-axis rotation angle is an integer multiple of a preset discrete precision, and verifying whether the A-axis rotation angle is within a preset safety range. Here, the B-axis is used to control the spindle azimuth angle of the right-angle milling head, and the A-axis is used to control the tool tilt angle of the right-angle milling head.
[0040] A-axis validity check: Only integer angles are allowed to ensure machine tool execution safety.
[0041] (1) Determine if the A-axis angle is within the allowable range: Determine if the A-axis angle is less than 0° or greater than 90°; if the condition is met, throw an error, stop the program and prompt "angle out of range"; (2) Determine if it is an integer: Round the angle using round(angle_A), and then calculate the difference between the original angle and the rounded result using abs(angle_A - round(angle_A)). If the difference is greater than the set tolerance (usually set to a very small value such as 0.001), it means that the angle is not an integer. At this time, an error is thrown, prompting "A-axis angle is not an integer", and the program execution stops.
[0042] The B-axis angle must meet the preset discrete precision: In this embodiment, after completing the rotation angle mapping, the discrete precision constraint verification of the B-axis angle is performed to ensure that the generated CNC instructions meet the control requirements of the target CNC system. B-axis validity judgment: round(quotient_B) rounds the quotient to the nearest integer. If the difference exceeds the tolerance, it means that it is not an integer multiple of the step size → illegal.
[0043] (1) Definition of Discrete Precision Let the mapped B-axis angle be: new_b Let the preset discrete precision be: step_angle Preferably: step_angle = 5° (2) Verification rules The B-axis angle must meet the following condition: the angle must be an integer multiple of the step angle.
[0044] That is, the B-axis angle must be an integer multiple of 5°.
[0045] (3) Verify the implementation method Considering floating-point errors, the following judgment method is preferred: First, calculate the ratio of the angle to the step angle, and take the nearest integer of this ratio. Then, calculate the absolute value of the difference between the actual ratio and the integer. Finally, determine whether the difference is greater than a very small allowable error value. If it is, it means that the angle is not an integer multiple of the step angle and is judged as illegal.
[0046] (4) Handling mechanism for verification failure When an illegal angle is detected, the following actions are performed: output an error message; terminate the post-processing flow; prevent the generation of G-code; (5) Specific examples Example 1 (Valid Angle): Input: new_b=90° Calculate: 90 ÷ 5 = 18 (integer) Judgment: Legal Output: B90 Example 2 (illegal angle): Input: new_b=37° Calculate: 37 ÷ 5 = 7.4 (not an integer) Judgment: Illegal Output error: B-axis angle does not meet the 5° discrepancy requirement, program terminates. Example 3 (Boundary Case): Input: new_b=360° Solution: 360%360 = 0° Calculate: 0 ÷ 5 = 0 (integer) Judgment: Legal Output: B0 Example 4 (Floating-point error case): Input: new_b=89.999999° Calculate: 89.999999 ÷ 5 ≈ 17.9999998 Tolerance judgment: ≈18 Judgment: Legal Output: B90 (or rounded) In other implementations: the discrete precision can be set to 1°, 2°, 10°, etc.; the angle can be verified by looking up a table; it can be automatically corrected to the nearest valid angle (e.g., 37°→35° or 40°). General example description: Example 1: Legal Angle B-axis (180): 180 / 5 = 36 → Integer → Valid A-axis (30): 30∈[0,90] and is an integer → valid Output: Normal output Example 2: Illegal angle on the B-axis B-axis (37): 37 / 5 = 7.4 → Not an integer → Illegal A-axis (30) is valid, but the entire process is deemed invalid. Output: Error, G118 generation stopped; Example 3: Illegal angle of A-axis B-axis (180) is valid. A-axis (91) 91>90→ Illegal Output: Error, G118 generation stopped; Example 4: Floating-point error handling B-axis (89.999999) 89.999999 / 5≈17.9999998 The difference between the integer 18 and the integer 18 is less than 1e-6, thus considered valid. By performing discrete precision verification on the rotation angle, this embodiment can: avoid generating illegal CNC commands; prevent machine tool errors or abnormal operation; and improve the safety and stability of the machining process.
[0047] Ultimately, the A-axis angle is limited to a preset range, and the program output terminates when the condition is not met.
[0048] This step automatically filters out illegal rotation angles to prevent machine tool errors; ensures that the angle of the generated G118 command meets system requirements; improves machining safety and reliability; and supports floating-point error tolerance processing, balancing calculation accuracy and machine tool execution stability.
[0049] S3: Based on the coordinate system offset and the verified rotation angle, automatically generate coordinate system G-code instructions for translation and rotation. In this embodiment, after the angle verification is passed, CNC system coordinate system instructions are generated based on the parsed coordinate offset and rotation angle, including G117 additional coordinate system instructions and G118 coordinate rotation instructions.
[0050] (1) Input parameters (coordinate system offset (representing the installation error of the mechanical structure or the reference offset of coordinate system transformation), A-axis angle (already verified, it is a valid angle value that the program can directly use), B-axis angle (already mapped and verified, it is a valid angle value that the program can directly use), fixture offset number (used to distinguish the installation deviation configuration of different fixtures or workpieces) etc.) (2) Generation of additional coordinate system command in G117 ① Generation rule, G117 is used to select the additional coordinate system, and its C value is calculated from the fixture offset number: First, determine the range of values for the fixture offset number, and select the corresponding calculation method according to different ranges. Then, calculate the value of parameter C according to the formula to provide the corresponding offset data for subsequent machining or control processes.
[0051] ② Command generation format: First, execute the G117 command and pass in the previously calculated C value to complete the setting of the coordinate system or offset parameters, providing the corresponding configuration for subsequent machining operations.
[0052] ③Example Example 1: First, set the fixture offset number to 1, and substitute it into the corresponding formula to calculate the C value. Then, output the corresponding G117 command based on the calculation result to complete the offset setting.
[0053] Example 2: First, set the fixture offset number to 6. Determine that the value exceeds the range (0,4). Substitute it into the corresponding formula to calculate the C value. Then, output the corresponding G117 command based on the calculation result to complete the offset setting.
[0054] (3) Generation of G118 coordinate rotation command ① Input parameters (coordinate system offset, A-axis angle (optional, you can choose whether to pass a verified angle value according to actual needs), B-axis angle (optional, you can choose whether to pass a mapped and verified angle according to actual needs)) ②Generation Logic Construct instructions according to the following rules: must include offsets (X, Y, Z) → output the corresponding axis parameters only if the angle exists → format the values (keep three decimal places and remove invalid zeros). ③ Generation process: First, initialize the G118 instruction string, then concatenate the offset parameters of the X / Y / Z axes in sequence, then determine whether the angle parameters of the A-axis and B-axis have been passed in. If they exist, they are appended to the instruction string, and finally the complete CNC instruction is generated.
[0055] ④ Example Explanation Example 1 (B-axis rotation only): First, set the coordinate system offset to (10.0, 20.0, -5.0), then set the B-axis angle to 90° to provide specific parameter values for the subsequent generation of G118 commands.
[0056] Output: First execute the G118 command, and pass in the offset of the X / Y / Z axes and the B-axis angle parameter to complete the setting of the workpiece coordinate system offset and the rotation axis angle.
[0057] Example 2 (A+B axis dual axis): First, set the coordinate system offset to (0,0,100), then set the A-axis angle to 30° and the B-axis angle to 180°, providing specific parameter values for the subsequent generation of G118 commands.
[0058] Output: First execute the G118 command, and pass in the offset of the X / Y / Z axes and the angle parameters of the A / B axes to complete the setting of the workpiece coordinate system offset and the angle of the dual rotation axes.
[0059] Example 3 (no rotation, only offset): First, set the coordinate system offset to (5,5,5), then set the angles of the A-axis and B-axis to None (not passed in), providing parameter values for the generation of subsequent G118 commands.
[0060] Output: First execute the G118 command and pass in the offset parameters of the X / Y / Z axes to complete the setting of the workpiece coordinate system offset.
[0061] (4) Guarantee of parameter validity (related to Example 3) Before generating G118, it must be ensured that: angle_A has passed the range check; angle_B has passed the dispersion check; if they fail, the generation of G118 instructions is prohibited.
[0062] In other implementations: the C-value calculation rules of G117 can be adjusted according to different machine tools; G118 can be expanded to support more rotary axes (such as the C-axis); the offset can support local coordinate system superposition.
[0063] Using the above method, this embodiment can: automatically generate coordinate system transformation commands; ensure that coordinate transformation is consistent with tool path; avoid manual calculation errors; and improve machining accuracy and safety.
[0064] S4: Traverse the machining path segment data and convert each path segment into corresponding motion control G-code instructions according to the path type. In this embodiment, when the machining path segment is an arc, the rotation direction of the arc can be automatically determined by calculating the dot product of the starting vector and the ending vector of the corresponding arc path, and the corresponding clockwise or counterclockwise arc interpolation instruction can be generated.
[0065] Specifically, corresponding G-code can be generated based on the path type: 1. Straight line → G01; 2. Fast movement → G00; 3. Arc → G02 / G03; The direction of the arc is determined by the vector dot product.
[0066] S5: Identify the drilling cycle type in the machining path, and automatically match or calculate the cycle parameters based on the feature type to generate the corresponding G-code instructions for a fixed cycle. In this embodiment, when a countersunk hole feature is identified and the tool position data lacks machining depth parameters, the machining depth is automatically calculated using geometric relationships based on the top diameter, bottom diameter, and countersunk angle of the countersunk hole. The formula for calculating the machining depth is: In the formula, This refers to the countersinking depth (i.e., the machining depth). The diameter of the conical inlet is... The diameter at the beginning of the cone surface. The vertex angle of the cone.
[0067] Fixed loop instructions employ a block-level modal management mechanism, which can be specifically: (1) When a fixed loop instruction is encountered for the first time, the fixed loop instruction is output and the current loop state is recorded; (2) Before encountering a fixed cycle cancellation command or switching to other types of cycles, only the coordinate values of subsequent holes are output; (3) When a fixed loop cancellation instruction is encountered, the corresponding instruction is forcibly output and the current loop state is reset to undefined.
[0068] Other parameters: 1. R-plane (safe height) Calculation method 1 (direct input): R=retract_plane, where retract_plane is the user-defined retraction plane height. After being assigned to the R variable, it can be directly used as the safety height parameter for hole machining commands such as G81 / G82 / G83, ensuring that the tool can safely retract after drilling and avoid collision with the workpiece or fixture.
[0069] Calculation Method 2 (Automatic Calculation): R = TopZ + clearance, where TopZ is the Z-coordinate of the workpiece surface and clearance is the safety clearance height. The sum of these two values gives the retraction plane height for the hole machining cycle, used to generate the R parameters for commands such as G81 / G82 / G83. This ensures the tool can safely and quickly move to the designated position above the workpiece before drilling, avoiding collisions. The safety distance is generally taken as 2~5mm.
[0070] 2. Z Depth (Non-countersunk hole) Z = feed_to, where feed_to represents the final cutting depth of the hole. After being assigned to the Z variable, it can be directly used in commands such as G81 / G82 / G83 to define the endpoint position of the tool feed cutting and ensure that the drilling depth meets the requirements of the machining drawing.
[0071] Alternatively, Z = TopZ - depth, where TopZ is the Z-axis coordinate of the top surface of the workpiece and depth is the drilling depth. Subtracting the two gives the final Z-axis position of the bottom of the hole, which is used to generate the Z parameters for commands such as G81 / G82 / G83, ensuring accurate drilling depth and that the tool can cut to the depth required by the drawing.
[0072] 3. Q parameter (layered feed / chip breaking) For G83 / G73: Q=step_depth, where step_depth is the user-defined depth of feed per step. After being assigned to the Q variable, it can be directly used in the G83 command to define the cutting depth for each drilling operation, ensuring step-by-step feeding during deep hole machining, effectively breaking and removing chips, and avoiding tool overheating or chip jamming.
[0073] Automatic calculation method: Q=k×tool_diameter, which automatically sets the single drilling depth according to the tool diameter, where k is an empirical coefficient (usually taken as 0.5-1). This ensures chip breaking and removal while avoiding excessive tool load due to excessive single feed depth. It is often used to generate stable and reliable deep hole machining programs in batches.
[0074] Where: k∈[0.5,1.5] Example: Tool diameter = 10mm, Q = 0.8 * 10 = 8mm 4. P parameter (pause time) For G82 / G89: P=dwell_time, where dwell_time is the dwell time at the bottom of the hole set by the user. After being assigned to the variable P, it can be directly used in commands such as G82 (counter-hole cycle) to define the dwell time after the tool reaches the bottom of the hole, which is used to finish the bottom of the hole and ensure the flatness of the bottom of the hole.
[0075] Automatic calculation: P = t × 1000. The dwell time t, which is in seconds, is converted to milliseconds, a unit commonly used in CNC systems, and assigned to the variable P. This is used for hole machining commands such as G82 to define the dwell time of the tool at the bottom of the hole, in order to meet the programming format requirements of different machine tool systems.
[0076] Where: t is seconds Example: Pause for 0.5 seconds → P500 In addition to machining depth, it also automatically calculates or matches parameters such as the retraction plane, layered feed rate, dwell time and feed rate in the drilling cycle. The parameters are adaptively generated through preset formulas or empirical models, thereby reducing manual intervention and improving machining stability.
[0077] The purpose of this step is to automatically convert the drilling path data output by CAM into standard fixed cycle instructions of the CNC system (such as G81 / G82 / G83, etc.) and to adaptively optimize the machining parameters.
[0078] This solution primarily addresses the following issues: ① CAM output does not directly correspond to G-code loops: CAM typically outputs "point-by-point paths," while CNC systems are better suited to "fixed loops (G81, etc.)." The solution is automatic conversion from path to loop instructions. ② Incomplete drilling parameters: For example, missing Z-depth (common in countersunk holes), missing pause times, and missing layer parameters. This embodiment achieves automatic completion of machining parameters. ③ Low programming efficiency and error-prone: Traditional methods involve manual depth calculation and manual selection of loop types. This embodiment achieves automatic identification and automatic matching.
[0079] Its specific functions can be analyzed from the following aspects.
[0080] 1. Function of loop type identification Determined based on path characteristics: First, select the corresponding fixed cycle instruction based on the processing type, and then execute the corresponding G code to complete the processing action.
[0081] Function: Automatically selects the correct processing method.
[0082] 2. Parameter adaptive generation function: For example: Deep hole → automatically generate Q; Pause → automatically generate P Purpose: To avoid manually entering parameters. 3. Automatic calculation of countersunk hole depth (core function): When the Z-depth is missing: it is automatically calculated based on geometric relationships.
[0083] Function: Eliminates manual calculation and ensures machining accuracy.
[0084] 4. Continuous hole optimization function: First, execute the G81 drilling cycle command, then process multiple holes in sequence, and finally use G80 to cancel the fixed cycle to complete all drilling operations.
[0085] 5. Complete process example: Input (CAM data): First, define the countersunk hole (CSINK) machining type and set the corresponding hole machining parameters to provide data support for the subsequent generation of machining instructions.
[0086] Calculation: First, calculate the machining depth based on the countersunk hole parameters, and then determine the final machining position of the Z-axis.
[0087] Matching cycle: First, use the G82 command to execute a drilling cycle with a pause at the bottom of the hole to complete the countersunk hole machining.
[0088] Output: First execute the G82 drilling cycle command with pause, then machine the countersunk hole at position X10Y10 to complete the countersunk hole operation.
[0089] Through this step, this embodiment achieves: automatic identification of processing features; automatic generation of optimal G-code loops; automatic completion of missing parameters; reduced manual intervention; and improved processing safety.
[0090] S6: Using a preset state machine mechanism, all G-code instructions are classified by function and their modal states are tracked. The corresponding instructions are output to the final CNC program only when the modal state of the instruction changes.
[0091] 1. When generating G-code, a state machine manages modal instructions, outputting instructions only when the state changes, thereby reducing redundant instructions and improving program execution efficiency. Initialization of states: Before processing begins, the state machine initializes each type of instruction, as shown in the table below: category Current state variable initial value Movement instructions current_motion None Plane selection current_plane None coordinate mode current_coord None Tool compensation current_tool_comp None feed mode current_feed None Loop Category current_cycle None Instruction Classification: When processing each G-code instruction, the instructions are classified into corresponding categories, as shown in the table below: instruction category G00 Movement instructions G01 Movement instructions G17 Plane selection G90 coordinate mode G41 Tool compensation G81 Drilling circulation 2. State Comparison and Output Rules For each parsed instruction: first determine whether the current state of the machine tool is consistent with the target state. If the state has not changed, no instruction is output; if the state has changed, the corresponding CNC instruction is output and the state record is updated. This avoids redundant instructions in the program and makes the program more concise and efficient.
[0092] 3. Examples of state changes Assuming the initial state: current_motion=None; current_plane=None; the initialization code for the two key state variables is used to track the current motion mode (such as G00 / G01 / G02 / G03) and the machining plane (such as G17 / G18 / G19), respectively. Initializing to None indicates that no state has been set yet. The subsequent program will use state comparison logic to output the corresponding G-code instruction only when the state changes, thereby generating a more concise CNC program.
[0093] Example 1: Continuous changes in motion commands ① Handling G00X0Y0 current_motion=None → different Output G00X0Y0 Update current_motion=G00 ②Process G00X10Y10 current_motion=G00 → Same Do not output G00 Output only coordinates X10Y10 ③ Process G01X20Y20 current_motion=G00→Different Output G01X20Y20 Update current_motion=G01 Example 2: Plane Selection ① Processing G17 current_plane=None → different Output G17 Update current_plane=G17 ②The next line is still G17 current_plane=G17→ Same G17 not output ③ Encounter G18 current_plane=G17→Different Output G18 Update current_plane=G18 Example 3: Tool Compensation ① Processing G41 current_tool_comp=None → Different Output G41 Update current_tool_comp=G41 ②Process G41 (continuous rows) urrent_tool_comp=G41 → Same G41 not output ③ Encounter G40 current_tool_comp=G41 → Different Output G40 Update current_tool_comp=G40 4. Overview of the Presidential Process 4.1 Initialize the state machine, with each category state being None. 4.2 Reading a single G-code line 4.3 Classification Instructions 4.4 Compare the current category status: If it has not changed, do not output; if it has changed, output the instruction and update the status.
[0094] 4.5 For motion commands of the same type consecutively, only the coordinate parameters are output. 4.6 Continue to the next G code. 4.7 Repeat until the program ends The aforementioned state machine eliminates redundant instructions (such as repeated G17 / G90 / G41 instructions); reduces the number of program lines, improving machine tool execution efficiency; ensures the correctness of program logic; and performs differential output on motion instructions, further compressing the program.
[0095] In this embodiment, all G-code instructions are classified into at least the following categories: Motion commands (used to describe tool movement): G00 (rapid traverse), G01 (linear interpolation), G02 (clockwise circular arc), G03 (counterclockwise circular arc); Plane selection classes (used to specify the interpolation plane): G17 (XY plane), G18 (ZX plane), G19 (YZ plane); Coordinate mode classes (used to specify coordinate programming methods): G90 (absolute coordinates), G91 (incremental coordinates); Tool compensation categories (used to control tool radius compensation): G40 (cancel compensation), G41 (left compensation), G42 (right compensation); Feed pattern class; Fixed loop classes (used for drilling cycles): G81, G82, G83, G84, G85, G89, etc. Drilling cycles are "block-level modal" instructions, unlike ordinary modal instructions. The loop must output G80 at the end, and current_cycle = None. Example: Input path (3 holes, hole 1 → hole 2 → hole 3, all 3 holes have the same parameters).
[0096] Each category has a corresponding current state variable, initially set to undefined. The state machine outputs the instruction and updates the state only when the parsed instruction differs from the current state of the corresponding category. For example, the initial states of current_motion, current_plane, current_coordinate_mode, current_tool_comp, current_feed_mode, and current_cycle are set to "undefined". State comparison and output rules: For each G-code to be output, the following logic is executed: (1) Analyze the category to which the current instruction belongs, for example: G01 → motion category, G17 → planar category; (2) Compare with the current state. If the current instruction equals the current state, do not output. If they are different, output and update the state. Special optimizations for motion commands: For motion commands (G00 / G01 / G02 / G03), further optimizations are made: If multiple consecutive lines have the same motion type: The first line outputs the G code (e.g., G01), and subsequent lines only output the coordinates; Example: G01X10Y10F100 X20Y20 X30Y30 State changes: OK instruction current_cycle changes 1 G81 None → G81 2 X20 Y20 constant 3 X30 Y30 constant 4 G80 G81 → None Drilling cycle: It is incorporated into a state machine, but has an "explicit termination mechanism", unlike ordinary modalities.
[0097] The state machine mechanism described above reduces repetitive modal instruction output, decreases program size, improves machine tool execution efficiency, and ensures program logic consistency.
[0098] S7: Before outputting the final CNC program, the instructions to be output are formatted and optimized: coordinate axis words that have not changed are omitted, continuous motion instructions with the same parameters are merged, and feed rate and spindle speed control instructions are output only when their values change. In this embodiment, after completing path transformation, coordinate system instruction generation, and loop processing, the generated CNC instructions are uniformly organized and optimized, and the final G-code program is output.
[0099] (1) Output content ① The final output is a standard CNC program, which includes the following instructions and parameters: Program structure instructions: First, the overall structure of a standard CNC program will be introduced, and then the function of each instruction will be explained.
[0100] ② Safety initialization command: First execute the program initialization command, then return the Z-axis to the reference point to prepare for subsequent machining.
[0101] Functions: Cancel tool offset; Set plane; Set unit; Return to reference point.
[0102] ③ Coordinate system commands (from S3): First execute the G117 command, then execute the G118 command.
[0103] Source parameters: offset_X / Y / Z; angle_A / B; fixture_bias.
[0104] ④ Tool change and tool control commands (from S1): First execute the tool change command, then call the tool length compensation to prepare the tool and compensation parameters for machining.
[0105] Source parameters: tool_id; tool_length_offset.
[0106] ⑤ Spindle and cooling control: Set the spindle speed in revolutions per minute (RPM). After execution, the spindle will rotate clockwise at the set speed. Source parameters: spindle_speed; coolant_flag.
[0107] ⑥ Motion path instructions (from S4): G00 Rapid positioning; G01 Linear interpolation; G02 Clockwise circular interpolation; G03 Counterclockwise circular interpolation; Source parameters: point_start / end, center, feed_rate.
[0108] ⑦ Fixed cycle commands (from S5): G81 Normal drilling cycle; G82 Countersinking / counterhead drilling cycle; G83 Deep hole drilling cycle (chip breaking); G84 Right-hand tapping cycle; Source parameters: cycle_type; depth / dwell / step.
[0109] ⑧ Program End Control: First, stop the spindle rotation with M5, turn off the coolant with M9, then use G91G28Z0 to return the Z-axis to the reference point in incremental mode. Next, execute M1 (optional stop) and wait for operator confirmation. Use T0M6 to switch to tool number 0 (cancel the current tool). Finally, use M30 to end the program and return to the beginning of the program, completing the machine tool reset and program termination after machining.
[0110] (2) Optimize output rules ① Modal instruction compression (from S6): Rule: If the instruction has not changed → no output. Example: First, move linearly to (X10,Y10) at the set feed rate, then move sequentially to (X20,Y20) and (X30,Y30) to achieve continuous path cutting.
[0111] ② Simplified Axis Output: Rule: Only output the axes that have changed. Example: If the coordinates of a certain axis are exactly the same as the previous point, the instruction for that axis can be omitted, and only the changed axis is output (here only the X-axis changes from 10 to 15), making the program more concise and efficient. Previous point: previous tool position X10 Y20 Z30; Current point: tool target position X15 Y20 Z30; Output: only X15 is written, omitting the unchanged Y20 and Z30.
[0112] ③ Numerical format optimization: Rules: Keep 3 decimal places; remove trailing zeros.
[0113] Example: 10.500 can be abbreviated to 10.5, removing the trailing zeros; 10.000 can be abbreviated to 10, removing the decimal point and trailing zeros. ④ Feed rate and spindle speed optimization: Rule: F and S are only output when they change; ⑤ Loop instruction optimization: Rule: The same loop parameter is only output once; subsequent outputs are only coordinates.
[0114] ⑥ Blank lines and structure optimization: Rule: Insert blank lines when switching processes; improve program readability.
[0115] (3) Output sequence control The preferred output sequence is as follows: First, execute the initialization command to restore the machine tool to its default state. Then, complete the preparatory actions such as tool change, G117 / G118 coordinate system setting, and G43 tool length compensation. Next, start the spindle and coolant. Then, execute the path cutting or hole machining cycle command. Finally, run the end command, use M30 to end the program and return to the beginning.
[0116] Complete example: Initialize the machine tool status using G40 / G49 / G17 / G21 / G94 and return the Z-axis to the reference point. Then, change to tool #1 and set the C54 coordinate system, workpiece offset, and 90° rotation of the B-axis using G117 / G118 commands. After calling tool length compensation using G43, start the spindle at 2000 rpm and turn on the coolant. Then, quickly move to the origin, cut straight down to depth Z-5 and follow a rectangular contour. Then, use the G81 drilling cycle to drill two holes at positions (10,10) and (20,20). Finally, stop the spindle and coolant using M5 / M9, return the Z-axis to the reference point, and end the program using M30 and return to the beginning.
[0117] By optimizing the output, this invention achieves the following: reduced program size; improved execution efficiency; reduced machine tool load; improved program readability; and reduced communication time.
[0118] In summary, compared with existing CNC machine tool post-processing methods, the post-processing method for right-angle milling heads of CNC machine tools in this embodiment has the following advantages: 1. This post-processing method for right-angle milling heads on CNC machine tools automatically normalizes, maps, and verifies the rotation angle, and uses a modal instruction state machine to classify, manage, and eliminate redundancy in G-code instructions. Simultaneously, it automatically identifies drilling cycle characteristics and adaptively calculates cycle parameters. This solves the technical problems of poor versatility and low efficiency in existing CNC machine tool post-processors, achieving the technical effects of automatically generating coordinate system instructions to improve programming efficiency, automatically verifying angles to improve machining safety, reducing redundant code to improve program execution efficiency, and automatically processing special machining features to improve versatility and reduce manual intervention.
[0119] 2. This post-processing method for right-angle milling heads on CNC machine tools automatically determines the rotation direction of the arc by calculating the dot product of the starting and ending vectors of the arc path. It eliminates the need for manual judgment or additional input of arc direction parameters, thereby improving the accuracy and automation of arc machining path conversion.
[0120] 3. The post-processing method for right-angle milling heads of CNC machine tools adopts a block-level modal management mechanism for fixed cycle instructions. During continuous hole machining, it automatically omits repeated fixed cycle instruction codes, outputs coordinate values only when the hole coordinates change, and automatically outputs a fixed cycle cancellation instruction at the end of the cycle. This further reduces program redundancy and improves the program execution efficiency of continuous hole machining.
[0121] 4. The post-processing method for right-angle milling heads of CNC machine tools can perform formatting optimization on instructions before outputting the CNC program. This includes omitting coordinate axis words that have not changed, merging continuous motion instructions with the same parameters, and outputting feed rate and spindle speed control instructions only when the values change. This effectively compresses the program size, reduces the communication load of the machine tool control system, and improves the readability and maintainability of the program.
[0122] Example 2 This embodiment provides a post-processing system for a right-angle milling head on a CNC machine tool, which applies the post-processing method for a right-angle milling head on a CNC machine tool in Embodiment 1. The system includes a data parsing module, a verification module, a coordinate system instruction generation module, a motion control instruction generation module, a fixed cycle generation module, and an instruction processing module.
[0123] The data parsing module parses the tool position data to obtain coordinate system offset, rotation angle, tool parameters, and machining path segment data. The verification module first normalizes the rotation angle and maps it to a preset standard angle range, then verifies the constraints of the mapped rotation angle. If the verification fails, the processing flow terminates.
[0124] The coordinate system instruction generation module automatically generates coordinate system G-code instructions for translation and rotation based on the coordinate system offset and the verified rotation angle. The motion control instruction generation module iterates through the machining path segment data and converts each path segment into corresponding motion control G-code instructions according to the path type.
[0125] The fixed cycle generation module identifies the drilling cycle type in the machining path and automatically matches or calculates cycle parameters based on the feature type to generate G-code instructions for the corresponding fixed cycle. The instruction processing module uses a preset state machine mechanism to classify all G-code instructions by function and track their modal states, and outputs the corresponding instruction to the final CNC program only when the modal state of the instruction changes.
[0126] Example 3 This embodiment provides an electronic device, including a memory, a processor, and a computer program stored in the memory and executable on the processor. When the processor executes the computer program, it implements the post-processing method for a right-angle milling head of a CNC machine tool as described in Embodiment 1.
[0127] The method in Example 1 can be applied in software form, such as by designing it as a standalone program and installing it on a computer terminal, which can be a computer, smartphone, control system, or other IoT device. Alternatively, the method in Example 1 can be designed as an embedded program and installed on a computer terminal, such as on a microcontroller.
[0128] Example 4 This embodiment provides a computer-readable storage medium on which a computer program is stored. When the program is executed by a processor, it implements the steps of the post-processing method for a right-angle milling head of a CNC machine tool according to Embodiment 1.
[0129] When applying the method of Example 1, it can be applied in the form of software, such as by designing it as a program that can run independently on a computer-readable storage medium. The computer-readable storage medium can be a USB flash drive, designed as a USB security token, and the program can be designed to start the entire method through an external trigger.
[0130] The above description is only a preferred embodiment of the present invention and is not intended to limit the present invention. Any modifications, equivalent substitutions, and improvements made within the spirit and principles of the present invention should be included within the protection scope of the present invention.
Claims
1. A post-processing method for a right-angle milling head on a CNC machine tool, characterized in that, It includes the following steps: S1: Analyze the tool position data to obtain coordinate system offset, rotation angle, tool parameters and machining path segment data; S2: First, normalize the rotation angle and map it to a preset standard angle range. Then, perform constraint condition verification on the mapped rotation angle. If the verification fails, terminate the processing flow. S3: Based on the coordinate system offset and the verified rotation angle, automatically generate coordinate system G-code instructions for translation and rotation; S4: Traverse the processing path segment data and convert each path segment into corresponding motion control G-code instructions according to the path type; S5: Identify the drilling cycle type in the machining path, and automatically match or calculate the cycle parameters according to the feature type to generate the corresponding fixed cycle G-code instructions; S6: Using a preset state machine mechanism, all G-code instructions are classified by function and their modal states are tracked. The corresponding instructions are output to the final CNC program only when the modal state of the instruction changes.
2. The post-processing method for a right-angle milling head on a CNC machine tool according to claim 1, characterized in that, In step S2, the constraint verification includes the following steps: Verify whether the B-axis rotation angle is an integer multiple of a preset discrete precision, and verify whether the A-axis rotation angle is within a preset safety range; wherein, the B-axis is used to control the spindle azimuth angle of the right-angle milling head, and the A-axis is used to control the tool tilt angle of the right-angle milling head.
3. The post-processing method for a right-angle milling head on a CNC machine tool according to claim 1, characterized in that, In step S5, when the countersunk hole feature is identified and the machining depth parameter is missing in the tool position data, the machining depth is automatically calculated using geometric relationships based on the top diameter, bottom diameter and countersunk angle of the countersunk hole.
4. The post-processing method for a right-angle milling head on a CNC machine tool according to claim 3, characterized in that, The formula for calculating the processing depth is: ; In the formula, For the depth of burrowing, The diameter of the conical inlet is... The diameter at the beginning of the cone surface. The vertex angle of the cone.
5. The post-processing method for a right-angle milling head on a CNC machine tool according to claim 1, characterized in that, In step S6, all G-code instructions are classified into at least the following categories: Motion command type, plane selection type, coordinate mode type, tool compensation type, feed mode type, and fixed cycle type; Each category has a corresponding current state variable, and the initial state is undefined. The state machine only outputs the instruction and updates the state when the parsed instruction is different from the current state of the corresponding category.
6. The post-processing method for a right-angle milling head on a CNC machine tool according to claim 5, characterized in that, The fixed loop instruction adopts a block-level modal management mechanism, specifically: Upon first encountering a fixed loop instruction, the fixed loop instruction is output and the current loop state is recorded; Before encountering a fixed loop cancellation command or switching to other types of loops, only the coordinate values of subsequent holes are output; When the fixed loop cancellation instruction is encountered, the corresponding instruction is forcibly output and the current loop state is reset to undefined.
7. The post-processing method for a right-angle milling head on a CNC machine tool according to claim 1, characterized in that, In step S4, when the processing path segment is an arc, the rotation direction of the arc is automatically determined by calculating the dot product of the starting vector and the ending vector of the corresponding arc path, and a corresponding clockwise or counterclockwise arc interpolation command is generated.
8. The post-processing method for a right-angle milling head on a CNC machine tool according to claim 1, characterized in that, In step S2, the rotation angle is normalized to the range of [-180°, 180°], and then, according to the interval to which the normalized angle value belongs, the normalized angle value is converted to the [0°, 360°] angle interval that the target system can recognize through a predefined mapping rule.
9. The post-processing method for a right-angle milling head on a CNC machine tool according to claim 1, characterized in that, The post-processing method further includes the following steps: S7: Before outputting the final CNC program, perform formatting optimization on the instructions to be output: omit coordinate axis words that have not changed, merge continuous motion instructions with the same parameters, and control the feed rate and spindle speed instructions to be output only when the values change.
10. A post-processing system for a right-angle milling head on a CNC machine tool, characterized in that, Its application is the post-processing method for right-angle milling heads of CNC machine tools according to any one of claims 1-9, wherein the system comprises: The data parsing module is used to parse tool position data and obtain coordinate system offset, rotation angle, tool parameters and machining path segment data; The verification module is used to first normalize the rotation angle and map it to a preset standard angle range, and then verify the constraint conditions of the mapped rotation angle. If the verification fails, the processing flow is terminated. The coordinate system instruction generation module is used to automatically generate coordinate system G-code instructions for translation and rotation based on the coordinate system offset and the verified rotation angle. The motion control instruction generation module is used to traverse the processing path segment data and convert each path segment into corresponding motion control G-code instructions according to the path type. The fixed cycle generation module is used to identify the drilling cycle type in the machining path, and automatically match or calculate the cycle parameters according to the feature type to generate the corresponding fixed cycle G-code instructions. The instruction processing module is used to classify all G-code instructions by function and track their modal states using a preset state machine mechanism, and outputs the corresponding instruction to the final CNC program only when the modal state of the instruction changes.