Design method of numerical control embedded PLC intermediate file conversion instruction list

文档序号:1815135 发布日期:2021-11-09 浏览:4次 中文

阅读说明:本技术 一种数控内嵌plc中间文件转化指令表的设计方法 (Design method of numerical control embedded PLC intermediate file conversion instruction list ) 是由 王庆华 胡延华 傅仁轩 何军拥 于 2021-07-29 设计创作,主要内容包括:本发明公开了一种数控内嵌PLC中间文件转化指令表的设计方法,该方法定义中间文件的数据结构BinCode,而每个BinCode占两个long int空间,而每个指令可以由一个或者几个BinCode数据结构表示,最后编译为二进制中间文件plc.bin,保存起来供后面程序处理,生成的二进制中间文件plc.bin可以由PLC编译执行器编译执行,从而实现整个工艺流程的输入输出控制。本发明通过编写不同的配置文件,可以满足不同厂家的要求,生成不同厂家的指令表语言,为学习不同指令的工程师或者学生能更快速的理解PLC代码功能提供了一个解决方案。(The invention discloses a design method of a numerical control embedded PLC intermediate file conversion instruction list, which defines the data structure BinCode of an intermediate file, each BinCode occupies two long int spaces, each instruction can be represented by one or more BinCode data structures, and finally compiled into a binary intermediate file plc.bin, and the binary intermediate file plc.bin is stored for later program processing, and the generated binary intermediate file plc.bin can be compiled and executed by a PLC compiling actuator, thereby realizing the input and output control of the whole process flow. The invention can meet the requirements of different manufacturers by compiling different configuration files, generates instruction list languages of different manufacturers, and provides a solution for engineers or students learning different instructions to understand the PLC code function more quickly.)

1. A design and compiling method of numerical control embedded PLC intermediate file is characterized in that the method defines the data structure BinCode of the intermediate file, each BinCode occupies two long int spaces, each instruction can be represented by one or more BinCode data structures, and finally, the BinCode data structures are compiled into a binary intermediate file plc.bin and stored for the processing of a subsequent program;

wherein, the data structure BinCode defining such an intermediate file is:

typedef struct{

char cmd;

char arg_t;

union{

unsigned int num;

struct{

unsigned char reg;

unsigned short no;

unsigned char bit;

}reg_no_bit;

}arg;

}BinCode;

the whole intermediate file consists of an array containing n BinCode structure bodies, and the specific meaning and value range of each member in the BinCode structure bodies are defined; cmd denotes an instruction code, which is divided into a basic instruction and a functional instruction; arg _ t represents a parameter type for indicating the meaning of data in the community; the structure reg _ no _ bit represents a register-group number-bit number; num represents a constant or state word.

2. The method for designing and compiling a numerical control embedded PLC intermediate file as claimed in claim 1, wherein the utility of cross-platform migration of the method can be further expanded, and the cross-platform translation process is as follows:

101. the intermediate file plc. bin and the vendor profile toir. txt are read in.

102. Writing a file, and opening the instruction list file plc.ir in a writing mode;

103. judging whether the BinCode is empty, if so, closing plc.ir, and exiting; otherwise, carrying out the next step;

104. reading rGetCmd (); reading cmd and possible parameters in the BinCode;

105. judging whether the cmd _ num is legal or not, if so, continuing the next step, and writing the cmd _ name [ cmd _ num ] into plc.ir;

106. judging whether the R _ num is legal or not, if so, continuing the next step, and writing the R _ name [ R _ num ] into plc.ir;

107. line feed is written to plc.

3. The method for designing and compiling a numerical control embedded PLC intermediate file as claimed in claim 2, wherein the step 101 specifically comprises: reading in ToIR, txt, and acquiring a relay list and a command list; bin is read in plc.

4. The method as claimed in claim 2, wherein in step 103, it is determined whether the PLC. If the translation is finished, closing the plc.ir file and exiting, thereby finishing the whole translation process; if not, the command is fetched.

5. The method for designing and compiling numerical control embedded PLC intermediate files as claimed in claim 2, wherein in the step 105, judging whether cmd _ num is legal is judging whether cmd exceeds a maximum range. If the range is legal, writing cmd _ name [ cmd _ num ] into plc.ir; if not, a command overrun is indicated.

6. The method for designing and compiling a digitally controlled embedded PLC intermediate file as recited in claim 2, wherein in step 106, it is determined whether an R _ num address exceeds a maximum range. If it is in legal range, write R _ name [ R _ num ] into plc.ir; if not, an address overrun is indicated.

Technical Field

