ModBus communication script generation method and device based on graphical programming

文档序号:1952106 发布日期:2021-12-10 浏览:20次 中文

阅读说明:本技术 基于图形化编程的ModBus通讯脚本生成方法和装置 (ModBus communication script generation method and device based on graphical programming ) 是由 王建民 李仲效 姜宇 于 2021-11-11 设计创作,主要内容包括:本申请提供了基于图形化编程的ModBus通讯脚本生成方法和装置,涉及图形化编程技术领域。生成方法包括:响应于用户对积木图形的拖动操作,在编辑界面上搭建ModBus图形组合,ModBus图形组合包括分别与至少一个类型的ModBus寄存器对应的寄存器积木图形,ModBus图形组合表示主站与从站中的至少一个类型的ModBus寄存器之间的数据交互逻辑;响应于用户在每个寄存器积木图形中的输入操作,确定主站对每个类型的ModBus寄存器的操作数据;对ModBus图形组合和操作数据进行解析,得到ModBus通讯的脚本文件。本申请提供的基于图形化编程的ModBus通讯脚本生成方法和装置可以解决现有的Modbus通讯的脚本文件编程难度较大的问题。(The application provides a ModBus communication script generation method and device based on graphical programming, and relates to the technical field of graphical programming. The generation method comprises the following steps: responding to the dragging operation of a user on the building block graph, building a ModBus graph combination on an editing interface, wherein the ModBus graph combination comprises register building block graphs corresponding to at least one type of ModBus register respectively, and the ModBus graph combination represents data interaction logic between at least one type of ModBus register in the master station and at least one type of ModBus register in the slave station; responding to input operation of a user in each register building block graph, and determining operation data of the master station on each type of ModBus register; and analyzing the ModBus graph combination and the operation data to obtain a script file of ModBus communication. The ModBus communication script generation method and device based on graphical programming can solve the problem that existing Modbus communication script files are difficult to program.)

1. A ModBus communication script generation method based on graphical programming is characterized by comprising the following steps:

responding to the dragging operation of a user on the building block graph, building a ModBus graph combination on an editing interface, wherein the ModBus graph combination comprises register building block graphs corresponding to at least one type of ModBus register respectively, and the ModBus graph combination represents data interaction logic between the ModBus registers of at least one type in the master station and the ModBus registers of the slave station;

responding to input operation of a user in each register building block graph, and determining operation data of the master station on each type of ModBus register;

and analyzing the ModBus graph combination and the operation data to obtain a script file of ModBus communication.

2. The method of claim 1, wherein the at least one type of ModBus register includes a coil register, the ModBus pattern combination including a fetch coil building block pattern corresponding to the coil register;

the obtaining of the coil building block figure comprises obtaining of a single coil building block figure, and the obtaining of the single coil building block figure comprises a first address edit bar;

and after a first address is input into the first address edit bar, the obtaining single-coil building block graph represents a process that the master station reads first data from the first address of the coil register of the slave station.

3. The method of claim 2, wherein said obtaining a coil building block pattern further comprises obtaining a multi-coil building block pattern;

the method comprises the steps that the obtained multi-coil building block graph comprises a second address editing column and a first digit editing column, when a second address is input into the second address editing column and a first digit n is input into the first digit editing column, the obtained multi-coil building block graph represents a process that the master station reads n second data from the second address of the coil register of the slave station and n-1 addresses adjacent to the second address, and n is larger than or equal to 2.

4. The method of claim 1, wherein the at least one type of ModBus register includes a coil register, the ModBus pattern combination including a set coil building block pattern corresponding to the coil register;

the setting of the coil building block graph comprises setting of a single-coil building block graph, and the setting of the single-coil building block graph comprises a third address edit bar and a third data edit bar;

and after a third address is input into the third address edit column and third data is input into the third data edit column, setting a single data building block graph to represent the process that the master station writes the third data into the third address of the coil register of the slave station.

5. The method of claim 4, wherein providing a loop block graphic further comprises providing a multi-loop block graphic;

and the set multi-coil building block graph comprises a fourth address edit column, a fourth data edit column and a second digit edit column, and after a fourth address is input into the fourth address edit column, m fourth data are input into the fourth data edit column and a second digit m is input into the second digit edit column, the set multi-coil building block graph represents a process that the master station sequentially writes the m fourth data into the fourth address of the coil register of the slave station and m-1 addresses adjacent to the fourth address, and m is larger than or equal to 2.

6. The method of claim 1, wherein the at least one type of ModBus register comprises a hold register, and wherein the ModBus pattern combination comprises a fetch hold building block pattern corresponding to the hold register;

