A method and device for high-speed data acquisition of an upper computer based on Ethernet
Patent Information
- Application Number
- CN202510487554.7
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2025-04-17
- Publication Date
- 2026-10-23
- Estimated Expiration
- 2045-04-17
AI Technical Summary
[0024]本发明的基于以太网的上位机高速数据采集的方法及装置,具有很强的实时性和灵活性,能以很快的速度对数据源进行记录和存储,PLC端读取到传感器实时数据后不必急于将数据送走,特别是遇到网络繁忙时能在PLC内形成缓冲,上位机只需在未读取数据被新数据覆盖之前,将未读取数据分段提走即可。本发明将毫秒级响应要求的数据采集工作降低到秒级执行,可以在有较高延时的网络中顺利完成数据采集工作。同时,本发明通过程序算法的优化,上位机只发送一条指令即可完成一次性读写四百个字节的连续数据,提高了网络通讯效率,而原先可能需要一百条指令才能读取同样的数据量。
Smart Images

Figure CN120447430B_ABST
Abstract
Description
Technical Field
[0001] This invention relates to the fields of PLC and computer technology, and specifically to a method and apparatus for high-speed data acquisition by a host computer based on Ethernet. Background Technology
[0002] With the rapid development of information technology, data has become a key basis for decision-making, optimization, and innovation in various fields of modern society. Host computer data acquisition, as an important bridge connecting underlying hardware devices and upper-level application systems, plays an indispensable role in many fields such as industry, scientific research, and communications. Especially in engineering projects, real-time data from important sensors carries information on the operating status of equipment. Accurate, continuous, and efficient acquisition of this data is crucial for determining whether equipment meets process requirements and is a core link in ensuring the smooth progress of engineering projects and the achievement of product quality standards.
[0003] Taking the position data acquisition of the crystallizer vibration device as an example, the basic data acquisition process is as follows: Figure 1 As shown. Since the PLC's scanning speed can reach a fixed cycle of several milliseconds, it is relatively easy to synchronously update the displacement sensor data at the PLC end according to the PLC scanning cycle.
[0004] If the host computer's read / write speed to the PLC is faster than the data update speed of the displacement sensors in the PLC, then the host computer can continuously access the real-time sensor data of the PLC according to the PLC's scan cycle, thus achieving real-time acquisition of the vibration position data of the crystallizer vibration device. In reality, the host computer's read / write speed to the PLC cannot be maintained continuously at a high speed due to various reasons, including network congestion and limitations in the host computer's software read / write capabilities, resulting in the host computer's data acquisition being neither continuous nor efficient. If the host computer fails to read data in time, the current real-time data will be lost.
[0005] Therefore, high-speed data acquisition via direct access to real-time data using ordinary host computer software is difficult to achieve. For example, the read / write cycle of well-known host computer software such as Siemens WinCC is typically no less than 500 milliseconds, making high-speed acquisition impossible. High-speed data acquisition usually requires the use of professional data acquisition software such as ibaPDA, and it is essential to ensure a stable network connection and that network latency is less than the scan cycle. Summary of the Invention
[0006] The purpose of this invention is to provide a method and apparatus for high-speed data acquisition from a host computer based on Ethernet, thereby enabling high-speed data acquisition from the host computer.
[0007] The first aspect of the present invention provides a method for high-speed data acquisition from a host computer based on Ethernet, the method comprising:
[0008] The PLC stores real-time data one by one in the first cycle, and divides the stored data into segments according to a fixed cycle or number of segments to create several continuous datasets of the same size. The PLC writes the real-time data into these datasets in sequence. When a dataset is filled, the corresponding segment writing completion flag is set to True to notify the host computer to collect data.
[0009] After the host computer starts data acquisition, it continuously reads the segment write completion status on the PLC in the second cycle. After the host computer reads the segment write completion mark as True for the first dataset, it reads the corresponding dataset and resets the segment write completion mark to False. The host computer waits for the segment write completion mark to be True for the next dataset, reads the next dataset, and resets the segment write completion mark to False. This operation is repeated to collect data from each segment in a loop.
[0010] After the PLC fills all the datasets in sequence, it starts writing over the first dataset again; after the host computer finishes reading the last dataset, it continues reading from the first dataset.
[0011] In some embodiments, the fixed period is a multiple of the first period.
[0012] In some embodiments, the second period is less than the segment duration, which is the product of the fixed period or the number of segmented data and the first period.
[0013] In some embodiments, overwrite is performed only when the segment write completion flag corresponding to the dataset is set to False.
[0014] In some embodiments, the segment write completion flag for all datasets is initialized to False.
[0015] Secondly, the present invention provides a device for high-speed data acquisition from a host computer based on Ethernet. The device includes a PLC and a host computer, which are connected via Ethernet.
[0016] The PLC stores real-time data one by one in the first cycle, and divides the stored data into segments according to a fixed cycle or number of segments to create several continuous datasets of the same size. The PLC writes the real-time data into these datasets in sequence. When a dataset is filled, the corresponding segment writing completion flag is set to True to notify the host computer to collect data.
[0017] After the host computer starts data acquisition, it continuously reads the segment write completion status on the PLC in the second cycle. After the host computer reads the segment write completion mark as True for the first dataset, it reads the corresponding dataset and resets the segment write completion mark to False. The host computer waits for the segment write completion mark to be True for the next dataset, reads the next dataset, and resets the segment write completion mark to False. This operation is repeated to collect data from each segment in a loop.
[0018] After the PLC fills all the datasets in sequence, it starts writing over the first dataset again; after the host computer finishes reading the last dataset, it continues reading from the first dataset.
[0019] In some embodiments, the fixed period is a multiple of the first period.
[0020] In some embodiments, the second period is less than the segment duration, which is the product of the fixed period or the number of segmented data and the first period.
[0021] In some embodiments, overwrite is performed only when the segment write completion flag corresponding to the dataset is set to False.
[0022] In some embodiments, the segment write completion flag for all datasets is initialized to False.
[0023] In summary, compared with the prior art, the above-described technical solutions conceived by this invention can achieve the following beneficial effects:
[0024] The present invention provides a method and apparatus for high-speed data acquisition via Ethernet-based host computer, which features strong real-time performance and flexibility. It can record and store data sources at high speeds. After the PLC reads real-time sensor data, it does not need to immediately send the data. Especially when the network is busy, a buffer can be formed within the PLC. The host computer only needs to retrieve unread data segments before it is overwritten by new data. This invention reduces the data acquisition process, which requires millisecond-level response time, to second-level execution, enabling successful data acquisition even in networks with high latency. Furthermore, through optimized program algorithms, the host computer can complete the reading and writing of 400 bytes of continuous data at once with just one instruction, improving network communication efficiency, whereas previously it might have required 100 instructions to read the same amount of data. Attached Figure Description
[0025] Figure 1 This is a schematic diagram illustrating the basic process of location data acquisition in the background technology;
[0026] Figure 2A schematic diagram of a PLC data storage model provided in an embodiment of this application;
[0027] Figure 3 A flowchart of host computer data acquisition is provided for an embodiment of this application;
[0028] Figure 4 This is a diagram illustrating an example of vibration data acquisition provided in an embodiment of this application. Detailed Implementation
[0029] To make the objectives, technical solutions, and advantages of this invention clearer, the invention will be further described in detail below with reference to the accompanying drawings and embodiments. It should be understood that the specific embodiments described herein are merely illustrative and not intended to limit the invention. All other embodiments obtained by those skilled in the art based on the embodiments provided in this application without inventive effort are within the scope of protection of this invention.
[0030] Obviously, the accompanying drawings described below are merely some examples or embodiments of this application. Those skilled in the art can apply this application to other similar scenarios based on these drawings without any inventive effort. Furthermore, it is understood that although the efforts made in this development process may be complex and lengthy, for those skilled in the art related to the content disclosed in this application, any changes to design, manufacturing, or production based on the technical content disclosed in this application are merely conventional technical means and should not be construed as insufficient disclosure of the content of this application.
[0031] In this application, the reference to "embodiment" means that a specific feature, structure, or characteristic described in connection with an embodiment may be included in at least one embodiment of this application. The appearance of this phrase in various places in the specification does not necessarily refer to the same embodiment, nor is it a separate or alternative embodiment that is mutually exclusive with other embodiments. It will be explicitly and implicitly understood by those skilled in the art that the embodiments described in this application may be combined with other embodiments without conflict.
[0032] Unless otherwise defined, the technical or scientific terms used in this application shall have the ordinary meaning understood by one of ordinary skill in the art to which this application pertains. The terms “a,” “an,” “an,” “the,” and similar words used in this application do not indicate quantity limitation and may indicate singular or plural. The terms “comprising,” “including,” “having,” and any variations thereof used in this application are intended to cover non-exclusive inclusion; 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 not listed, or may include other steps or units inherent to these processes, methods, products, or devices. The terms “connected,” “linked,” “coupled,” and similar words used in this application are not limited to physical or mechanical connections, but may include electrical connections, whether direct or indirect. “Multiple” used in this application refers to two or more. “And / or” describes the relationship between related objects, indicating that three relationships may exist; for example, “A and / or B” can represent: A alone, A and B simultaneously, and B alone. The character " / " generally indicates that the preceding and following objects are in an "or" relationship. The terms "first," "second," and "third" used in this application are merely to distinguish similar objects and do not represent a specific ordering of the objects.
[0033] This application provides a method and apparatus for high-speed data acquisition by a host computer based on Ethernet, which achieves millisecond-level response and data acquisition, and has been implemented in 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 by a host computer based on Ethernet provided in this application includes:
[0035] During high-speed data acquisition, the host computer and PLC work in tandem. The PLC first stores and protects the real-time data in a very short initial cycle. Then, it segments the stored data into several continuous datasets of the same size, based on a fixed cycle or number of segments. The PLC sequentially writes the real-time data into these datasets. After all datasets are filled, it overwrites the previous data starting from the beginning. After each dataset is filled, the PLC sets the segment completion flag to True, thus notifying the host computer to start data acquisition. After the host computer starts data acquisition, it continuously reads the segment completion flag status on the PLC at a cycle shorter than the segment duration. Once the host computer reads the first segment completion flag as True, it immediately reads the corresponding dataset and resets the segment completion flag to False. It waits for the next segment completion flag from the PLC to be True, and then repeats the above read and write operations, continuously acquiring data from each segment.
[0036] The fixed period is a multiple of the first period, and the multiple represents the number of data points in the segment. The shorter the fixed period, the better the real-time performance of the data; the longer the fixed period, the lower the requirement for network latency, and the more data can be collected each time.
[0037] To prevent data from being overwritten by new data, overwriting only occurs when the segment write completion flag for the corresponding dataset is set to False. The segment write completion flag for all datasets can be initialized to False.
[0038] In addition, this application also provides an apparatus for implementing the above method embodiment of high-speed data acquisition based on Ethernet host computer. The apparatus includes a PLC and a host computer, and the PLC and the host computer are connected via Ethernet.
[0039] The PLC stores real-time data one by one in the first cycle, and divides the stored data into segments according to a fixed cycle or number of segments to create several continuous datasets of the same size. The PLC writes the real-time data into these datasets in sequence. When a dataset is filled, the corresponding segment writing completion flag is set to True to notify the host computer to collect data.
[0040] After the host computer starts data acquisition, it continuously reads the segment write completion status on the PLC in the second cycle. After the host computer reads the segment write completion mark as True for the first dataset, it reads the corresponding dataset and resets the segment write completion mark to False. The host computer waits for the segment write completion mark to be True for the next dataset, reads the next dataset, and resets the segment write completion mark to False. This operation is repeated to collect data from each segment in a loop.
[0041] After the PLC fills all the datasets in sequence, it starts writing over the first dataset again; after the host computer finishes reading the last dataset, it continues reading from the first dataset.
[0042] Finally, this application provides a high-speed data acquisition example. In this example, a Siemens S7-1500 series PLC is used. The sensor data reading cycle and program execution cycle are set at 10ms. Each segment is designed with a data volume of 1 second and is planned to have a 5-second buffer capacity. Calculations show that each segment needs to set 100 elements, and a total of 5 segment storage areas are required.
[0043] The host computer uses C# programming software and references the S7.net library to implement Ethernet communication (S7 communication) between the host computer and the Siemens PLC. A 300ms timer is defined to read the segment write completion status every 300ms. If it is detected that the monitored segment has been written, the data content of that segment is read and sent to the host computer for processing. Then, the monitored segment moves down, and the above operation is repeated. Finally, the result is as follows. Figure 4 As shown.
[0044] The PLC program summary is as follows:
[0045] Declare a global variable #m, of data type Int, for use as a segmented pointer.
[0046] Declare a global variable #n, of data type Int, to be used as a pointer to an element in the segment.
[0047] Declare a global variable #DataSource, with data type Real, to receive the data source.
[0048] Declare a global variable #Points, of data type Array[0..3,0..499]of Real, to store real-time data.
[0049] Declare a global variable #DoneSts, of data type Array[0..15]of Bool, to be used as a segment completion marker.
[0050] Declare a global variable #Run, of data type Bool, to be used as a start flag.
[0051] / / Data initialization before execution;
[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; / / Marker indicating completion of segment writing
[0065] #n:=0; / / Initial element pointer for the new segment
[0066] #m+=1;
[0067] IF#m>4THEN
[0068] #m:=0;
[0069] END_IF; / / Segment pointer
[0070] END_IF;
[0071] The summary of the host computer program is as follows:
[0072]
[0073]
[0074]
[0075] In summary, this application offers strong real-time performance and flexibility, enabling rapid recording and storage of data sources. After the PLC reads real-time sensor data, it doesn't need to immediately send the data, especially during network congestion, as a buffer can be formed within the PLC. The host computer only needs to retrieve unread data segments before it's overwritten by new data. This application reduces data acquisition from millisecond-level response requirements to second-level execution, allowing for successful data acquisition even in networks with high latency. Furthermore, through optimized program algorithms, this example allows the host computer to complete the reading and writing of 400 bytes of continuous data in a single instruction, improving network communication efficiency compared to the previous requirement of one hundred instructions for reading the same amount of data.
[0076] It should be noted that the technical features of the above embodiments can be combined arbitrarily. For the sake of brevity, not all possible combinations of the technical features in the above embodiments have been described. However, as long as the combination of these technical features does not contradict each other, it should be considered within the scope of this specification. In addition, depending on the implementation needs, the various steps / components described in this application can be broken down into more steps / components, or two or more steps / components or parts of steps / components can be combined into new steps / components to achieve the purpose of this invention.
[0077] It will be readily understood by those skilled in the art that the above-described embodiments merely illustrate several implementation methods of this application, and while the descriptions are relatively specific and detailed, they should not be construed as limiting the scope of the invention patent. It should be noted that those skilled in the art can make various modifications and improvements without departing from the concept of this application, and these all fall within the protection scope of this application. Therefore, the protection scope of this patent application should be determined by the appended claims.
Claims
1. A method for high-speed data acquisition from a host computer based on Ethernet, characterized in that, The method includes: The PLC stores real-time data one by one in the first cycle, and divides the stored data into segments according to a fixed cycle or number of segments to create at least three continuous datasets of the same size; the PLC writes the real-time data into these datasets in sequence, and sets the segment completion flag of each dataset to True after it is filled, thereby notifying the host computer to collect data; the fixed cycle is a multiple of the first cycle. After the host computer starts data acquisition, it continuously reads the segment write completion flag status on the PLC in the second cycle. Once the host computer reads the segment write completion flag corresponding to the first dataset as True, it reads the corresponding dataset and resets the segment write completion flag to False. The host computer waits for the segment write completion flag corresponding to the next dataset to be True, then reads the next dataset and resets the segment write completion flag to False, repeating this operation to cyclically acquire data from each segment. The second cycle is shorter than the segment duration. After the PLC fills all the datasets in sequence, it starts writing over the first dataset again. Overwriting is only performed when the corresponding segment of the dataset is marked as False after writing is completed. After the host computer finishes reading the last dataset, it continues reading from the first dataset.
2. The method for high-speed data acquisition by a host computer based on Ethernet according to claim 1, characterized in that, The segment duration is the product of the fixed period or the number of segmented data and the first period.
3. The method for high-speed data acquisition by a host computer based on Ethernet according to claim 1, characterized in that, The segment write completion flag for all datasets is initialized to False.
4. A high-speed data acquisition device for a host computer based on Ethernet, characterized in that, The device includes a PLC and a host computer, which are connected via Ethernet. The PLC stores real-time data one by one in the first cycle, and divides the stored data into segments according to a fixed cycle or number of segments to create at least three continuous datasets of the same size; the PLC writes the real-time data into these datasets in sequence, and sets the segment completion flag of each dataset to True after it is filled, thereby notifying the host computer to collect data; the fixed cycle is a multiple of the first cycle. After the host computer starts data acquisition, it continuously reads the segment write completion flag status on the PLC in the second cycle. Once the host computer reads the segment write completion flag corresponding to the first dataset as True, it reads the corresponding dataset and resets the segment write completion flag to False. The host computer waits for the segment write completion flag corresponding to the next dataset to be True, then reads the next dataset and resets the segment write completion flag to False, repeating this operation to cyclically acquire data from each segment. The second cycle is shorter than the segment duration. After the PLC fills all the datasets in sequence, it starts writing over the first dataset. Only when the segment corresponding to the dataset is written and marked as False will the overwrite be performed. After the host computer finishes reading the last dataset, it continues reading from the first dataset.
5. The device for high-speed data acquisition from a host computer based on Ethernet according to claim 4, characterized in that, The segment duration is the product of the fixed period or the number of segmented data and the first period.
6. The device for high-speed data acquisition from a host computer based on Ethernet according to claim 4, characterized in that, The segment write completion flag for all datasets is initialized to False.
Citation Information
Patent Citations
Method for realizing high-speed data acquisition and storage with upper computer through PLC
CN105700462A