CN103942041A - Design method of NC code interpreter in numeric control simulation system - Google Patents

Design method of NC code interpreter in numeric control simulation system Download PDF

Info

Publication number
CN103942041A
CN103942041A CN201310754409.8A CN201310754409A CN103942041A CN 103942041 A CN103942041 A CN 103942041A CN 201310754409 A CN201310754409 A CN 201310754409A CN 103942041 A CN103942041 A CN 103942041A
Authority
CN
China
Prior art keywords
word
rule
program
code
nnn
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
Application number
CN201310754409.8A
Other languages
Chinese (zh)
Inventor
白瑞林
张和祥
邹骏宇
Current Assignee (The listed assignees may be inaccurate. Google has not performed a legal analysis and makes no representation or warranty as to the accuracy of the list.)
XINJE ELECTRONIC CO Ltd
Jiangnan University
Original Assignee
XINJE ELECTRONIC CO Ltd
Jiangnan University
Priority date (The priority date 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 date listed.)
Filing date
Publication date
Application filed by XINJE ELECTRONIC CO Ltd, Jiangnan University filed Critical XINJE ELECTRONIC CO Ltd
Priority to CN201310754409.8A priority Critical patent/CN103942041A/en
Publication of CN103942041A publication Critical patent/CN103942041A/en
Pending legal-status Critical Current

Links

Abstract

Provided is a design method of an NC code interpreter in a numeric control simulation system. Feature classification is carried out on NC procedure codes, a general rule database is constructed, in the grammatical analysis process, a standard numeric control code rule is described formally through a regular expression, at the same time, the grammatical analysis is carried out on the NC codes based on the recursive-descent parsing method from top to bottom, for default instruction words, corresponding preparatory function procedure words are deduced from non-default instruction words automatically and upwards, the default instruction words are automatically complemented through the preparatory function procedure words according to the rule database, and the flexibility and the grammatical analysis efficiency of the NC code interpreter are improved greatly.

Description

