CN115826492A - Universal PLC data processing method and device - Google Patents

Universal PLC data processing method and device Download PDF

Info

Publication number
CN115826492A
CN115826492A CN202211477317.5A CN202211477317A CN115826492A CN 115826492 A CN115826492 A CN 115826492A CN 202211477317 A CN202211477317 A CN 202211477317A CN 115826492 A CN115826492 A CN 115826492A
Authority
CN
China
Prior art keywords
data
plc
variable
description file
variables
Prior art date
Legal status (The legal status is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the status listed.)
Pending
Application number
CN202211477317.5A
Other languages
Chinese (zh)
Inventor
侯奔
高静
毛桂庭
杨杰
宋紫棋
柯熠
欧阳邓培
Current Assignee (The listed assignees may be inaccurate. Google has not performed a legal analysis and makes no representation or warranty as to the accuracy of the list.)
Changsha Research Institute of Mining and Metallurgy Co Ltd
Original Assignee
Changsha Research Institute of Mining and Metallurgy Co Ltd
Priority date (The priority date is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the date listed.)
Filing date
Publication date
Application filed by Changsha Research Institute of Mining and Metallurgy Co Ltd filed Critical Changsha Research Institute of Mining and Metallurgy Co Ltd
Priority to CN202211477317.5A priority Critical patent/CN115826492A/en
Publication of CN115826492A publication Critical patent/CN115826492A/en
Pending legal-status Critical Current

Links

Images

Classifications

    • YGENERAL TAGGING OF NEW TECHNOLOGICAL DEVELOPMENTS; GENERAL TAGGING OF CROSS-SECTIONAL TECHNOLOGIES SPANNING OVER SEVERAL SECTIONS OF THE IPC; TECHNICAL SUBJECTS COVERED BY FORMER USPC CROSS-REFERENCE ART COLLECTIONS [XRACs] AND DIGESTS
    • Y02TECHNOLOGIES OR APPLICATIONS FOR MITIGATION OR ADAPTATION AGAINST CLIMATE CHANGE
    • Y02PCLIMATE CHANGE MITIGATION TECHNOLOGIES IN THE PRODUCTION OR PROCESSING OF GOODS
    • Y02P90/00Enabling technologies with a potential contribution to greenhouse gas [GHG] emissions mitigation
    • Y02P90/02Total factory control, e.g. smart factories, flexible manufacturing systems [FMS] or integrated manufacturing systems [IMS]

Landscapes

  • Communication Control (AREA)

Abstract

The invention relates to the technical field of data information transmission, and discloses a universal PLC data processing method and a universal PLC data processing device, which are used for dividing a single communication transmission protocol into two parts, namely a communication transmission protocol and a structured data description file capable of being automatically and universally processed by an upper computer, so that development and debugging efficiency is improved. According to the invention, the symbol table of the PLC is processed through the upper computer software, the variable information in the symbol table is extracted, the variables are grouped according to types and sequenced according to variable initial addresses, and a cross-platform universal data description file is further automatically generated. In the communication transmission process, the PLC only needs to organize data uploading according to the description file, and the upper computer only needs to segment the binary data stream according to the description file to obtain all data. Because the data description file adopts a fixed generation rule, the method has universality, and the data acquisition and transmission between the upper computer and the PLC are automated.

Description