the obtaining and holding building block graph comprises a fifth address edit bar and a first type edit bar, and after a fifth address is input into the fifth address edit bar and a first data type is input into the first type edit bar, the obtaining and holding building block graph represents a process that the master station reads fifth data corresponding to the first data type from the fifth address of the holding register of the slave station.

7. The method of claim 1, wherein the at least one type of ModBus register comprises a hold register, and wherein the ModBus pattern combination comprises a set hold building block pattern corresponding to the hold register;

the set and maintained building block graph comprises a sixth address editing column, a sixth data editing column and a second type editing column, and after a sixth address is input into the sixth address editing column, sixth data is input into the sixth data editing column and a second data type is input into the second type editing column, the set and maintained building block graph represents a process that the master station writes sixth data corresponding to the second data type into the sixth address of the maintaining register of the slave station.

8. The method of claim 1, wherein the at least one type of ModBus register includes a contact register, the ModBus pattern combination including a get contact building block pattern corresponding to the contact register;

the acquisition contact block graph comprises a seventh address edit bar, and after a seventh address is input into the seventh address edit bar, the acquisition contact block graph represents a process that the master station reads seventh data from the seventh address of the contact register of the slave station.

9. The method of claim 1, wherein the at least one type of ModBus register includes an input register, wherein the ModBus pattern combination includes a get input building block pattern corresponding to the input register;

the obtaining input building block graph comprises an eighth address edit bar and a third type edit bar, and after an eighth address is input into the eighth address edit bar and a third data type is input into the third type edit bar, the obtaining input building block graph represents a process that the master station reads eighth data from the eighth address of the input register of the slave station.

10. The method of any of claims 2 to 9, wherein the ModBus graphic combination further comprises creating a connecting building block graphic;

and the created connecting building block graph comprises an IP editing column, a port editing column and an ID editing column, and shows the process that the master station initiates active connection to the slave station corresponding to the IP address, the data port and the equipment number after the IP address is input into the IP editing column, the data port is input into the port editing column and the equipment number is input into the ID editing column.

11. The method of claim 10, wherein the ModBus graphic combination further comprises identifying a connected building block graphic;

and after the connection building block graph is established, the connection building block graph is confirmed to represent a process of confirming a connection result of the master station and the slave station, and the connection result is connection failure or connection success.

12. A ModBus communication script generating device based on graphical programming is characterized by comprising:

the building unit is used for responding to dragging operation of a user on the building block graph, building a ModBus graph combination on an editing interface, wherein the ModBus graph combination comprises register building block graphs corresponding to at least one type of ModBus register respectively, and the ModBus graph combination represents data interaction logic between the at least one type of ModBus register in the master station and the at least one type of ModBus register in the slave station;

the input unit is used for responding to input operation of a user in each register building block graph, and determining operation data of the master station on each type of ModBus register;

and the analysis unit is used for analyzing the ModBus graph combination and the operation data to obtain a script file of ModBus communication.

13. A robot comprising a robot arm, a memory, a processor, and a computer program stored in the memory and executable on the processor, the robot arm being connected to the processor, the processor implementing the method of any one of claims 1 to 11 when executing the computer program.

14. A terminal device comprising a memory, a processor and a computer program stored in the memory and executable on the processor, characterized in that the processor implements the method according to any of claims 1 to 11 when executing the computer program.

15. A computer-readable storage medium, in which a computer program is stored which, when being executed by a processor, carries out the method according to any one of claims 1 to 11.

Technical Field

The application relates to the technical field of graphical programming, in particular to a ModBus communication script generation method and device based on graphical programming.

Background

The Modbus communication protocol is a serial communication protocol based on a Programmable Logic Controller (PLC). In the field of industrial control, during Modbus communication between a master station and slave stations, the master station can read data in registers of the slave stations or write data into the registers of the slave stations, so that interactive control is performed between the master station and the slave stations. The register comprises a coil register, a contact register, a holding register and an input register. At present, script files of Modbus communication need professional personnel to compile codes. However, the difficulty of programming is high, and it is difficult for most users who are not computer professional to efficiently write out an accurate script file.

Disclosure of Invention

The embodiment of the application provides a ModBus communication script generation method and device based on graphical programming, and the problem that the existing Modbus communication script file is difficult to program can be solved.

In a first aspect, an embodiment of the present application provides a method for generating a ModBus communication script based on graphical programming, including: responding to the dragging operation of a user on the building block graph, building a ModBus graph combination on an editing interface, wherein the ModBus graph combination comprises register building block graphs corresponding to at least one type of ModBus register respectively, and the ModBus graph combination represents data interaction logic between at least one type of ModBus register in the master station and at least one type of ModBus register in the slave station; responding to input operation of a user in each register building block graph, and determining operation data of the master station on each type of ModBus register; and analyzing the ModBus graph combination and the operation data to obtain a script file of ModBus communication.

