CN109085798B - An embedded system G-code asynchronous communication mechanism, protocol and programming method - Google Patents

An embedded system G-code asynchronous communication mechanism, protocol and programming method Download PDF

Info

Publication number
CN109085798B
CN109085798B CN201810882541.XA CN201810882541A CN109085798B CN 109085798 B CN109085798 B CN 109085798B CN 201810882541 A CN201810882541 A CN 201810882541A CN 109085798 B CN109085798 B CN 109085798B
Authority
CN
China
Prior art keywords
instruction
protocol
code
protocol format
command
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.)
Active
Application number
CN201810882541.XA
Other languages
Chinese (zh)
Other versions
CN109085798A (en
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.)
Changzhou Vocational Institute of Light Industry
Original Assignee
Changzhou Vocational Institute of Light Industry
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 Changzhou Vocational Institute of Light Industry filed Critical Changzhou Vocational Institute of Light Industry
Priority to CN201810882541.XA priority Critical patent/CN109085798B/en
Publication of CN109085798A publication Critical patent/CN109085798A/en
Application granted granted Critical
Publication of CN109085798B publication Critical patent/CN109085798B/en
Active legal-status Critical Current
Anticipated expiration legal-status Critical

Links

Images

Classifications

    • GPHYSICS
    • G05CONTROLLING; REGULATING
    • G05BCONTROL OR REGULATING SYSTEMS IN GENERAL; FUNCTIONAL ELEMENTS OF SUCH SYSTEMS; MONITORING OR TESTING ARRANGEMENTS FOR SUCH SYSTEMS OR ELEMENTS
    • G05B19/00Programme-control systems
    • G05B19/02Programme-control systems electric
    • G05B19/18Numerical control [NC], i.e. automatically operating machines, in particular machine tools, e.g. in a manufacturing environment, so as to execute positioning, movement or co-ordinated operations by means of programme data in numerical form
    • G05B19/4093Numerical control [NC], i.e. automatically operating machines, in particular machine tools, e.g. in a manufacturing environment, so as to execute positioning, movement or co-ordinated operations by means of programme data in numerical form characterised by part programming, e.g. entry of geometrical information as taken from a technical drawing, combining this with machining and material information to obtain control information, named part programme, for the NC machine
    • GPHYSICS
    • G05CONTROLLING; REGULATING
    • G05BCONTROL OR REGULATING SYSTEMS IN GENERAL; FUNCTIONAL ELEMENTS OF SUCH SYSTEMS; MONITORING OR TESTING ARRANGEMENTS FOR SUCH SYSTEMS OR ELEMENTS
    • G05B19/00Programme-control systems
    • G05B19/02Programme-control systems electric
    • G05B19/18Numerical control [NC], i.e. automatically operating machines, in particular machine tools, e.g. in a manufacturing environment, so as to execute positioning, movement or co-ordinated operations by means of programme data in numerical form
    • G05B19/408Numerical control [NC], i.e. automatically operating machines, in particular machine tools, e.g. in a manufacturing environment, so as to execute positioning, movement or co-ordinated operations by means of programme data in numerical form characterised by data handling or data format, e.g. reading, buffering or conversion of data
    • GPHYSICS
    • G05CONTROLLING; REGULATING
    • G05BCONTROL OR REGULATING SYSTEMS IN GENERAL; FUNCTIONAL ELEMENTS OF SUCH SYSTEMS; MONITORING OR TESTING ARRANGEMENTS FOR SUCH SYSTEMS OR ELEMENTS
    • G05B19/00Programme-control systems
    • G05B19/02Programme-control systems electric
    • G05B19/18Numerical control [NC], i.e. automatically operating machines, in particular machine tools, e.g. in a manufacturing environment, so as to execute positioning, movement or co-ordinated operations by means of programme data in numerical form
    • G05B19/4155Numerical control [NC], i.e. automatically operating machines, in particular machine tools, e.g. in a manufacturing environment, so as to execute positioning, movement or co-ordinated operations by means of programme data in numerical form characterised by programme execution, i.e. part programme or machine function execution, e.g. selection of a programme
    • GPHYSICS
    • G05CONTROLLING; REGULATING
    • G05BCONTROL OR REGULATING SYSTEMS IN GENERAL; FUNCTIONAL ELEMENTS OF SUCH SYSTEMS; MONITORING OR TESTING ARRANGEMENTS FOR SUCH SYSTEMS OR ELEMENTS
    • G05B2219/00Program-control systems
    • G05B2219/30Nc systems
    • G05B2219/45Nc applications
    • G05B2219/45136Turning, lathe