The method for designing of NC code interpretative device in a kind of Numerical Control Machining Simulation
Technical field
The present invention relates to the method for designing of NC code interpreter in a kind of NC lathe machining simulation system, specifically refer to the method for designing of code interpretative device in a kind of Numerical Control Machining Simulation.
Background technology
Numerical control machining simulation system is the mapping in computing machine as actual process, and its process also should be controlled by numerical control program.And NC code interpretative device becomes motion command as a nucleus module in Numerical Control Machining Simulation by NC code interpreter, drive cutter to carry out the processing of part.
The NC code interpretative device technical issues that need to address mainly contain lexical analysis, grammatical analysis, the processing instruction transformation of NC code.Numerical control program explains that the operation efficiency of decoding directly affects effect and the precision of numerical control machining simulation system.
With regard to numerical control NC, explain decoding technique, research both at home and abroad obtains a series of achievement.Sha Zhihua and 5 degeneration-resistant propositions utilize special-purpose LEX instrument automatically to generate lexical analyzer, and adopt regular formula to describe morphological rule, simple in rule, are applicable to the lexical analysis of simple NC code.Trip Hua Yun, adopting on the basis of special-purpose LEX instrument, utilizes regular expression to describe numerical control code and carries out grammatical feature description.This kind of method adopts suitable optimization method, generates high efficiency lexical scan device.The people such as LEE WB propose a kind of more efficient special-purpose morphology instrument ANTLR, set morphology description rule, and rule is imported in ANTLR and just can generate lexical analyzer.The people such as Li Shanfeng and GUO DE-GU analyze the relation between processing instruction and shape, and processing instruction is classified.This kind of method adopts top-down algorithm to carry out grammatical analysis, adopts eight yuan of formula structure record syntax analysis results simultaneously, makes grammatical analysis flow process simple.The people such as Ji Hua and Liu Yadong are described grammer by setting address word table, and G code is divided into groups, and utilize function pointer to realize the decomposition of address word simultaneously, and lexical analysis is simple, clear.Make system constructing become simple.The people such as flood great waves have set up grammar mistake testing mechanism according to the different grouping of G code and M code.The method is carried out mode grouping, by the code grouping of action attributes of the same race, improve grammatical analysis efficiency, but algorithm is complicated.
Summary of the invention
The object of the present invention is to provide the method for designing of NC code interpretative device in a kind of Numerical Control Machining Simulation, NC code interpretative device high efficiency in realization and raising Numerical Control Machining Simulation.Technical scheme provided by the invention is as follows:
In Numerical Control Machining Simulation, NC code interpretative device execution step is as follows successively:
(1) lexical analysis, the instruction set based on tagsort, builds rule database, and according to rule database, adopts address word function table to solve address word resolution problem in lexical analysis, gets rid of thus the unallowable instruction digit in numerical control program.
(2) grammatical analysis, adopt regular expression to carry out formal description to standard numerical control code regulation, and adopt top-down recursive descent parsing method, with above-mentioned regular expression description rule, travel through whole numerical control program, the illegal program statement in rejected program.
(3) processing instruction transformation, numerical control program is through lexical analysis, grammatical analysis, in rule database, set up the index relative between numerical control program instruction address word and instruction address word function, read processing instruction, according to index relative, call corresponding function and process, parse cutter location file corresponding to instruction, for driving cutter to process.
Advantage of the present invention is as follows: the present invention proposes the method for designing of NC code interpretative device in a kind of Numerical Control Machining Simulation.NC program code is carried out to tagsort, and formation rule database, decomposes NC instruction based on address word function table and carries out lexical analysis simultaneously.Adopt regular expression to carry out formal description to standard numerical control code regulation, grammar rule is simple, simultaneously based on top-down recursive descent parsing method, grammatical analysis is carried out in instruction lexical analysis being obtained with above-mentioned grammar rule, for the default situation of program word, auto-complete program, improves dirigibility and the applicability of NC interpreter greatly.
Accompanying drawing explanation
The overall flowchart of Fig. 1 the present invention
Fig. 2 lexical analysis process flow diagram of the present invention
Fig. 3 grammatical analysis process flow diagram of the present invention
Fig. 4 the present invention supplements example code process flow diagram automatically
The whole code flow figure that automatically supplements of Fig. 5 the present invention
Embodiment
For realizing goal of the invention, make technical scheme and feature clearer, below in conjunction with drawings and the specific embodiments, the invention will be further described:
Accompanying drawing 1 is the whole flowchart of NC code interpretative device of the present invention.
Flow process comprises the lexical analysis of NC code, grammatical analysis, processing instruction transformation, and concrete steps are as follows:
Lexical analysis
The first step: according to the relation between processing instruction and machining shape, processing instruction is carried out to tagsort, comprise the function types such as single interpolation, specific interpolation, fixed cycles, free curve.As shown in the table:
Processing instruction tagsort table
Command function Instruction feature Instruction set
Single interpolation Procedure of processing is single The interpolation such as straight line, circular arc
Specific interpolation There is definite procedure of processing Thread cylinder polar coordinate interpolation
Fixed cycles To fixed cell cyclic process The instruction of various fixedly fabrication cycles
Free curve Need machined parameters and circulation point Free curve class interpolation instruction
According to sorted instruction, formation rule database is specified address word and rules of order in database, comprising:
One, rules of order
1, preparatory function word G (setting up the mode of motion of digital control system), rule is as follows:
Gnn?Xnnnn.nnn?Ynnnn.nnn(Rnnnn.nnn)
2, subsidiary function word M (the definition state of main shaft and the state of liquid coolant), rule is as follows:
Mnn
3, address word F, S etc. (specifying cutting speed of feed, main shaft gyration number etc.), rule is as follows:
Fnnnn、Snnnn。Wherein n span is 0~9.
Two, set up the common character list in digital control system, for the lexical analysis of NC code, character list is as follows:
Letter: A~Z;
Numeral: 0|1|2|3|4|5|6|7|8|9;
Symbol: .|+|-|; | %|:|; |
Three, set up address word function table, function table, for analyzing the address word reading, is its matching parameter and command function, and address word function table is as follows:
analyze_function_pointer_analyze?s[]=
{analyze_f,analyze_g,analyze_i,
analyze_j,analyze_K,analyze_m,
analyze_x,analyze_y,analyze_z,......}
Function in call list is address word matching parameter and command function, extracts machining information.
Second step: read in row of N C code, it is carried out to pretreatment operation, the garbage in the middle of removing (annotation and space).After pre-service, NC code is separated into the set of some program words.For example, for row of N C code N0001G00X200Y300, can be decomposed into " N0001 ", " G00 ", " X200 ", " Y200 " these four program words.
The 3rd step: for the program word decompositing, analyze first one by one each character, get rid of character mistake; Next is broken down into address word and numerical value, and in call address function of word table, corresponding function is done further processing to address word.For example, for " G00 " program word, the analyze_g function in call function table for its coupling fast positioning function, is specified X-axis and Y-axis parameter according to rules of order for it according to the numerical value decompositing simultaneously, and parameter value scope.
Grammatical analysis
Syntactic analyser is the core of program compiler, and its effect is whether the word sequence that judgement is provided by lexical analysis meets given grammar form.The NC code regulation of describing for EBNF (Backus normal form of expansion) is complicated, grammatical analysis efficiency is low, require the deficiency of the complete NC code of input, the present invention proposes to adopt regular expression to describe NC code grammar rule, simultaneously based on making downward analytic approach by oneself, the regular expression rule of take is carried out grammatical analysis as nonterminal symbol search rule, and automatically supplements default program word for incomplete numerical control program.Specific as follows:
The first step: adopt regular expression to carry out formal description to standard numerical control code regulation, set up NC code regular expression grammar rule, NC code regulation has following rule conventionally:
Program number rule, by a capital O and four program numbers that numeral forms, can generate following rule according to standard:
O\d{4}
Program segment sequence number rule, is comprised of capital N and 4 numerals, according to standard, generates following rule:
N\d{4}
Address word G and M etc.: by capitalization G or M and two numerals, formed, according to standard, generate following rule:
G d{2} and M d{2}
Address word F and S etc.: by capital F or S and two numerals, formed, according to standard, generate following rule:
F d{4} and S d{4}
Second step: according to top-down recursive descent parsing method, from the initial rule of regular expression, derive downwards by leftmost derivation mode, for each nonterminal symbol constructor program, call successively corresponding process downwards, complete the analysis of full line code, get rid of illegal program segment.The NC code reading has instruction word abridged situation, automatically supplements default program word.
For example:
N0001G01X30Z-50F100;
N0002X42;
At N0002 line program, according to semantic known above, default G01, Z-50, F100 supervisor word need automatically to be supplemented complete, specific as follows in automatically downward analytic process:
(1) while reading X42, from then on line code starts automatically upwards to derive, and finds nearest program word G01, by reading the rule of this program word in rule base, and based on regular expression, default program word G01, Z-50, F100 are described, be constructed as follows rule:
_G01_Z-50F100
(2) X42 is replaced X30 to add in default program word simultaneously, forms complete program, supplement the complete following program that obtains:
N0002_X42__+_G01_Z-50F100=
N0002G01X42Z-50F100:
Whole process as shown in Figure 4.
After NC numerical control code is supplementary complete, from initial rule, call subroutine is analyzed full line code successively.
Processing instruction transformation
Index relative between Database numerical control program instruction address word and instruction address word function, NC numerical control code is through grammatical analysis, and lexical analysis, obtains standard NC code.According to the row of N C code reading, the address word invoking performance function being gone out by address word function decomposition, analyze the address word number of every row NC program, species code of address word, address word data type, data type species code, number of parameters, parameter species code, supplemental characteristic species code etc. obtain the cutter location file information that driving arrangement is processed.
By speed of feed v (mm/min) and timeslice T (ms), calculate amount of feeding f (mm).
f = v 60 × 1000 × T - - - ( 1 )
By f and arc radius R, calculate central angle δ (radian) corresponding to tool feeding in the sheet T time.
δ = 2 arcsin f 2 R - - - ( 2 )
According to the coordinate of circular arc starting point S and terminal E and arc radius R, calculate the central angle θ (radian) of circular arc.
θ = 2 arcsin = ( x E - x S ) 2 + ( y E - y S ) 2 2 R - - - ( 3 )
The displacement of i step is calculated as follows:
Δ x i = R [ cos ( α + iδ ) - cos ( α + ( i - 1 ) δ ) ] Δ y i = R [ sin ( α + iδ ) - sin ( α + ( i - 1 ) δ ) ] - - - ( 4 )
The initial angle that wherein α is circular arc, just can obtain the interior circular interpolation of each T in the displacement of change in coordinate axis direction by (4) formula.

