Disclosure of Invention
The invention provides a machining simulation method, terminal equipment and a computer-readable storage medium, aiming at the defects that different G codes require different 3D demonstration terminals to analyze and simulate machining instructions represented by the G codes and a 3D demonstration terminal capable of integrating multiple G codes for machining simulation does not exist.
A first aspect of an embodiment of the present invention provides a machining simulation method, including:
carrying out syntax check on the original G code by referring to a preset format;
if the checking result of the grammar checking is correct, the original G code is interpreted to generate an action event list; if the G code is wrong, the original G code is changed according to a preset format, and grammar check is repeatedly carried out until a check result is correct;
and matching corresponding action events from the action event list according to the triggered actions, and sending the action events obtained by matching to a simulation end for model processing demonstration.
Further, before syntax checking is performed on the original G code with reference to a preset format, the method includes:
the original G code is received and saved.
Further, the original G code is interpreted to generate an action event list, which includes:
interpreting the original G code to generate a plurality of action events;
a number of action events are placed into the event manager in the order of occurrence of the events.
Further, the action event obtained by matching is sent to a simulation end for model processing demonstration, and the method comprises the following steps:
processing the three-dimensional coordinate points of the cutter to form a cutter height map;
processing the three-dimensional coordinate points of the workpiece prototype to form a workpiece prototype height map;
projecting the tool height map onto the workpiece prototype height map to form a deformed workpiece height map;
and generating a deformed workpiece according to the height map of the deformed workpiece and demonstrating the deformed workpiece.
Further, after the corresponding action event is matched from the action event list according to the triggered action and the matched action event is sent to the simulation terminal for demonstration, the method comprises the following steps:
and coloring the surface of the model for demonstration by the simulation end.
A second aspect of an embodiment of the present invention provides a machining simulation apparatus, including:
the checking module is used for checking the grammar of the original G code according to a preset format;
the generating module is used for judging whether the checking result of the grammar checking is correct or not, interpreting the original G code and then generating an action event list; if the G code is wrong, the original G code is changed according to a preset format, and grammar check is repeatedly carried out until a check result is correct;
and the machining demonstration module is used for matching corresponding action events from the action event list according to the triggered actions and sending the action events obtained by matching to the simulation end for model machining demonstration.
Further, the generating module specifically includes:
the interpretation unit is used for interpreting the original G code to generate a plurality of action events;
and the placing unit is used for placing a plurality of action events into the event manager according to the occurrence sequence of the events.
Further, the apparatus further comprises:
and the coloring module is used for coloring the surface of the model which is demonstrated by the simulation end.
A third aspect of an embodiment of the present invention provides a machining simulation terminal device, including a memory, a processor, and a computer program stored in the memory and executable on the processor, where the processor implements the following steps when executing the computer program:
carrying out syntax check on the original G code by referring to a preset format;
if the checking result of the grammar checking is correct, the original G code is interpreted to generate an action event list; if the G code is wrong, the original G code is changed according to a preset format, and grammar check is repeatedly carried out until a check result is correct;
and matching corresponding action events from the action event list according to the triggered actions, and sending the action events obtained by matching to a simulation end for model processing demonstration.
A fourth aspect of an embodiment of the present invention provides a computer-readable storage medium for machining simulation, where a computer program is stored, and when the computer program is executed by a processor, the computer program implements the following steps:
carrying out syntax check on the original G code by referring to a preset format;
if the checking result of the grammar checking is correct, the original G code is interpreted to generate an action event list; if the G code is wrong, the original G code is changed according to a preset format, and grammar check is repeatedly carried out until a check result is correct;
and matching corresponding action events from the action event list according to the triggered actions, and sending the action events obtained by matching to a simulation end for model processing demonstration.
Compared with the prior art, the embodiment of the invention has the following beneficial effects: according to the invention, the G codes with different formats are changed into the G code format with a uniform format, and the G codes are output to the 3D simulation end for processing demonstration, so that the compatibility of the 3D simulation end is enhanced, different source G codes can be conveniently input into the 3D simulation end to check the processing process of the workpiece, and the cost for configuring different source equipment is reduced.
Detailed Description
In the following description, for purposes of explanation and not limitation, specific details are set forth, such as particular system structures, techniques, etc. in order to provide a thorough understanding of the embodiments of the invention. It will be apparent, however, to one skilled in the art that the present invention may be practiced in other embodiments that depart from these specific details. In other instances, detailed descriptions of well-known systems, devices, circuits, and methods are omitted so as not to obscure the description of the present invention with unnecessary detail.
In order to explain the technical means of the present invention, the following description will be given by way of specific examples.
FIG. 1 is a schematic flow chart illustrating an implementation of a method for machining simulation according to an embodiment of the present invention; FIG. 2 is a system architecture diagram of the method of machining simulation provided in FIG. 1; FIG. 3 is a scenario application flow diagram of the method of machining simulation provided in FIG. 1. As shown in fig. 1 to fig. 3, an execution subject of the present embodiment is a 3D demonstration terminal, and the machining simulation method provided by the present embodiment may include:
101. carrying out syntax check on the original G code by referring to a preset format;
specifically, the original G code needs to be received and saved first before syntax checking with reference to a preset format is performed on the original G code. The original G code saved here is different source G code developed by various manufacturers on the market. The preset format is a unified format for storing the G code specified by the presentation terminal, for example, the G code is deleted with irrelevant information such as blank line, space, comment, start mark, end mark, etc., and only keyword information is left. The preset format is not limited herein.
It should be noted that there are many 3D presentation terminals on the market, and the description is given by taking unity3D as the 3D presentation terminal in this embodiment.
102. If the checking result of the grammar checking is correct, the original G code is interpreted to generate an action event list; if the G code is wrong, the original G code is changed according to a preset format, and grammar check is repeatedly carried out until a check result is correct;
specifically, the generating of the action event list after the original G code is interpreted includes: interpreting the original G code to generate a plurality of action events; a number of action events are placed into the event manager in the order of occurrence of the events. Further, a cnc (computer numerical control) numerical control system is an abbreviation of a numerical control system, executes a part or all of numerical control functions according to a control program stored in a computer memory, and is provided with a dedicated computer system of an interface circuit and a servo drive device. The G code may be compiled in a CNC code compiler. In this embodiment, the CNC code compiler is packaged as a DLL file and embedded in a script code editor of U3D (Universal 3D graphics format). The format of the input original G code is determined by calling a syntax checking function in the CNC code compiler.
If the format is judged to be wrong, the input original G code format is not consistent with the preset format, and the format is judged again after the format is required to be changed into the format specified by the preset format. If the format is judged to be correct, the input original G code has no grammar and logic errors, and then the G code is read line by line in a new file. The G code in the new file is processed standard G code referring to a preset format, and irrelevant information such as blank lines, spaces, comments, start marks, end marks and the like is deleted. After each line of processed G code is transmitted to a CNC code compiler, the compiler interprets and translates the G code and finally delivers the G code to a U3D demonstration terminal in the form of an event list.
Further, each line of G code may be translated into multiple instructions that are placed into the event manager in the order in which the actions occur. After the translation is completed, the CNC code compiler automatically triggers the first instruction, and the action corresponding to the instruction is implemented in the U3D interface (if the action instruction exists in U3D). After the action is completed, U3D takes over the event manager, triggers the next instruction and implements its action or function, and so on until all events and instructions are completed. And then sending the next line of G codes to a CNC code compiler, and repeating the process until all the G codes are processed and stored in a preset format.
103. And matching corresponding action events from the action event list according to the triggered actions, and sending the action events obtained by matching to a simulation end for model processing demonstration.
Specifically, the working actions of the simulation end in model processing demonstration are shown in the following table:
the deformation process of the workpiece is demonstrated, and a tool for cutting the workpiece is selected. The cutting tool is a tool used for cutting in machine manufacturing, and is also called as a cutting tool. Most knives are machine-operated and also hand-operated. Since tools used in machine manufacturing are basically used for cutting metal materials, the term "tool" is generally understood to mean a metal cutting tool. The types of the cutters are various, and the proper cutters are selected according to the machining shapes of the parts.
Further, the action event obtained by matching is sent to a simulation end for model processing demonstration, and the method comprises the following steps: processing the three-dimensional coordinate points of the cutter to form a cutter height map; processing the three-dimensional coordinate points of the workpiece prototype to form a workpiece prototype height map; projecting the tool height map onto the workpiece prototype height map to form a deformed workpiece height map; and generating a deformed workpiece according to the height map of the deformed workpiece and demonstrating the deformed workpiece. And further, extracting three-dimensional coordinate points of the cutter, and projecting the cutter onto a virtual plane by methods of invalid elimination, position conversion, scaling conversion, rotating set points and the like to form a cutter height map. And generating a dynamic workpiece prototype height map by using the three-dimensional coordinate points of the workpiece prototype, and setting the normal of the workpiece prototype and the coordinates of the literary sketch. And the subsequent workpiece deformation operation projects the cutter height map onto the workpiece height map, a new deformed workpiece height map is formed through height conversion, and a new deformed workpiece is formed through the deformed workpiece height map. Wherein, the process of deforming the workpiece comprises the whole process that the blank workpiece is regularly cut and gradually becomes a part in the machining and cutting process.
It should be understood that, the sequence numbers of the steps in the foregoing embodiments do not imply an execution sequence, and the execution sequence of each process should be determined by its function and inherent logic, and should not constitute any limitation to the implementation process of the embodiments of the present invention.
The method provided by the embodiment can be seen that the method changes the G codes with different formats into the G code format with a uniform format and outputs the G codes to the 3D simulation end for processing demonstration, so that the compatibility of the 3D simulation end is enhanced, different source G codes can be conveniently input into the 3D simulation end to check the processing process of the workpiece, and the cost for configuring different source equipment is reduced.
FIG. 4 is a schematic flow chart illustrating an implementation of a method for machining simulation according to another embodiment of the present invention; as shown in fig. 4, the execution subject in this embodiment is a 3D demonstration terminal, and after the action event provided in this embodiment is matched with the corresponding action event from the action event list according to the triggered action and the matched action event is sent to the simulation end for demonstration, the method may further include:
401. and coloring the surface of the model for demonstration by the simulation end.
Specifically, the contour of the workpiece after deformation is not obvious, and the actual effect is difficult to be highlighted. In this case, a color separation means is used to generate a texture with a bright color profile by the height difference of each coordinate point in the height map of the deformed workpiece, and the texture is attached to the deformed workpiece.
Compared with the previous embodiment, the present embodiment can clearly observe the deformation effect of the actual workpiece by adding the surface texture to the workpiece.
It should be understood that, the sequence numbers of the steps in the foregoing embodiments do not imply an execution sequence, and the execution sequence of each process should be determined by its function and inherent logic, and should not constitute any limitation to the implementation process of the embodiments of the present invention.
FIG. 5 is a schematic block diagram of an apparatus for process simulation provided by an embodiment of the present invention; as shown in fig. 5, the execution subject of the present embodiment is a 3D demonstration terminal, and the apparatus for machining simulation provided by the present embodiment may include:
a checking module 51, configured to perform syntax checking on the original G code with reference to a preset format;
the generating module 52 is configured to interpret the original G code and generate an action event list if the checking result of the syntax checking is correct; if the G code is wrong, the original G code is changed according to a preset format, and grammar check is repeatedly carried out until a check result is correct;
and the machining demonstration module 53 is configured to match a corresponding action event from the action event list according to the triggered action, and send the action event obtained through matching to the simulation end for model machining demonstration.
It should be noted that, since each module in the system provided in the embodiment of the present invention is based on the same concept as that of the embodiment of the method of the present invention, the technical effect brought by the embodiment of the method of the present invention is the same as that of the embodiment of the method of the present invention, and specific contents may be referred to the description in the embodiment of the method of the present invention, and are not described herein again.
The device provided by the embodiment also shows that the invention changes the G codes with different formats into the G code format with a uniform format and outputs the G codes to the 3D simulation end for processing demonstration, thereby enhancing the compatibility of the 3D simulation end, facilitating the input of different source G codes into the 3D simulation end to check the processing process of the workpiece and reducing the cost for configuring different source equipment.
Fig. 6 is a schematic diagram of a terminal device for machining simulation according to an embodiment of the present invention. As shown in fig. 6, the terminal device 6 of the machining simulation of this embodiment includes: a processor 60, a memory 61 and a computer program 62 stored in the memory 61 and executable on the processor 60, such as a computer program for implementing a method of machining simulation. The processor 60, when executing the computer program 62, implements the steps in the various method embodiments of the machining simulation described above, such as the steps 101-104 shown in FIG. 1. Alternatively, the processor 60, when executing the computer program 62, implements the functions of the various modules/units in the above-described apparatus embodiments, such as the functions of the modules 51 to 54 shown in fig. 5.
The invention proposes a computer program 62 for implementing a method of machining simulation, comprising: carrying out syntax check on the original G code by referring to a preset format; if the checking result of the grammar checking is correct, the original G code is interpreted to generate an action event list; if the G code is wrong, the original G code is changed according to a preset format, and grammar check is repeatedly carried out until a check result is correct; and matching corresponding action events from the action event list according to the triggered actions, and sending the action events obtained by matching to a simulation end for model processing demonstration. The computer program 62 may be divided into one or more modules/units, which are stored in the memory 61 and executed by the processor 60 to implement the present invention. One or more of the modules/units may be a series of computer program instruction segments capable of performing specific functions, which are used to describe the execution of the computer program 62 in the terminal device 6 for machining simulation. For example, the computer program 62 may be divided into a synchronization module, a summarization module, an acquisition module, and a return module (a module in a virtual device), each of which functions specifically as follows:
the terminal device 6 for processing simulation may be a desktop computer, a notebook, a palm computer, a cloud server, or other computing devices. The terminal equipment for machining simulation may include, but is not limited to, a processor 60, and a memory 61. Those skilled in the art will appreciate that fig. 6 is merely an example of the process simulation terminal device 6 and does not constitute a limitation of the process simulation terminal device 6 and may include more or fewer components than shown, or some components in combination, or different components, e.g., the process simulation terminal device 6 may also include input-output devices, network access devices, buses, etc.
The Processor 60 may be a Central Processing Unit (CPU), other general purpose Processor, a Digital Signal Processor (DSP), an Application Specific Integrated Circuit (ASIC), an off-the-shelf Programmable Gate Array (FPGA) or other Programmable logic device, discrete Gate or transistor logic, discrete hardware components, etc. A general purpose processor may be a microprocessor or the processor may be any conventional processor or the like.
The memory 61 may be an internal storage unit of the machining simulation terminal device 6, such as a hard disk or a memory of the machining simulation terminal device 6. The memory 61 may also be an external storage device of the simulation terminal device 6, such as a plug-in hard disk, a Smart Media Card (SMC), a Secure Digital (SD) Card, a Flash memory Card (Flash Card), and the like, which are provided on the simulation terminal device 6. Further, the memory 61 may also include both an internal storage unit and an external storage device of the machining simulation terminal device 6. The memory 61 is used to store computer programs and other programs and data required for processing the simulated terminal device 6. The memory 61 may also be used to temporarily store data that has been output or is to be output.
It will be apparent to those skilled in the art that, for convenience and brevity of description, only the above-mentioned division of the functional units and modules is illustrated, and in practical applications, the above-mentioned function distribution may be performed by different functional units and modules according to needs, that is, the internal structure of the apparatus is divided into different functional units or modules, so as to perform all or part of the functions described above. Each functional unit and module in the embodiments may be integrated in one processing unit, or each unit may exist alone physically, or two or more units are integrated in one unit, and the integrated unit may be implemented in a form of hardware, or in a form of software functional unit. In addition, specific names of the functional units and modules are only for convenience of distinguishing from each other, and are not used for limiting the protection scope of the present application. The specific working processes of the units and modules in the system may refer to the corresponding processes in the foregoing method embodiments, and are not described herein again.
In the above embodiments, the descriptions of the respective embodiments have respective emphasis, and reference may be made to the related descriptions of other embodiments for parts that are not described or illustrated in a certain embodiment.
Those of ordinary skill in the art will appreciate that the various illustrative elements and algorithm steps described in connection with the embodiments disclosed herein may be implemented as electronic hardware or combinations of computer software and electronic hardware. Whether such functionality is implemented as hardware or software depends upon the particular application and design constraints imposed on the implementation. Skilled artisans may implement the described functionality in varying ways for each particular application, but such implementation decisions should not be interpreted as causing a departure from the scope of the present invention.
In the embodiments provided in the present invention, it should be understood that the disclosed apparatus/terminal device and method may be implemented in other ways. For example, the above-described embodiments of the apparatus/terminal device are merely illustrative, and for example, a module or a unit may be divided into only one logical function, and may be implemented in other ways, for example, a plurality of units or components may be combined or integrated into another system, or some features may be omitted or not executed. In addition, the shown or discussed mutual coupling or direct coupling or communication connection may be an indirect coupling or communication connection through some interfaces, devices or units, and may be in an electrical, mechanical or other form.
Units described as separate parts may or may not be physically separate, and parts displayed as units may or may not be physical units, may be located in one place, or may be distributed on a plurality of network units. Some or all of the units can be selected according to actual needs to achieve the purpose of the solution of the embodiment.
In addition, functional units in the embodiments of the present invention may be integrated into one processing unit, or each unit may exist alone physically, or two or more units are integrated into one unit. The integrated unit can be realized in a form of hardware, and can also be realized in a form of a software functional unit.
The integrated modules/units, if implemented in the form of software functional units and sold or used as separate products, may be stored in a computer readable storage medium. Based on such understanding, all or part of the flow in the method according to the embodiments of the present invention may also be implemented by a computer program to instruct related hardware, where the computer program may be stored in a computer readable storage medium, and when the computer program is executed by a processor, the computer program may implement the steps of the embodiments of the method. Wherein the computer program comprises computer program code, which may be in the form of source code, object code, an executable file or some intermediate form, etc. The computer readable medium may include: any entity or device capable of carrying computer program code, recording medium, U-disk, removable hard disk, magnetic disk, optical disk, computer Memory, Read-Only Memory (ROM), random-access Memory (RAM), electrical carrier wave signals, telecommunications signals, software distribution media, and the like. It should be noted that the computer readable medium may contain other components which may be suitably increased or decreased as required by legislation and patent practice in jurisdictions, for example, in some jurisdictions, in accordance with legislation and patent practice, the computer readable medium does not include electrical carrier signals and telecommunications signals.
The above examples are only intended to illustrate the technical solution of the present invention, but not to limit it; although the present invention has been described in detail with reference to the foregoing embodiments, it will be understood by those of ordinary skill in the art that: the technical solutions described in the foregoing embodiments may still be modified, or some technical features may be equivalently replaced; such modifications and substitutions do not substantially depart from the spirit and scope of the embodiments of the present invention, and are intended to be included within the scope of the present invention.