Method and system for collecting data of intelligent gateway

文档序号:1908174 发布日期:2021-11-30 浏览:23次 中文

阅读说明:本技术 智能网关数据采集的方法与系统 (Method and system for collecting data of intelligent gateway ) 是由 周煜申 赵旭 杨璇 康望星 吴忠华 钱小聪 于 2021-08-31 设计创作,主要内容包括:本发明公开一种智能网关数据采集的方法与系统。所述的方法包括下述步骤:网关向服务器端发出查询PLC的IP地址的指令;网关向服务器返回的IP地址的PLC发送查询指令;网关接收到PLC返回的变量配置数据后,存储在网关中,并把这些配置数据传输给服务器;网关接收服务器返回的修改后变量配置数据;网关依据修改后变量配置数据按照配置规则采集PLC里面的数据,并把获取的数据通过F传输给服务器进行保存。通过这种方法,远端不需要把配置参数发送给网关,网关就能自动获取所有PLC地址数据。节省了配置时间,保证了一个网关可以任意接入某个PLC,而无需在意这个盒子以前是不是配置过其他PLC参数。(The invention discloses a method and a system for acquiring data of an intelligent gateway. The method comprises the following steps: the gateway sends an instruction for inquiring the IP address of the PLC to the server; the gateway sends a query instruction to the PLC of the IP address returned by the server; after receiving the variable configuration data returned by the PLC, the gateway stores the variable configuration data in the gateway and transmits the configuration data to a server; the gateway receives modified variable configuration data returned by the server; and the gateway acquires the data in the PLC according to the modified variable configuration data and the configuration rule, and transmits the acquired data to the server for storage through the F. By the method, the remote end does not need to send the configuration parameters to the gateway, and the gateway can automatically acquire all PLC address data. The configuration time is saved, and a gateway can be randomly accessed to a certain PLC without configuring other PLC parameters before the box is noticed.)

1. A method for collecting data of an intelligent gateway is characterized by comprising the following steps:

a) the gateway sends an instruction for inquiring the IP address of the PLC to the server;

b) the gateway sends a query instruction to the PLC of the IP address returned by the server;

c) after receiving the variable configuration data returned by the PLC, the gateway stores the variable configuration data in the gateway and transmits the configuration data to a server;

d) the gateway receives modified variable configuration data returned by the server;

e) and the gateway acquires the data in the PLC according to the modified variable configuration data and the configuration rule, and transmits the acquired data to the server for storage through the F.

2. The method of claim 1, wherein the method is specifically the method of intelligent gateway data acquisition

a) The gateway sends an instruction for inquiring the IP address of the PLC to the server; after the auxiliary acquisition module C returns the ip address to the auxiliary acquisition module B, the auxiliary acquisition module B uses the ip address to connect the PLC.

b) The gateway connects the corresponding PLC by using the IP address returned by the server, and sends a query instruction after successfully connecting the PLC;

c) the gateway receives the version number sent by the PLC and compares the version number with the local version number of the PLC:

if the two parties are not 0 and are consistent, the gateway does not act, and data acquisition is terminated;

if the two parties are not consistent or both parties are 0, the gateway sends a data extraction instruction to the PLC; after receiving the variable configuration data returned by the PLC, the gateway stores the configuration data in a database of the gateway; then updating the local version number of the PLC of the gateway according to the version number returned by the PLC;

d) the gateway transmits the configuration data to the server;

e) the gateway receives an acquisition instruction of the server and sends an acquisition data instruction to the PLC;

f) and the gateway receives the data returned by the PLC, stores the data and then sends the data to the server.

3. The method of claim 2, wherein the variable configuration data includes but is not limited to variable name, variable address, variable comment, variable type.

4. The system for acquiring the intelligent gateway data is characterized in that the system is a network system consisting of a PLC, a gateway and a server; each PLC is provided with an auxiliary acquisition module A, each gateway is provided with an auxiliary acquisition module B and a data acquisition module D, and the server is provided with an auxiliary acquisition module C;