Claims (2)

1. the object of the present invention is to provide the method for designing of NC code interpretative device in a kind of Numerical Control Machining Simulation, it is characterized in that: processing instruction is carried out to tagsort, build rule database, according to address word constructed fuction table, by address word binding rule storehouse, carry out lexical analysis; Adopt regular expression to carry out formal description to standard numerical control code regulation simultaneously, and adopt top-down recursive descent parsing method to carry out grammatical analysis, for there being the default situation of instruction word, automatic makeup charges whole numerical control code, greatly improves dirigibility and the programming efficiency of the grammatical analysis of NC interpreter.Comprise following several step:
Lexical analysis
The first step: processing instruction is carried out to tagsort, and formation rule database, based on address word in storehouse, constructs address word function table simultaneously;
Second step: read a line numerical control program, carry out pre-service, remove space and annotation, and program is resolved into program word;
The 3rd step: to the program word decompositing, reading character, gets rid of character mistake, is broken down into address word and numerical value, and calls corresponding address function of word in conjunction with the numerical value decompositing, is program word coupling holding function, with and parameter characteristic;
Grammatical analysis
The first step: set up regular expression grammar rule, as follows for conventional NC code regulation:
Program number rule: O \ d{4}; Program segment sequence number rule: N d{4};
The rule such as address word G and M: G \ d{2} and M d{2};
The rule such as address word F and S: F d{4} and S \ d{4};
Second step: according to top-down recursive descent parsing method, from the initial rule of regular expression, derive and carry out grammatical analysis downwards by leftmost derivation mode; For NC code, there is the default situation of instruction word, the rule of describing with regular expression, automatically supplement default program word, step specific as follows:
(1) while reading not default program word, from then on line code starts automatically upwards to derive, and according to rule base and regular expression, constructs default program word rule;
(2) not default program word rule is added in default program word rule, form complete program, after NC numerical control code is supplementary complete, from initial rule, call subroutine is analyzed full line code successively.
2. the method for designing of NC code interpretative device in a kind of Numerical Control Machining Simulation according to claim 1, is characterized in that; In described grammatical analysis second step, comprising:
In top-down method, calling regular expression describes numerical control program syntax rule and carries out in grammatical analysis, run into the program that has default procedures word, shape is as Nnnnn Xnnnn.nnn (other situation default procedures word processing processes are similar), automatic basis is semantic completion program above, specific as follows:
(1) in top-down method, according to not default program word Xnnnn.nnn, from Nnnnn line code start upwards to derive the successively program word Gnn of associated, definition according to Gnn in rule base, search corresponding with it parameter, and utilize regular expression to construct default program word form, shown in being constructed as follows:
_Gnn_Y|Znnnn.nnn(R|Fnnnn.nnn);
(2) form complete program with not default program word Xnnnn.nnn, anabolic process is as follows:
Nnnnn_Xnnnn.nnn_(_);+_Gnn_Y|Znnnn.nnn(R|Fnnnn.nnn);=Nnnnn?Gnn?Xnnnn.nnn?Y|Znnnn.nnn(R|Fnnnn.nnn);
Whole automatically supplementary process as shown in Figure 5.
After full line code is supplementary complete, from the initial rule of regular expression, by leftmost derivation mode, derive downwards, for each nonterminal symbol constructor program, call successively corresponding process downwards, complete the grammatical analysis of full line code.
CN201310754409.8A 2013-12-31 2013-12-31 Design method of NC code interpreter in numeric control simulation system Pending CN103942041A (en)