Based on the ModBus communication script generation method based on graphical programming provided by the application, a user can set up a ModBus graph combination on an editing interface by dragging a register building block graph corresponding to at least one type of ModBus register. According to the input operation of a user in each register building block graph in the ModBus graph combination, the operation data of the master station to the corresponding type of register in the slave station can be determined, and after the ModBus graph combination and the operation data are analyzed, a script file for ModBus communication between the master station and the slave station can be obtained. In the ModBus communication design process, a user does not need to compile script codes by using a professional programming language, and can quickly acquire an accurate ModBus communication script file by only completing building of building block graphs and inputting of operation data. The method provided by the application solves the problem that the script file programming difficulty of ModBus communication is high.

Optionally, the at least one type of ModBus register includes a coil register, and the ModBus pattern combination includes an acquired coil building block pattern corresponding to the coil register; the method comprises the steps of obtaining a coil building block graph, wherein the obtaining of the single-coil building block graph comprises a first address edit bar; and when the first address is input into the first address edit bar, acquiring a single-coil building block graph to show the process that the master station reads the first data from the first address of the coil register of the slave station.

Optionally, the obtaining of the coil building block graph further comprises obtaining a multi-coil building block graph; the method comprises the steps that a multi-coil building block graph is obtained and comprises a second address editing column and a first digit editing column, when a second address is input into the second address editing column and a first digit n is input into the first digit editing column, the multi-coil building block graph is obtained and represents a process that a master station reads n second data from a second address of a coil register of a slave station and n-1 addresses adjacent to the second address, and n is larger than or equal to 2.

Optionally, at least one type of ModBus register includes a coil register, and the ModBus pattern combination includes a set coil building block pattern corresponding to the coil register; setting a coil building block graph comprises setting a single-coil building block graph, and setting the single-coil building block graph comprises a third address edit bar and a third data edit bar; and after a third address is input into the third address edit column and third data is input into the third data edit column, setting a single data building block graph to show the process that the master station writes the third data into the third address of the coil register of the slave station.

Optionally, the setting of the coil building block graph further comprises setting a multi-coil building block graph; and after a fourth address is input into the fourth address editing column, m fourth data are input into the fourth data editing column and a second digit m is input into the second digit editing column, the multi-coil building block graph is set to represent a process that the master station sequentially writes m fourth data into a fourth address of a coil register of the slave station and m-1 addresses adjacent to the fourth address, and m is larger than or equal to 2.

Optionally, the at least one type of ModBus register includes a holding register, and the ModBus pattern combination includes a fetch holding building block pattern corresponding to the holding register; and when a fifth address is input into the fifth address edit bar and a first data type is input into the first type edit bar, the obtaining and maintaining block graph represents a process that the master station reads fifth data corresponding to the first data type from the fifth address of the maintaining register of the slave station.

Optionally, the at least one type of ModBus register includes a holding register, and the ModBus pattern combination includes a set holding building block pattern corresponding to the holding register; and after a sixth address is input into the sixth address edit bar, sixth data is input into the sixth data edit bar and a second data type is input into the second type edit bar, the set and maintained building block graph represents a process that the master station writes sixth data corresponding to the second data type into the sixth address in the maintaining register of the slave station.

Optionally, the at least one type of ModBus register includes a contact register, and the ModBus pattern combination includes a touch point obtaining building block pattern corresponding to the contact register; and the acquired contact building block graph comprises a seventh address edit column, and after a seventh address is input into the seventh address edit column, the acquired contact building block graph represents a process that the master station reads seventh data from the seventh address of the contact register of the slave station.

Optionally, the at least one type of ModBus register includes an input register, and the ModBus pattern combination includes an acquisition input building block pattern corresponding to the input register; and the obtained input building block graph represents a process that the master station reads eighth data from the eighth address of the input register of the slave station after the eighth address is input into the eighth address edit column and the third data type is input into the third type edit column.

Optionally, the ModBus graph combination further comprises creating a connection building block graph; and after the IP address is input into the IP edit column, the data port is input into the port edit column and the equipment number is input into the ID edit column, the connection building block graph is created to show the process that the master station initiates active connection to the slave station corresponding to the IP address, the data port and the equipment number.

Optionally, the ModBus graph combination further comprises a confirmation connection building block graph; and confirming that the connection building block graph is built after the connection building block graph is created, wherein the confirmation connection building block graph represents a process of confirming a connection result of the master station and the slave station, and the connection result is connection failure or connection success.