Landscapes

  • Engineering & Computer Science (AREA)
  • Physics & Mathematics (AREA)
  • Human Computer Interaction (AREA)
  • Manufacturing & Machinery (AREA)
  • General Physics & Mathematics (AREA)
  • Automation & Control Theory (AREA)
  • Geometry (AREA)
  • Computer And Data Communications (AREA)
  • Communication Control (AREA)

Abstract

本发明公开了一种嵌入式系统G代码异步通讯机制、协议及编程方法,通过上位机将G程序文件经过协议封装生成指定的协议格式,将协议格式发送给下位机,若存在交互控制实时指令,则通过判断协议格式与交互控制实时指令的优先级高低对下位机进行发送,并先发送优先级较高的;下位机在接收到上位机发送的协议格式,通过协议解析模块进行解析,然后将解析完成的数据通过顺序指令填入模块填入至命令FIFO存储器,再按照填入命令FIFO存储器的位置进行指令预读和指令执行;若协议解析模块解析得到的为实时指令,则不需要存储至所述命令FIFO存储器直接实施指令执行;本发明有效的降低了上下位运动控制系统的整体成本,提高了嵌入式系统G代码执行效率。

Figure 201810882541

The invention discloses a G code asynchronous communication mechanism, protocol and programming method of an embedded system. A G program file is encapsulated by a host computer to generate a specified protocol format, and the protocol format is sent to a lower computer. If there is an interactive control real-time instruction , then the lower computer is sent to the lower computer by judging the priority of the protocol format and the interactive control real-time command, and the higher priority is sent first; the lower computer receives the protocol format sent by the upper computer, and parses it through the protocol parsing module, and then Fill the parsed data into the command FIFO memory through the sequential instruction filling module, and then perform instruction pre-reading and instruction execution according to the position filled in the command FIFO memory; if the protocol parsing module parses real-time instructions, it does not need to be stored. Directly implements instruction execution to the command FIFO memory; the present invention effectively reduces the overall cost of the upper and lower motion control systems and improves the G code execution efficiency of the embedded system.

Figure 201810882541

Description