Priority Applications (1)

Application Number Priority Date Filing Date Title
CN201310754409.8A CN103942041A (en) 2013-12-31 2013-12-31 Design method of NC code interpreter in numeric control simulation system

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
CN201310754409.8A CN103942041A (en) 2013-12-31 2013-12-31 Design method of NC code interpreter in numeric control simulation system

Publications (1)

Publication Number Publication Date
CN103942041A true CN103942041A (en) 2014-07-23

Family

ID=51189719

Family Applications (1)

Application Number Title Priority Date Filing Date
CN201310754409.8A Pending CN103942041A (en) 2013-12-31 2013-12-31 Design method of NC code interpreter in numeric control simulation system

Country Status (1)

Country Link
CN (1) CN103942041A (en)

Cited By (6)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN104133421A (en) * 2014-08-01 2014-11-05 南京埃斯顿自动化股份有限公司 Motion control code analysis method based on process control
CN104503754A (en) * 2014-12-16 2015-04-08 江南大学 Programming and compiling design method in robot graphical programming system
CN106774168A (en) * 2016-12-09 2017-05-31 中国电子科技网络信息安全有限公司 A kind of numerical control NC code safety filtering system
CN108920186A (en) * 2018-06-25 2018-11-30 杭州电子科技大学 A kind of movement instruction analysis method and device
CN110221580A (en) * 2019-05-29 2019-09-10 华中科技大学 A kind of feeding speed optimization method based on main shaft data simulation
CN116339705A (en) * 2023-05-30 2023-06-27 天津金城银行股份有限公司 Webpage H5 editor code prompting method, device and equipment

Citations (1)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN101901001A (en) * 2010-07-23 2010-12-01 杭州捷塔科技有限公司 CNC elbow processing-oriented coding control system and decoding control system

Patent Citations (1)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN101901001A (en) * 2010-07-23 2010-12-01 杭州捷塔科技有限公司 CNC elbow processing-oriented coding control system and decoding control system