In a second aspect, an embodiment of the present application provides a ModBus communication script generating device based on graphical programming, including: the building unit is used for responding to dragging operation of a user on the building block graph, building a ModBus graph combination on an editing interface, wherein the ModBus graph combination comprises register building block graphs corresponding to at least one type of ModBus register, and the ModBus graph combination represents data interaction logic between at least one type of ModBus register in the master station and at least one type of ModBus register in the slave station; the input unit is used for responding to input operation of a user in each register building block graph and determining operation data of each type of ModBus register; and the analysis unit is used for analyzing the ModBus graph combination and the operation data by the master station to obtain a script file of ModBus communication.

In a third aspect, embodiments of the present application provide a robot, including a robot arm, a memory, a processor, and a computer program stored in the memory and executable on the processor, the robot arm being connected to the processor; the processor, when executing the computer program, implements the method as described in any of the above first aspects.

In a fourth aspect, an embodiment of the present application provides a terminal device, which includes a memory, a processor, and a computer program stored in the memory and executable on the processor, and when the processor executes the computer program, the method according to any one of the first aspect is implemented.

In a fifth aspect, the present application provides a computer-readable storage medium, which stores a computer program, and when the computer program is executed by a processor, the computer program implements the method according to any one of the above first aspects.

In a sixth aspect, the present application provides a computer program product, which when run on a terminal device, causes the terminal device to perform the method of any one of the above first aspects.

It is understood that the beneficial effects of the second to sixth aspects can be seen from the description of the first aspect, and are not described herein again.

Drawings

In order to more clearly illustrate the technical solutions in the embodiments of the present application, the drawings needed to be used in the embodiments or the prior art descriptions will be briefly described below, and it is obvious that the drawings in the following description are only some embodiments of the present application, and it is obvious for those skilled in the art to obtain other drawings based on these drawings without inventive exercise.

FIG. 1 is an interface diagram of a graphical programming software provided by an embodiment of the present application;

fig. 2 is a flowchart of a ModBus communication script generation method based on graphical programming according to an embodiment of the present application;

FIG. 3 is an editing interface constructed with ModBus graphic combinations according to an embodiment of the present application;

FIG. 4 is an editing interface showing a ModBus graphic composition with operation data according to an embodiment of the present application;

FIG. 5 is a script file of ModBus communication displayed in the graphical programming software according to an embodiment of the present application;

fig. 6 is an operation flowchart of a user building a ModBus graph combination and obtaining a script file according to an embodiment of the present application;

fig. 7 is a schematic structural diagram of a ModBus communication script generating device based on graphical programming according to an embodiment of the present application;

fig. 8 is a schematic structural diagram of a terminal device according to an embodiment of the present application.

Detailed Description

In the following description, for purposes of explanation and not limitation, specific details are set forth, such as particular system structures, techniques, etc. in order to provide a thorough understanding of the embodiments of the present application. It will be apparent, however, to one skilled in the art that the present application may be practiced in other embodiments that depart from these specific details. In other instances, detailed descriptions of well-known systems, devices, circuits, and methods are omitted so as not to obscure the description of the present application with unnecessary detail.

In the field of industrial control, during Modbus communication between a master station and a slave station, the master station can read data in a register of the slave station or write data in a register of the slave station, so that data interaction is performed between the master station and the slave station. The register comprises a coil register, a contact register, a holding register and an input register, wherein a plurality of storage addresses are arranged in each register, and each storage address is used for storing one datum. The coil register and the holding register can realize the writing and reading of one or more data, and the contact register and the input register can only realize the reading of one data. The script file of the current Modbus communication needs professional personnel to compile codes. However, the difficulty of programming is high, and it is difficult for most users who are not computer professional to efficiently write out an accurate script file.

In order to solve the foregoing technical problem, an embodiment of the present application provides a method and an apparatus for generating a ModBus communication script based on graphical programming. In the graphical programming software, a user can set up ModBus graph combinations on an editing interface by dragging a plurality of register building block graphs, and after corresponding operation data is input into each ModBus graph combination, the graphical programming software can automatically analyze the ModBus graph combinations set up by the user and the input operation data to obtain script files corresponding to ModBus communication between a master station and a slave station. In the ModBus communication design process, a user does not need to write script codes, only needs to complete building of building block graphs and data input, can obtain a script file of ModBus communication, and solves the problem that the programming difficulty of the script file of the existing ModBus communication is high.

The technical solution of the present application is described in detail below with reference to the accompanying drawings. The embodiments described below with reference to the drawings are exemplary and intended to be used for explaining the present application and should not be construed as limiting the present application.

The application provides graphical programming software, and ModBus building block graphs required for ModBus communication between a master station and slave stations are arranged in the graphical programming software. The user can drag the ModBus building block graphs to an editing interface to build ModBus graph combinations so as to represent data interaction logics between one or more types of ModBus registers arranged in the master station and the slave station, and the user can also input operation data required by ModBus communication in an editing column of each ModBus building block graph.