The invention relates to the technical field of Programmable Logic Controllers (PLC) embedded in a numerical control system or an industrial robot control system, in particular to a design method of a numerical control embedded PLC intermediate file conversion instruction list.

Background

Programmable Logic Controllers (PLCs) are special purpose computers designed to perform industrial automation tasks. It uses a programmable memory, in which the instructions for implementing logical operation, sequence control, timing, counting and arithmetic operation are stored, and utilizes digital or analog input and output to control various mechanical equipments or production processes. In the PLC system, a control program represented in a form of an instruction list obtained by converting a ladder diagram is downloaded from an upper computer to a PLC main controller, the control logic of the PLC program can be realized by compiling (see figure 1) or explaining and executing the instruction list, and the field equipment is driven to execute a control task through a corresponding IO port module.

Chinese patent (CN101364098A) gefen et al discloses an example of a ladder diagram conversion into an instruction list in a PLC. Chinese patent (CN10104317631A) discloses an example of converting a command table into a ladder diagram in a PLC. Chinese patent (CN101957745A) discloses an example of a ladder diagram conversion to a structured text language in a PLC. The article "PLC source program coding method and interpretation execution algorithm design" discloses an algorithm design for structured text interpretation execution. The study and implementation of a Lex & Yacc-based PLC instruction compiler discloses a design method for instruction list compilation. The article "design and implementation of compiled PLC" discloses another design method for compiling an instruction list. The paper "software implementation of embedded PLC ladder programming in numerical control system" simply introduces the implementation method of PLC ladder software of a certain manufacturer.

The above patents and papers are examples of several programming languages for general purpose or embedded PLC and the transformation of the intermediate files, and little to no description of the structure compiled into the intermediate files and the intermediate files, resulting in no better utilization of the intermediate files for greater energy efficiency.

In production, because the programming methods of products of various manufacturers are very different and the technical specificity is strong, a worker can master the programming method of a certain product only through long-time professional training, so that the PLC application is not smooth, and particularly, the direct reading of a binary (intermediate) target file is not particularly convenient to understand.

Disclosure of Invention

Based on this, in order to solve the above problems, the primary object of the present invention is to provide a method for designing a numerical control embedded PLC intermediate file conversion instruction list, which is capable of reading and understanding the functions implemented by PLC codes more quickly.

The invention also aims to provide a design method of the numerical control embedded PLC intermediate file conversion instruction list, which can load the converted instruction list codes of different manufacturers into the PLC compiling environment of the manufacturer or a third party, directly compile and download, realize code intercommunication, function intercommunication and result intercommunication with little or no modification of the codes, thereby realizing the cross-platform transplantation of the PLC codes.

In order to achieve the purpose, the invention provides the following technical scheme:

a design method for a numerical control embedded PLC intermediate file conversion instruction list defines the data structure BinCode of an intermediate file, each BinCode occupies two long int spaces, and each instruction can be represented by one or more BinCode data structures, so that the operation of people on the instruction list can be facilitated; and finally compiling the file into a binary intermediate file plc. The generated binary intermediate file plc.bin can be compiled and executed by a PLC compiling executor, thereby realizing input and output control of the whole process flow.

Wherein, the data structure BinCode defining such an intermediate file is:

typedef struct{

char cmd;

char arg_t;

union{

unsigned int num;

struct{

unsigned char reg;

unsigned short no;

unsigned char bit;

}reg_no_bit;

}arg;

}BinCode;

the whole intermediate file consists of an array containing n BinCode structure bodies, and the specific meaning and value range of each member in the BinCode structure bodies are defined; cmd denotes an instruction code, which is divided into a basic instruction and a functional instruction; arg _ t denotes a parameter type for indicating the meaning of data in the common volume. 0: no parameters, 1: register-set number-bit number, 2: register-set number, 3: constant, 4: a status word; arg determines the information of the common body according to the meaning of arg _ t; the structure reg _ no _ bit represents a register-group number-bit number; num represents a constant or state word.

The generated binary intermediate file plc.bin is compiled and executed by a PLC compiling executor, so that the input and output control of the whole process flow is realized, and the cross-platform transplantation utility of the binary intermediate file plc.bin can be expanded, wherein the cross-platform translation process is as follows:

101. the intermediate file plc. bin and the vendor profile toir. txt are read in.

The method specifically comprises the following steps: reading in ToIR, txt, and acquiring a relay list and a command list; reading in plc.bin; 102. writing a file, and opening the instruction list file plc.ir in a writing mode;

103. judging whether the BinCode is empty, if so, closing plc.ir, and exiting; otherwise, carrying out the next step;

