CN108845804A - A kind of design method of the NC code interpreter based on CYCLE circulation - Google Patents
A kind of design method of the NC code interpreter based on CYCLE circulation Download PDFInfo
- Publication number
- CN108845804A CN108845804A CN201711410879.7A CN201711410879A CN108845804A CN 108845804 A CN108845804 A CN 108845804A CN 201711410879 A CN201711410879 A CN 201711410879A CN 108845804 A CN108845804 A CN 108845804A
- Authority
- CN
- China
- Prior art keywords
- code
- instruction
- analysis
- cycle
- design method
- Prior art date
- Legal status (The legal status is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the status listed.)
- Pending
Links
Classifications
-
- G—PHYSICS
- G06—COMPUTING; CALCULATING OR COUNTING
- G06F—ELECTRIC DIGITAL DATA PROCESSING
- G06F8/00—Arrangements for software engineering
- G06F8/40—Transformation of program code
- G06F8/41—Compilation
- G06F8/43—Checking; Contextual analysis
-
- G—PHYSICS
- G06—COMPUTING; CALCULATING OR COUNTING
- G06F—ELECTRIC DIGITAL DATA PROCESSING
- G06F8/00—Arrangements for software engineering
- G06F8/40—Transformation of program code
- G06F8/41—Compilation
- G06F8/42—Syntactic analysis
Landscapes
- Engineering & Computer Science (AREA)
- General Engineering & Computer Science (AREA)
- Theoretical Computer Science (AREA)
- Software Systems (AREA)
- Physics & Mathematics (AREA)
- General Physics & Mathematics (AREA)
- Numerical Control (AREA)
Abstract
The present invention discloses a kind of design method of NC code interpreter based on CYCLE circulation, and for fields of numeric control technique, numerical control interpreter can check whether NC code is correct and provide for analogue system being capable of identified machine tool motion information.The invention proposes a kind of design methods of NC code interpreter based on CYCLE circulation, morphology and syntactic analysis are carried out to numerical control code by regular expression rule base, check the integrality of code and the reasonability of collocation, CYCLE recursion instruction is decomposed by numerical control elementary instruction by semantic module again, Tool in Cutting route is planned simultaneously, generates the machine tool motion information intermediate file that can be simulated software identification.Design method of the present invention compared with other numerical control interpreters, morphology with higher, syntactic analysis efficiency, while eliminating and parsing mistake caused by grammatical ambiguity, and complicated CYCLE recursion instruction can be decomposed into the simple intermediate file form of structure.
Description
Technical field
The invention belongs to fields of numeric control technique, in particular to a kind of NC code interpreter based on CYCLE circulation to set
Meter method.
Background technique
In Numerical Control Machining Simulation, computer can not obtain machine tool motion information directly from numerical control program, it is necessary to have phase
The module answered serves as the role of interpreter, and machine tool motion information is extracted from numerical control program, it is identifiable to be converted into computer
Intermediate data structure, then computer drives the movement of machine tool component by reading intermediate data structure, to realize processing
The progress of emulation.But from the point of view of numerical control NC both domestic and external explains decoding technique at present, parser is more complex and the text of definition
Regulation is then complicated, and the intermediate data structure extracted is relatively simple, it is also necessary to which emulation module is further processed.
Although the design multiplicity of NC code interpretative device, its final purpose are provided to precheck from syntax rule
The correctness of NC code and the intermediate data structure that can identify NC code conversion for computer, to carry out machining simulation.This
Invention proposes a kind of design method of NC code interpreter based on CYCLE circulation, by utilizing designed canonical table
Morphology and syntactic analysis are carried out up to formula rule base and complicated CYCLE recursion instruction is decomposed into numerical control elementary instruction, the syntax
Simple in rule, Tool in Cutting intermediate data structure is reasonable, occupies little space.
Summary of the invention
The purpose of the present invention is to provide a kind of design methods of NC code interpreter based on CYCLE circulation, realize
The high efficiency of NC code interpreter in Numerical Control Machining Simulation, avoids the ambiguity for explaining the syntax.The skill that the present invention uses
Art scheme is:Regular expression rule base is constructed according to machining code coding line first;Then morphological analysis is carried out, according to reading
Machining Instruction word rule searching library in code, analyzes the legitimacy and numerical limitations of character in NC code, analysis
It is correct then carry out the syntactic analysis phase;Syntax Analysis Module reading output information from the output of Lexical Analysis Module checks journey
Sequence, the integrality of program segment, and the legitimacy and integrality that each instruction is arranged in pairs or groups are checked using regular expression, correctly then carry out
Semantic module;CYCLE recursion instruction is decomposed into numerical control elementary instruction by semantic module, and is determined by loop parameter
Tool in Cutting route in processing generates the intermediate data structure that analogue system can identify.
Advantages of the present invention has:
The invention proposes a kind of design methods of NC code interpreter based on CYCLE recursion instruction.Using canonical
Expression formula carries out morphological analysis and instruction collocation validity checking to the NC code recycled based on CYCLE, and grammar rule is simple, effect
Rate is higher, while can avoid explaining the ambiguity of the syntax.The present invention plans Tool in Cutting track by semantic module, will
CYCLE recursion instruction is decomposed into numerical control elementary instruction, and scalability is good, while the Tool in Cutting intermediate file structure letter generated
List, memory space are small.
Detailed description of the invention
Fig. 1 is NC code interpreter overall execution flow chart of the invention
Fig. 2 is morphological analysis rule classification figure of the present invention
Fig. 3 is morphological analysis flow chart of the present invention
Fig. 4 is syntactic analysis flow chart of the present invention
Fig. 5 is the Path planning schematic diagram of one concrete example of the present invention
Fig. 6 is the outer profile roughing code map of a concrete example of the invention
Specific embodiment
To realize goal of the invention, technical solution and feature is more clearly understood, the present invention is made with reference to the accompanying drawing detailed
It describes in detail bright:Attached drawing 1 is interpreter overall execution flow chart of the invention, and detailed process includes the morphological analysis of NC code, grammer point
Analysis, semantic analysis, specific step is as follows:
1. morphological analysis
Regular expression rule base often is constructed with Machining Instruction according to turning, to rule classification such as Fig. 2.
Morphological analysis detailed process is as follows:
1) row of N C code is read, is directly stored into List if including CYCLE circulation, on the contrary it will by space
It is divided into distinct program word, and stores into List.Such as N10G00G40X50Z50, it can be broken down into "
N10 ", " G00 ", " G40 ", " X50 ", " Z50 " this five program words, and store into List.
2) for the program word decomposited, character is taken out one by one, first determines whether initial character in rule non-CYCLE circulation
It whether there is in library, such as B10, B instruction is in rule base and is not present, therefore morphological analysis malfunctions.If deposited in rule base
Then corresponding regular expression is handled in calling rule library, and having Corresponding matching, then the program word is correct, otherwise morphological analysis
Error.3) postpositive disposal process.By program segment number, such as " N10 ", program segment is reconstructed and is stored into List1;If journey
Existing in sequence section " CYCLE95 " then according to the subprogram segment title in its parameter inquires subprogram segment name when traversing List
After title, program segment it will store into List2 thereafter.
2. syntactic analysis
Syntactic analysis is analyzed primarily directed to program segment, judge the output of morphological analysis whether can constitute one it is legal
Program segment and entire program integrality.
The legitimacy and integrity checking main flow of program segment are as follows:
1) element in list1/list2 is read, whether judgement wherein includes " CYCLE ", if comprising skipping to 2, it is no
Then skip to 3;
2) corresponding regular expression rule is transferred by number after CYCLE to be matched, having return value then indicates correct,
Return to 1;Otherwise syntax error is exported.
3) do not include CYCLE at this time to recycle, then syntax check is from left to right carried out to program segment.It is same that G instruction is carried out first
Group checks that if there is same group of instruction then exports syntax error, such as G01, the instruction such as G02 cannot occur simultaneously in same program section.
4) other instruction recheckings are carried out, such as:X instruction, Z instruction etc.
5) must there are X, Z, CR coding line or I, K instruction after carrying out integrity detection, such as G02 instruction for corresponding instruction
Word indicates center location, the imperfect syntactic analysis error of ELSE instruction.
6) check what whether list1 was checked with M30 ending.
7) if syntactic analysis malfunctions, syntax error is exported;Otherwise, list1 and list2 are exported to semantic analysis mould
Block.
3. the generation of semantic analysis and intermediate file
The module extracts cutter path instruction in NC code, and CYCLE recursion instruction is decomposed into G00, G01, G02, G03
Etc. elementary instructions form, segment and plan its circulating path, generate input of the intermediate file as emulation module
Intermediate file format is defined first, the elementary instruction finally extracted only needs G00, G01, G02, and tetra- kinds of G03
, therefore only need to be defined as 00,01,02,03 in intermediate file;It is subsequent to need to provide in G00 instruction
Two kinds of data of X, Z, G01 need X, Z, F, G02 and G03 to need X, Z, CR or I, K, F.Wherein F instruction can be default.
Now shown in Fig. 5 for part, the process for planning the part outer profile cutting tool path locus is elaborated.It is right
It is as shown in Figure 6 in the machining code of the part outer profile.
Firstly the need of roughing cutter location data are obtained, first parameter recycled by CYCLE95 is available to son
The starting of program segment terminates title, and each outer profile G command status value of subprogram and cutter location coordinate, root are taken out from List2
It is rough machined that outer profile is got according to the method that the allowance for finish of X-axis specified by loop parameter and Z axis uses apex offset
The coordinate data of each cutter location.
Chipping allowance cutter location data are obtained, Tool route is determined according to the cutting depth of X-direction and withdrawing amount and are cut
Cut number.Available to roughing mode by CYCLE loop parameter, the processing method used in general CYCLE circulation is
Parallel to the axis processing method, and the processing method in loop parameter is only used to distinguish thick/essence, inside/outside processing, therefore for Tool route
Planning can carry out as follows:
1) part blank information Xr, Zr are got by subprogram first, subprogram segment code is then successively traversed, by sub- journey
Sequence section code reconstructs roughing contour line equation by allowance for finish, and will originate Z coordinate as key, and profile line segment equation is made
It is stored in for value in LinkedHashMap<Integer,String>In S1, and X-axis to be processed is judged by a token variable
Whether non-increasing is stored to S2, if there is then the part is concave contour to reduce its manufacturing procedure coordinate.Get X-axis
Minimum value, that is, Xmin on direction, then depth to be cut is X=Xr-Xmin, then Tool in Cutting number is T=X/MID, is actually cut
Cutting depth is dx=X/T.
2) cutter path trajectory planning:
A) loop start that tool motion is processed to outer profile;
B) cutter first feeds a cutting depth to X-axis, then along the feeding of Z axis negative direction is parallel to, traverses S1, obtains the
One section of starting X-coordinate value is less than the Eigenvector L of current cutter X-coordinate valuei, friendship is calculated according to the parametric equation of Eigenvector
Point coordinate.
C) L is taken out from S1iAll Eigenvectors later then directly will if it is not yet finished Eigenvector
It is processed in band output intermediate file
D) then cutter moves _ VRT distance to 45 degree of directions of the square first angle of Z axis in a manner of G00, then just to Z axis
Direction moves to point identical with loop start Z coordinate value, repeats ii) step, it is completed until S1 is traversed
E) concave contour processing is then carried out in the same manner, and step is as before.
Planned Tool route figure is as shown in Figure 5 in this example.
Claims (4)
1. a kind of design method of the NC code interpreter based on CYCLE circulation, it is characterised in that:
Lexical Analysis Module carries out morphological analysis to NC code, analyzes the character legitimacy in NC code, if legal
Then carry out syntactic analysis;
Syntax Analysis Module reading output information from the output of Lexical Analysis Module, and syntactic analysis is carried out to it, it examines each
Can instruction form legal program segment, and semantic analysis is carried out if legal;
The output of syntax Analysis Module is carried out Command Resolution by semantic module, plans cutter cutting line, and will walk cutter track
Line information is stored as intermediate file, as the input of analogue system.
2. the design method of the NC code interpreter according to claim 1 based on CYCLE circulation, it is characterised in that:Word
Method analysis module constructs regular expression rule base previously according to machining code coding line, by reading the Machining Instruction in code
Word binding rule library carries out morphological analysis.
3. the design method of the NC code interpreter according to claim 1 based on CYCLE circulation, it is characterised in that:Language
Method analysis module checks the output information of Lexical Analysis Module, first analysis program, program segment integrality as unit of program segment,
Regular expression rule is recycled to carry out instruction collocation legitimacy analysis.
4. the design method of the NC code interpreter according to claim 1 based on CYCLE circulation, it is characterised in that:Language
Adopted analysis module by the way that CYCLE recursion instruction is decomposed into numerical control elementary instruction and determines chipping allowance knife according to parameter in circulation
The data information in site determines Tool in Cutting route in actual processing, generates machine tool motion information intermediate file.
Priority Applications (1)
Application Number | Priority Date | Filing Date | Title |
---|---|---|---|
CN201711410879.7A CN108845804A (en) | 2017-12-23 | 2017-12-23 | A kind of design method of the NC code interpreter based on CYCLE circulation |
Applications Claiming Priority (1)
Application Number | Priority Date | Filing Date | Title |
---|---|---|---|
CN201711410879.7A CN108845804A (en) | 2017-12-23 | 2017-12-23 | A kind of design method of the NC code interpreter based on CYCLE circulation |
Publications (1)
Publication Number | Publication Date |
---|---|
CN108845804A true CN108845804A (en) | 2018-11-20 |
Family
ID=64211735
Family Applications (1)
Application Number | Title | Priority Date | Filing Date |
---|---|---|---|
CN201711410879.7A Pending CN108845804A (en) | 2017-12-23 | 2017-12-23 | A kind of design method of the NC code interpreter based on CYCLE circulation |
Country Status (1)
Country | Link |
---|---|
CN (1) | CN108845804A (en) |
Cited By (2)
Publication number | Priority date | Publication date | Assignee | Title |
---|---|---|---|---|
CN111708525A (en) * | 2020-06-24 | 2020-09-25 | 华中科技大学 | Graphical programming system interpreter based on XML industrial robot |
CN111881266A (en) * | 2019-07-19 | 2020-11-03 | 马上消费金融股份有限公司 | Response method and device |
Citations (2)
Publication number | Priority date | Publication date | Assignee | Title |
---|---|---|---|---|
JPH05337667A (en) * | 1992-06-08 | 1993-12-21 | Mitsubishi Electric Corp | Preparing method for nc program for three-dimensional laser beam machine |
CN101206467A (en) * | 2006-12-22 | 2008-06-25 | 南京理工大学 | Universal numerical control code analysis method |
-
2017
- 2017-12-23 CN CN201711410879.7A patent/CN108845804A/en active Pending
Patent Citations (2)
Publication number | Priority date | Publication date | Assignee | Title |
---|---|---|---|---|
JPH05337667A (en) * | 1992-06-08 | 1993-12-21 | Mitsubishi Electric Corp | Preparing method for nc program for three-dimensional laser beam machine |
CN101206467A (en) * | 2006-12-22 | 2008-06-25 | 南京理工大学 | Universal numerical control code analysis method |
Non-Patent Citations (2)
Title |
---|
伍抗逆: "面向开放式数控系统平台的NC代码解释器开发", 《中国机械工程》 * |
曹胜彬: "微型数控铣床控制系统及NC代码编译算法的研究", 《机械设计与制造》 * |
Cited By (3)
Publication number | Priority date | Publication date | Assignee | Title |
---|---|---|---|---|
CN111881266A (en) * | 2019-07-19 | 2020-11-03 | 马上消费金融股份有限公司 | Response method and device |
CN111708525A (en) * | 2020-06-24 | 2020-09-25 | 华中科技大学 | Graphical programming system interpreter based on XML industrial robot |
CN111708525B (en) * | 2020-06-24 | 2021-07-30 | 华中科技大学 | Graphical programming system interpreter based on XML industrial robot |
Similar Documents
Publication | Publication Date | Title |
---|---|---|
CN101206467B (en) | Universal numerical control code analysis method | |
CN113064586B (en) | Code completion method based on abstract syntax tree augmented graph model | |
CN103123590A (en) | Compiling method from intermediate language (IL) program to C language program of instruction list | |
EP2417498B1 (en) | Method for automatically partitioning a part program into fundamental operations | |
CN101617328A (en) | The automatic configuration method and the device that in problem solving environment, are used for meta-heuristic algorithms | |
US20110093465A1 (en) | Product classification system | |
CN100480916C (en) | Method for establishing digital control system software based on digital control code encoder | |
CN110502227A (en) | The method and device of code completion, storage medium, electronic equipment | |
CN111610744B (en) | Logic control program generation method and system based on process time sequence and storage medium | |
CN107193745A (en) | Automated construction method of the PLC program to NuSMV input models | |
CN101968767A (en) | Macroprogram-based code debugging and simulation method and device | |
EP2799981A1 (en) | Method for providing code, code generator and software development environment | |
CN104626593A (en) | CNC system for 3D printing, generation method of printed documents and printing method | |
CN108845804A (en) | A kind of design method of the NC code interpreter based on CYCLE circulation | |
CN104281096A (en) | Construction method of numerical-control code compiler | |
Chen et al. | Intelligent computer-aided process planning of multi-axis CNC tapping machine | |
CN114547619A (en) | Vulnerability repairing system and method based on tree | |
CN107291045A (en) | A kind of workshop programing system | |
Brown et al. | A Description of the APT Language | |
CN115481396A (en) | NC code abnormality detection method, device, equipment and storage medium | |
Biundo et al. | Deductive planning and plan reuse in a command language environment | |
CN101201750B (en) | Method of providing data for encoding/decoding using syntax lexical analysis tool | |
CN105137919B (en) | A kind of method for generating character array numerical control macroprogram | |
Moutinho et al. | Ecore representation for extending PNML for Input-Output Place-Transition nets | |
CN116541286A (en) | High coverage rate test data generation method based on pile insertion and symbol execution |
Legal Events
Date | Code | Title | Description |
---|---|---|---|
PB01 | Publication | ||
PB01 | Publication | ||
SE01 | Entry into force of request for substantive examination | ||
SE01 | Entry into force of request for substantive examination | ||
WD01 | Invention patent application deemed withdrawn after publication | ||
WD01 | Invention patent application deemed withdrawn after publication |
Application publication date: 20181120 |