Embedded system G code asynchronous communication mechanism, protocol and programming method
Technical Field
The invention belongs to the technical field of numerical control machine tool control, and particularly relates to an embedded system G code asynchronous communication mechanism, a protocol and a programming method.
Background
The numerical control system is a typical application of computer technology in the field of mechanical manufacturing, integrates a plurality of technologies such as computer, machining, micro-electronics and automatic control, and is a high and new technology which develops rapidly in the application field in recent years. Since the 70 s, modern basic machines represented by numerical control machines have become the most important technical features of manufacturing industry, and the level of numerical control machines and the degree of numerical control rate of machine tools have become important marks for measuring the level of national industrialization.
At present, the general trend of the technical development of numerical control systems at home and abroad is as follows: the new generation of numerical control systems is developing towards the direction of PC and open architecture. The driving device is developed in the direction of alternating current and digitalization. The communication function is enhanced, and the development is towards networking. The numerical control system develops towards intellectualization in control performance. The development from a special closed open-loop control mode to a general open real-time dynamic full closed-loop control mode is realized.
The machine tool has modularized structure and specialized numerical control function, and the cost performance of the machine tool is obviously improved and accelerated. In order to adapt to the characteristics of multiple varieties and small batch of numerical control machines, the machine tool structure is modularized, the numerical control function is specialized, the cost performance of the machine tool is obviously improved, and the optimization is accelerated. Personalization is a particularly evident trend in recent years.
With the development of market globalization, market competition is unprecedented and the product produced by a manufacturer is required to be low in price, good in quality, short in delivery time and good in after-sale service, and fully meets the special requirements of users, namely the product is required to be personalized. The traditional numerical control system is a special closed system and cannot meet the requirement of market development. New environments require CNC to further translate to open control systems.
At present, the open numerical control systems of numerical control system manufacturers at home and abroad are mainly concentrated in high-end markets and are high in price. With the application of more and more small numerical control systems, more and more attention is paid to an economic, open and intelligent embedded small multi-axis open type economic numerical control system.
Currently, there are roughly several embedded small systems:
1. the controller of the structure takes the DSP and the FPGA as control cores, has good real-time performance and control precision and low cost, but the human-computer interaction and the motion algorithm of the controller depend on the DSP processor, if the good human-computer interaction is considered, the DSP processor seems to be careless, the real-time performance is seriously influenced, and the expansibility is poor.
2. The industrial control platform mainly adopts an X86 processor structure, has higher processing capacity and strong system expansibility, but has high cost and great application difficulty in small-size motion control requirements.
3. The single-chip microcomputer structure mainly adopts a single ARM or 51-kernel 32-bit processor, is low in cost, but is very closed, low in expansibility and difficult to change once the system is shaped.
Disclosure of Invention
The invention mainly aims to provide an embedded system G code asynchronous communication mechanism, a protocol and a programming method, wherein the method adopts the coordination and cooperation between an upper computer and a lower computer, realizes the real-time property and the diversified humanization of control, and is used for solving the problems of poor real-time property and poor expansibility in the prior art; the specific technical scheme is as follows:
an embedded system G code asynchronous communication mechanism, protocol and programming method, employ the communication between host computer and lower computer, adopt the asynchronous communication mode between host computer and lower computer in the said method, the host computer encapsulates the G code program into the appointed protocol format, and transmit the said protocol format to the lower computer, for the lower computer to analyze and carry out; the method comprises the steps of preparing and sending the G code program file by the upper computer and receiving and processing the protocol format by the lower computer, wherein:
the process of preparing and sending the G code program file by the upper computer comprises the following steps:
s11: generating a set of instruction sets capable of being sequentially executed by a human-computer interaction interface or a parameterization setting interface to form a G program file, and packaging the G program file into a sequential instruction buffer area;
s12: judging whether an upper computer generates an interactive control real-time instruction needing real-time processing, if so, storing the interactive control real-time instruction into an insertion instruction buffer area, and storing the interactive control real-time instruction into an instruction sending buffer area; otherwise, the G program files packaged and encapsulated in the sequence instruction buffer area are saved in the instruction sending buffer area;
s13: the protocol sending module detects whether the instruction sending buffer area has an instruction needing to be sent or not, judges whether a sending condition is met or not, if yes, the protocol sending module sends the instruction to a lower computer in sequence, and otherwise, the protocol sending module does not execute sending operation;
the process that the lower computer receives and processes the protocol format comprises the following steps:
s21: receiving the protocol format by a protocol receiving module in the lower computer in an interrupt mode and sending the protocol format to a protocol receiving buffer;
s22: the protocol analysis module monitors the protocol receiving buffer in real time, judges whether the protocol receiving buffer stores data, decomposes and extracts the data based on the protocol format, and judges the type of the data at the same time;
s23: if the data is a sequential instruction, the sequential instruction is stored in a command FIFO memory through a sequential instruction filling module, otherwise, the data is a real-time instruction, and the real-time instruction is executed;
s24: reading the sequential instructions stored in the command FIFO memory through an instruction pre-reading module, executing the sequential instructions by an instruction execution module, pre-reading and pre-processing the next sequential instructions in the command FIFO memory through a pre-reading instruction and data processing module, and storing the next sequential instructions in a waiting execution module;
s25: and judging whether the instruction execution module finishes the instruction execution, if so, continuing to execute the sequence instruction stored in the waiting execution module, otherwise, keeping the waiting execution module in a waiting state.
Further, the protocol format is composed of a header, a byte number, a command code, control data, a CRC check and a trailer, wherein the header is fixed data 0x7E for identifying the protocol format; the byte number is used for assisting a lower computer to accurately find the command code, the control data and the CRC; the command codes are used for carrying out thinning numbering on the instructions sent by the upper computers; the CRC check is used for judging whether the protocol format is legal or not; the trailer is fixed data 0x0D, and the lower computer identifies whether the instruction contained in the protocol format is finished according to the specific data of the trailer.
Further, in step S22, the method further includes: the lower computer traverses the protocol receiving buffer area, searches a header and a trailer of each protocol format, monitors the size of a storage space of the command FIFO memory through the sequential instruction filling module, if the storage space is full, the upper computer does not send the protocol format, and consumes the protocol format stored in the command FIFO memory through the instruction pre-reading module and the instruction execution module; otherwise, the command FIFO memory continues to receive the protocol format sent by the upper computer.
Further, the header and the trailer are represented by hexadecimal data, and the byte number, the command code, the control data and the CRC check are represented by ASCII codes.
Further, the protocol format is stored in the command FIFO memory as 32-bit data after passing through the protocol parsing module.
The embedded system G code asynchronous communication mechanism, the protocol and the programming method of the invention generate a specified protocol format by protocol encapsulation of a G program file through an upper computer, send the protocol format to a lower computer, if an interactive control real-time instruction exists, send the lower computer by judging the priority of the protocol format and the interactive control real-time instruction, and send the lower computer with higher priority first; the lower computer receives the protocol format sent by the upper computer, analyzes the protocol format through the protocol analysis module, fills the analyzed data into the command FIFO memory through the sequential instruction filling module, performs instruction pre-reading and instruction execution according to the position of the command FIFO memory, performs pre-reading and pre-processing on the next instruction through the pre-reading instruction and data processing module, sends the pre-reading and pre-processing result to the execution waiting module, and waits for execution; if the real-time instruction is analyzed by the protocol analysis module, the instruction execution is directly implemented without storing the real-time instruction into the command FIFO memory; compared with the prior art, the invention can realize that the upper computer organizes and generates the G code by using a programming method such as a high-level language and the like under the condition of limited CPU processing resources of the embedded system, enhances the programming of human-computer interaction and other humanized codes, realizes the support of the lower computer on the instruction of the G code, effectively reduces the overall cost of the upper and lower motion control systems, and improves the execution efficiency of the G code of the embedded system.
Drawings
Fig. 1 is a block diagram illustrating a communication flow between the upper computer and the lower computer according to an embodiment of the present invention;
FIG. 2 is a schematic diagram of a G file preparing and sending mechanism of the upper computer in the embodiment of the present invention;
FIG. 3 is a schematic diagram of a receiving and processing mechanism of the lower computer according to an embodiment of the present invention;
FIG. 4 is a schematic diagram of a file delivery protocol format of the upper computer in the embodiment of the present invention;
FIG. 5 is a schematic diagram of the command FIFO storage format according to the embodiment of the present invention;
FIG. 6 is a flowchart illustrating a command parsing procedure according to an embodiment of the present invention.
And (4) marking and explaining: 5-sequential instruction buffer, 6-insert instruction buffer, 7-instruction issue buffer, 14-command FIFO memory.
Detailed Description
In order to make the technical solutions of the present invention better understood, the technical solutions in the embodiments of the present invention will be clearly and completely described below with reference to the drawings in the embodiments of the present invention.
Referring to fig. 1, fig. 2 and fig. 3, the invention provides an embedded system G code asynchronous communication mechanism, protocol and programming method, which applies communication between an upper computer and a lower computer, in the method, the upper computer and the lower computer adopt an asynchronous communication mode, the upper computer encapsulates a G code program into a specified protocol format, and transmits the protocol format to the lower computer for the lower computer to analyze and execute; the method comprises the steps of preparing and sending the G code program file by the upper computer and receiving and processing the protocol format by the lower computer, wherein the step of preparing and sending the G code program file by the upper computer comprises the following steps: s11: generating a set of instruction sets capable of being sequentially executed by a human-computer interaction interface or a parameterization setting interface to form a G program file 1, and packaging the G program file 1 into a sequential instruction buffer area 3; s12: judging whether the upper computer generates an interactive control real-time instruction 4 needing real-time processing, if so, storing the interactive control real-time instruction 4 into an insertion instruction buffer area 6, and storing the instruction into an instruction sending buffer area 7; otherwise, storing the G program file 1 packaged and encapsulated into the sequential instruction buffer 5 into an instruction sending buffer 7; s13: the protocol sending module 8 detects whether the instruction sending buffer 7 has an instruction to be sent, and judges whether a sending condition is met, if so, the instructions are sent to a lower computer in sequence, otherwise, the sending operation is not executed.
The process that the lower computer receives and processes the protocol format comprises the following steps: s21: a protocol receiving module 9 in the lower computer receives a protocol format in an interrupt mode and sends the protocol format to a protocol receiving buffer; s22: the protocol analysis module 10 monitors the protocol receiving buffer in real time, judges whether the protocol receiving buffer stores data, decomposes and extracts the data based on the protocol format, and judges the type of the data at the same time; s23: if the data is a sequential instruction, the sequential instruction is stored in the command FIFO memory 14 through the sequential instruction filling module 11, otherwise, the data is a real-time instruction 12, and the real-time instruction 12 is executed; s24: the sequential instructions stored in the command FIFO memory 14 are read by the instruction pre-reading module 15 and executed by the instruction execution module 16, while the next sequential instructions in the command FIFO memory 14 are pre-read and pre-processed by the pre-reading instruction and data processing module 17 and stored in the waiting execution module 18; s25: it is determined whether the instruction execution module 16 completes the execution of the instruction, and if so, the execution of the sequential instruction stored in the wait execution module 18 is continued, otherwise, the wait execution module 18 is in a wait state.
Referring to fig. 4, in the embodiment of the present invention, the protocol format is composed of a header 19, a byte number 20, a command code 21, a command encoding 22, control data 23, a CRC check 24, and a trailer 25, where the header 19 is fixed data 0x7E for identifying the protocol format; the byte number 20 is used for assisting the lower computer to accurately find the command code 21, the command code 22, the control data 23 and the CRC check 24; the command code 21 is used for carrying out thinning numbering on the instructions sent by the upper computer; the CRC check 24 is used to determine whether the protocol format is legitimate; the trailer 25 is fixed data 0x0D, and the lower computer identifies whether the instruction contained in the protocol format is finished according to the specific data of the trailer 25; wherein in the particular embodiment the header 19 and trailer 25 are represented by hexadecimal data and the byte count 20, command code 21, command code 22, control data 23 and CRC check 24 are represented by ascii codes.
Specifically, when the protocol receiving module intercepts a complete piece of protocol data, the byte number 20 can help the lower computer to accurately find the accurate positions of the command code 21, the command number 22, the control data 23 and the CRC check 24, so that the lower computer can conveniently extract the data and calculate the CRC check data; the CRC check 24 judges whether the protocol data is a legal available protocol according to the calculation result of the CRC check data, and if the CRC check is incorrect, the protocol data is invalidated; the command code 21 then essentially identifies the command type of the protocol, such as: the character 'G' represents that the protocol is a motion control instruction, 'M' represents that the protocol is an IO control instruction, 'F' represents that the protocol is a parameter setting instruction; the command number 22 is used for detailing the number of a class of instructions, so that the instructions can conveniently execute corresponding programs; the control data 23 is data required for a certain type of instruction, and corresponds to the fact that a 'G' type instruction is motion data of each axis, a 'M' type instruction is an IO control parameter, and a 'F' type instruction is an operation parameter of a system in a lower computer, and the like.
Referring to fig. 5, in the present invention, the protocol format is stored in the command FIFO memory 14 as 32-bit data 26 after passing through the protocol parsing module 10, as can be seen from the figure, each 32-bit data 26 is composed of 4 8-bit data, and each 8-bit data may mean a command type, a command number, command configuration data, command parameters, etc. according to the difference of the command code 21, depending on the number of the command code 21.
With reference to fig. 6, in the embodiment of the present invention, the analyzing, by the lower computer, the instruction command sent by the upper computer in step S22 further includes: the lower computer traverses the protocol receiving buffer area, specifically, a header and a trailer of each protocol format are searched to implement comprehensive traversal operation, the size of a storage space of the command FIFO memory 14 is monitored through the sequential instruction filling module 11, if the storage space is full, the upper computer does not send the protocol format, and the protocol format stored in the command FIFO memory 14 is consumed through the instruction pre-reading module 15 and the instruction execution module 16; otherwise, the FIFO memory 14 is instructed to continue to receive the protocol format sent by the upper computer; the storage space in the command FIFO memory 14 is enough to satisfy the instruction execution fluency of the lower computer, and the interruption of instruction execution caused by the state transition of the command FIFO memory 14 being full or the command FIFO memory space being free can not be caused, thereby ensuring the fluency of the continuity of the upper computer controlling the lower computer in the G code asynchronous communication mechanism, the protocol and the programming method of the embedded system, namely the fluency of the whole embedded system.
Preferably, in the embodiment of the invention, the upper computer adopts an A8 processor with a main frequency of up to 1GHz, the lower computer adopts an ARM7 processor with a main frequency of 128MHz, the characteristics of high processing capability and strong expansibility are considered by the upper computer, and the characteristics of high real-time supervision and control progress are considered by the lower computer, so that the hardware implementation cost of the system is reduced on the whole; of course, the present invention does not limit and fix this, and can be selected according to actual situations.
The embedded system G code asynchronous communication mechanism, the protocol and the programming method of the invention produce the appointed protocol format by the protocol encapsulation of the G program file through the upper computer, send the protocol format to the lower computer, if the interactive control real-time instruction exists, send the lower computer by judging the priority level of the protocol format and the interactive control real-time instruction, and send the priority level to be higher first; the lower computer receives the protocol format sent by the upper computer, analyzes the protocol format through the protocol analysis module, fills the analyzed data into the command FIFO memory through the sequential instruction filling module, performs instruction pre-reading and instruction execution according to the position of the command FIFO memory, performs pre-reading and pre-processing on the next instruction through the pre-reading instruction and data processing module, sends the pre-reading and pre-processing result to the execution waiting module, and waits for execution; if the real-time instruction is obtained by the protocol analysis module, the instruction execution is directly carried out without storing the real-time instruction into the command FIFO memory; compared with the prior art, the invention can realize that the upper computer organizes and generates the G code by using a programming method such as a high-level language and the like under the condition of limited CPU processing resources of the embedded system, enhances the programming of human-computer interaction and other humanized codes, realizes the support of the lower computer on the instruction of the G code, effectively reduces the overall cost of the upper and lower motion control systems, and improves the execution efficiency of the G code of the embedded system.
Although the present invention has been described in detail with reference to the foregoing embodiments, it will be apparent to those skilled in the art that modifications may be made to the embodiments described in the foregoing detailed description, or equivalent changes may be made in some of the features of the embodiments described above. All equivalent structures made by using the contents of the specification and the attached drawings of the invention can be directly or indirectly applied to other related technical fields, and are also within the protection scope of the patent of the invention.

