Data communication method, device, medium, equipment and battery testing device
By periodically obtaining and storing sampled data, the lower computer uploads it according to the actual query time value, solving the problem of low communication efficiency between the middle computer and the lower computer, and achieving efficient data transmission and optimization of storage space.
Patent Information
- Application Number
- CN202211031553.4
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2022-08-26
- Publication Date
- 2025-08-22
- Estimated Expiration
- 2042-08-26
AI Technical Summary
In the prior art, the data communication efficiency between the median and the lower computer is low, especially when the data volume of the lower computer is large, a large amount of data processing overhead during transmission is wasted on the end of the bag, resulting in a decrease in efficiency, and the number of channels of the lower computer is limited, the number of MCU pins is insufficient and signal interference is serious.
The median computer periodically acquires sampled data and stores it. The lower computer uploads sampled data from multiple time points based on the actual query time value. By correcting the query data frame, it ensures effective data transmission, reduces duplication and loss, and uses RS485, PLC, CAN and other bus communication.
It increases the proportion of effective data, reduces data processing overhead, improves communication efficiency, and ensures stable data transmission and storage space utilization.
Smart Images

Figure CN115499095B_ABST
Abstract
Description
Technical Field
[0001] The present invention relates to the technical field of testing equipment, and in particular to a data communication method, device, medium, equipment and a battery testing device. Background Art
[0002] With the advancement of industrial technology, data acquisition equipment is widely used in various fields. These devices typically consist of a central computer and multiple slave computers, with one central computer and multiple slave computers present in the system. The central computer, such as a battery tester, polls data collected by the slave computers in real time. However, when the slave computers are receiving a large amount of data, data communication efficiency is significantly reduced. In particular, the percentage of valid data acquired during each polling cycle is relatively small, and a significant amount of data processing overhead is wasted on packet header and trailer transmission and data parsing, further reducing data communication efficiency.
[0003] The current existing technology effectively improves data communication efficiency by increasing the number of channels of the lower computer, allowing the middle computer to read data from multiple channels at a time. However, this has the following disadvantages: (1) the number of channels supported by a lower computer is limited; (2) too many channels will result in insufficient MCU pins and easily cause signal interference, resulting in data transmission delays. Summary of the Invention
[0004] To address the low data communication efficiency issues in the prior art, the present invention provides a data communication method, device, medium, equipment, and battery testing device. The specific solutions are as follows:
[0005] In a first aspect, an embodiment of the present application provides a data communication method, which is applied to data communication between an intermediate computer and at least one lower computer, and the method includes the following steps: periodically acquiring sampling data at multiple time points according to a preset interval time value and storing the data in the lower computer; the intermediate computer sends a query data frame according to a preset query time value; the lower computer receives the sent query data frame and calculates an actual query time value; the actual query time value is the actual query interval time from the query data frame last received by the lower computer to the query data frame received this time; based on the actual query time value, the lower computer simultaneously uploads the sampling data at several time points within the actual query time value to the intermediate computer.
[0006] In another embodiment of the first aspect, the step of correcting the query data frame sent down for the (N+1)th time after the intermediate computer receives the sampling data for the Nth time is further included, and then sending the corrected query data frame down to the lower computer to enable the lower computer to clear the sampling data uploaded for the Nth time and only retain the sampling data that has not been uploaded for subsequent uploading is included.
[0007] In another embodiment of the first aspect, the intermediate computer corrects the query data frame sent down for the (N+1)th time by adding 1 to the serial number of the query data frame sent down for the (N+1)th time.
[0008] In another embodiment of the first aspect, the preset interval time value is less than a preset query time value.
[0009] In another embodiment of the first aspect, the intermediate computer and the lower computer are connected via bus communication, and the bus adopts one of RS485, PLC, and CAN.
[0010] In another embodiment of the first aspect, the intermediate computer uses a Linux system or a FreeRTOS system, and the lower computer uses a FreeRTOS system or no operating system.
[0011] In a second aspect, an embodiment of the present application provides a data communication device, applied to data communication between an intermediate computer and at least one lower computer, the device comprising:
[0012] A data acquisition module, used to periodically acquire sampling data at multiple time points according to a preset interval time value and store it in the slave computer;
[0013] An instruction issuing module, configured to issue a query data frame according to a preset query time value via the intermediate machine;
[0014] An instruction receiving module is used to receive the query data frame sent by the lower computer and calculate an actual query time value; the actual query time value is the actual query interval time from the query data frame last received by the lower computer to the query data frame received this time;
[0015] The data uploading module is used to upload the sampled data at several time points within the actual query time value to the intermediate computer through the lower computer based on the actual query time value.
[0016] In a third aspect, an embodiment of the present application provides a battery testing device, which adopts the data communication method provided in the first aspect or any other embodiment of the first aspect, or adopts the data communication device provided in the embodiment of the second aspect.
[0017] In a fourth aspect, an embodiment of the present application provides a computer-readable storage medium, which stores computer instructions. When the computer is executed by a processor, it implements the data communication method provided in the first aspect or any other embodiment of the first aspect.
[0018] In a fifth aspect, an embodiment of the present application provides an electronic device comprising at least one processor and a memory communicatively connected to the processor, wherein the memory stores instructions executable by at least one processor, and the instructions are executed by at least one processor to enable the processor to execute a data communication method as provided in the first aspect or any other embodiment of the first aspect.
[0019] Based on the above, compared with the existing technology, the data communication method provided by the present invention increases the proportion of valid data in each query by uploading the sampling data of multiple time points within the period to the intermediate computer at the same time according to the actual query interval received when the intermediate computer and the lower computer communicate, thereby effectively reducing the data processing overhead of the lower computer and the upper computer and greatly improving the data communication efficiency.
[0020] Other features and beneficial effects of the present invention will be described in the following description, and in part will become apparent from the description, or will be understood by practicing the present invention. The objectives and other beneficial effects of the present invention can be achieved and obtained by the structures particularly pointed out in the description, claims and drawings. BRIEF DESCRIPTION OF THE DRAWINGS
[0021] In order to more clearly illustrate the embodiments of the present invention or the technical solutions in the prior art, a brief introduction will be given below to the drawings required for use in the embodiments or the description of the prior art. Obviously, the drawings described below are some embodiments of the present invention. For ordinary technicians in this field, other drawings can be obtained based on these drawings without any creative work. The positional relationships described in the drawings in the following description are based on the directions of the components drawn in the diagrams, unless otherwise specified.
[0022] Figure 1 A data interaction flow chart of a data communication method in one embodiment of the present invention;
[0023] Figure 2 A structural block diagram of the data communication device provided by the present invention;
[0024] Figure 3 This is a structural block diagram of the electronic device provided by the present invention. DETAILED DESCRIPTION
[0025] In order to make the purpose, technical solutions and advantages of the embodiments of the present invention clearer, the technical solutions in the embodiments of the present invention will be clearly and completely described below in conjunction with the drawings in the embodiments of the present invention. Obviously, the described embodiments are part of the embodiments of the present invention, not all of the embodiments; the technical features designed in different implementation modes of the present invention described below can be combined with each other as long as they do not conflict with each other; based on the embodiments of the present invention, all other embodiments obtained by ordinary technicians in this field without making creative work are within the scope of protection of the present invention.
[0026] In the description of the present invention, it should be noted that all terms used in the present invention (including technical terms and scientific terms) have the same meanings as those generally understood by ordinary technicians in the field to which the present invention belongs, and should not be understood as limiting the present invention; it should be further understood that the terms used in the present invention should be understood to have meanings consistent with the meanings of these terms in the context of this specification and in the relevant fields, and should not be understood in an idealized or overly formal sense, unless explicitly defined as such in the present invention.
[0027] In order to better solve the problem of unsatisfactory data communication effect in the prior art, an embodiment of the present invention provides a data communication method, which can increase the proportion of valid data in each query, thereby effectively reducing the data processing overhead of the lower computer and the upper computer, and greatly improving data communication efficiency.
[0028] Specifically, the data communication method provided in the embodiment of the present application can be applied to data communication between a middle computer and at least one lower computer. The middle computer can be a PC or other computer, and the lower computer can be a PLC (Programmable Logic Controller), a single-chip microcomputer or an ARM (Advanced RISC Machines) microprocessor, etc. In addition, those skilled in the art should know that the middle computer in the present application is a computer that issues control instructions, and the lower computer is a controlled module. Therefore, the data communication method can also be applied to data communication between an upper computer and a middle computer or between an upper computer and a lower computer, etc. Please refer to Figure 1 , the data communication method at least includes the following steps:
[0029] The sampling data at multiple time points is periodically acquired at a preset interval and stored in the lower computer. In a specific implementation, the lower computer can communicate with the device to be acquired via a bus and issue acquisition instructions to the device to be acquired at the preset interval to acquire the sampling data at the corresponding time points. The preset interval can be set according to actual work requirements and is not limited here.
[0030] The intermediate computer sends query data frames according to a preset query time value. In specific implementations, the preset query time value can also be set according to actual work requirements and is not limited here. Preferably, the preset interval time value is less than the preset query time value. In other words, the acquisition frequency of the lower computer is higher than the frequency of data transmission from the lower computer to the upper computer, thereby ensuring efficient data transmission.
[0031] The lower computer receives the query data frame sent down and calculates the actual query time value; the actual query time value is the actual query interval time from the query data frame received by the lower computer last time to the query data frame received this time, that is, the actual query time value is equal to the time point of receiving the query data frame this time minus the time point of receiving the query data frame last time. In specific implementation, since the query data frame sent by the intermediate computer may be affected by signal interference, the time interval of the query data frame received by the lower computer may change, especially when the query fails, it needs to be resent. Therefore, the time intervals of the query data frames actually received by the lower computer are not equal, and the number of sampled data collected by the lower computer within this time interval is also different. For this reason, the lower computer needs to recalculate the actual query interval time.
[0032] Based on the actual query time value, the lower computer only uploads the sampled data at several time points within the actual query time value to the intermediate computer at the same time.
[0033] Specifically, taking the preset query time value of the lower computer as 100ms as an example, if the time point when the upper computer sends the query data frame is 200ms, the actual query time is 200ms, and the lower computer will upload the sampling data at the two time points of 100ms and 200ms, that is, upload two groups of data at a time; if the time point when the upper computer sends the query data frame is 300ms, the actual query time is 100ms, and the lower computer will only upload the sampling data at the time point of 300ms, that is, upload one group of data at a time; if the time point when the upper computer sends the query data frame is 600ms, the actual query time is 300ms, and the lower computer will upload the sampling data at the three time points of 400ms, 500ms, and 600ms, that is, upload three groups of data in sequence, and so on.
[0034] This approach effectively avoids issues like duplicate or lost data uploads caused by the lower computer uploading data according to a pre-set query time. Simultaneously uploading sampled data from multiple time points increases the effective data content of each frame and the percentage of valid data, thereby effectively reducing the time wasted in packet header and tail transmission and improving communication efficiency.
[0035] Furthermore, due to the limited storage space of the lower computer, the upper computer needs to send a query data frame to upload the sampled data when the lower computer has not reached the storage limit, otherwise data loss will occur. Therefore, in order to solve the above problem, in this embodiment, after the intermediate computer receives the Nth sampling data, it will correct the query data frame sent for the (N+1)th time, and then send the corrected query data frame to the lower computer, so that the lower computer will clear the Nth uploaded sampling data and only retain the unuploaded sampling data for subsequent uploads. Such a setting can facilitate the lower computer to free up the corresponding storage space, further ensuring that data will not be uploaded repeatedly or lost during upload. It can not only extend the interval time of each polling of the lower computer to upload sampling data to the intermediate computer, but also ensure that the lower computer periodically obtains sampling data at multiple time points at the preset interval time value, thereby ensuring the effective transmission of data.
[0036] Preferably, the intermediate computer corrects the query data frame sent down for the (N+1)th time by adding 1 to the serial number in the query data frame sent down for the (N+1)th time. By adding 1 to the serial number, it is indicated that the sample data uploaded for the Nth time has been successfully acquired by the intermediate computer, and the lower computer can clear the Nth sample data in the storage space. Of course, according to the concept of the present invention, those skilled in the art can also replace the method of adding 1 to the serial number with other identification methods that can indicate that the sample data has been successfully acquired by the intermediate computer and can be cleared by the lower computer, which also falls within the scope of protection of this application.
[0037] In some embodiments, the intermediate computer and the lower computer are connected through bus communication. The bus adopts one of RS485, PLC, CAN, and can also adopt RS422, RS232, LIN or any other method that can realize data communication. The specific selection can be made according to actual work requirements.
[0038] In some other embodiments, the intermediate computer uses a Linux system or a FreeRTOS system, and the lower computer uses a FreeRTOS system or no operating system.
[0039] For example, the central computer can use Linux and the slave computers can use FreeRTOS; or the central computer can use Linux and the slave computers can use no operating system; or the central computer can use FreeRTOS and the slave computers can use FreeRTOS; or the central computer can use FreeRTOS and the slave computers can use no operating system. The specific settings can be determined according to work requirements and are not limited here.
[0040] The following takes the case where the middle computer uses the Linux system and the lower computer uses the FreeRTOS system, and the two are connected via an RS485 bus with the baud rate set to 230400 as an example. The preset query time value of the middle computer is set to 1μs, and the preset interval time value of the lower computer is set to 1ms, and the upload of the sampled data is tested. Under the same data conditions, when data transmission is performed according to the data communication method adopted in the prior art, a total of 48 bytes can be sent and received at a time, which consumes 4ms; while when data transmission is performed according to the data communication method provided in this embodiment, it can be measured that 112 bytes can be sent and received at a time, which consumes 5ms. It can be seen that the effective data upload amount can be increased by more than 3 times by using the data communication method adopted in this embodiment, while the time is only increased by 25%. This further shows that the data communication method provided in this application can increase the proportion of effective data in each query, effectively improving the communication efficiency between the middle computer and the lower computer.
[0041] As a preferred solution, based on the above method embodiments, the number of channels of the lower computer can be increased, and multiple channels can be used to upload sampling data at multiple time points to further increase the proportion of valid data and improve data communication efficiency.
[0042] See also Figure 2 The present application also provides a data communication device for data communication between a middle computer and at least one lower computer. The device includes:
[0043] The data acquisition module is used to periodically acquire sampling data at multiple time points according to a preset interval time value and store the data in the lower computer.
[0044] The instruction sending module is used to send the query data frame according to the preset query time value through the intermediate machine.
[0045] The instruction receiving module is used to receive the query data frame sent by the lower computer and calculate the actual query time value; the actual query time value is the actual query interval time from the query data frame received last by the lower computer to the query data frame received this time.
[0046] The data uploading module is used to upload the sampled data at several time points within the actual query time value to the intermediate computer through the lower computer based on the actual query time value.
[0047] Optionally, it also includes a data clearing module, that is, after the intermediate computer receives the sampling data for the Nth time, it will correct the query data frame sent down for the (N+1)th time, and then send the corrected query data frame down to the lower computer, so that the lower computer will clear the sampling data uploaded for the Nth time, and only retain the sampling data that has not been uploaded for subsequent uploads.
[0048] An embodiment of the present application further provides a battery testing device, which adopts the data communication method provided in the above method embodiment, or adopts the data communication device provided in the above embodiment.
[0049] It should be noted that the data communication method or data communication device provided in this application is not limited to data transmission for battery testing devices. Those skilled in the art can apply it to other data acquisition devices based on the concept of the present invention, such as power acquisition equipment, temperature acquisition equipment, etc.
[0050] An embodiment of the present application further provides a computer-readable storage medium, wherein the computer-readable storage medium stores computer instructions, and when the computer is executed by a processor, the data communication method as described in the above method embodiment is implemented.
[0051] In a specific implementation, the computer-readable storage medium is a magnetic disk, an optical disk, a read-only memory (ROM), a random access memory (RAM), a flash memory (Flash Memory), a hard disk drive (HDD) or a solid-state drive (SSD), etc.; the computer-readable storage medium may also include a combination of the above types of memory.
[0052] See also Figure 3 An embodiment of the present application also provides an electronic device, comprising at least one processor and a memory communicatively connected to the processor, wherein the memory stores instructions that can be executed by at least one processor, and the instructions are executed by at least one processor to enable the processor to execute the data transmission method described in the above method embodiment.
[0053] In a specific implementation, the number of processors may be one or more, and the processor may be a central processing unit (CPU). The processor may also be other general-purpose processors, digital signal processors (DSP), application-specific integrated circuits (ASIC), field-programmable gate arrays (FPGA), or other programmable logic devices, discrete gate or transistor logic devices, discrete hardware components, or a combination of the above chips. The general-purpose processor may be a microprocessor or any conventional processor.
[0054] The memory and the processor may be communicatively connected via a bus or other means. The memory stores instructions that can be executed by at least one processor. The instructions are executed by at least one processor so that the processor executes the data communication method described in the above method embodiment.
[0055] In summary, compared with existing technologies, the data communication method, apparatus, medium, device, and battery testing apparatus provided by the present invention have the following advantages: they can increase the proportion of valid data in each query, thereby effectively reducing the data processing overhead of the lower and upper computers and greatly improving data communication efficiency. They can also ensure that data collected at a fixed period is neither lost nor duplicated during transmission, resulting in excellent stability.
[0056] In addition, those skilled in the art should understand that, although there are many problems in the prior art, each embodiment or technical solution of the present invention may be improved in only one or several aspects, without having to simultaneously solve all the technical problems listed in the prior art or background art. Those skilled in the art should understand that any content not mentioned in a claim should not be construed as limiting the claim.
[0057] Although terms such as lower computer, intermediate computer, preset interval time value, preset query time value, query data frame, actual query time value, and sampled data are frequently used in this document, the possibility of using other terms is not excluded. These terms are used only to more conveniently describe and explain the essence of the present invention; interpreting them as any additional limitations is contrary to the spirit of the present invention; the terms "first", "second", etc. (if any) in the description and claims of the embodiments of the present invention and the above-mentioned drawings are used to distinguish similar objects and are not necessarily used to describe a specific order or sequence.
[0058] Finally, it should be noted that the above embodiments are only used to illustrate the technical solutions of the present invention, rather than to limit it. Although the present invention has been described in detail with reference to the above embodiments, those skilled in the art should understand that they can still modify the technical solutions described in the above embodiments, or replace some or all of the technical features therein with equivalents. However, these modifications or replacements do not cause the essence of the corresponding technical solutions to deviate from the scope of the technical solutions of the embodiments of the present invention.
Claims
1. A data communication method, characterized in that: Applied to data communication between a middle computer and at least one lower computer, the method comprises the following steps: Periodically acquiring sampling data at multiple time points according to a preset interval time value and storing the data in the lower computer; The intermediate machine sends the query data frame according to the preset query time value; The lower computer receives the query data frame sent down and calculates an actual query time value; the actual query time value is the actual query interval time from the query data frame received last time by the lower computer to the query data frame received this time; Based on the actual query time value, the lower computer simultaneously uploads the sampled data at several time points within the actual query time value to the intermediate computer; After the intermediate computer receives the Nth sampling data, it will correct the query data frame sent down for the (N+1)th time, and then send the corrected query data frame down to the lower computer, so that the lower computer will clear the sampling data uploaded for the Nth time and only retain the sampling data that has not been uploaded for subsequent uploads.
2. The data communication method according to claim 1, wherein: The intermediate machine corrects the query data frame sent for the (N+1)th time by adding 1 to the serial number of the query data frame sent for the (N+1)th time.
3. The data communication method according to claim 1, wherein: The preset interval time value is smaller than the preset query time value.
4. The data communication method according to claim 1, wherein: The intermediate computer and the lower computer are connected via bus communication, and the bus adopts one of RS485, PLC, and CAN.
5. The data communication method according to claim 1, wherein: The intermediate computer uses the Linux system or the FreeRTOS system, and the lower computer uses the FreeRTOS system or no operating system.
6. A data communication device, characterized in that: Applicable to data communication between a middle computer and at least one lower computer, the device comprises: A data acquisition module, used to periodically acquire sampling data at multiple time points according to a preset interval time value and store it in the slave computer; An instruction issuing module, configured to issue a query data frame according to a preset query time value via the intermediate machine; An instruction receiving module is used to receive the query data frame sent by the lower computer and calculate an actual query time value; the actual query time value is the actual query interval time from the query data frame last received by the lower computer to the query data frame received this time; A data uploading module, based on the actual query time value, is used to upload the sampled data at several time points within the actual query time value to the intermediate computer through the lower computer at the same time; The data clearing module corrects the query data frame sent down for the (N+1)th time after the intermediate computer receives the sampling data for the Nth time, and then sends the corrected query data frame down to the lower computer, so as to instruct the lower computer to clear the sampling data uploaded for the Nth time and only retain the sampling data that has not been uploaded for subsequent uploading.
7. A battery testing device, characterized in that: Adopt the data communication method according to any one of claims 1 to 5, or adopt the data communication device according to claim 6.
8. A computer-readable storage medium, characterized in that: The computer-readable storage medium stores computer instructions, and when the computer is executed by a processor, the data communication method according to any one of claims 1 to 5 is implemented.
9. An electronic device, characterized in that: The method comprises at least one processor and a memory communicatively connected to the processor, wherein the memory stores instructions executable by the at least one processor, and the instructions are executed by the at least one processor so that the processor executes the data communication method according to any one of claims 1 to 5.