Fig. 1 is an interface diagram of graphical programming software provided in an embodiment of the present application. The graphical programming software may be Scratch, Makecode, Mixly, MBlock, Mind +, or others. After the user starts the graphical programming software, a programming interface as shown in fig. 1 can be displayed, and the programming interface comprises a first display interface, a second display interface and an editing interface. The first display interface comprises various types of icons and names, such as events, controls, ModBus and the like.

After the user clicks any type of icon or name in the first display interface, all the building block graphs in the corresponding type can be displayed in the second display interface. For example, as shown in fig. 1, after the user clicks an icon corresponding to the event type in the first display interface, a building block graph which is included in the event type and starts to be run is displayed in the second display interface. After clicking the icon corresponding to the control type, the user displays the building block graph with the circulation function, the building block graph with the condition judgment function and the building block graph with other functions in the control type in the second display interface, and only the condition judgment building block graph corresponding to the if-then statement and the printed building block graph corresponding to the output statement are shown in fig. 1. In addition, after clicking the icon corresponding to the ModBus type, the user displays a register building block graph corresponding to at least one ModBus register of the type, creates a connection building block graph and confirms the connection building block graph in a second display interface. At least one type of ModBus register includes any one or more of a coil register, a hold register, a contact register, and an input register.

By way of example and not limitation, in one example, a register block pattern corresponding to a coil register product includes obtaining a coil block pattern. Obtaining the coil building block pattern includes obtaining a single coil register. The obtaining of the single-coil building block graph comprises a first address edit field, and after the user inputs a first address in the first address edit field, the obtaining of the single-coil register represents a process that the master station reads first data from the first address of the coil register of the slave station.

Optionally, obtaining the coil block figure may further include obtaining a multi-coil block figure. The multi-coil building block graph obtaining method comprises a second address editing column and a first digit editing column. And after a user inputs a second address in the second address editing column and inputs a first digit n in the first digit editing column, acquiring a multi-coil building block graph to represent a process that the master station reads n second data from a second address of a coil register of the slave station and n-1 addresses adjacent to the second address, wherein n is more than or equal to 2.

In another example, the register block pattern corresponding to the coil register may further include setting a coil block pattern. Setting up the coil building block figure includes setting up the monocoil building block figure, and setting up the monocoil building block figure includes third address edit bar and third data edit bar. And after the user inputs a third address in the third address edit column and third data in the third data edit column, setting a single-data building block graph to show the process that the master station writes the third data in the third address of the coil register of the slave station.

Optionally, the step of providing a coil building block pattern may further comprise providing a multi-coil building block pattern. And the multi-coil building block graph is arranged to comprise a fourth address edit bar, a fourth data edit bar and a second digit edit bar. And after a user inputs a fourth address in the fourth address edit column, m fourth data in the fourth data edit column and a second digit m in the second digit edit column, setting a multi-coil building block graph to show the process that the master station sequentially writes m fourth data in the fourth address of the coil register of the slave station and m-1 addresses adjacent to the fourth address, wherein m is more than or equal to 2.

In one example, the register block graph corresponding to the holding register includes a fetch holding block graph. And after the user inputs a fifth address in the fifth address edit bar and inputs a first data type in the first type edit bar, acquiring the holding building block graph to show a process that the master station reads fifth data corresponding to the first data type from the fifth address of the holding register of the slave station.

Optionally, the register block pattern corresponding to the holding register may further include setting a holding block pattern. And after the user inputs a sixth address in the sixth address editing column, sixth data in the sixth data editing column and a second data type in the second type editing column, setting the holding building block graph to show the process that the master station writes sixth data corresponding to the second data type in the sixth address in the holding register of the slave station.

The register block graph corresponding to the contact register includes an acquisition contact block graph. The acquired contact building block graph comprises a seventh address edit field, and after the seventh address is input in the seventh address edit field by the user, the acquired contact building block graph represents a process that the master station reads seventh data from the seventh address of the contact register of the slave station.

The register block graph corresponding to the input register includes obtaining an input block graph. And the acquired input building block graph represents a process that the master station reads eighth data from the eighth address of the input register of the slave station after a user inputs an eighth address in the eighth address edit bar and a third data type in the third type edit bar. For example, the first data type, the second data type, and the third data type may be u8, u16, u32, s8, s16, s32, Size _ t, or other data types.