Non-Patent Citations (8)

* Cited by examiner, † Cited by third party
Title
LONG CHEN ETC.: "Design and Implement of a Modularized CNC Interpreterbased on the integration of tool path planning module", 《COMPUTER SCIENCE AND AUTOMATION ENGINEERING (CSAE), 2012 IEEE INTERNATIONAL CONFERENCE》 *
张庆等: "一种开放式数控系统NC代码解释器设计与实现", 《控制与检测》 *
徐建国等: "通用数控程序解析方法研究", 《计算机集成制造系统》 *
洪海涛等: "数控代码解释器模块化结构的研究与实现", 《小型微型计算机系统》 *
游华云等: "多数控代码解释器共存的设计与应用", 《计算机工程与应用》 *
禹丹等: "基于ANTLR的NC代码编译器的设计与实现", 《计算机应用》 *
肖忠跃: "数控虚拟仿真系统代码编译器的研究与开发", 《中国优秀博硕士学位论文全文数据库 (硕士)工程科技I辑》 *
董立岩等: "数控车床仿真系统中指令解释器的设计与实现", 《吉林大学学报(理学版)》 *

Cited By (9)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN104133421A (en) * 2014-08-01 2014-11-05 南京埃斯顿自动化股份有限公司 Motion control code analysis method based on process control
CN104503754A (en) * 2014-12-16 2015-04-08 江南大学 Programming and compiling design method in robot graphical programming system
CN104503754B (en) * 2014-12-16 2018-05-11 江南大学 A kind of design method for programming and compiling in robot graphic programming system
CN106774168A (en) * 2016-12-09 2017-05-31 中国电子科技网络信息安全有限公司 A kind of numerical control NC code safety filtering system
CN106774168B (en) * 2016-12-09 2019-06-28 中国电子科技网络信息安全有限公司 A kind of numerical control NC code safety filtering system
CN108920186A (en) * 2018-06-25 2018-11-30 杭州电子科技大学 A kind of movement instruction analysis method and device
CN110221580A (en) * 2019-05-29 2019-09-10 华中科技大学 A kind of feeding speed optimization method based on main shaft data simulation
CN110221580B (en) * 2019-05-29 2020-07-10 华中科技大学 Feed speed optimization method based on main shaft data simulation
CN116339705A (en) * 2023-05-30 2023-06-27 天津金城银行股份有限公司 Webpage H5 editor code prompting method, device and equipment

Similar Documents

Publication Publication Date Title
CN103942041A (en) Design method of NC code interpreter in numeric control simulation system
CN107832229B (en) NLP-based system test case automatic generation method
CN101206467B (en) Universal numerical control code analysis method
CN107193745B (en) Automated construction method of the PLC program to NuSMV input model
CN102682118B (en) Multidimensional data model access method and device
CN103123590A (en) Compiling method from intermediate language (IL) program to C language program of instruction list
CN108763064A (en) A kind of code tester generation method and device based on black box function and machine learning
US20100211197A1 (en) Methods and apparatus to configure a process control system using an electronic description language script
CN105279269B (en) A kind of support matrix freely associated SQL generation methods and system
CN103123624A (en) Method of confirming head word, device of confirming head word, searching method and device
CN112585547B (en) Analysis device, analysis method, and recording medium
CN111610744B (en) Logic control program generation method and system based on process time sequence and storage medium
CN101876939B (en) System test method and device
CN104915293A (en) Software testing method and system
CN110888756A (en) Diagnostic log generation method and device
CN107862133B (en) Method for generating BIM models of piers in batches
CN103235757B (en) Several apparatus and method that input domain tested object is tested are made based on robotization
CN105224455B (en) A kind of method for automatically generating character string type test case
CN114064009A (en) Processing method and processing device for milling round hole, electronic equipment and storage medium
CN103885810A (en) Gerber file compiler based on regular expressions
CN102508691B (en) Graphic language program ordered decomposition method and ordered decomposer
CN104827339A (en) Machine tool spindle thermal error optimum working condition determination method based on orthogonal test analysis
CN107239264A (en) The generation method and device of code prompt message
CN104298657A (en) Evaluation index analysis system based on expression
CN103617170B (en) Automatic exposure machine document checking system

Legal Events

Date Code Title Description
C06 Publication
PB01 Publication
C10 Entry into substantive examination
SE01 Entry into force of request for substantive examination
WD01 Invention patent application deemed withdrawn after publication

Application publication date: 20140723

WD01 Invention patent application deemed withdrawn after publication