Claims (5)

1.一种嵌入式系统G代码异步通讯机制、协议及编程方法,应用与上位机与下位机之间的通信,其特征在于,所述方法中上位机与下位机之间采用异步通讯的方式,上位机将G代码程序封装成指定的协议格式,并将所述协议格式传输给下位机,供下位机解析和执行;方法包括上位机对G代码程序文件的准备和发送过程以及下位机接收和处理所述协议格式的过程,其中:上位机对G代码程序文件的准备和发送过程包括步骤:1. a kind of embedded system G code asynchronous communication mechanism, protocol and programming method, the communication between application and upper computer and lower computer, it is characterized in that, adopt the mode of asynchronous communication between upper computer and lower computer in described method , the upper computer encapsulates the G code program into a specified protocol format, and transmits the protocol format to the lower computer for analysis and execution by the lower computer; the method includes the preparation and sending process of the G code program file by the upper computer and the reception of the lower computer. and the process of processing the protocol format, wherein: the preparation and sending process of the G code program file by the host computer comprises the steps: S11:由人机交互界面或参数化设置界面生成一套可以顺序执行的指令集构成G程序文件,将所述G程序文件打包封装到顺序指令缓冲区;S11: Generate a set of instruction sets that can be executed sequentially to form a G program file from a human-computer interaction interface or a parameterized setting interface, and package the G program file into a sequential instruction buffer; S12:判断上位机是否产生需要实时处理的交互控制实时指令,若有则将所述交互控制实时指令存入插入指令缓冲区,并保存至指令发送缓冲区;否则将打包封装至所述顺序指令缓冲区的所述G程序文件保存至所述指令发送缓冲区;S12: Determine whether the host computer generates an interactive control real-time instruction that needs real-time processing, and if so, store the interactive control real-time instruction in the insert instruction buffer, and save it to the instruction sending buffer; otherwise, pack and encapsulate it into the sequential instruction The G program file in the buffer is stored in the instruction sending buffer; S13:由协议发送模块检测所述指令发送缓冲区是否有需要发送的指令,并判断是否满足发送条件,若满足,则将依次发送指令至下位机,否则,不执行发送操作;S13: The protocol sending module detects whether the command sending buffer has commands that need to be sent, and judges whether the sending conditions are met. If so, the commands will be sent to the lower computer in sequence, otherwise, the sending operation will not be performed; 下位机接收和处理所述协议格式的过程包括步骤:The process of receiving and processing the protocol format by the lower computer includes the steps: S21:由下位机中的协议接收模块通过中断的方式接收所述协议格式,并发送至协议接收缓冲器中;S21: The protocol format is received by the protocol receiving module in the lower computer by means of interruption, and sent to the protocol receiving buffer; S22:由协议解析模块对所述协议接收缓冲器进行实时监测,判断所述协议接收缓冲器是否存有数据,并基于所述协议格式对所述数据进行分解和提取操作,同时判断数据的类型;S22: Real-time monitoring of the protocol receiving buffer by the protocol analysis module, judging whether the protocol receiving buffer has data, decomposing and extracting the data based on the protocol format, and judging the type of data at the same time ; S23:若所述数据为顺序指令,则通过顺序指令填入模块将所述顺序指令保存到命令FIFO存储器中,否则就为实时指令,并执行所述实时指令;S23: if the data is a sequential instruction, then the sequential instruction is filled in the module to save the sequential instruction in the command FIFO memory, otherwise it is a real-time instruction, and the real-time instruction is executed; S24:通过指令预读模块读取存入所述命令FIFO存储器的所述顺序指令,并由指令执行模块执行,同时通过预读指令及数据处理模块预读取和预处理所述命令FIFO存储器内的下一个所述顺序指令,并将下一个顺序指令存入等待执行模块中;S24: Read the sequential instructions stored in the command FIFO memory through an instruction pre-reading module, and execute them by an instruction execution module, while pre-reading and pre-processing the command FIFO memory through a pre-reading instruction and data processing module The next described sequence instruction, and the next sequence instruction is stored in the waiting execution module; S25:判断所述指令执行模块是否完成指令执行,完成则继续执行存入所述等待执行模块的顺序指令,否则所述等待执行模块一直处于等待状态。S25: Determine whether the instruction execution module completes the execution of the instruction, and if completed, continue to execute the sequence instruction stored in the waiting execution module, otherwise the waiting execution module is always in a waiting state. 2.根据权利要求1所述的一种嵌入式系统G代码异步通讯机制、协议及编程方法,其特征在于,所述协议格式由报头、字节数、命令码、命令编码、控制数据、CRC检验和报尾构成,其中所述报头为固定数据0x7E,用于识别所述协议格式;字节数用于协助下位机准确找到所述命令码、命令编码、控制数据和CRC检验;所述命令码用于对一类上位机发送的指令进行细化编号;所述CRC检验用于判断协议格式是否合法;所述报尾为固定数据0x0D,下位机根据报尾的具体数据识别所述协议格式中包含的指令是否结束。2. a kind of embedded system G code asynchronous communication mechanism, protocol and programming method according to claim 1, is characterized in that, described protocol format is composed of header, number of bytes, command code, command code, control data, CRC Checksum and trailer composition, wherein the header is fixed data 0x7E, which is used to identify the protocol format; the number of bytes is used to assist the lower computer to accurately find the command code, command code, control data and CRC check; the command The code is used to refine and number the instructions sent by a type of upper computer; the CRC check is used to judge whether the protocol format is legal; the tail is fixed data 0x0D, and the lower computer identifies the protocol format according to the specific data at the tail Whether the instruction contained in it ends. 3.根据权利要求2所述的一种嵌入式系统G代码异步通讯机制、协议及编程方法,其特征在于,在步骤S22中,还包括:下位机对所述协议接收缓冲区进行遍历,寻找每个所述协议格式的报头和报尾,并通过所述顺序指令填入模块监测所述命令FIFO存储器的存储空间大小,若所述存储空间已满,则所述上位机不再发送所述协议格式,并通过所述指令预读模块和所述指令执行模块对存储在所述命令FIFO存储器的所述协议格式进行消耗;否则所述命令FIFO存储器将继续接收上位机发送的所述协议格式。3. a kind of embedded system G code asynchronous communication mechanism, protocol and programming method according to claim 2, is characterized in that, in step S22, also comprises: lower computer traverses described protocol receiving buffer area, finds The header and trailer of each protocol format, and the sequence instruction filling module monitors the storage space size of the command FIFO memory. If the storage space is full, the host computer will no longer send the protocol format, and consume the protocol format stored in the command FIFO memory through the instruction pre-reading module and the instruction execution module; otherwise, the command FIFO memory will continue to receive the protocol format sent by the host computer . 4.根据权利要求2所述的一种嵌入式系统G代码异步通讯机制、协议及编程方法,其特征在于,所述报头和报尾由十六进制数据表示,所述字节数、命令码、命令编码、控制数据和CRC检验均由ASCⅡ码表示。4. a kind of embedded system G code asynchronous communication mechanism, protocol and programming method according to claim 2, is characterized in that, described header and trailer are represented by hexadecimal data, described byte number, command Code, command code, control data and CRC check are all represented by ASCII code. 5.根据权利要求1~4任一项所述的一种嵌入式系统G代码异步通讯机制、协议及编程方法,其特征在于,所述协议格式经过所述协议解析模块后以32位数据存储在所述命令FIFO存储器中。5. a kind of embedded system G code asynchronous communication mechanism, protocol and programming method according to any one of claim 1~4, it is characterized in that, described protocol format is stored with 32-bit data after described protocol analysis module in the command FIFO memory.
CN201810882541.XA 2018-08-06 2018-08-06 An embedded system G-code asynchronous communication mechanism, protocol and programming method Active CN109085798B (en)