The created connection building block graph comprises an IP edit bar, a port edit bar and an ID edit bar. After a user inputs an IP address in the IP edit column, inputs a data port in the port edit column and inputs a device number in the ID edit column, a connection building block graph is created to represent the process that a master station initiates active connection to a slave station corresponding to the IP address, the data port and the device number. And confirming that the connection building block graph is built after the connection building block graph is created, wherein the confirmation connection building block graph represents a process of confirming a connection result of the master station and the slave station, and the connection result is connection failure or connection success.

Based on the graphical programming software provided in the above embodiment, the application provides a graphical programming-based ModBus communication script generation method. An exemplary flow chart of a graphical programming based ModBus communication script generation method is shown in fig. 2, and the method includes the following steps:

and S101, responding to the dragging operation of a user on the building block graph, and building a ModBus graph combination on an editing interface, wherein the ModBus graph combination comprises register building block graphs corresponding to at least one type of ModBus register respectively, and the ModBus graph combination represents data interaction logic between at least one type of ModBus register in the master station and at least one type of ModBus register in the slave station.

Illustratively, it is assumed that the slave station includes a plurality of types of ModBus registers, respectively, a coil register, a hold register, an input register, and a contact register. The logic of data interaction between multiple types of ModBus registers in the master station and the slave station is as follows: the master station initiates an active connection with the slave station, and after the connection is successful, the master station writes data 0 into the address 00000 of the coil register of the slave station, writes data 0,0,0,1 into the address 00001-. Further, the master station can also read data at the address 30000 of the input register, the address 20001 of the holding register, the address 40000 of the touch point register, and the address 00009 of the coil register, respectively, and move to the point P1 according to the data read from the address 00009 of the coil register.

If the data interaction logic of the ModBus communication is to be realized, a user can determine building block graphs required by ModBus graph combination. After the user starts the editing interface, the building block graph for realizing the data interaction logic is dragged to the editing interface, and the ModBus graph combination is built on the editing interface.

Illustratively, a ModBus graphic combination is built on the editing interface shown in FIG. 3. After a user drags the starting-operation building block graph from the second display interface to the editing interface, three graph groups obtained by combining the printing building block graph with the acquisition data input building block graph, the acquisition data retention building block graph and the acquisition data contact building block graph respectively and a graph group obtained by combining the condition judgment building block graph with the acquisition single data coil building block graph can be sequentially built and created after the starting-operation building block graph, the single coil building block graph, the multi-coil building block graph and the storage building block graph are set, and the ModBus graph combination is built on the editing interface.

And S102, responding to the input operation of the user in each register building block graph, and determining the operation data of the master station to each type of ModBus register.

According to data interaction logic when ModBus communication is carried out between the master station and the slave station, a user can determine parameters needing to be input in each register building block graph, and therefore configuration parameters needed when ModBus communication is carried out between the master station and the slave station are determined.

By way of example and not limitation, the data interaction logic for ModBus communication between the master station and the slave station provided in step S101 is taken as an example to describe the data input process of the user in each register block graph.

As shown in fig. 4, after the user enters "192.168.5.10" in the IP edit column, enters "502" in the port edit column, and enters "1" in the ID edit column of the created connection block graph, the created connection block graph represents a process in which the master initiates an active connection with the slave having an IP address of 192.168.5.10, a data port of 502, and a device number of 1, thereby establishing a ModBus communication connection. After the master station is successfully connected with the slave station, the master station can perform data interaction with the slave station through the data port '502'.

After the user enters "00000" in the third address edit field and "0" in the third data edit field of the set single-coil block graphic, the set single-coil block graphic indicates that the master station writes data 0 to the slave station at the memory address 00000 in the coil register.

After the user inputs "00001" in the fourth address edit field, 4 fourth data "{ 0,0,0,1} in the fourth data edit field, and" 4 "in the second digit edit field of the set multi-coil block pattern, the set multi-coil block pattern indicates that the address" 00001 "of the coil register of the slave station is the start address, and the master station sequentially writes 4 fourth data into each of the addresses 00001 to 00004, that is, writes data 0 in address 00001, writes data 0 in address 00002, writes data 0 in address 00003, and writes data 1 in address 00004.

After the user enters the sixth address "20000" in the sixth address edit column of the setup hold block graphic, the sixth data "50" in the sixth data edit column and the second data type "U16" in the second type edit column, the setup hold block graphic indicates that the master station writes the sixth data 50 into data of the U16 type into the storage address 20000 of the slave station's hold register.

After the user enters the eighth address "30000" in the eighth address edit field and "U16" in the third type edit field of the fetch input block graphic representing the master station reading the eighth data stored in the address 30000 of the input register of the slave station. And outputting the eighth data read from the input register by the graphic group constructed by the printing building block graphic and the obtaining input building block graphic.