whether the plc. bin file organized in BinCode is read in and processed is judged. If the translation is finished, closing the plc.ir file and exiting, thereby finishing the whole translation process; if not, the command is fetched.

104. Reading rGetCmd (); reading cmd and possible parameters in the BinCode;

105. judging whether the cmd _ num is legal or not, if so, continuing the next step, and writing the cmd _ name [ cmd _ num ] into plc.ir;

judging whether cmd _ num is legal or not is judging whether cmd exceeds the maximum range or not. If the range is legal, writing cmd _ name [ cmd _ num ] into plc.ir; if not, a command overrun is indicated.

106. Judging whether the R _ num is legal or not, if so, continuing the next step, and writing the R _ name [ R _ num ] into plc.ir;

and judging whether the R _ num address exceeds the maximum range. If it is in legal range, write R _ name [ R _ num ] into plc.ir; if not, an address overrun is indicated.

107. Line feed is written into plc.ir; and returns to step 103.

Therefore, this intermediate file of PLC bins (containing basic instructions) can be translated into instruction list languages of different vendors by defining the configuration files of PLCs of different vendors. For more functional instructions with the characteristics of each manufacturer, more relays and registers and more practical functional instructions can be expanded through the data structure and definition, so that the cross-platform translator is more flexible and has more powerful functions.

Compared with the prior art, the invention has the beneficial effects that:

the invention can meet the requirements of different manufacturers by compiling different configuration files, generates instruction list languages of different manufacturers, and provides a solution for engineers or students learning different instructions to understand the PLC code function more quickly.

Meanwhile, the invention can load the converted instruction table codes of different manufacturers into the PLC compiling environment of the manufacturer or a third party, and directly compile and download, and the code intercommunication, function intercommunication and result intercommunication can be realized with little or no modification of the codes, thereby realizing the cross-platform transplantation of the PLC codes; and more relays and registers and more practical functional instructions are expanded through the data structure and the definition, so that the cross-platform translator is more flexible and has more powerful functions.

Drawings

FIG. 1 is a flow chart of an embedded PLC intermediate file compiler.

Fig. 2 is a flowchart of an embedded PLC intermediate file conversion instruction table according to the present invention.

Fig. 3 is an intermediate file of the embedded PLC of the present invention.

FIG. 4 is a configuration file ToIR. txt implementing custom IR, Siemens S7-200 STL, and FANUC instruction sheet in accordance with the present invention.

Fig. 5 is a plc. ir file of custom, S7-200, and FANUC transformed according to fig. 3 and 4 in accordance with the present invention.

Detailed Description

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, and it is obvious that the described embodiments are only a part of the embodiments of the present invention, and not all of the embodiments. All other embodiments, which can be derived by a person skilled in the art from the embodiments given herein without making any creative effort, shall fall within the protection scope of the present invention.

The design method of the numerical control embedded PLC intermediate file conversion instruction list comprises the steps of firstly defining the data structures BinCodes of the intermediate files, wherein each BinCode occupies two long int spaces, and each instruction can be represented by one or more BinCode data structures, so that the operation of people on the instruction list can be facilitated; and finally compiling the file into a binary intermediate file plc. The generated binary intermediate file plc.bin can be compiled and executed by a PLC compiling executor, thereby realizing input and output control of the whole process flow.

Wherein, the data structure BinCode defining such an intermediate file is:

typedef struct{

char cmd;

char arg_t;

union{

unsigned int num;

struct{

unsigned char reg;

unsigned short no;

unsigned char bit;

}reg_no_bit;

}arg;

}BinCode;

the whole intermediate file consists of an array containing n BinCode structure bodies, and the specific meaning and value range of each member in the BinCode structure bodies are defined; cmd denotes an instruction code, which is divided into a basic instruction and a functional instruction; arg _ t denotes a parameter type for indicating the meaning of data in the common volume. 0: no parameters, 1: register-set number-bit number, 2: register-set number, 3: constant, 4: a status word; arg determines the information of the common body according to the meaning of arg _ t; the structure reg _ no _ bit represents a register-group number-bit number; num represents a constant or state word.

The generated binary intermediate file plc.bin is compiled and executed by a PLC compiling executor, so that input and output control of the whole process flow is realized, and the cross-platform migration utility of the binary intermediate file plc.bin can be expanded, wherein the cross-platform translation process is shown in fig. 2:

101. the intermediate file plc. bin and the vendor profile toir. txt are read in.

102. Writing a file, and opening the instruction list file plc.ir in a writing mode;

103. judging whether the BinCode is empty, if so, closing plc.ir, and exiting; otherwise, carrying out the next step;

104. reading rGetCmd (); reading cmd and possible parameters in the BinCode;