Priority Applications (1)

Application Number Priority Date Filing Date Title
CN201810882541.XA CN109085798B (en) 2018-08-06 2018-08-06 An embedded system G-code asynchronous communication mechanism, protocol and programming method

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
CN201810882541.XA CN109085798B (en) 2018-08-06 2018-08-06 An embedded system G-code asynchronous communication mechanism, protocol and programming method

Publications (2)

Publication Number Publication Date
CN109085798A CN109085798A (en) 2018-12-25
CN109085798B true CN109085798B (en) 2021-01-26

Family

ID=64833521

Family Applications (1)

Application Number Title Priority Date Filing Date
CN201810882541.XA Active CN109085798B (en) 2018-08-06 2018-08-06 An embedded system G-code asynchronous communication mechanism, protocol and programming method

Country Status (1)

Country Link
CN (1) CN109085798B (en)

Families Citing this family (4)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN109889481B (en) * 2018-12-26 2022-09-20 广州市中海达测绘仪器有限公司 Data acquisition and fusion method and device based on multi-sensor equipment
JP6997131B2 (en) * 2019-04-05 2022-01-17 ファナック株式会社 Numerical control device
CN111522588B (en) * 2020-04-16 2023-05-05 珠海泰芯半导体有限公司 Chip operation interaction method and communication system based on SWD protocol
CN112925266B (en) * 2021-02-02 2024-08-06 深圳市显控科技股份有限公司 G code generation method, device, equipment and storage medium based on universal HMI