wherein the content of the first and second substances,

a) the auxiliary acquisition module B sends an IP address instruction for inquiring the PLC to the auxiliary acquisition module C; after the auxiliary acquisition module C returns the ip address to the auxiliary acquisition module B, the auxiliary acquisition module B uses the ip address to connect the PLC;

b) after the PLC is connected successfully, the auxiliary acquisition module B sends a data starting instruction to a specific DB address block to trigger the auxiliary acquisition module A to start running; (the auxiliary acquisition module A monitors the data bit all the time)

c) After the auxiliary acquisition module A operates, the version number Va of the auxiliary acquisition module A is sent to an auxiliary acquisition module B, the auxiliary acquisition module B compares the version number Vb of the auxiliary acquisition module B, and if the version number Va of the auxiliary acquisition module A is not 0 and is consistent with the version number Vb of the auxiliary acquisition module B, data acquisition is terminated;

if the two parties are not consistent or both parties are 0, the auxiliary acquisition module A is told to start to circularly scan all DB data blocks of the PLC, then variables in all the data blocks are read out to be transmitted to the auxiliary acquisition module B,

including but not limited to variable name, variable address, variable annotation, variable type;

d) after the auxiliary acquisition module B receives the variable configuration data sent by the auxiliary acquisition module A; firstly, storing configuration data in a database of a cloud box; secondly, the version number is updated, the version number of the user is modified to be the same as that of the auxiliary acquisition module A, namely Va is Vb;

e) transmitting the configuration data to the cloud platform again, and ensuring that Vc is consistent with Vb version numbers by the cloud platform; and modifying the variables to indicate data to be collected;

f) after the auxiliary acquisition module C is modified, the configuration data is sent to the auxiliary acquisition module B again; the auxiliary acquisition module B marks variables which do not need to be acquired in the database according to the configuration data sent by the auxiliary acquisition module C;

g) the auxiliary acquisition module B starts to configure the acquisition data acquisition module D and sends variables and addresses to be acquired to the PLC;

h) and after the data acquisition module D completes configuration, acquiring data in the PLC according to the configuration rule, and transmitting the acquired data to the server for storage.

Technical Field

The invention relates to the field of Internet of things. The invention particularly relates to a method for acquiring data of an intelligent gateway.

Background

PLC generally refers to programmable logic controllers. The intelligent control system integrates computer technology, automatic control technology and communication technology, adopts user-oriented 'natural language' programming to control, is suitable for industrial environment, is simple and easy to understand, is simple and convenient to operate, and is industrial control equipment with high reliability.

In the last decade, one of the most important technological changes is the widespread adoption of internet of things devices in various industries. Industrial internet of things devices may become more and more widespread in the coming decade. The convergence of PLC and industrial internet of things will become more and more compact. In actual production, the PLC is responsible for controlling the primary automation equipment on an industrial site, and the Internet of things is responsible for transmitting control parameters and data of the PLC in a cloud mode so as to facilitate remote mobile display and control.

The most important device in the internet of things is an industrial internet of things gateway (cloud box) which is responsible for supporting various communication protocols of the PLC and then converting data into an internet of things universal standard protocol for transmission. The cloud box acquires data in the PLC and needs the upper computer to carry out address configuration, namely the cloud box does not know which address section the data in the PLC to be acquired is stored in, and after the data are configured by upper computer programmers, the data are issued to the cloud box through a configuration protocol, and the cloud box can read the address responded in the PLC. For a large industrial field, the number of the PLCs is hundreds, each PLC has tens of thousands of address variables, and even if the PLC does not need to be read completely, the PLC is a huge configuration workload for operators of the upper computer. And such multi-point data also has the problem of mismatching.

Disclosure of Invention

In order to solve the problems, the patent designs and invents an intelligent gateway data acquisition method.

In order to achieve the above purpose, the method for collecting data of the intelligent gateway of the present invention comprises the following steps:

f) the gateway sends an instruction for inquiring the IP address of the PLC to the server;

g) the gateway sends a query instruction to the PLC of the IP address returned by the server;