Universal PLC data processing method and device
Technical Field
The invention relates to the technical field of data information transmission, in particular to a universal PLC data processing method and device.
Background
A PLC (programmable logic controller) is a control device widely used in industrial production due to its simple extension and reliable performance. The large amount of sensor data collected by the PLC and a lot of process data generated in the process of simultaneous operation have great storage and analysis values. Therefore, the data in the PLC are obtained through the upper computer, and the premise that systems such as real-time monitoring, man-machine interaction, data storage and analysis and the like are constructed to further improve the production or management quality is provided.
Generally, there are three ways to collect transmission data from a PLC:
the first is to adopt upper computer software provided by a PLC manufacturer, and the software acquires data by using a proprietary protocol of the PLC and stores the data in a proprietary data format. However, the upper computer software provided by the PLC manufacturer is generally a commercial copyright, has a high cost, can only communicate with the PLC of its own, and is difficult to integrate with other software to achieve the purpose of data exchange.
The second method is to set up an OPC (OLEForProcessControl, object linking and embedded process control) server and develop upper computer software, and adopt an OPC protocol and related interface functions to acquire data. Similarly, the server side of OPC is also generally a commercial copyright, and the programming interface is complex, and can only be deployed in a device running a windows system, which is more limited.
And the third method is to adopt a self-defined communication transmission protocol method, and the upper computer and the PLC simultaneously follow protocol convention to carry out data transmission. The method has the disadvantages that human negotiation of protocols is needed, data grouping, transmission sequence, data name designation and each data length specification are specified, subjective factors are more, data definition and communication transmission protocol are difficult to be coupled, communication cost is high, and maintenance is complex.
And moreover, the data exchange between the upper computer and the PLC is realized through a self-defined protocol, and no fixed standard or format exists. The existing method generally writes a text-type communication transmission protocol file, the text specifies the specific fields and format of the data frames used for communication transmission, and the two parties communicate according to the transmission format. The data field of the data frame generally represents PLC data transmitted in the frame, the PLC data is filled in the data frame, and the upper computer decodes and stores the data according to protocol convention after receiving the data. Therefore, in the text of the communication transmission protocol, a large part of contents are word descriptions for naming, grouping, prescribed sequence, specified length and the like of the data of the PLC in the "data field", wherein the subjective randomness of the grouping and the prescribed sequence is large. The method for describing data in the protocol causes the communication transmission protocol to be too fat and difficult to maintain, an upper computer cannot automatically process the communication transmission protocol text, and the development and debugging efficiency is low.
Disclosure of Invention
The invention aims to disclose a universal PLC data processing method and a universal PLC data processing device, which are used for splitting a single communication transmission protocol into two parts, namely a communication transmission protocol and a structured data description file which can be automatically and universally processed by an upper computer, so that the development and debugging efficiency is improved.
In order to achieve the above purpose, the general PLC data processing method disclosed by the present invention includes:
s100, configuring a data structure buffer area by an upper computer according to an acquisition and transmission rule table created by a user;
s200, the upper computer derives a PLC symbol table, selects records corresponding to the variable types of the acquisition and transmission rule table from the derived PLC symbol table, converts the records into structural variables, stores the structural variables in corresponding data structure buffers in a grouping mode, and creates a universal data description file; the data description file is used for describing the number of the structure variables related to the data field, the name, the length and the offset information of each structure variable and the sequencing information in the data field and is independent of a communication transmission protocol;
s300, sequentially putting the content of the corresponding variable into a buffer area with continuous addresses and updating the content of the buffer area in each scanning period by the PLC according to the sequence of each structural variable in the data description file, and uploading the content of the buffer area through a data frame by the PLC according to the format of a communication transmission protocol after receiving a reading command of an upper computer; the communication transmission protocol omits the explanation of PLC data determined by the data description file;
s400, the upper computer extracts a data field in the data frame through protocol analysis and processing, and temporarily stores the data field as a binary byte stream; and then, automatically finishing data extraction and analysis of the temporary storage byte stream according to the data description file so as to obtain binary values corresponding to the structure variable names in the data uploaded by the PLC.
Preferably, the specific process of generating the data description file includes:
s4: the upper computer generates a structured data description file by adopting a standard universal markup language format, firstly generates a data domain root node element, and newly establishes a total data number sub-node element in the data domain root node element;
s5: the upper computer reads the PLC symbol table according to the rows, judges the PLC variable type of the 'address' field content of each row one by one, if the type is not in the acquisition and transmission rule table, discards the corresponding row, otherwise extracts the information of the corresponding row, saves the information in the corresponding member of the structure variable, and additionally stores the structure variable in the corresponding data structure buffer area; after the last line is read, updating the attribute value of the total data number element in the data description file into an effective line number;
s6: the upper computer sorts the structural variables of each data structure buffer area in an ascending order according to the addresses of the PLC variables stored by the members to form sorted data structure buffer areas;
s7: the upper computer sequentially takes out the sorted structural variables in the first buffer area according to the sequence of the acquisition and transmission rule table, newly establishes a 'transmission variable' child node element in the description file for each structural variable, wherein the child elements of the child node elements at least comprise 'name', 'length' and 'offset', and then writes the child node elements under a 'data field' root node of the data description file;
s8: and the upper computer finishes the extraction of the structural variables of all the remaining buffer areas and the generation and writing of the sub-node elements of the transmission variables in sequence according to the operation of S7 to form a final data description file.
In order to achieve the above object, the present invention further discloses a general PLC data processing apparatus, which is specifically an upper computer, and includes a memory, a processor, and a computer program stored in the memory and capable of running on the processor, wherein when the processor executes the computer program, a series of steps corresponding to the upper computer in the above method are implemented.
Preferably, the functional modules within the computer program include:
the control processing module: the main control module is used for initiating corresponding operation and finishing logic control, communication transmission control and data processing of the software;
the rule database module: the PLC acquisition and transmission system is composed of a transmission rule database and corresponding operation interface functions, wherein the transmission rule database comprises acquisition and transmission rule tables, and each acquisition and transmission rule table corresponds to a PLC of a specific model;
symbol table processing module: the PLC processing system is used for finishing the processing of the PLC symbol table, sequentially extracting one row of the symbol table, extracting PLC variable names from a 'symbol' column of the row, extracting types and initial addresses of PLC variables from an 'address' column, storing the extracted information by members of structural variables, and storing the structural variables in corresponding buffer areas in groups;
the description file management module: for writing and reading the data description file.
The invention has the following beneficial effects:
1. a single communication transmission protocol is divided into a communication transmission protocol and a structured data description file, wherein the data description file is used for describing specific contents of a data field in the communication transmission protocol, the data description file can be automatically generated by software, and an upper computer can automatically process the data description file to obtain detailed description of binary byte streams in the data field.
2. The mainstream PLC supports a symbol table, which contains information such as a variable name, a variable type, and a start address in the PLC. Therefore, the invention processes the symbol table of the PLC through the upper computer software, extracts the variable information in the symbol table, groups the variables according to the types, sorts the variables according to the variable initial addresses, and further automatically generates a cross-platform universal data description file which uses the information such as data name, length, transmission sequence, offset and the like to describe the composition of a 'data field' in a communication transmission protocol. In the communication transmission process, the PLC only needs to organize data uploading according to the description file, and the upper computer only needs to segment the binary data stream according to the description file to obtain all data. The method completely discards a great deal of word definition work of a data field in the communication transmission protocol in the prior art, and greatly simplifies the protocol formulation and negotiation process. Because the data description file adopts a fixed generation rule, the data description file has universality, and the data acquisition and transmission between the upper computer and the PLC are automated.
3. The invention can realize the high-efficiency reading and transmission of PLC data without the help of upper computer software or third-party components, protocols and the like of PLC manufacturers, and is suitable for any model of PLC.
4. The invention has no requirement on the operating system of the upper computer, and is suitable for any forms of PC, tablet personal computers, embedded board cards and the like.
5. The data description is stripped from the communication transmission protocol, so that the formulation of the communication transmission protocol is greatly simplified, and great convenience is provided for communication and maintenance.
6. The information of the data description file is extracted from the PLC symbol table, is automatically generated by using a fixed rule through software, does not need human participation, greatly reduces the workload, and avoids omission and errors.
7. When the data of the PLC end is newly added or deleted, the upper computer end only needs to update the data description file according to the new symbol table without other communication.
8. When the software of the upper computer is rewritten or replaced, only the data description file needs to be read again.
9. The PLC data batch reading and transmission device is very suitable for batch reading and transmission of PLC data.
The present invention will be described in further detail below with reference to the accompanying drawings.
Drawings
The accompanying drawings, which are incorporated in and constitute a part of this application, are included to provide a further understanding of the invention, and are incorporated in and constitute a part of this specification. In the drawings:
fig. 1 is a schematic diagram of a generation flow of a data description file according to an embodiment of the present invention.
Fig. 2 is a block diagram of a PLC data processing system according to an embodiment of the present invention.
Fig. 3 is a schematic diagram of an S7-200PLC acquisition transmission rule table disclosed in an embodiment of the present invention.
Fig. 4 is a partial content screenshot of a data description file generated according to a PLC symbol table according to an embodiment of the present invention.
Detailed Description
The embodiments of the invention will be described in detail below with reference to the drawings, but the invention can be implemented in many different ways as defined and covered by the claims.
Example 1
The embodiment discloses a general PLC data processing method. The method mainly comprises three parts of generating a data description file, formulating a communication transmission protocol and transmitting data. The three processes are detailed as follows:
1. referring to fig. 1, the process of generating the data description file is as follows:
s1: the method comprises the steps of formulating an acquisition transmission rule table for defining a transmission rule of PLC data, wherein each line represents a PLC variable, and the table comprises fields of an upper computer variable type, a PLC variable type, a data length and a classification number, wherein the upper computer variable type is a corresponding form of the PLC variable type in an upper computer, the data length is the number of bytes occupied by the PLC variable type in transmission, and the classification number is a numerical value and is used as a role of a command code in communication.
S2: the upper computer prepares a data structure buffer area for each PLC variable according to the row sequence of the acquisition and transmission rule table S1 (each buffer area can contain a plurality of structure variables, and the members of the structure variables are used for storing the names, types and addresses of the variables analyzed when the read PLC symbol table is read), and each PLC variable (namely each buffer area) can be regarded as a group.
S3: exporting a symbol table of the PLC and storing the symbol table as a file in a csv format or other text formats, wherein the content of at least two columns of symbols and addresses or the corresponding content of other columns of fields which can equivalently represent names, types and addresses of the PLC variables is required to be exported, the content of the column of the symbols contains the names of the PLC variables, and the content of the column of the addresses contains the types and the starting addresses of the PLC variables.
S4: the upper computer generates a new structured data description file, can adopt a standard universal markup language (XML) format, firstly generates a root node element, such as a 'data field' element, the subsequent elements are all nested in the 'data field' element, and a 'total data number' child node element is newly built in the 'data field' element.
S5: and the upper computer reads the symbol table file of the PLC according to the row, judges the PLC variable type of the field content of the address of the row, discards the row if the type is not in the acquisition and transmission rule table of S1, otherwise extracts the information of the row and stores the information in the corresponding member of the S2 structure variable, and additionally stores the structure variable in the data structure buffer zone (namely the group) corresponding to the structure variable. And after the last line is read, updating the attribute value of the total data number element in the data description file into the effective line number.
S6: and S2, sorting the storage contents (namely structure variables) of each data structure buffer area according to the ascending order of addresses of the PLC variables stored by the members to form the sorted data structure buffer areas.
S7: according to the sequence of the acquisition transmission rule table in the S1, the sorted contents (structure variables) in the first buffer area are sequentially taken out, a 'transmission variable' child node element is newly established in the description file for each structure variable, the element comprises child elements such as 'name', 'length', 'offset', and the like, the value of the 'length' element is the length of the type of PLC variable data, the unit is byte, the 'name' is the name of the PLC variable, the two values are both obtained from the members of the structure variable, the 'offset' is the initial position of the variable in the group, the unit is byte, the two values can be sequentially calculated, and the child node element is written into the data description file under the root node of the 'data field'.
S8: and (5) sequentially finishing the taking out of the remaining buffer area structure variables and the generation and writing of the 'transmission variable' child node elements according to the operation of S7 to form a final data description file.
2. There are two ways to make communication transmission protocol, which are:
firstly, a communication transmission protocol is established, the established protocol at least has a plurality of fields of 'data field length', 'data field' and 'command code', and the 'command code' field indicates which group of data needs to be uploaded by the PLC, and the data of all the groups can be uploaded together.
The simpler way is to use a known communication transmission protocol, and the simplest way uses a modbus protocol to transmit all the grouped data collectively at one time by using a 'command code' 03H.
3. The data communication transmission process comprises the following steps:
and the PLC sequentially puts the contents of the corresponding variables into a buffer area with continuous addresses according to the sequence of each 'transmission variable' in the data description file and updates the contents of the buffer area in each scanning period.
And the upper computer initiates a reading command, and the PLC uploads the content of the buffer area through a data frame according to the format of a communication transmission protocol.
The upper computer extracts a data field in the data frame through protocol analysis and processing, and stores the data field as a binary byte stream.
And the upper computer reads the data description file, and when the content of one transmission variable child node element is obtained, the binary byte stream is operated according to the name, length and offset information provided by the element to obtain the variable name and binary value of the data in the corresponding PLC for subsequent processing.
Example 2
Corresponding to the above embodiments, this embodiment discloses a general PLC data processing apparatus, which is specifically an upper computer, and includes a memory, a processor, and a computer program stored in the memory and capable of running on the processor, where the processor implements a series of steps corresponding to the upper computer in the method according to the above embodiments when executing the computer program.
Wherein, this embodiment host computer and PLC's interaction and relevant data processing include at least:
s100, configuring a data structure buffer area by an upper computer according to an acquisition and transmission rule table created by a user;
s200, the upper computer derives a PLC symbol table, selects records corresponding to the variable types of the acquisition and transmission rule table from the derived PLC symbol table, converts the records into structural variables, stores the structural variables in corresponding data structure buffers in a grouping mode, and creates a universal data description file; the data description file is used for describing the number of the structure variables related to the data field, the name, the length and the offset information of each structure variable and the sequencing information in the data field and is independent of a communication transmission protocol;
s300, sequentially putting the content of the corresponding variable into a buffer area with continuous addresses and updating the content of the buffer area in each scanning period by the PLC according to the sequence of each structural variable in the data description file, and uploading the content of the buffer area through a data frame by the PLC according to the format of a communication transmission protocol after receiving a reading command of an upper computer; the communication transmission protocol omits the explanation of PLC data determined by the data description file;
s400, the upper computer extracts a data field in the data frame through protocol analysis and processing, and temporarily stores the data field as a binary byte stream; and then, automatically completing data extraction and analysis of the temporary storage byte stream according to the data description file to obtain binary values corresponding to the structure variable names in the data uploaded by the PLC.
As shown in fig. 2, the system applied in this embodiment is composed of a PLC, a physical channel, an upper computer, and software: the PLC can be any brand and model PLC, the physical channel is a communication channel (RS 232, RS485, ethernet or field bus interface and the like) supported by the PLC and the upper computer, and the upper computer can be a PC, a panel, an embedded mainboard and the like running any operating system.
The upper computer software comprises a control processing module, a rule database module, a symbol table processing module, a description file management module and a channel management module.
The control processing module: the main control module is a main control module of upper computer software, and all operations are initiated by the main control module to complete logic control, communication transmission control and data processing of the software.
The rule database module: the system is composed of a transmission rule database and a corresponding operation interface function. The database comprises a plurality of acquisition and transmission rule tables, and each acquisition and transmission rule table corresponds to a PLC of a specific model. The collection and transmission rule table generally includes fields such as "id", "upper computer variable type", "PLC variable type", "data length", "classification number", and the like. One row of the collection transmission rule table represents a rule (for example, the analog input type AIW of the PLC is a rule), and the "id" field represents the order of the rules, which is also the order between the PLC data groups. The 'upper computer variable type' and the 'PLC variable type' are in one-to-one correspondence, for example, the upper computer variable type corresponding to analog input AIW in PLC is 16-bit short integer type, the 'data length' is the number of bytes occupied by the current variable type in transmission, and the 'classification number' is used for distinguishing data packets and is also used for 'command codes' in a communication transmission protocol.
Symbol table processing module: the module finishes the processing of the PLC symbol table stored in a text format, sequentially extracts one row of the symbol table, extracts PLC variable names from a 'symbol' column of the row, extracts PLC variable types and initial addresses from an 'address' column, stores the extracted information by members of S2 structure variables, and stores the structure variables in corresponding buffer areas of groups.
The description file management module: the module provides writing and reading of the description file, wherein the writing refers to writing a row of information in the processed symbol table into a 'transmission variable' node of the description file, and the reading refers to reading the value of each 'transmission variable' node and each sub-node in the description file into a memory for processing a 'data field' binary byte stream received in communication transmission.
A channel management module: a group of high-level channel read-write operation functions is provided, so that the control processing module can read and write different physical channels by using a uniform interface without concerning the read-write details of each physical channel, and the maintenance of a program is facilitated.
Example 3
This embodiment is an example of specific applications of the above two embodiments.
For the convenience of description, a structure variable named Var and a buffer vector < structVar > for storing the structure variable are defined in the following, where Var has three members of name, type and address, all the structure variables mentioned in the embodiments have the same structure as Var, all the data structure buffers mentioned have the same structure as vector < structVar >, and the definition uses the description in C + + language, but other high-level programming languages have equivalent functions:
structural variable definition:
structVar{
stringname; // name
stringtype; // type
stringaddress; // starting Address
}
Buffer definition:
vector<structVar>
in this embodiment, the data transmission workflow between the upper computer software and the PLC specifically is:
s20: and judging whether the data description table exists, if so, jumping to S25 for execution. Otherwise, generating a data description table by S21-S24.
S21: the control processing module reads a corresponding rule table in the rule database according to the actual PLC type, and establishes a data buffer vector < structVar > for each rule (each PLC variable type) for storing the Var structure variable.
S22: the control processing module processes the symbol table derived by the PLC through the symbol table processing module, reads one row each time, judges whether the row variable is allowed by the rule (for example, intermediate variables such as a timer and a counter of the PLC have no communication transmission value, so the intermediate variables do not match the rule and are filtered out), extracts the PLC variable name, the variable type and the initial address carried by the row and stores the PLC variable name, the variable type and the initial address in members of the structural variable Var if the rule allows, and stores the structural variable in a corresponding data buffer area according to the variable type.
S23: after the reading-in processing of all rows of the PLC symbol table is completed, the control processing module sequentially completes the sequencing of the structural variables in the buffer area according to the sequence between the vector < struct Var > of the data buffer area, and the sequencing rule is the ascending sequence of the PLC variable initial addresses stored by the structural variables Var.
S24: and the control processing module sequentially takes out all the structure variables according to the sequence of the data buffer area and the sequence of the structure variables in the buffer area, manipulates the description file management module to generate a transmission variable node for each structure variable, assigns values to the sub-elements of the name, the type, the length and the offset of the node, and sequentially writes all the transmission variable nodes into the root node of the data domain of the data description file.
S25: the control processing module requires the PLC to upload data according to the communication transmission protocol, the PLC sequentially puts the corresponding data into a region with continuous addresses according to the node sequence of the transmission variable of the data description file and puts the region into the data field of the data frame for integral uploading, and the control processing module extracts the binary byte stream corresponding to the data field and temporarily stores the binary byte stream into the memory.
S26: the control processing module reads the value of the transmission variable node into the memory through the description file management module, extracts the binary byte stream according to the information of the transmission variable node, and obtains the binary content of the corresponding data.
Example 4
This embodiment is a further example of a specific application scenario in embodiment 3.
Specific processes of formulating a corresponding rule table and generating a data description file for data acquisition and transmission of the S7-200PLC are shown in FIGS. 3 and 4:
s301: an S7-200 rule table is generated in a database, and a plurality of data columns of 'id', 'PLC variable type', 'upper computer variable type', 'variable length' and 'classification number' are added to the table, as shown in FIG. 3, the 'id' field data is used for classifying different PLC variable types, the 'PLC variable type' field data is used for enumerating the PLC variable types needing communication transmission, in this example, the types of the switching value input, output, analog value input, output and intermediate V registers are used, and considering that the PLC data is not much, the classification number directly adopts a command code 03H in a modbus protocol to indicate that all the data are read at one time.
S302: and exporting the S7-200PLC symbol table to an upper computer. And (3) scanning the rule table by software, reading 11 rules in the figure 3, and establishing 11 structure variable buffer areas, for example, a 7 th buffer area is specially used for storing analog quantity input variables corresponding to the symbol table. Each time the software reads one line of the symbol table, judges whether the variable type is in the rule table, for example, if the variable type in one line of the symbol table is read as AIW, the name of the PLC variable in the line is extracted and stored in the name member of Var, the type member of Var stores the corresponding variable type in the rule table, the address stores the address of the PLC variable, and the Var variable is stored in the 7 th buffer area. After extraction of all rows of the symbol table is completed, updating of 11 buffers is completed;
s303: and sequencing each buffer area in an ascending order of the var variable address members according to the sequence of the buffer areas to form a sequenced buffer area. Traversing the buffer area in sequence, taking out a Var structure variable, correspondingly generating a Transmission _ variable node, and assigning the value of the Var member variable to the child element of the Transmission _ variable element. After all the Var structural variables are traversed, a data description file is generated, as shown in fig. 4, in a Transmission _ variable element corresponding to an analog input variable "7# high-pressure pump pressure" in a PLC symbol table, a value of a name node is a variable name "7# high-pressure pump pressure", a value of a type node is a host computer variable type s16, a value of a length node is 2 bytes, and a value of an offset node is an offset 28 th byte. The PLC prepares data according to the sequence of the description files, and the upper computer software automatically finishes data extraction and analysis of the byte stream after reading the description files.
In summary, the general PLC data processing method and apparatus disclosed in the above embodiments of the present invention at least have the following advantages:
1. a single communication transmission protocol is divided into a communication transmission protocol and a structured data description file, wherein the data description file is used for describing specific contents of a data field in the communication transmission protocol, the data description file can be automatically generated by software, and an upper computer can automatically process the data description file to obtain detailed description of binary byte streams in the data field.
2. The mainstream PLC supports a symbol table, which contains information such as a variable name, a variable type, and a start address in the PLC. Therefore, the invention processes the symbol table of the PLC through the upper computer software, extracts the variable information in the symbol table, groups the variables according to the types, sorts the variables according to the variable initial addresses, and further automatically generates a cross-platform universal data description file which uses the information such as data name, length, transmission sequence, offset and the like to describe the composition of a 'data field' in a communication transmission protocol. In the communication transmission process, the PLC only needs to organize data uploading according to the description file, and the upper computer only needs to segment the binary data stream according to the description file to obtain all data. The method completely discards a great deal of word definition work of a data field in the communication transmission protocol in the prior art, and greatly simplifies the protocol formulation and negotiation process. Because the data description file adopts a fixed generation rule, the data description file has universality, and the data acquisition and transmission between the upper computer and the PLC are automated.
3. The invention can realize the high-efficiency reading and transmission of PLC data without the help of upper computer software or third-party components, protocols and the like of PLC manufacturers, and is suitable for any model of PLC.
4. The invention has no requirement on the operating system of the upper computer, and is suitable for any forms of PC, tablet personal computers, embedded board cards and the like.
5. The data description is stripped from the communication transmission protocol, so that the formulation of the communication transmission protocol is greatly simplified, and great convenience is provided for communication and maintenance.
6. The information of the data description file is extracted from the PLC symbol table, is automatically generated by using a fixed rule through software, does not need human participation, greatly reduces the workload, and avoids omission and errors.
7. When the data of the PLC end is newly added or deleted, the upper computer end only needs to update the data description file according to the new symbol table, and other communication is not needed.
8. When the software of the upper computer is rewritten or replaced, only the data description file needs to be read again.
9. The PLC data batch reading and transmission device is very suitable for batch reading and transmission of PLC data.
The above description is only a preferred embodiment of the present invention and is not intended to limit the present invention, and various modifications and changes may be made by those skilled in the art. Any modification, equivalent replacement, or improvement made within the spirit and principle of the present invention should be included in the protection scope of the present invention.