Citations (5)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN101534259A (en) * 2009-04-15 2009-09-16 兰州大成自动化工程有限公司 An asynchronous communication controller and its control method
CN101826273A (en) * 2009-11-11 2010-09-08 深圳市和怡科技有限公司 Network connection based teaching equipment adopting multiple numerical control systems and communication method
CN102665298A (en) * 2012-02-06 2012-09-12 福建三元达软件有限公司 Wireless communication module multiple return state processing method in foreground-background design
CN103888227A (en) * 2014-04-21 2014-06-25 华北水利水电大学 Data frame receiving and analyzing device and method based on VL
CN104239254A (en) * 2014-09-04 2014-12-24 西南技术物理研究所 Serial asynchronous communication data transmission method

Family Cites Families (1)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
US20090013284A1 (en) * 2007-07-02 2009-01-08 Virsycom, Inc. Systems and Methods for Communicating Information

Patent Citations (5)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN101534259A (en) * 2009-04-15 2009-09-16 兰州大成自动化工程有限公司 An asynchronous communication controller and its control method
CN101826273A (en) * 2009-11-11 2010-09-08 深圳市和怡科技有限公司 Network connection based teaching equipment adopting multiple numerical control systems and communication method
CN102665298A (en) * 2012-02-06 2012-09-12 福建三元达软件有限公司 Wireless communication module multiple return state processing method in foreground-background design
CN103888227A (en) * 2014-04-21 2014-06-25 华北水利水电大学 Data frame receiving and analyzing device and method based on VL
CN104239254A (en) * 2014-09-04 2014-12-24 西南技术物理研究所 Serial asynchronous communication data transmission method