After the user enters the fifth address "20001" in the fifth address edit field of the fetch holding block graphic and "U16" in the first type edit field, the fetch holding block graphic indicates that the master station reads the fifth data stored in the address 20001 of the holding register of the slave station. And outputting the fifth data read from the holding register by the graphic group representation constructed by printing the building block graphic and acquiring the holding building block graphic.

After the user inputs the seventh address "40000" in the seventh address edit field of the acquired contact block figure, the acquired contact block figure indicates that the master station reads the seventh data stored in the address 40000 of the contact register of the slave station. And outputting seventh data read from the contact register by the graphic group representation constructed by the printing building block graph and the acquiring contact building block graph.

Embedding and acquiring a single-coil building block graph, a motion mode building block graph and a printed building block graph in a condition judgment building block graph, after a user inputs a first address '00009' in first address editing in the single-coil building block graph, inputs a preset motion mode 'MovJ' and a position P1 of a motion point in the motion mode building block graph and inputs 'Hello word' in the printed building block graph, the graph group represents that a master station acquires first data stored in an address 00009 of a coil register of the slave station, judges whether the first data is 1 or not, if the condition is met, the master station moves to a point P1 based on a joint motion instruction, and otherwise, outputs the Hello word.

It should be noted that step S101 and step S102 may be executed successively or alternately. For example, after the ModBus graphic combination is built, the user may perform an input operation on each building block graphic in the ModBus graphic combination. Or dragging one of the building block graphs to an editing interface, finishing the input operation of the building block graph, dragging the other building block graph to the editing interface, and so on until the ModBus graph combination is built and the input operation of each building block graph is finished.

In addition, for each edit bar in the building block graph, a user can directly input corresponding data in the edit bar through a keyboard, and embedded plug-ins such as pull-down combination buttons, sliders and the like can also be arranged in the edit bar. If a pull-down combination button, such as an inverted triangle button, is set in the edit bar, the user clicks the pull-down combination button in the edit bar, and then displays a plurality of data in the pull-down list, and the graphical programming software may respond to the user's click operation on one of the plurality of data, and display the data selected by the user in the corresponding edit bar.

And S103, analyzing the ModBus graph combination and the operation data to obtain a script file of ModBus communication.

In the embodiment of the application, after a user builds a ModBus graphic combination in an editing interface and completes the input operation of each building block graphic in the ModBus graphic combination, graphic programming software can automatically analyze the ModBus graphic combination and operation data to obtain a code for realizing TCP communication. The specific codes are as follows:

resultCreate,id=ModbusCreate(‘192.168.5.10’,502,1)

SetCoils(00000,1,{0})

SetCoils(00001,4,{0,0,0,1})

SetHoldRegs(20000,1,{50},“U16”)

Print((GetInregs(30000,1,“U16”)[1]))

Print((GetHoldRegs(20001,1,“U16”)[1]))

Print((GetInBits(40000,1)[1]))

If ((GetCoils(00009,1)[1]))=1

Go(P1)

else

Print(“Hello world!”)

optionally, after the user triggers the first operation, a program interface may be displayed, and the script file for ModBus communication and the code are displayed on the program interface. Illustratively, referring to fig. 4, after clicking a "debug" button in a programming interface of the graphical programming software, a program interface as shown in fig. 5 is displayed, and specific codes in a script file of ModBus communication are displayed in the program interface. The user clicks the "run" button to run the code in the script file. In addition, the user can click a save button in a programming interface or a program interface of the graphical programming software to save the script file of the ModBus communication.

According to the ModBus communication script generation method based on graphical programming, register building block graphs corresponding to ModBus registers of multiple types are set in graphical programming software, and a user can build ModBus graph combinations on an editing interface based on the register building block graphs. According to the building connection building block graph created in the ModBus graph combination by a user and the input operation in each register building block graph, the operation data of the master station to each type of register in the slave station can be determined, and after the ModBus graph combination and the operation data are analyzed, a script file of ModBus communication can be obtained. In the ModBus communication design process, a user does not need to write script codes, only needs to put together the required register building block graphs in a building block piling mode, and can complete the ModBus communication design, even if the user in the non-professional field can quickly and accurately obtain the script files of ModBus communication. The method provided by the application solves the problem that the script file programming difficulty of ModBus communication is high.

Referring to fig. 6, an operation flow chart for building a ModBus graph combination and obtaining a script file based on graphical programming software for a user provided by the present application is shown. The method comprises the following specific steps:

s201, a user drags the first building block graph and the register building block graphs corresponding to the ModBus registers of at least one type to an editing interface, and a ModBus graph combination is built on the editing interface.

Illustratively, the first block graphic is a beginning running block graphic.

S202, a user inputs corresponding operation data in each register building block graph according to data interaction logic for ModBus communication between at least one type of ModBus register in the master station and the slave station.