Claims (10)

1. A general PLC data processing method is characterized by comprising the following steps:
s100, configuring a data structure buffer area by an upper computer according to an acquisition and transmission rule table created by a user;
s200, the upper computer derives a PLC symbol table, selects records corresponding to the variable types of the acquisition and transmission rule table from the derived PLC symbol table, converts the records into structural variables, stores the structural variables in corresponding data structure buffers in a grouping mode, and creates a universal data description file; the data description file is used for describing the number of the structure variables related to the data field, the name, the length and the offset information of each structure variable and the sequencing information in the data field and is independent of a communication transmission protocol;
s300, sequentially putting the content of the corresponding variable into a buffer area with continuous addresses and updating the content of the buffer area in each scanning period by the PLC according to the sequence of each structural variable in the data description file, and uploading the content of the buffer area through a data frame by the PLC according to the format of a communication transmission protocol after receiving a reading command of an upper computer; the communication transmission protocol omits the explanation of PLC data determined by the data description file;
s400, the upper computer extracts a data field in the data frame through protocol analysis and processing, and temporarily stores the data field as a binary byte stream; and then, automatically completing data extraction and analysis of the temporary storage byte stream according to the data description file to obtain binary values corresponding to the structure variable names in the data uploaded by the PLC.
2. The method according to claim 1, wherein each row of the collection transmission rule table represents a PLC variable type to be collected by the upper computer and includes at least four fields of "upper computer variable type", "PLC variable type", "data length", and "class number";
and the upper computer prepares a data structure buffer area for each PLC variable according to the row sequence of the acquisition and transmission rule table, each buffer area can contain at least two structure variables, and the members of the structure variables are used for storing the name, type and address of the variables analyzed from the read PLC symbol table.
3. The method according to claim 2, wherein all the group data corresponding to each data structure buffer area are uploaded together by a modbus protocol in the communication transmission process of the PLC and the upper computer, and the corresponding classification number is 03H.
4. The method of claim 1, wherein at least contents of two columns of "sign" and "address" are included in the derived PLC symbol table, the contents of the "sign" column contain names of PLC variables, and the contents of the "address" column contain types and start addresses of PLC variables.
5. The method of claim 1, wherein the ordering of the structure variables in the data field is ordered according to the same type of variables in ascending order of start address and the ordering of the different types of variables in the data field is ordered according to the row order of the transmission rule table.
6. The method according to any one of claims 1 to 5, wherein the specific process of generating the data description file comprises:
s4: the upper computer generates a structured data description file by adopting a standard universal markup language format, firstly generates a data domain root node element, and newly establishes a total data number sub-node element in the data domain root node element;
s5: the upper computer reads the PLC symbol table according to the rows, judges the PLC variable type of the 'address' field content of each row one by one, if the type is not in the acquisition and transmission rule table, discards the corresponding row, otherwise extracts the information of the corresponding row, saves the information in the corresponding member of the structure variable, and additionally stores the structure variable in the corresponding data structure buffer area; after the last line is read, updating the attribute value of the total data number element in the data description file into an effective line number;
s6: the upper computer sorts the structural variables of each data structure buffer area in an ascending order according to the addresses of the PLC variables stored by the members to form sorted data structure buffer areas;
s7: the upper computer sequentially takes out the sorted structural variables in the first buffer area according to the sequence of the acquisition and transmission rule table, newly establishes a 'transmission variable' child node element in the description file for each structural variable, wherein the child elements of the child node elements at least comprise 'name', 'length' and 'offset', and then writes the child node elements under a 'data field' root node of the data description file;
s8: and the upper computer finishes the extraction of the structural variables of all the remaining buffer areas and the generation and writing of the sub-node elements of the transmission variables in sequence according to the operation of S7 to form a final data description file.
7. The method of claim 1, further comprising:
and converting the derived PLC symbol table into a file in a csv format or other text format so as to extract the structural variables required by the data description file.
8. A general PLC data processing apparatus, which is specifically a host computer, and includes a memory, a processor, and a computer program stored in the memory and executable on the processor, wherein the processor implements a series of steps corresponding to the host computer in the method according to any one of claims 1 to 7 when executing the computer program.
9. The apparatus of claim 8, wherein the functional modules within the computer program comprise:
the control processing module: the main control module is used for initiating corresponding operation and finishing logic control, communication transmission control and data processing of the software;
the rule database module: the PLC acquisition and transmission system is composed of a transmission rule database and corresponding operation interface functions, wherein the transmission rule database comprises acquisition and transmission rule tables, and each acquisition and transmission rule table corresponds to a PLC of a specific model;
symbol table processing module: the PLC processing system is used for finishing the processing of the PLC symbol table, sequentially extracting one row of the symbol table, extracting PLC variable names from a 'symbol' column of the row, extracting types and initial addresses of PLC variables from an 'address' column, storing the extracted information by members of structural variables, and storing the structural variables in corresponding buffer areas in groups;
the description file management module: for writing and reading the data description file.
10. The apparatus of claim 9, wherein the functional modules within the computer program further comprise:
a channel management module: the method is used for providing a group of high-level channel read-write operation functions, so that the control processing module uses a uniform interface to read and write different physical channels without paying attention to the details of reading and writing of each physical channel.
CN202211477317.5A 2022-11-23 2022-11-23 Universal PLC data processing method and device Pending CN115826492A (en)