h) after receiving the variable configuration data returned by the PLC, the gateway stores the variable configuration data in the gateway and transmits the configuration data to a server;

i) the gateway receives modified variable configuration data returned by the server;

j) and the gateway acquires the data in the PLC according to the modified variable configuration data and the configuration rule, and transmits the acquired data to the server for storage through the F.

k) The configuration parameters are re-issued to the secondary acquisition module C whenever the version number of the secondary acquisition module B changes. If the version number is not changed, it is not retransmitted.

Further, the method is concretely

a) The gateway sends an instruction for inquiring the IP address of the PLC to the server; after the auxiliary acquisition module C returns the ip address to the auxiliary acquisition module B, the auxiliary acquisition module B uses the ip address to connect the PLC.

b) The gateway connects the corresponding PLC by using the IP address returned by the server, and sends a query instruction after successfully connecting the PLC;

c) the gateway receives the version number sent by the PLC and compares the version number with the local version number of the PLC:

if the two parties are not 0 and are consistent, the gateway does not act, and data acquisition is terminated;

if the two parties are not consistent or both parties are 0, the gateway sends a data extraction instruction to the PLC; after receiving the variable configuration data returned by the PLC, the gateway stores the configuration data in a database of the gateway; then updating the local version number of the PLC of the gateway according to the version number returned by the PLC;

d) the gateway transmits the configuration data to the server;

e) the gateway receives an acquisition instruction of the server and sends an acquisition data instruction to the PLC;

f) and the gateway receives the data returned by the PLC, stores the data and then sends the data to the server.

Further, the variable configuration data includes, but is not limited to, variable name, variable address, variable comment, and variable type.

In order to achieve the aim, the system for acquiring the intelligent gateway data is a network system consisting of a PLC, a gateway and a server; each PLC is provided with an auxiliary acquisition module A, each gateway is provided with an auxiliary acquisition module B and a data acquisition module D, and the server is provided with an auxiliary acquisition module C;

wherein the content of the first and second substances,

a) the auxiliary acquisition module B sends an IP address instruction for inquiring the PLC to the auxiliary acquisition module C; after the auxiliary acquisition module C returns the ip address to the auxiliary acquisition module B, the auxiliary acquisition module B uses the ip address to connect the PLC;

b) after the PLC is connected successfully, the auxiliary acquisition module B sends a data starting instruction to a specific DB address block to trigger the auxiliary acquisition module A to start running; (the auxiliary acquisition module A monitors the data bit all the time)

c) After the auxiliary acquisition module A operates, the version number Va of the auxiliary acquisition module A is sent to an auxiliary acquisition module B, the auxiliary acquisition module B compares the version number Vb of the auxiliary acquisition module B, and if the version number Va of the auxiliary acquisition module A is not 0 and is consistent with the version number Vb of the auxiliary acquisition module B, data acquisition is terminated;

if the two parties are not consistent or both parties are 0, the auxiliary acquisition module A is told to start to circularly scan all DB data blocks of the PLC, and then variables in all the data blocks are read and transmitted to the auxiliary acquisition module B, wherein the variables include but are not limited to variable names, variable addresses, variable comments and variable types;

d) after the auxiliary acquisition module B receives the variable configuration data sent by the auxiliary acquisition module A; firstly, storing configuration data in a database of a cloud box; secondly, the version number is updated, the version number of the user is modified to be the same as that of the auxiliary acquisition module A, namely Va is Vb;

e) transmitting the configuration data to the cloud platform again, and ensuring that Vc is consistent with Vb version numbers by the cloud platform; and modifying the variables to indicate data to be collected;

f) after the auxiliary acquisition module C is modified, the configuration data is sent to the auxiliary acquisition module B again; the auxiliary acquisition module B marks variables which do not need to be acquired in the database according to the configuration data sent by the auxiliary acquisition module C;

g) the auxiliary acquisition module B starts to configure the acquisition data acquisition module D and sends variables and addresses to be acquired to the PLC;