105. judging whether the cmd _ num is legal or not, if so, continuing the next step, and writing the cmd _ name [ cmd _ num ] into plc.ir;

106. judging whether the R _ num is legal or not, if so, continuing the next step, and writing the R _ name [ R _ num ] into plc.ir;

107. line feed is written into plc.ir; and returns to step 103.

Therefore, this intermediate file of PLC bins (containing basic instructions) can be translated into instruction list languages of different vendors by defining the configuration files of PLCs of different vendors. For more function instructions with the characteristics of each manufacturer, an example plc. More relays and registers and more practical functional instructions can be expanded through the data structure and the definition, so that the cross-platform translator is more flexible and has more powerful functions.

One embodiment is as follows:

writing a basic instruction list of a PLC with a two-stage structure to realize some basic operation requirements on a numerical control machine tool, such as:

//EMERGENCY

1 LD X3.1

2 ORI F3.0

3 OUT G3.1

4 END1

5 LDI X5.4

6 SET R5.3

7 LD F0.4

8 OR X0.1

9 ANI X0.2

10 AND X0.4

11 RST Y5.4

12 END2

bin, as shown in fig. 3, a binary intermediate file plc. bin compiled according to the above method.

The flow of translating the intermediate file is as follows:

s1, reading a file;

as shown in fig. 2, the intermediate file plc.bin and the vendor profile toir.txt are read in. Briefly introduce the format of the toir.

Sequence numbers 1-20 are address tables for the PLC, as shown in table 1:

currently 14, 15-20 for expansion. As shown in fig. 4, the address tables of different manufacturers are configured according to the labels in table 1, and if they do not exist, they can be replaced by other addresses that do not affect the program, such as M relay for F relay and G relay.

S2, writing a file;

open the command table file plc. The method can generate instruction formats of different manufacturers according to different configuration files.

S3, judging whether the BinCode is empty;

whether the plc. bin file organized in BinCode is read in and processed is judged. If the translation is finished, closing the plc.ir file and exiting, thereby finishing the whole translation process; if not, the command is fetched.

S4, reading cmd;

reading cmd in BinCode and possible parameters: some commands may not have parameters, such as END 1; there are commands with a parameter, such as LD; there are commands with two parameters, such as TMRC; some commands have multiple parameters, and all the parameters are read.

S5, judging whether the cmd is legal or not;

and judging whether the cmd exceeds the maximum range. If the range is legal, writing cmd _ name [ cmd _ num ] into plc.ir; if not, a command overrun is indicated.

S6, judging whether R _ num is legal or not

And judging whether the R _ num address exceeds the maximum range. If it is in legal range, write R _ name [ R _ num ] into plc.ir; if not, an address overrun is indicated.

S7, write plc.ir; and returns to the loop for translation.

In the specific translation process, as shown in fig. 2, under the condition that the address and the command are legal, the content after the configuration file tag is replaced, and finally the content is written into plc.

And (3) translating the intermediate file extension: for more functional instructions with the characteristics of each manufacturer, more relays and registers and more practical functional instructions can be expanded through the data structure and definition, so that the cross-platform translator is more flexible and has more powerful functions.

Instruction list transplanting: and loading or copying the converted instruction list codes plc.ir of different manufacturers to a PLC compiling environment of the manufacturer or a third party, directly compiling and downloading, and realizing code intercommunication, function intercommunication and result intercommunication by slightly modifying or even not modifying the codes, thereby realizing cross-platform transplantation of the PLC codes.

In a word, the invention can meet the requirements of different manufacturers by compiling different configuration files, generate instruction list languages of different manufacturers and provide a solution for engineers or students learning different instructions to understand the PLC code function more quickly.

Meanwhile, the invention can load the converted instruction table codes of different manufacturers into the PLC compiling environment of the manufacturer or a third party, and directly compile and download, and the code intercommunication, function intercommunication and result intercommunication can be realized with little or no modification of the codes, thereby realizing the cross-platform transplantation of the PLC codes; and more relays and registers and more practical functional instructions are expanded through the data structure and the definition, so that the cross-platform translator is more flexible and has more powerful functions.

The above description is only for the preferred embodiment of the present invention, but the scope of the present invention is not limited thereto, and any person skilled in the art should be able to cover the technical solutions and the inventive concepts of the present invention within the technical scope of the present invention.

13页详细技术资料下载
上一篇:一种医用注射器针头装配设备
下一篇:用于摇饮料机器人的数据采集传输的律动动感控制系统

网友询问留言

已有0条留言

还没有人留言评论。精彩留言会获得点赞!

精彩留言,会给你点赞!

技术分类