Priority Applications (1)

Application Number Priority Date Filing Date Title
CN202211477317.5A CN115826492A (en) 2022-11-23 2022-11-23 Universal PLC data processing method and device

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
CN202211477317.5A CN115826492A (en) 2022-11-23 2022-11-23 Universal PLC data processing method and device

Publications (1)

Publication Number Publication Date
CN115826492A true CN115826492A (en) 2023-03-21

Family

ID=85530845

Family Applications (1)

Application Number Title Priority Date Filing Date
CN202211477317.5A Pending CN115826492A (en) 2022-11-23 2022-11-23 Universal PLC data processing method and device

Country Status (1)

Country Link
CN (1) CN115826492A (en)

Cited By (1)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN117459650A (en) * 2023-12-20 2024-01-26 长沙矿冶研究院有限责任公司 Digital video watermarking method and system aiming at copyright protection

Cited By (2)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN117459650A (en) * 2023-12-20 2024-01-26 长沙矿冶研究院有限责任公司 Digital video watermarking method and system aiming at copyright protection
CN117459650B (en) * 2023-12-20 2024-03-22 长沙矿冶研究院有限责任公司 Digital video watermarking method and system aiming at copyright protection

Similar Documents

Publication Publication Date Title
US10977014B2 (en) Web-based programming environment for embedded devices
CN102520619B (en) General-purpose satellite remote sensing simulator
CN100520649C (en) Program creating device for programmable controller, program creating method for programmable controller, and recording medium
US20150254305A1 (en) Control device
CN115826492A (en) Universal PLC data processing method and device
US7505875B2 (en) Monitor system, and monitor device and data collecting device therefor
CN110769002A (en) LabVIEW-based message analysis method, system, electronic device and medium
CN115098218A (en) Method for describing and simulating functional block model from FMU (functional modeling Unit) model to configuration software
CN111556141A (en) Intelligent gateway data acquisition system and method based on Json data sheet
CN113986985B (en) IO reading method, system, equipment and storage medium for energy management
CN111741057A (en) Normalization acquisition system and method for multi-source Internet of things data
CN113887182A (en) Table generation method, device, equipment and storage medium
CN114513410A (en) Method and system for equipment to rapidly access Internet of things platform
CN106325242A (en) MES system based on modularized control units
CN101853025B (en) Method and device for data acquisition and processing of multiple industrial-control system platforms
CN111752188A (en) IO configuration method and system
CN105824684B (en) A kind of implementation method of multi-mode big data software simulator
CN110853327B (en) Ship cabin equipment data field debugging and collecting method and device based on single chip microcomputer
CN102722592B (en) Universal digital information recording device and method
CN114268650A (en) Configuration method and system for establishing communication connection
CN110061990A (en) A kind of DTU protocol extension method
JP4282961B2 (en) System that defines data input / output in the controller
JP7215509B2 (en) Industrial equipment data collection system, industrial equipment data collection method, and program
Zhou Soft PLC Research And Development System Based On PC
TWI758175B (en) A data processing system and method

Legal Events

Date Code Title Description
PB01 Publication
PB01 Publication
SE01 Entry into force of request for substantive examination
SE01 Entry into force of request for substantive examination