h) and after the data acquisition module D completes configuration, acquiring data in the PLC according to the configuration rule, and transmitting the acquired data to the server for storage.

By the method, the remote end does not need to send the configuration parameters to the cloud box, and the cloud box can automatically acquire all PLC address data. The configuration time is saved, and a cloud box can be randomly accessed to a certain PLC without worrying whether other PLC parameters are configured before the box.

Drawings

FIG. 1: overall system frame diagram

FIG. 2: working principle of auxiliary acquisition module

Detailed Description

As shown in fig. 1, the present invention involves three partial definitions:

1, PLC: and the user independently develops a primary automatic control system. The variable data of the PLC are stored in the DB area. Data can only be read from the PLC if the address of a particular DB block is known. The DB area is referred to herein as a generic term, and different PLCs may refer to the data area differently.

2. The auxiliary acquisition module A: the method belongs to an independent PLC program and needs to be matched with a cloud box for use. Belonging to the core content of the patent. The user needs to transplant the auxiliary acquisition module A into the PLC program. After the PLC is powered on, the program can circularly traverse all variables of the DB data area, and all variable names, variable addresses, variable types, comments and the like are transmitted to the auxiliary acquisition module B on the cloud box.

3. Cloud box (gateway): one kind of industry thing allies oneself with gateway for gather PLC's data, and send to cloud platform through public network. The cloud box communicates with the PLCs through own protocols of the PLCs and obtains variable values of corresponding addresses in the DB data area of the PLCs. For example, DB1 DW4 is an unsigned integer value for address 4 inside a block of the DB1 region.

4. And an auxiliary acquisition module B: the PLC variable addresses are used for receiving the PLC variable addresses sent by the auxiliary acquisition module A, the variable addresses are configured to the acquisition data acquisition module D of the cloud box, and the acquisition auxiliary acquisition module is provided with corresponding DB addresses for data reading or writing.

5. A data acquisition module D: for communicating with the PLC, reading the variable value of the relevant address from the PLC, or writing the variable value into the relevant address of the PLC.

6. Cloud communication auxiliary acquisition module F: the PLC variable value receiving module is used for transmitting the PLC variable value received by the data collecting module D to the cloud platform for storage in a standard protocol mode. The standard MQTT protocol may be used here and the method is not part of the patent.

7. Cloud platform (server): the cloud box is used for receiving data transmitted by the cloud box.

8. And an auxiliary acquisition module C: and the PLC is used for receiving and displaying the PLC variable and address parameters transmitted by the auxiliary acquisition module B at a far end. The operation and maintenance engineer can modify which variables are not used and which variables need to read data at a remote end.

And then the modified variables are sent to the auxiliary acquisition module B again.

The focus of the present invention is on the auxiliary acquisition modules A, B and C. After the PLC and the cloud box are respectively electrified, the auxiliary acquisition module starts to work. The auxiliary acquisition module B is connected with the PLC through a network and a PLC protocol, and after the auxiliary acquisition module B is successfully connected with the PLC, a specific address of the auxiliary acquisition module A is sent to trigger the auxiliary acquisition module A to start working. And the auxiliary acquisition module A starts working, traverses and inquires variables in all DB area blocks of the PLC, and acquires variable names, variable addresses, variable comments, variable types and the like. These acquired information are then sent to the secondary acquisition module B. After receiving the information, the auxiliary acquisition module B performs specific address configuration on the acquisition data acquisition module D and sends the variable data to the auxiliary acquisition module C, and the auxiliary acquisition module C is manually maintained and modified by operation and maintenance personnel and then is sent to the auxiliary acquisition module B again, so that new configuration of the acquisition data acquisition module D is triggered again.

The acquisition data acquisition module D can directly communicate with the PLC after completing address configuration, thereby bypassing the auxiliary acquisition module A and directly reading out the required variable value from the DB area of the PLC. The read data are sent to the cloud platform through the cloud communication auxiliary acquisition module F and are stored in a database on the cloud platform.

The following examples are further illustrated

Examples