S203, the user triggers a first operation and displays the script file of ModBus communication.

The specific contents of steps S201 to S203 may refer to the specific description of the ModBus communication script generation method based on graphical programming, and are not described herein again.

Based on the same inventive concept, the embodiment of the application also provides a ModBus communication script generation device based on graphical programming. As shown in fig. 7, the ModBus communication script generating device 300 includes a building unit 301, an input unit 302, and an analysis unit 303.

Specifically, the building unit 301 is configured to build, in response to a dragging operation of a user on a building block graph, a ModBus graph combination on an editing interface, where the ModBus graph combination includes register building block graphs corresponding to at least one type of ModBus register, respectively, and the ModBus graph combination represents data interaction logic between at least one type of ModBus register in the master station and at least one type of ModBus register in the slave station.

The input unit 302 is used for responding to input operation of a user in each register building block graph and determining operation data of the master station on each type of ModBus register.

The parsing unit 303 is configured to parse the ModBus graphic combination and the operation data to obtain a script file for ModBus communication.

In the embodiments provided in the present application, it should be understood that the disclosed apparatus/electronic device and method may be implemented in other ways. For example, the above-described apparatus/electronic device embodiments are merely illustrative, and for example, a module or a unit may be divided into only one logic function, and may be implemented in other ways, for example, a plurality of units or components may be combined or integrated into another system, or some features may be omitted or not executed. The specific content of each unit implementation may refer to the specific description in the other embodiments described above, and is not described herein again.

The units described as separate parts may or may not be physically separate, and parts displayed as units may or may not be physical units, may be located in one place, or may be distributed on a plurality of network units. Some or all of the units can be selected according to actual needs to achieve the purpose of the solution of the embodiment.

The embodiment of the application also provides a robot. The robot includes a robotic arm, a memory, a processor, and a computer program stored in the memory and executable on the processor, the robotic arm coupled to the processor. The steps of the above-described embodiments of the method may be implemented when the computer program is executed by a processor. When the robot runs the script file corresponding to the ModBus communication, the robot can be regarded as a master station.

The embodiment of the application also provides the terminal equipment. As shown in fig. 8, the terminal apparatus 400 includes: at least one processor 403, a memory 401, and a computer program 402 stored in the memory 401 and executable on the at least one processor 403, wherein the processor 403 executes the computer program 402 to implement the ModBus communication script generating method based on graphical programming provided in the present application.

The embodiments of the present application also provide a computer-readable storage medium, where a computer program is stored, and when the computer program is executed by a processor, the computer program implements the steps in the above-mentioned method embodiments.

The embodiments of the present application provide a computer program product, which, when running on an electronic device, enables a terminal device to implement the steps in the above method embodiments when executed.

Reference throughout this application to "one embodiment" or "some embodiments," etc., means that a particular feature, structure, or characteristic described in connection with the embodiment is included in one or more embodiments of the application. Thus, appearances of the phrases "in one embodiment," "in some embodiments," "in other embodiments," or the like, in various places throughout this specification are not necessarily all referring to the same embodiment, but rather "one or more but not all embodiments" unless specifically stated otherwise. The terms "comprising," "including," "having," and variations thereof mean "including, but not limited to," unless expressly specified otherwise.

In the description of the present application, it is to be understood that the terms "first", "second" are used for descriptive purposes only and are not to be construed as indicating or implying relative importance or implying any number of technical features indicated. Thus, a feature defined as "first" or "second" may explicitly or implicitly include at least one such feature. It should also be understood that the term "and/or" as used in this specification and the appended claims refers to and includes any and all possible combinations of one or more of the associated listed items.

In addition, in the present application, unless otherwise explicitly specified or limited, the terms "connected," "connected," and the like are to be construed broadly, e.g., as meaning both mechanically and electrically; the terms may be directly connected or indirectly connected through an intermediate medium, and may be used for communicating between two elements or for interacting between two elements, unless otherwise specifically defined, and the specific meaning of the terms in the present application may be understood by those skilled in the art according to specific situations.

The above embodiments are only used for illustrating the technical solutions of the present application, and not for limiting the same; although the present application has been described in detail with reference to the foregoing embodiments, it should be understood by those of ordinary skill in the art that: the technical solutions described in the foregoing embodiments may still be modified, or some or all of the technical features may be equivalently replaced; and the modifications or the substitutions do not make the essence of the corresponding technical solutions depart from the scope of the technical solutions of the embodiments of the present application.

20页详细技术资料下载
上一篇:一种医用注射器针头装配设备
下一篇:基于图形化编程的机械臂搬运脚本生成方法和装置

网友询问留言

已有0条留言

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

精彩留言,会给你点赞!