Method and device for high-speed data acquisition of upper computer based on Ethernet
By storing data in segments on the PLC end and using the write completion marking method, the high-speed data acquisition problem between the host computer and the PLC is solved, efficient data acquisition in a high-delay network is achieved, and real-time data acquisition and network communication efficiency are improved.
Patent Information
- Application Number
- CN202510487554.7
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2025-04-17
- Publication Date
- 2025-08-08
AI Technical Summary
In the prior art, it is difficult for the upper computer to realize high-speed data acquisition with the PLC, especially when the network delay is high, resulting in real-time data loss.
By storing real-time data segments on the PLC side and setting write completion marks, using Ethernet connections, the host computer reads these marks in fixed cycles to achieve data acquisition and optimizes network communication efficiency.
It realizes the second-level data acquisition of millisecond response in high-delay networks, improves the real-time and flexibility of data acquisition and reduces network load.
Smart Images

Figure CN120447430A_ABST
Abstract
Description
Technical Field
[0001] The present invention relates to the field of PLC and computer technology, and in particular to a method and device for high-speed data acquisition of a host computer based on Ethernet. Background Art
[0002] With the rapid development of information technology, data has become a key basis for decision-making, optimization, and innovation in all areas of modern society. As a crucial bridge connecting underlying hardware devices with upper-level application systems, host computer data acquisition plays an indispensable role in numerous fields, including industry, scientific research, and communications. In engineering projects, in particular, real-time data from important sensors carries information about the equipment's operating status. Accurate, continuous, and efficient data collection is crucial for determining whether equipment meets process requirements and is a key component in ensuring the smooth progress of engineering projects and the achievement of product quality standards.
[0003] Taking the position data collection of the crystallizer vibration device as an example, the basic process of data collection is as follows: Figure 1 As shown in the figure, since the scanning speed of the PLC can reach a fixed cycle execution of several milliseconds, it is relatively easy to synchronize the displacement sensor data with the PLC scanning cycle on the PLC side.
[0004] If the host computer's read and write speed to the PLC is faster than the PLC's displacement sensor data update rate, then the host computer can continuously access the PLC's real-time sensor data during the PLC's scan cycle to achieve real-time collection of vibration position data from the mold vibration device. In reality, the host computer's read and write speed to the PLC cannot maintain sustained high speeds. Various factors, including network congestion and limitations in the host computer software's read and write capabilities, prevent the host computer from collecting data efficiently and continuously. If the host computer fails to read data in a timely manner, the current real-time data will be lost.
[0005] Therefore, high-speed data acquisition is difficult to achieve using standard host software that directly accesses real-time data. For example, well-known host software such as Siemens WinCC typically has a read and write cycle of at least 500 milliseconds, making high-speed data acquisition impossible. High-speed data acquisition typically requires the use of specialized data acquisition software such as ibaPDA, and requires a smooth network connection and latency less than the scan cycle. Summary of the Invention
[0006] The purpose of the present invention is to provide a method and device for high-speed data acquisition of a host computer based on Ethernet, so as to realize high-speed data acquisition of the host computer.
[0007] The first aspect of the present invention provides a method for high-speed data acquisition of a host computer based on Ethernet, the method comprising:
[0008] The PLC stores the real-time data one by one in the first cycle, and segments the stored data into several continuous data sets of the same specifications according to a fixed cycle or number. The PLC writes the real-time data into these data sets in sequence. When a data set is full, the segment write completion flag corresponding to the data set is set to True, thereby notifying the host computer to collect data.
[0009] After the host computer starts data acquisition, it continuously reads the segment write completion mark status on the PLC in the second cycle. After the host computer reads the segment write completion mark corresponding to the first data set as True, it reads the corresponding data set and resets the segment write completion mark corresponding to the data set to False; after the host computer waits for the segment write completion mark corresponding to the next data set to be True, it reads the next data set and resets the segment write completion mark corresponding to the next data set to False. This operation is repeated to cyclically collect data for each segment.
[0010] After the PLC has filled all data sets in sequence, it will overwrite the data set from the first one; after the host computer has read the last data set, it will continue reading from the first one.
[0011] In some embodiments, the fixed period is a multiple of the first period.
[0012] In some embodiments, the second period is smaller than the segment duration, where the segment duration is the product of the fixed period or the number of segment data and the first period.
[0013] In some embodiments, overwriting is performed only when the segment write completion flag corresponding to the data set is False.
[0014] In some embodiments, the segment write completion flags corresponding to all data sets are initialized to False.
[0015] In a second aspect, the present invention provides a device for high-speed data acquisition of a host computer based on Ethernet, the device comprising a PLC and a host computer, the PLC and the host computer being connected via Ethernet;
[0016] The PLC stores the real-time data one by one in the first cycle, and segments the stored data into several continuous data sets of the same specifications according to a fixed cycle or number. The PLC writes the real-time data into these data sets in sequence. When a data set is full, the segment write completion flag corresponding to the data set is set to True, thereby notifying the host computer to collect data.
[0017] After the host computer starts data acquisition, it continuously reads the segment write completion mark status on the PLC in the second cycle. After the host computer reads the segment write completion mark corresponding to the first data set as True, it reads the corresponding data set and resets the segment write completion mark corresponding to the data set to False; after the host computer waits for the segment write completion mark corresponding to the next data set to be True, it reads the next data set and resets the segment write completion mark corresponding to the next data set to False. This operation is repeated to cyclically collect data for each segment.
[0018] After the PLC has filled all data sets in sequence, it will overwrite the data set from the first one; after the host computer has read the last data set, it will continue reading from the first one.
[0019] In some embodiments, the fixed period is a multiple of the first period.
[0020] In some embodiments, the second period is smaller than the segment duration, where the segment duration is the product of the fixed period or the number of segment data and the first period.
[0021] In some embodiments, overwriting is performed only when the segment write completion flag corresponding to the data set is False.
[0022] In some embodiments, the segment write completion flags corresponding to all data sets are initialized to False.
[0023] In general, the above technical solutions conceived by the present invention can achieve the following beneficial effects compared with the prior art:
[0024] The method and device for high-speed data acquisition based on Ethernet for a host computer of the present invention have strong real-time performance and flexibility, and can record and store data sources at a very high speed. After the PLC reads the real-time data of the sensor, there is no need to rush to send the data away. In particular, when the network is busy, a buffer can be formed in the PLC. The host computer only needs to remove the unread data in segments before it is overwritten by new data. The present invention reduces the data acquisition work required for millisecond-level response to the execution level of seconds, and can successfully complete the data acquisition work in a network with a higher delay. At the same time, through the optimization of the program algorithm, the present invention allows the host computer to complete the one-time reading and writing of 400 bytes of continuous data by sending only one instruction, thereby improving the efficiency of network communication. Originally, one hundred instructions might be required to read the same amount of data. BRIEF DESCRIPTION OF THE DRAWINGS
[0025] Figure 1 A schematic diagram of the basic process of location data collection in the background technology;
[0026] Figure 2A schematic diagram of a PLC data storage model provided in an embodiment of the present application;
[0027] Figure 3 A data collection flow chart of a host computer provided in an embodiment of the present application;
[0028] Figure 4 This is a diagram showing an example of vibration data collection provided in an embodiment of the present application. DETAILED DESCRIPTION
[0029] In order to make the purpose, technical solutions and advantages of the present invention more clear, the present invention is further described in detail below with reference to the accompanying drawings and examples. It should be understood that the specific embodiments described herein are only used to explain the present invention and are not intended to limit the present invention. Based on the embodiments provided in this application, all other embodiments obtained by those of ordinary skill in the art without making creative work are within the scope of protection of the present invention.
[0030] Obviously, the drawings described below are merely examples or embodiments of the present application. Those skilled in the art can, without inventive effort, apply the present application to other similar scenarios based on these drawings. Furthermore, it is also understood that, although the effort involved in such a development process may be complex and lengthy, for those skilled in the art related to the content disclosed in this application, changes in design, manufacturing, or production based on the technical content disclosed in this application are merely conventional technical means and should not be construed as an insufficiency of the content disclosed in this application.
[0031] References to "embodiments" in this application mean that a particular feature, structure, or characteristic described in connection with the embodiment may be included in at least one embodiment of the application. The appearance of this phrase in various places in the specification does not necessarily refer to the same embodiment, nor does it refer to independent or alternative embodiments that are mutually exclusive of other embodiments. It is understood, both explicitly and implicitly, by those skilled in the art that the embodiments described in this application may be combined with other embodiments unless there is a conflict.
[0032] Unless otherwise defined, the technical or scientific terms used in this application should have the ordinary meaning understood by a person of ordinary skill in the technical field to which this application belongs. The words "one", "a", "the" and the like used in this application do not indicate a limit on quantity and may indicate the singular or plural. The terms "include", "comprise", "have" and any variations thereof used in this application are intended to cover non-exclusive inclusions; for example, a process, method, system, product or device that includes a series of steps or modules (units) is not limited to the listed steps or units, but may also include steps or units that are not listed, or may also include other steps or units that are inherent to these processes, methods, products or devices. The words "connect", "connected", "coupled" and the like used in this application are not limited to physical or mechanical connections, but may include electrical connections, whether direct or indirect. The word "multiple" used in this application refers to two or more. "And / or" describes the association relationship of associated objects, indicating that three relationships can exist. For example, "A and / or B" can mean: A exists alone, A and B exist at the same time, and B exists alone. The character " / " generally indicates that the objects before and after are in an "or" relationship. The terms "first", "second", "third", etc. involved in this application are only used to distinguish similar objects and do not represent a specific order for the objects.
[0033] The present application provides a method and device for high-speed data acquisition of a host computer based on Ethernet, which achieves second-level response and millisecond-level data acquisition, and realizes engineering applications, especially in the detection of crystallizer vibration position.
[0034] like Figure 2 and Figure 3 As shown, the method for high-speed data acquisition of a host computer based on Ethernet provided by this application includes:
[0035] During high-speed data collection, the host computer and the PLC divide the work. The PLC first stores and protects the real-time data one by one in an extremely short first cycle. It then segments the stored data according to a fixed cycle or number to create several continuous data sets of the same specifications. The PLC writes the real-time data into these data sets in sequence. Once all data sets are filled, it overwrites the previous data from the starting position. After the PLC fills each data set, it sets the segment write completion flag of the corresponding data set to True, thereby notifying the host computer to start data collection. After the host computer starts data collection, it continuously reads the segment write completion flag status on the PLC at a cycle shorter than the segment length. When the host computer reads the first segment completion flag as True, it immediately reads the corresponding data set and resets the segment write completion flag to False. It waits for the next segment write completion flag from the PLC to be True, and then repeats the above read and write operations, collecting data from each segment over and over again.
[0036] The fixed period is a multiple of the first period, where the multiple is the number of data points in the segment. A shorter fixed period results in better real-time data. A longer fixed period reduces network latency requirements and allows for more data to be collected each time.
[0037] To prevent data from being overwritten by new data, overwriting is performed only when the segment write completion flag corresponding to the dataset is False. The segment write completion flags corresponding to all datasets can be initialized to False.
[0038] In addition, the present application also provides a device for high-speed data acquisition of a host computer based on Ethernet for implementing the above method embodiment, the device includes a PLC and a host computer, and the PLC and the host computer are connected via Ethernet;
[0039] The PLC stores the real-time data one by one in the first cycle, and segments the stored data into several continuous data sets of the same specifications according to a fixed cycle or number. The PLC writes the real-time data into these data sets in sequence. When a data set is full, the segment write completion flag corresponding to the data set is set to True, thereby notifying the host computer to collect data.
[0040] After the host computer starts data acquisition, it continuously reads the segment write completion mark status on the PLC in the second cycle. After the host computer reads the segment write completion mark corresponding to the first data set as True, it reads the corresponding data set and resets the segment write completion mark corresponding to the data set to False; after the host computer waits for the segment write completion mark corresponding to the next data set to be True, it reads the next data set and resets the segment write completion mark corresponding to the next data set to False. This operation is repeated to cyclically collect data for each segment.
[0041] After the PLC has filled all data sets in sequence, it will overwrite the data set from the first one; after the host computer has read the last data set, it will continue reading from the first one.
[0042] Finally, this application provides a high-speed data acquisition example. In this example, the PLC uses a Siemens S7-1500 series PLC. The sensor data reading cycle and program execution cycle are set to 10ms. Each segment is designed for 1 second of data and is planned with a 5-second buffer capacity. Calculation shows that each segment requires 100 elements, requiring a total of 5 segment storage areas.
[0043] The host computer uses C# programming software and references the S7.net library file to implement the Ethernet communication connection (S7 communication) between the host computer and the Siemens PLC. A 300ms timer is defined to read the status information of the segment writing completion every 300ms. If it is known that the monitored segment has been written, the data content in the segment is read and sent to the host computer for processing. Then, the monitored segment is moved down and the above operation is repeated. Finally, the result is as follows Figure 4 shown.
[0044] Among them, the PLC end program summary is as follows:
[0045] Declare a global variable #m of data type Int, used for segment pointer.
[0046] Declare a global variable #n of data type Int, which is used as the element pointer in the segment.
[0047] Declare a global variable #DataSource with data type Real to receive the data source.
[0048] Declare a global variable #Points, data type Array[0..3,0..499] of Real, used to store real-time data.
[0049] Declare a global variable #DoneSts, data type Array[0..15] of Bool, used for segment completion marking.
[0050] Declare a global variable #Run with data type Bool, which is used as the start marker.
[0051] / / Data initialization before running;
[0052] IF NOT #Run THEN
[0053] #m:=0;
[0054] #n:=0;
[0055] FILL_BLK(IN:=FALSE,
[0056] COUNT:=16,
[0057] OUT=>#DoneSts[0]);
[0058] RETURN;
[0059] END_IF;
[0060] / / Record data
[0061] #Points[#m,#n]:=#DataSource;
[0062] #n+=1;
[0063] IF#n>99THEN
[0064] #DoneSts[#m]:=True; / / Segment writing completed mark
[0065] #n:=0; / / Initial element pointer of new segment
[0066] #m+=1;
[0067] IF#m>4THEN
[0068] #m:=0;
[0069] END_IF; / / segment pointer
[0070] END_IF;
[0071] The host computer program summary is as follows:
[0072]
[0073]
[0074]
[0075] In summary, the present application has strong real-time and flexibility, and can record and store data sources at a very fast speed. After the PLC reads the real-time data from the sensor, it does not have to rush to send the data away. In particular, when the network is busy, a buffer can be formed in the PLC. The host computer only needs to remove the unread data in segments before it is overwritten by new data. The present application reduces the data collection work with millisecond-level response requirements to second-level execution, and can successfully complete the data collection work in a network with a higher delay. At the same time, through the optimization of the program algorithm, the host computer only needs to send one instruction to complete the one-time reading and writing of four hundred bytes of continuous data, thereby improving the efficiency of network communication. Originally, one hundred instructions might be required to read the same amount of data.
[0076] It should be noted that the various technical features of the above-described embodiments can be combined in any manner. To simplify the description, not all possible combinations of the various technical features in the above-described embodiments are described. However, as long as there are no contradictions in the combination of these technical features, they should be considered to be within the scope of this specification. In addition, according to the needs of implementation, the various steps / components described in this application can be split into more steps / components, and two or more steps / components or partial operations of steps / components can be combined into new steps / components to achieve the purpose of the present invention.
[0077] Those skilled in the art will readily understand that the above-described embodiments merely represent several implementation methods of the present application, and their descriptions are relatively specific and detailed, but should not be construed as limiting the scope of the invention. It should be noted that a person of ordinary skill in the art may make several variations and improvements without departing from the concept of the present application, and these variations and improvements fall within the scope of protection of the present application. Therefore, the scope of protection of the present patent application shall be based on the appended claims.
Claims
1. A method for high-speed data acquisition of a host computer based on Ethernet, characterized in that: The method includes: The PLC stores the real-time data one by one in the first cycle, and segments the stored data into several continuous data sets of the same specifications according to a fixed cycle or number. The PLC writes the real-time data into these data sets in sequence. When a data set is full, the segment write completion flag corresponding to the data set is set to True, thereby notifying the host computer to collect data. After the host computer starts data acquisition, it continuously reads the segment write completion mark status on the PLC in the second cycle. After the host computer reads the segment write completion mark corresponding to the first data set as True, it reads the corresponding data set and resets the segment write completion mark corresponding to the data set to False; after the host computer waits for the segment write completion mark corresponding to the next data set to be True, it reads the next data set and resets the segment write completion mark corresponding to the next data set to False. This operation is repeated to cyclically collect data for each segment. After the PLC has filled all data sets in sequence, it will overwrite the data set from the first one; after the host computer has read the last data set, it will continue reading from the first one.
2. The method for high-speed data acquisition based on Ethernet according to claim 1, characterized in that: The fixed period is a multiple of the first period.
3. The method for high-speed data acquisition based on Ethernet host computer according to claim 1 or 2, characterized in that: The second period is smaller than the segment duration, where the segment duration is the product of the fixed period or the number of segment data and the first period.
4. The method for high-speed data acquisition based on Ethernet host computer according to claim 1, characterized in that: Overwriting is performed only when the segment write completion mark corresponding to the dataset is False.
5. The method for high-speed data acquisition based on Ethernet host computer according to claim 1, characterized in that: The segment write completion flags corresponding to all datasets are initialized to False.
6. A device for high-speed data acquisition based on Ethernet, characterized in that: The device includes a PLC and a host computer, and the PLC and the host computer are connected via Ethernet; The PLC stores the real-time data one by one in the first cycle, and segments the stored data into several continuous data sets of the same specifications according to a fixed cycle or number. The PLC writes the real-time data into these data sets in sequence. When a data set is full, the segment write completion flag corresponding to the data set is set to True, thereby notifying the host computer to collect data. After the host computer starts data acquisition, it continuously reads the segment write completion flag status on the PLC in the second cycle. After the host computer reads the segment write completion flag corresponding to the first data set as True, it reads the corresponding data set and resets the segment write completion flag corresponding to the data set to False. The host computer waits for the segment write completion flag corresponding to the next data set to be True, then reads the next data set and resets the segment write completion flag corresponding to the next data set to False. This operation is repeated to cyclically collect data for each segment. After the PLC has filled all data sets in sequence, it will start overwriting from the first data set; After the host computer finishes reading the last data set, it continues reading from the first data set.
7. The device for high-speed data acquisition based on Ethernet according to claim 1, characterized in that: The fixed period is a multiple of the first period.
8. The device for high-speed data acquisition based on Ethernet of claim 6 or 7, characterized in that: The second period is smaller than the segment duration, where the segment duration is the product of the fixed period or the number of segment data and the first period.
9. The device for high-speed data acquisition based on Ethernet according to claim 1, characterized in that: Overwriting is performed only when the segment write completion mark corresponding to the dataset is False.
10. The device for high-speed data acquisition based on Ethernet according to claim 1, characterized in that: The segment write completion flags corresponding to all datasets are initialized to False.
Citation Information
Patent Citations
Method for realizing high-speed data acquisition and storage with upper computer through PLC
CN105700462A
High-speed data acquisition and control system based on PLC
CN112631196A
Method for improving PLC data acquisition efficiency
CN114995280A
Data transmission method and device, data storage method and device, electronic equipment and medium
CN119311218A