Also Published As

Publication number Publication date
CN109085798A (en) 2018-12-25

Similar Documents

Publication Publication Date Title
CN109085798B (en) An embedded system G-code asynchronous communication mechanism, protocol and programming method
CN110620712B (en) Method for realizing real-time EtherCAT master station of Window platform
CN107193271A (en) Preposition service adapter and trouble-shooter for industrial information physical system
CN102787932A (en) Apparatus and method for matching and calibrating electric control diesel engine based on serial communication
CN105912339A (en) development and integration method and system
CN103207771B (en) A kind of PLC program actuator IP kernel
CN111277600A (en) Data transmission method and device
CN111897296A (en) Intelligent management system for industrial production line based on 5G communication
CN114860437A (en) Data acquisition method, edge calculation host and computer-readable storage medium
CN102377506A (en) Test message processing system
CN105721568A (en) Remote debugging system, method and device
JP2008065823A (en) Method for improving communication speed of hid device
US7296187B1 (en) Hardware debug device having script-based host interface
CN112559264B (en) Simulation test method for realizing FPGA (field programmable Gate array) universal serial port by verification platform based on UVM (Universal verification Module)
CN110032115B (en) Internet of things control system and method utilizing near field connection for real-time interaction
CN109634203B (en) Control system for controlling IO terminal based on numerical control controller and corresponding method
CN114125032B (en) Edge protocol data processing method and system
CN110794731A (en) An Embedded Soft PLC Control System Supporting Ethernet
CN109922088A (en) Industrial communication unification of three nets device and its working method
CN110990252B (en) A test method for testing quality and efficiency of embedded flight control software
CN102819508B (en) Method for responding to signals from security monitoring subsystem
CN116149253B (en) PLC online monitoring and debugging system and implementation method thereof
Yuan et al. CAN message unpack and pack based on simulink automatic code generation technology
CN108334035A (en) A kind of digital control system programmed method
CN113535627A (en) Method and device for realizing integration of multiple protocols

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
CB02 Change of applicant information

Address after: 213164 No.28, Mingxin Middle Road, Wujin District, Changzhou City, Jiangsu Province

Applicant after: Changzhou Polytechnic

Address before: 213164 No.28, Mingxin Middle Road, Wujin District, Changzhou City, Jiangsu Province

Applicant before: CHANGZHOU VOCATIONAL INSTITUTE OF LIGHT INDUSTRY

CB02 Change of applicant information
GR01 Patent grant
GR01 Patent grant