Method for generating numerical control machining program, electronic device and storage medium
By constructing a tree structure for CNC machining programs and clarifying the hierarchical relationship of instruction strings, CNC machining programs are generated, solving the problems of poor flexibility and high maintenance difficulty in existing technologies, and achieving more efficient programming and maintenance.
Patent Information
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- BEIJING NOVICK DIGITAL EQUIP CO LTD
- Filing Date
- 2025-08-07
- Publication Date
- 2026-07-28
AI Technical Summary
Existing CNC machining programs suffer from poor flexibility, high maintenance and readability when faced with complex and flexible machining requirements, making it difficult to meet users' ever-changing machining needs.
By constructing a tree structure for the CNC machining program, clarifying the hierarchical relationship between instruction strings, and generating the CNC machining program, the following steps are taken: determining the first and second instruction strings of the graphic to be machined, constructing an instruction string set based on the machining process, and generating the CNC machining program using a pre-order traversal method.
It improves the readability, scalability, and flexibility of CNC machining programs, reduces maintenance difficulty, increases programming efficiency, and meets more complex and flexible machining needs.
Smart Images

Figure CN120928780B_ABST
Abstract
Description
Technical Field
[0001] This article relates to, but is not limited to, the field of CNC machine tool technology, and in particular to a method for generating CNC machining programs, electronic equipment, and storage media. Background Technology
[0002] A Computer Numerical Control Machine Tool (CNC machine tool) is an automated machine tool that controls the machining process through digital program instructions. It can automatically complete machining operations according to a pre-written machining program without direct human intervention. G-code is a programming language, specifically a numerical control programming language composed of instruction characters and numerical text, and is the most widely used CNC programming language for machine tools. Existing CNC machine tools widely use G-code to write CNC machining programs, and then use these programs to machine mechanical products. A CNC machining program consists of instruction strings, which are independently executable lines of code within the CNC machining program. Instruction strings include instructions or combinations of instructions and parameters. Using CNC machining programs, CNC machine tools can be controlled to perform operations such as rapid positioning, reverse circular interpolation, forward circular interpolation, and jump machining.
[0003] In the field of CNC machine tools, CNC machining programs are typically generated by gradually producing corresponding instruction strings based on the drawings and machining processes created using software such as CAD. However, with the expansion of machine tool processing range and the continuous changes and increases in processing requirements, when it is necessary to make extensive modifications and adaptations to the instruction strings in existing CNC machining programs, CNC machining programs generated based on existing technologies suffer from problems such as poor flexibility, high maintenance and reading difficulty. Summary of the Invention
[0004] This application provides a method for generating CNC machining programs, an electronic device, and a storage medium that can clearly describe the hierarchical relationship between instruction strings within a CNC machining program, thereby improving the readability, scalability, flexibility, and accuracy of the CNC machining program.
[0005] In a first aspect, this application provides a method for generating a CNC machining program, comprising: determining at least one first instruction string corresponding to the workpiece to be machined based on the shape parameters of any workpiece to be machined and the process parameters corresponding to the workpiece to be machined; obtaining machining parameters from a preset machining parameter library based on the process parameters corresponding to the workpiece to be machined, and determining at least one second instruction string corresponding to the workpiece to be machined based on the obtained machining parameters; constructing an instruction string set corresponding to the workpiece to be machined based on the machining process corresponding to the workpiece to be machined, and based on at least one first instruction string and at least one second instruction string corresponding to the workpiece to be machined; and generating a CNC machining program based on the instruction string set corresponding to the workpiece to be machined.
[0006] In one possible implementation, based on the processing flow corresponding to the graphic to be processed, an instruction string set corresponding to the graphic to be processed is constructed according to at least one first instruction string and at least one second instruction string corresponding to the graphic to be processed. This includes: based on the processing flow corresponding to the graphic to be processed, using at least one first instruction string corresponding to the graphic to be processed as a leaf node and using at least one second instruction string corresponding to the graphic to be processed as a non-leaf node, constructing a tree-structured instruction string set corresponding to the graphic to be processed.
[0007] In one possible implementation, the method further includes: displaying a set of instruction strings corresponding to the graphic to be processed through an interactive interface; and modifying the set of instruction strings corresponding to the graphic to be processed in response to a modification command input by the user.
[0008] In one possible implementation, the first instruction string includes at least one of the following: an instruction string corresponding to a motion-related G instruction, and an instruction string corresponding to a motion-related M instruction; the second instruction string includes at least one of the following: an instruction string corresponding to an H instruction, an instruction string corresponding to a T instruction, an instruction string corresponding to an N instruction, an instruction string corresponding to an E instruction, and an instruction string corresponding to a compensation-related G instruction.
[0009] In one possible implementation, generating a CNC machining program based on the instruction string set corresponding to the instruction string set corresponding to the instruction string set corresponding to each instruction string set corresponding to the instruction string set corresponding to each instruction string set corresponding to the instruction string set corresponding to each instruction string set corresponding to each instruction string set corresponding to each instruction string set corresponding to each instruction string set corresponding to each instruction string set corresponding to each instruction string set corresponding to each instruction string set corresponding to each instruction string set corresponding to each instruction string set, generates a CNC machining program capable of machining the instruction string set corresponding to each instruction string set corresponding to each instruction string set.
[0010] In one possible implementation, a tree-structured instruction string set corresponding to the workpiece to be processed is constructed based on the tree-structured instruction string set corresponding to each graphic to be processed. This includes: setting an empty instruction as the root node of the tree-structured instruction string set corresponding to the workpiece to be processed, setting the child nodes of the root node as the root nodes of the tree-structured instruction string sets corresponding to each graphic to be processed, and constructing the tree-structured instruction string set corresponding to the workpiece to be processed based on the tree-structured instruction string set corresponding to each graphic to be processed.
[0011] In one possible implementation, generating a CNC machining program based on the instruction string set corresponding to the graphic to be processed includes: using a pre-order traversal method to traverse the tree-structured instruction string set corresponding to the graphic to be processed, and generating a CNC machining program capable of processing the graphic to be processed.
[0012] In one possible implementation, generating a CNC machining program capable of machining the workpiece based on the instruction string set corresponding to the workpiece to be machined includes: using a pre-order traversal method to traverse the tree-structured instruction string set corresponding to the workpiece to be machined, and generating a CNC machining program capable of machining the workpiece to be machined.
[0013] Secondly, this application also provides an electronic device, including a processor, a communication interface, a memory, and a communication bus, wherein the processor, the communication interface, and the memory communicate with each other through the communication bus;
[0014] Memory, used to store computer programs;
[0015] A processor, when executing a program stored in memory, implements any of the methods provided in the first aspect.
[0016] Thirdly, this application also provides a computer-readable storage medium, characterized in that the computer-readable storage medium stores a computer program, which, when executed by a processor, implements any of the methods provided in the first aspect.
[0017] The CNC machining program generation method, electronic device, and storage medium provided in this application determine at least one first instruction string corresponding to a workpiece based on the shape parameters of any workpiece to be machined and the process parameters corresponding to the workpiece to be machined; obtain machining parameters from a preset machining parameter library based on the process parameters corresponding to the workpiece to be machined, and determine at least one second instruction string corresponding to the workpiece to be machined based on the obtained machining parameters; construct an instruction string set corresponding to the workpiece to be machined based on the machining process corresponding to the workpiece to be machined, according to at least one first instruction string and at least one second instruction string corresponding to the workpiece to be machined; and generate a CNC machining program based on the instruction string set corresponding to the workpiece to be machined. This method can clearly describe the hierarchical relationship between instruction strings within the CNC machining program, improving the readability, scalability, flexibility, and accuracy of the CNC machining program, and reducing maintenance difficulty; at the same time, it effectively improves programming efficiency and better meets the more complex and flexible machining needs in the field of CNC machine tool processing.
[0018] Other features and advantages of this application will be set forth in the following description, and will be apparent in part from the description, or may be learned by practicing the application. Other advantages of this application can be realized and obtained by means of the solutions described in the description and the accompanying drawings. Attached Figure Description
[0019] The accompanying drawings are used to provide an understanding of the technical solutions of this application and constitute a part of the specification. They are used together with the embodiments of this application to explain the technical solutions of this application and do not constitute a limitation on the technical solutions of this application.
[0020] Figure 1 A flowchart illustrating a method for generating a CNC machining program, provided in an embodiment of this application;
[0021] Figure 2 A schematic diagram of a display interface provided in an embodiment of this application;
[0022] Figure 3 A schematic diagram of a tree-structured instruction string set corresponding to a graphic to be processed, provided in an embodiment of this application;
[0023] Figure 4 This is a schematic diagram of the shape of a graphic to be processed, provided in an embodiment of this application. Detailed Implementation
[0024] This application describes several embodiments, but these descriptions are exemplary and not restrictive, and it will be apparent to those skilled in the art that many more embodiments and implementations are possible within the scope of the embodiments described herein. Although many possible combinations of features are shown in the drawings and discussed in the detailed description, many other combinations of the disclosed features are also possible. Unless specifically limited, any feature or element of any embodiment may be used in combination with, or may replace, any feature or element of any other embodiment.
[0025] Furthermore, in describing representative embodiments, the specification may have presented methods and / or processes as a specific sequence of steps. However, the method or process should not be limited to a specific order of steps to the extent that it does not depend on this specific order. As will be understood by those skilled in the art, other sequences of steps are also possible. Therefore, the specific order of steps set forth in the specification should not be construed as a limitation of the claims. Moreover, the claims relating to the method and / or process should not be limited to the steps performed in the order written, and those skilled in the art will readily understand that these orders can be varied and still remain within the spirit and scope of the embodiments of this application.
[0026] Traditional CNC machining programs generate corresponding instruction strings step-by-step based on the drawing to be machined and the machining process. There is no hierarchical distinction between these instruction strings, making maintenance and reading difficult. As user demands increase and workpiece complexity rises, the number of instruction strings (program segments) in CNC machining programs also increases. CNC machining programs obtained through traditional methods suffer from poor flexibility and high modification difficulty due to their inherent characteristics, making it difficult to meet user requirements. To address this issue, this application provides a method for generating CNC machining programs. This method extracts the "part-whole" hierarchical structure between the instruction strings in the CNC machining program, ensuring consistency in the use of different instructions. The calling logic and interfaces of each instruction string are highly unified during the CNC machining program generation process, effectively improving its readability, scalability, and maintainability.
[0027] Figure 1 A flowchart illustrating a method for generating a CNC machining program provided in this application embodiment is shown below. Figure 1 As shown, the method includes:
[0028] S101. Based on the shape parameters of any graphic to be processed corresponding to the workpiece and the process parameters corresponding to the graphic to be processed, determine at least one first instruction string corresponding to the graphic to be processed.
[0029] The workpiece to be processed is the workpiece to be CNC machined, which may include one or more drawings to be processed.
[0030] The shape parameters of the graphic to be processed are data used to describe its shape. For example, for a rectangle, the shape parameters are the coordinates of its four vertices; for a circle, the shape parameters are the coordinates of its center and its radius. Different graphics correspond to different shape parameters, and this is not limited to a specific aspect.
[0031] Process parameters refer to the physical quantities determined during the machining process planning stage that guide the cutting process. These are typically technical decisions made by process engineers based on factors such as part material, cutting tools, machine tools, and quality requirements. They include one or more of the following parameters: Cutting parameters: cutting speed (Vc), feed rate (F), depth of cut (ap), width of cut (ae), etc. Cutting tool parameters: tool type, tool diameter (D), tool length compensation (L), tool radius compensation (R), etc. Machine tool parameters: spindle speed (S), coordinate system selection, unit settings, plane selection, etc. Quality control parameters: surface roughness, dimensional tolerances, etc.
[0032] S102. Obtain the processing parameters from the preset processing parameter library according to the process parameters corresponding to the graphic to be processed, and determine at least one second instruction string corresponding to the graphic to be processed based on the obtained processing parameters.
[0033] G-code encompasses various CNC instructions, including G, M, S, F, T, D, H, E, X, Y, and Z instructions. Among these, the X, Y, and Z instructions, which are related to coordinate parameters, all rely on G instructions to achieve motion. G instructions are the most core, frequently used, and numerous instruction category, directly affecting the toolpath. In the industry, CNC machining programs written using G-code are often simply referred to as G-code, and the program segment corresponding to each instruction is called an instruction string.
[0034] In one possible implementation, the first instruction string includes at least one of the following: an instruction string corresponding to a motion-related G instruction, an instruction string corresponding to a motion-related M instruction; the second instruction string includes at least one of the following: an instruction string corresponding to an H instruction, an instruction string corresponding to a T instruction, an instruction string corresponding to an N instruction, an instruction string corresponding to an E instruction, and an instruction string corresponding to a compensation-related G instruction.
[0035] For example, the first instruction string includes G00 X_Y_, G01 X_Y_, G02 X_Y_I_J_, G03 X_Y_I_J_, M00, M02, M30, etc., where G00 X_Y_ is used to indicate rapid positioning, G01 X_Y_ is used to indicate linear interpolation, G02 X_Y_I_J_ is used to indicate clockwise circular interpolation, G03 X_Y_I_J_ is used to indicate counterclockwise circular interpolation, M00 is used to indicate program pause, M02 is used to indicate machine tool reset, and M30 is used to indicate program end. M00, M02, and M30 all correspond to motion stop. It is understandable that G00 X_Y_, G01 X_Y_, G02 X_Y_I_J_, and G03 X_Y_I_J are just illustrations. In actual applications, the hyphens after X, Y, I, and J in the above instruction strings can be replaced with the corresponding values according to the actual situation.
[0036] The second instruction string includes the instruction strings corresponding to the H instruction, T instruction, N instruction, E instruction, G41 instruction, G42 instruction, and G40 instruction, etc. Among them, the instruction string corresponding to the H instruction is used to specify the length compensation value; the instruction string corresponding to the T instruction is used to specify the tool; the instruction string corresponding to the N instruction is used to specify the sequence number; the instruction string corresponding to the E instruction is used to specify the feed rate; the instruction string corresponding to G41 is used to indicate left-side compensation; the instruction string corresponding to G42 is used to indicate right-side compensation; and the instruction string corresponding to G40 is used to indicate cancellation of compensation.
[0037] Machining parameters are the specific numerical execution of process parameters, and the specific parameter configuration for each machining action.
[0038] The machining parameters are retrieved from a pre-defined machining parameter library based on the process parameters corresponding to the graphic to be machined. This can be based on a pre-defined mapping relationship between process parameters and machining parameters. The pre-defined machining parameter library is searched according to the process parameters corresponding to the graphic to be machined to determine the machining parameters corresponding to the process parameters corresponding to the graphic to be machined. One process parameter can correspond to one or more machining parameters.
[0039] S103. Based on the processing flow corresponding to the graphic to be processed, construct a set of instruction strings corresponding to the graphic to be processed according to at least one first instruction string and at least one second instruction string corresponding to the graphic to be processed.
[0040] Based on the processing flow corresponding to the graphic to be processed, a hierarchical set of instruction strings can be constructed according to at least one first instruction string and at least one second instruction string corresponding to the graphic to be processed. The processing flow reflects the logical order of processing steps and determines the execution order between instruction strings. The order of each instruction string (first instruction string and second instruction string) is determined according to the processing flow, and these instruction strings are combined to construct the set of instruction strings corresponding to the graphic to be processed.
[0041] In one possible implementation, based on the processing flow corresponding to the graphic to be processed, an instruction string set corresponding to the graphic to be processed is constructed according to at least one first instruction string and at least one second instruction string corresponding to the graphic to be processed. This includes: based on the processing flow corresponding to the graphic to be processed, using at least one first instruction string corresponding to the graphic to be processed as a leaf node and using at least one second instruction string corresponding to the graphic to be processed as a non-leaf node, constructing a tree-structured instruction string set corresponding to the graphic to be processed.
[0042] Non-leaf nodes, also known as composite nodes, can have other leaf or non-leaf nodes added as their children. Leaf nodes cannot have children. Non-leaf and leaf nodes share a unified interface for retrieving corresponding instruction strings.
[0043] For example, according to the processing flow corresponding to the graphic to be processed, all the corresponding leaf nodes and non-leaf nodes are combined to form a tree-like hierarchical structure, thus constructing the instruction string set of the tree structure corresponding to the graphic to be processed.
[0044] S104. Generate a CNC machining program based on the instruction string set corresponding to the graphic to be processed.
[0045] Based on the instruction string set corresponding to the graphic to be processed, a CNC machining program is generated. This is achieved by sorting the instruction strings in a certain order according to the instruction string set corresponding to the graphic to be processed.
[0046] The CNC machining program can be either a CNC machining program capable of machining the workpiece to be machined, or a CNC machining program capable of machining the graphic to be machined. When the workpiece to be machined includes only one graphic, the CNC machining program capable of machining the workpiece is also the CNC machining program capable of machining the graphic; when the workpiece to be machined includes multiple graphics, the CNC machining program capable of machining the workpiece includes the CNC machining program capable of machining each graphic.
[0047] In one possible implementation, generating a CNC machining program based on the instruction string set corresponding to the graphic to be processed includes: using a pre-order traversal method to traverse the tree-structured instruction string set corresponding to the graphic to be processed, and generating a CNC machining program capable of processing the graphic to be processed.
[0048] For example, the root node of the instruction string set of the tree structure corresponding to the graphic to be processed is first accessed, and then each node is accessed in turn to output the corresponding instruction string in turn, thereby generating a CNC machining program that can process the graphic to be processed.
[0049] This method can avoid omissions, improve the readability of CNC machining programs, reduce maintenance difficulty, and lower the error rate of CNC machining programs.
[0050] In another possible implementation, based on the multiple workpieces to be processed corresponding to the multiple workpieces to be processed, and based on the instruction string set corresponding to the workpieces to be processed, the CNC machining program is generated by: constructing a tree-structured instruction string set corresponding to the workpieces to be processed based on the tree-structured instruction string set corresponding to each workpiece to be processed; and generating a CNC machining program capable of processing the workpieces to be processed based on the tree-structured instruction string set corresponding to the workpieces to be processed.
[0051] For example, using the instruction string set of the tree structure corresponding to each graphic to be processed as a subtree of the root node, a tree structure instruction string set corresponding to the workpiece to be processed is constructed. Based on the instruction string set of the tree structure corresponding to the workpiece to be processed, a CNC machining program capable of processing the workpiece is generated. It is easy to understand that the root node of each subtree is a composite node.
[0052] This method allows for a more refined generation process of the CNC machining program for the workpiece, based on the number of corresponding graphics. The resulting CNC machining program for the workpiece has advantages such as high readability and low dimensional complexity.
[0053] Optionally, based on the instruction string set of the tree structure corresponding to each graphic to be processed, a tree structure instruction string set corresponding to the workpiece to be processed is constructed, including: setting an empty instruction as the root node of the instruction string set of the tree structure corresponding to the workpiece to be processed, setting the child nodes of the root node as the root nodes of the instruction string set of the tree structure corresponding to each graphic to be processed, and constructing a tree structure instruction string set corresponding to the workpiece to be processed based on the instruction string set of the tree structure corresponding to each graphic to be processed.
[0054] For example, the root node of the instruction string set of the tree structure corresponding to the workpiece to be processed is initialized to an empty instruction. The descendant nodes of this root node correspond to the instruction string sets of the tree structure corresponding to each graphic to be processed. A list of child nodes is defined for this root node, which includes the root node of the instruction string set of the tree structure corresponding to each graphic to be processed. For example, a list of child nodes named "children" is defined for the root node of the instruction string set of the tree structure corresponding to the workpiece to be processed, where each child node "child" in the list of child nodes is the root node of the instruction string set of the tree structure corresponding to each graphic to be processed.
[0055] This method uses the tree-structured instruction string set corresponding to each graphic to be processed as a subtree of the tree-structured instruction string set corresponding to the workpiece to be processed, establishing a connection between the instruction string sets corresponding to different graphics to be processed. This facilitates a clear description of the graphics to be processed included in the workpiece. By constructing a tree structure, the situation of the instruction string set corresponding to each graphic to be processed can be clearly defined, making it easier to maintain and modify the instruction string sets corresponding to different graphics, as well as the CNC machining programs corresponding to different graphics.
[0056] Optionally, generating a CNC machining program capable of machining the workpiece based on the instruction string set corresponding to the workpiece to be machined includes: using a pre-order traversal method to traverse the tree-structured instruction string set corresponding to the workpiece to be machined, and generating a CNC machining program capable of machining the workpiece to be machined.
[0057] For example, the root node of the instruction string set of the tree structure corresponding to the workpiece to be processed is first accessed, and then each subtree is accessed in turn to output the corresponding instruction strings in turn, thereby generating a CNC machining program that can process the workpiece to be processed.
[0058] For example, using a pre-root traversal method, all child nodes (children) of the root node's child list (children) of the instruction string set corresponding to the tree structure of the workpiece to be processed are traversed, and the corresponding instruction strings are output. Then, the instruction strings corresponding to all descendant nodes of child are output in the same way. Descendant nodes include the child nodes, grandchild nodes, and lower-level nodes of child. After traversing all nodes corresponding to a child node, a CNC machining program for one workpiece to be processed is generated. Similarly, after traversing all child nodes (children) of the child list (children), CNC machining programs for all workpieces to be processed are generated, thus generating the CNC machining program for each workpiece.
[0059] This method can generate CNC machining programs corresponding to the workpieces to be machined, based on the graphic to be machined, thereby improving the readability of the CNC machining programs and reducing the difficulty of maintenance; at the same time, it can reduce the error rate and improve the accuracy of the CNC machining programs.
[0060] The generated CNC machining program can be saved as a .nc file. The CNC machine tool loads and runs this file to complete the machining of the graphic or workpiece. In some exemplary embodiments, the generated CNC machining program is applied to an electrical discharge wire cutting machine, or other types of CNC machine tools. The specific instruction formats may differ for different CNC machine tools; the specific instructions should be adjusted according to the specific CNC machine tool.
[0061] The CNC machining program generation method provided in this application determines at least one first instruction string corresponding to the workpiece to be machined based on the shape parameters of any workpiece to be machined and the process parameters corresponding to the workpiece to be machined; obtains machining parameters from a preset machining parameter library based on the process parameters corresponding to the workpiece to be machined, and determines at least one second instruction string corresponding to the workpiece to be machined based on the obtained machining parameters; constructs an instruction string set corresponding to the workpiece to be machined based on the machining process corresponding to the workpiece to be machined, according to at least one first instruction string and at least one second instruction string; and generates a CNC machining program based on the instruction string set corresponding to the workpiece to be machined. This method can clearly describe the hierarchical relationship between instruction strings within the CNC machining program, improving the readability, scalability, flexibility, and accuracy of the CNC machining program, and reducing maintenance difficulty; at the same time, it effectively improves programming efficiency and better meets the more complex and flexible machining needs in the field of CNC machine tool processing.
[0062] Furthermore, optionally, based on the above embodiments, the CNC machining program generation method provided in this application further includes: displaying the instruction string set corresponding to the graphic to be machined through an interactive interface; and modifying the instruction string set corresponding to the graphic to be machined in response to a modification instruction input by the user.
[0063] Understandably, when a workpiece corresponds to multiple workpieces, the instruction string set corresponding to each workpiece can be displayed through the interactive interface; in response to the user's input modification command, the instruction string set corresponding to any workpiece can be modified.
[0064] It is easy to understand that when a workpiece corresponds to multiple graphics to be processed, the set of instruction strings corresponding to each graphic to be processed is the set of instruction strings corresponding to the workpiece.
[0065] For example, the instruction string set can be displayed in a tree structure or a tree list structure through an interactive interface.
[0066] For example, users can input modification commands by clicking to trigger, and there are no restrictions on the specific input method.
[0067] User-inputted modification commands can include deletion, insertion, creation, and editing. Users can modify the command string set by inputting the corresponding commands. Users can also save or preview the current command string set by inputting commands.
[0068] For example, Figure 2 This is a schematic diagram of a display interface provided in an embodiment of this application. The display interface shows the instruction string sets corresponding to the two graphics to be processed of the workpiece in a tree list structure. The CNC machining program for the workpiece is a .nc file. Users can modify the instruction string sets by clicking delete, insert, create, edit, etc., and inputting corresponding modification commands. Users can also save or preview the current instruction string set by inputting save or preview commands.
[0069] A graphical interface can improve the readability of CNC machining programs and enhance the user experience. Users can flexibly combine different instruction strings, easily add, delete, or replace instruction strings, and add new strings without modifying the original program. Different instruction string sets can be dynamically customized to meet different machining needs, and the maintainability of CNC machining programs can be improved while ensuring code quality.
[0070] For ease of understanding, this application also provides a specific example. Figure 3 A schematic diagram of a tree-structured instruction string set corresponding to a graphic to be processed, provided in an embodiment of this application, is shown below. Figure 4 As shown, the graphic to be processed is a square, and its shape parameters include the coordinates of each vertex, which are (0,0), (0,10000), (10000,10000), and (10000,0). The process parameters include: separation length 500, temporary allowance 300, and number of cuts 2.
[0071] Figure 3The first instruction string in the example shown includes: G00X+0Y-3000, G01X+0Y-500, G01X+0Y+0, G01X+0Y+10000, G01X+10000Y+10000, G01X+10000Y+0, G01X+3000Y+0, G01X+3000Y-500, G01X+3000Y+0, G01X+10000Y+0, G01X+10000Y+10000, G01X+0Y+10000, G01X+0Y+0, G01X+0Y-500, G01X+0Y+0, G01X+3000Y+0, G01X+3000Y-500, and M02.
[0072] The second instruction string includes: N0001, E0120 = 030 100 01 0 06 000 3 00, E0121 = 032112 01 0 06 000 3 00, E0122 = 008 030 02 0 04 000 1 00, T84 T86—T85 T87, E0120, E0121, E0122, E0120, E0121, G41H001, G41H000, G41H002, G41H000, G41H000, G41H007 and G41H000. It should be noted that E0120 = 030 100 01 0 06 000 3 00, E0121 = 032 112 01 0 06000 3 00, and E0122 = 008 030 02 0 04 000 1 00 are a second instruction string in multi-line format.
[0073] based on Figure 3 The generated CNC machining program includes:
[0074] N0001
[0075] E0120 = 032 112 01 0 06 000 3 00
[0076] E0121 = 032 112 01 0 06 000 3 00
[0077] E0122 = 008 030 02 0 04 000 1 00
[0078] T84 T86
[0079] G00X+0Y-3000
[0080] E0120
[0081] G01X+0Y-500
[0082] E0121
[0083] G41H000
[0084] G01X+0Y+0
[0085] G41H001
[0086] G01X+0Y+10000
[0087] G01X+10000Y+10000
[0088] G01X+10000Y+0
[0089] G01X+3000Y+0
[0090] G40H000
[0091] G01X+3000Y-500
[0092] E0122
[0093] G42H000
[0094] G01X+3000Y+0
[0095] G42H002
[0096] G01X+10000Y+0
[0097] G01X+10000Y+10000
[0098] G01X+0Y+10000
[0099] G01X+0Y+0
[0100] G40H000
[0101] G01X+0Y-500
[0102] E0120
[0103] G42H000
[0104] G01X+0Y+0
[0105] E0121
[0106] G42H007
[0107] G01X+3000Y+0
[0108] G40H000
[0109] G01X+3000Y-500
[0110] T85 T87
[0111] M02
[0112] In the above CNC machining program, T84 indicates the coolant pump is on, T85 indicates the coolant pump is off, T86 indicates the wire feed is started, and T87 indicates the high-pressure jet is off. That is, instruction strings T84 T86 and T85 T87 can appear in pairs. Instruction strings T84 T86 and T85 T87 can be treated as two nodes. To simplify the tree structure and further improve its readability, it can also be... Figure 3 As shown, T84 and T86 are set to correspond to the same node as T85 and T87. Specifically, T84 and T86 can be set as the start string of this node, and T85 and T87 can be set as the end string of this node. When traversing the instruction string set of the tree structure, the start string is output on the first traversal of this node, and the end string is output after all nodes have been traversed. It can be understood that this method is not limited to instruction strings T84 and T86 and instruction strings T85 and T87, but is also applicable to other paired instruction strings.
[0113] This application also provides an electronic device, including a processor, a communication interface, a memory, and a communication bus, wherein the processor, the communication interface, and the memory communicate with each other through the communication bus; the memory is used to store computer programs.
[0114] When a processor executes a program stored in memory, it implements any of the methods provided in the above-described method embodiments.
[0115] This application also provides a computer-readable storage medium storing a computer program, which, when executed by a processor, implements any of the methods provided in the above-described method embodiments.
[0116] It will be understood by those skilled in the art that all or some of the steps, systems, or apparatuses disclosed above, and their functional modules / units, can be implemented as software, firmware, hardware, or suitable combinations thereof. In hardware implementations, the division between functional modules / units mentioned above does not necessarily correspond to the division of physical components; for example, a physical component may have multiple functions, or a function or step may be performed collaboratively by several physical components. Some or all components may be implemented as software executed by a processor, such as a digital signal processor or microprocessor, or as hardware, or as an integrated circuit, such as an application-specific integrated circuit (ASIC). Such software may be distributed on a computer-readable medium, which may include computer storage media (or non-transitory media) and communication media (or transient media). As is known to those skilled in the art, the term computer storage media includes volatile and non-volatile, removable and non-removable media implemented in any method or technology for storing information (such as computer-readable instructions, data structures, program modules, or other data). Computer storage media include, but are not limited to, RAM, ROM, EEPROM, flash memory or other memory technologies, CD-ROM, digital versatile disc (DVD) or other optical disc storage, magnetic cartridges, magnetic tape, disk storage or other magnetic storage devices, or any other medium that can be used to store desired information and can be accessed by a computer. Furthermore, it is well known to those skilled in the art that communication media typically contain computer-readable instructions, data structures, program modules, or other data in modulated data signals such as carrier waves or other transmission mechanisms, and may include any information delivery medium.
Claims
1. A method of generating a numerical control machining program, characterized by, include: Based on the shape parameters of any graphic to be processed corresponding to the workpiece to be processed and the process parameters corresponding to the graphic to be processed, at least one first instruction string corresponding to the graphic to be processed is determined; Based on the process parameters corresponding to the graphic to be processed, the processing parameters are obtained from a preset processing parameter library, and at least one second instruction string corresponding to the graphic to be processed is determined based on the obtained processing parameters. Based on the processing flow corresponding to the graphic to be processed, an instruction string set corresponding to the graphic to be processed is constructed according to at least one first instruction string and at least one second instruction string corresponding to the graphic to be processed; A CNC machining program is generated based on the instruction string set corresponding to the graphic to be processed.
2. The method of claim 1, wherein, The step of constructing an instruction string set corresponding to the graphic to be processed, based on the processing flow corresponding to the graphic to be processed and according to at least one first instruction string and at least one second instruction string corresponding to the graphic to be processed, includes: Based on the processing flow corresponding to the graphic to be processed, a tree-structured instruction string set corresponding to the graphic to be processed is constructed, with at least one first instruction string corresponding to the graphic to be processed as a leaf node and at least one second instruction string corresponding to the graphic to be processed as a non-leaf node.
3. The method of claim 1, wherein, The method further includes: The set of instruction strings corresponding to the graphic to be processed is displayed through an interactive interface; In response to a user-inputted modification command, the instruction string set corresponding to the graphic to be processed is modified.
4. The method according to claim 1, characterized in that, The first instruction string includes at least one of the following: an instruction string corresponding to a motion-related G instruction, and an instruction string corresponding to a motion-related M instruction; The second instruction string includes at least one of the following: the instruction string corresponding to the H instruction, the instruction string corresponding to the T instruction, the instruction string corresponding to the N instruction, the instruction string corresponding to the E instruction, and the instruction string corresponding to the G instruction related to compensation.
5. The method according to any of claims 2-4, characterized by, The workpiece to be processed corresponds to multiple drawings to be processed, and the generation of the CNC machining program based on the instruction string set corresponding to the drawings to be processed includes: Based on the tree-structured instruction string set corresponding to each of the graphics to be processed, construct the tree-structured instruction string set corresponding to the workpiece to be processed; Based on the tree-structured instruction string set corresponding to the workpiece to be processed, a CNC machining program capable of processing the workpiece is generated.
6. The method of claim 5, wherein, The step of constructing a tree-structured instruction string set corresponding to the workpiece to be processed based on the tree-structured instruction string set corresponding to each of the graphics to be processed includes: An empty instruction is set as the root node of the instruction string set of the tree structure corresponding to the workpiece to be processed, and the child nodes of the root node are set as the root nodes of the instruction string set of the tree structure corresponding to each of the graphics to be processed. Based on the instruction string set of the tree structure corresponding to each of the graphics to be processed, the instruction string set of the tree structure corresponding to the workpiece to be processed is constructed.
7. The method according to any one of claims 2-4, characterized in that, The step of generating a CNC machining program based on the instruction string set corresponding to the graphic to be processed includes: The method of first-order traversal is used to traverse the tree-structured instruction string set corresponding to the graphic to be processed, and generate a CNC machining program that can process the graphic to be processed.
8. The method according to claim 5, characterized in that, The step of generating a CNC machining program capable of machining the workpiece based on the instruction string set corresponding to the workpiece to be machined includes: The method of first-order traversal is used to traverse the tree-structured instruction string set corresponding to the workpiece to be processed, and generate a CNC machining program that can process the workpiece to be processed.
9. An electronic device, characterized in that, include: One or more processors; Storage device for storing one or more programs. When the one or more programs are executed by the one or more processors, the one or more processors implement the method for generating CNC machining programs as described in any one of claims 1-8.
10. A computer storage medium, characterized in that, The storage medium stores a computer program, wherein the computer program is configured to execute, when running, the method for generating a CNC machining program as described in any one of claims 1-8.