As shown in fig. 2

The PLC is Siemens brand S7-1200, and the communication protocol of the PLC is S7 protocol.

Data fields in the PLC are DB1 DW0 ═ 32 (temperature value ℃) and DW4 ═ 12 (humidity value%); DB2 DD0 is 2 (current value a) and DD2 is 220 (voltage value V) (DW stands for four bytes and is thus represented in PLC as DW0, 4, 8, 12; DD stands for 2 bytes and is thus represented in PLC as DD0, 2, 4, 6, 8).

The IP address of the PLC is 192.168.0.100; the cloud box and the PLC are in the same network segment, and the address is 192.168.0.101; the cloud platform is a fixed IP address of the public network in the public network.

The auxiliary acquisition module A, the auxiliary acquisition module B and the auxiliary acquisition module C respectively store version numbers Va, Vb and Vc, and initialization defaults from 0.

a) And the program of the auxiliary acquisition module A attached to the cloud box is transplanted into the PLC to be acquired. And the auxiliary acquisition module C needs to be configured with the IP address of the PLC corresponding to the auxiliary acquisition module A.

b) The cloud box and the PLC are respectively powered on. And the auxiliary acquisition module B in the cloud box can inquire the IP address of the PLC to the auxiliary acquisition module C of the cloud platform. After the auxiliary acquisition module C returns the ip address to the auxiliary acquisition module B, the auxiliary acquisition module B uses the ip address to connect the PLC.

c) Upon successful PLC attachment, data 128 is sent to a specific DB address block (e.g., DB255 DB0, which is not used by the normal PLC program), thereby triggering the auxiliary acquisition module a to begin operation. (the auxiliary acquisition module A monitors the data bit all the time)

d) After the auxiliary acquisition module A operates, the version number Va of the auxiliary acquisition module A can be sent to the auxiliary acquisition module B, the auxiliary acquisition module B compares the version number Vb of the auxiliary acquisition module B, and if the version number Va of the auxiliary acquisition module B is not 0 and is consistent with the version number Vb of the auxiliary acquisition module B, the auxiliary acquisition module A is told not to need extra action. If the two parties are not consistent or both parties are 0, the auxiliary acquisition module A is told to start to circularly scan all DB data blocks of the PLC, and then variables in all the data blocks are read out to be transmitted to the auxiliary acquisition module B, wherein the variables include but are not limited to variable names, variable addresses, variable comments, variable types (floating points, integer types, bits, bytes and the like).

e) And the auxiliary acquisition module B receives the variable configuration data sent by the A. Firstly, storing configuration data in a database of a cloud box; secondly, the version number is updated, the version number of the user is modified to be the same as that of the auxiliary acquisition module A, namely Va is Vb;

f) again, these configuration data are transmitted to the cloud platform, which ensures that Vc is consistent with Vb version number. The operation and maintenance engineer can check the addresses on a remote computer and modify the variables, wherein the variables need to be acquired and the variables do not need to be acquired.

g) And the auxiliary acquisition module C sends the configuration data to the auxiliary acquisition module B again after being modified, and the auxiliary acquisition module B marks variables which do not need to be acquired in the database according to the configuration data sent by the auxiliary acquisition module C.

h) Finally, the auxiliary acquisition module B starts to configure the acquisition data acquisition module D and tells the acquisition auxiliary acquisition module which variables are to be read, and the physical addresses of the variables in the PLC;

i) after the acquisition data acquisition module D completes configuration, the data in the PLC are acquired according to the configuration rules, and the acquired data are transmitted to the cloud platform through the F for storage.

j) The configuration parameters are re-issued to the secondary acquisition module C whenever the version number of the secondary acquisition module B changes. If the version number is not changed, it is not retransmitted.

This patent is given above as an example, but not limited to this example. Also, this patent gives a method.

9页详细技术资料下载
上一篇:一种医用注射器针头装配设备
下一篇:一种STN网络补链业务倒换方法及装置

网友询问留言

已有0条留言

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

精彩留言,会给你点赞!