Ultrasonic water meter data storage method and ultrasonic water meter

By using multi-segment cyclic storage and dual-memory synchronous storage in ultrasonic water meters, the data loss problem in the face of interference and failure is solved, and high reliability and real-time storage of data are achieved.

CN120104068AInactive Publication Date: 2025-06-06BEIJING JOYO SMART WATER METER

Patent Information

Application Number
CN202510585994.6
Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
Filing Date
2025-05-08
Publication Date
2025-06-06
Estimated Expiration
Not applicable · inactive patent

AI Technical Summary

Technical Problem

In the face of strong magnetic interference, electromagnetic interference or signal fluctuations, existing ultrasonic water meters may lead to data storage errors or EEPROM chip failures, resulting in data loss and affecting the reliability of metered data.

Method used

The multi-segment cyclic storage method is adopted to double backup data in the EEPROM chip and Flash memory, and the storage frequency is intelligently adjusted according to the data numerical value, and the dual memory storage of static configuration data is synchronized to ensure high reliability and real-time data.

Benefits of technology

It significantly improves the reliability and efficiency of ultrasonic water meter data storage, avoids data loss and storage space exhaustion, extends the life of the storage medium, and ensures the integrity and accuracy of the metered data.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN120104068A_ABST
    Figure CN120104068A_ABST
Patent Text Reader

Abstract

The invention relates to the technical field of data storage, in particular to an ultrasonic water meter data storage method and an ultrasonic water meter. The method comprises the following steps: receiving current frame data; when the current frame data is the static configuration data, the current frame data is stored in an EEPROM chip and a Flash memory of the ultrasonic water meter; when the current frame data is the dynamic accumulated data, respectively determining storage periods of the current frame data in the EEPROM chip and the Flash memory based on the numerical value of the current frame data; and based on the storage periods respectively determined by the EEPROM chip and the Flash memory, storing the current frame data into the EEPROM chip and the Flash memory by adopting a multi-section circulating storage mode. The reliability of data storage of the ultrasonic water meter can be improved.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present application relates to the technical field of data storage, and in particular to an ultrasonic water meter data storage method and an ultrasonic water meter. Background Art

[0002] Ultrasonic water meter is a water metering instrument and a pure electronic water meter. Its water consumption data can only be stored in the storage chip of the circuit board. This is different from previous water meters. For early mechanical water meters, water consumption data is mainly obtained through pointer dials, and the data will not be lost; for water meters with electronic devices, when the electronic indication is wrong or lost, the settlement will be based on the mechanical dial number; for pure electronic water meters, since there is no mechanical indication, settlement can only be based on the electronic indication, so the reliability of its measurement data storage is very important.

[0003] In the related art, the water meter data storage method is to add an EEPROM storage chip to the circuit board, and the microcontroller unit (MCU) in the water meter writes the relevant metering data to a specific area of ​​the external EEPROM chip. When the ultrasonic water meter is reset and restarted, these parameters are read from a specific position of the EEPROM chip. However, when the ultrasonic water meter is subject to strong magnetic interference and exceeds the anti-electromagnetic interference capability of the ultrasonic water meter, or when the communication line of the wired (RS485 / MBUS) ultrasonic water meter is subject to interference such as high pulses, or when the Internet of Things (NB-IOT / 4G) ultrasonic water meter uploads under weak signal conditions, the valve is blocked, etc., and a large current is generated, causing a drastic fluctuation in the power supply voltage, if data is stored at this time, it may cause storage data errors. In addition, there are defects in a batch of the selected storage chips. It is normal when the water meter is tested at the factory, but some data storage errors may soon occur during the later operation process, or even the entire EEPROM chip may suddenly break down. Although the ultrasonic water meter can report the EEPROM chip failure and can be displayed through the LCD, the data may be lost at any time. When the above situation occurs, if the ultrasonic water meter is reset and restarted under specific circumstances, data reading errors may occur when initializing the data (the data is zero, or there is a large deviation from the data before the restart), resulting in the loss of important data such as cumulative flow, affecting trade settlement, causing water use disputes, and reducing the reliability of the product. In addition, the loss of data such as meter number, caliber, range, flow correction factor, etc. will also affect the subsequent use of the product. Therefore, it is particularly important to find a more reliable data storage method. Summary of the invention

[0004] In order to improve the reliability of ultrasonic water meter data storage, the present application provides an ultrasonic water meter data storage method and an ultrasonic water meter.

[0005] In a first aspect, the present application provides an ultrasonic water meter data storage method, which adopts the following technical solution: An ultrasonic water meter data storage method, executed by a microcontroller unit of an ultrasonic water meter, comprises: Receive current frame data; When the current frame data is static configuration data, the current frame data is stored in the EEPROM chip and the Flash memory of the ultrasonic water meter respectively; When the current frame data is dynamically accumulated data, determining the storage period of the current frame data in the EEPROM chip and the Flash memory respectively based on the value of the current frame data; Based on storage cycles determined by the EEPROM chip and the Flash memory respectively, the current frame data is stored in the EEPROM chip and the Flash memory in a multi-segment cyclic storage manner.

[0006] By adopting the above technical solution, dual memories are used for synchronous storage of static configuration data to ensure high-reliability backup of key parameters; for dynamic accumulated data, the storage frequency is intelligently adjusted according to the value size, which significantly reduces the write loss of EEPROM / Flash while ensuring the real-time performance of the data; combined with the overwrite mechanism of multi-segment cyclic storage, it not only avoids the problem of storage space exhaustion, but also maintains the life of the storage medium through periodic data refresh, ultimately achieving a balance between storage efficiency, data security and hardware durability.

[0007] In a preferred example, the present application may be further configured as follows: determining the storage period of the current frame data in the EEPROM chip based on the value of the current frame data, including: When the value of the current frame data is greater than zero and less than a preset threshold, determining the storage period of the current frame data in the EEPROM chip as a first storage period; When the value of the current frame data is not less than the preset threshold, the storage period of the current frame data in the EEPROM chip is determined to be a second storage period; wherein the first storage period is greater than the second storage period.

[0008] By adopting the above technical solution, when the data value is less than the preset threshold (such as low flow state), a longer first storage cycle is used, which significantly reduces the write loss of low-frequency small data to the EEPROM; when the data value exceeds the threshold (such as high flow state), it automatically switches to a shorter second storage cycle to ensure the real-time performance of key data. This elastic storage strategy based on data value not only avoids the waste of resources caused by frequent writing of small data, but also ensures data integrity under high flow conditions, maximizes the limited erase and write life of the EEPROM, and improves the efficiency and reliability of the storage system as a whole.

[0009] In a preferred example, the present application may be further configured as follows: determining the storage period of the current frame data in the Flash memory based on the value of the current frame data, including: When the value of the current frame data is greater than zero, the storage period of the current frame data in the Flash memory is determined to be a third storage period; wherein the third storage period is greater than the first storage period.

[0010] By adopting the above technical solution, a third storage cycle longer than that of EEPROM is set for the Flash memory, and the large capacity characteristics of Flash are used to achieve low-frequency but stable data backup. When the data value is greater than zero, storage is triggered, which not only avoids invalid zero values ​​from occupying space, but also ensures that valid data is persisted.

[0011] In a preferred example, the present application may be further configured as follows: when the value of the current frame is equal to zero, the method further includes: the current frame data is not stored in the EEPROM chip or the Flash memory.

[0012] By adopting the above technical solution, the occupation of storage space by invalid data is effectively avoided, the utilization rate of storage resources is improved, unnecessary write operations are significantly reduced, and the erase and write loss of EEPROM and Flash memory is reduced.

[0013] In a preferred example, the present application can be further configured as follows: based on the storage period determined by the EEPROM chip, the current frame data is stored in the EEPROM chip using a multi-segment cyclic storage method, including: The frame data obtained in each storage cycle is sequentially stored in each storage unit of the storage unit area of ​​the EEPROM chip, wherein each storage unit is used to store one frame of data; When the previous frame data of the current frame data is stored in the last storage unit of the storage unit area, the current frame data is stored in the first storage unit of the storage unit area, overwriting the frame data stored in the first storage unit in the previous cycle; The next frame data of the current frame data is stored in the second storage unit of the storage unit area, covering the frame data stored in the second storage unit in the previous cycle, and so on, to achieve multi-segment cyclic storage.

[0014] By adopting the above technical solution, a sequential writing and cyclic overwriting mechanism is adopted to ensure the sustainable use of storage space and avoid the problem of storage area exhaustion; by evenly distributing write operations to all storage units and coordinating the storage cycle control of the EEPROM chip, dynamic wear leveling is achieved, significantly extending the service life of the chip; the characteristic of the latest data always overwriting the oldest data is maintained, and the timeliness of the data is automatically maintained within a limited storage space.

[0015] In a preferred example, the present application may be further configured as follows: storing the current frame data in the EEPROM chip and the Flash memory of the ultrasonic water meter respectively includes: The current frame data is stored in fixed locations of the EEPROM chip and the Flash memory respectively; The data format of the current frame data includes: a start mark, an accumulated value of frame storage times, ultrasonic water meter data, a sum check, a CRC check and an end mark.

[0016] By adopting the above technical solution, static configuration data is synchronously stored in a fixed location using EEPROM and Flash to form a double backup to ensure data security and reliability; the data integrity and error detection capabilities are significantly improved through a standardized frame structure that includes start / end identifiers and double checks (sum check + CRC); the introduction of the accumulated value of the frame storage times facilitates data version management and the latest status tracking.

[0017] In a preferred example, the present application can be further configured as follows: the method further includes: When the ultrasonic water meter is reset and restarted, all frame data in the storage unit area of ​​the EEPROM chip and the Flash memory are read, and all the obtained frame data are stored in a one-dimensional array; Checking the validity of each frame of data in the one-dimensional array in turn to obtain a number of valid frame data; Determine a frame data with the largest accumulated value of frame storage times from the plurality of valid frame data as the latest frame data; The ultrasonic water meter data in the latest frame data is extracted, and the ultrasonic water meter data is assigned to corresponding variables.

[0018] By adopting the above technical solution, a complete data set is constructed by reading full data from dual memories, avoiding data loss caused by single point failures, strictly screening valid data, ensuring the integrity and accuracy of recovered data, and identifying the latest data version by comparing the accumulated value of frame storage times, ensuring fast and reliable data recovery.

[0019] In a preferred example, the present application may be further configured as follows: sequentially checking the validity of each frame of data in the one-dimensional array includes: For each frame data in the one-dimensional array, the start identifier, end identifier, sum check and CRC check of the frame data are checked. When the start identifier, end identifier, sum check and CRC check of the frame data are all checked and passed, the frame data is determined to be valid frame data.

[0020] By adopting the above technical solution, a four-fold verification mechanism (start mark, end mark, sum check and CRC check) is used to achieve three-dimensional protection of data integrity.

[0021] In a second aspect, the present application provides an electronic device, which adopts the following technical solution: one or more processors; Memory; At least one application, wherein the at least one application is stored in a memory and configured to be executed by at least one processor, and the at least one application is configured to: execute the ultrasonic water meter data storage method as described in any one of the first aspects.

[0022] In a third aspect, the present application provides a computer-readable storage medium, which adopts the following technical solution: A computer-readable storage medium stores a computer program, which, when executed in a computer, causes the computer to execute the ultrasonic water meter data storage method as described in any one of the first aspects.

[0023] In a fourth aspect, the present application provides a computer program product, which adopts the following technical solution: A computer program product comprises a computer program. When the computer program is executed by a processor, the ultrasonic water meter data storage method as described in any one of the first aspects is implemented.

[0024] In summary, the present application includes the following beneficial technical effects: the present application adopts dual-memory synchronous storage for static configuration data to ensure high-reliability backup of key parameters; for dynamic accumulated data, the storage frequency is intelligently adjusted according to the numerical value, which significantly reduces the write loss of EEPROM / Flash while ensuring the real-time performance of the data; combined with the overwrite mechanism of multi-segment cyclic storage, it not only avoids the problem of storage space exhaustion, but also maintains the life of the storage medium through periodic data refresh, and finally achieves a balance between storage efficiency, data security and hardware durability. BRIEF DESCRIPTION OF THE DRAWINGS

[0025] Figure 1 It is a flow chart of an ultrasonic water meter data storage method provided in an embodiment of the present application; Figure 2 It is a storage flow chart of static configuration data provided by an embodiment of the present application; Figure 3 is a storage flow chart of dynamic accumulated data provided by an embodiment of the present application; Figure 4 It is a sub-storage flow chart in the storage flow chart of dynamically accumulated data provided in an embodiment of the present application. DETAILED DESCRIPTION

[0026] The following is combined with Figure 1 -Attached Figure 4 This application is described in further detail.

[0027] This specific embodiment is merely an explanation of the present application and is not a limitation of the present application. After reading this specification, those skilled in the art may make modifications to the present embodiment without any creative contribution as needed, but such modifications are protected by the patent law as long as they are within the scope of the claims of the present application.

[0028] In order to make the purpose, technical solution and advantages of the embodiments of the present application clearer, the technical solution in the embodiments of the present application will be clearly and completely described below in conjunction with the drawings in the embodiments of the present application. Obviously, the described embodiments are part of the embodiments of the present application, not all of the embodiments. Based on the embodiments in the present application, all other embodiments obtained by ordinary technicians in this field without creative work are within the scope of protection of this application.

[0029] In addition, the term "and / or" in this article is only a description of the association relationship of associated objects, indicating that there can be three relationships. For example, A and / or B can represent: A exists alone, A and B exist at the same time, and B exists alone. In addition, the character " / " in this article, unless otherwise specified, generally means that the associated objects before and after are in an "or" relationship.

[0030] It should be noted that in the optional embodiments of the present application, the object information and other related data involved, when the embodiments in the present application are applied to specific products or technologies, need to obtain the permission or consent of the object, and the collection, use and processing of the relevant data need to comply with the relevant laws, regulations and standards of the relevant countries and regions. In other words, if the embodiments of the present application involve data related to the object, it needs to be obtained with the authorization and consent of the object, the authorization and consent of the relevant departments, and in compliance with the relevant laws, regulations and standards of the country and region. If personal information is involved in the embodiments, the acquisition of all personal information needs to obtain the consent of the individual. If sensitive information is involved, the separate consent of the information subject needs to be obtained. The embodiments also need to be implemented with the authorization and consent of the object.

[0031] The present application provides an ultrasonic water meter, comprising: a microcontroller unit, an EEPROM chip and a Flash memory; the microcontroller unit is used to store data acquired by the ultrasonic water meter in the EEPROM chip and the Flash memory.

[0032] At present, the microcontroller unit is provided with a Flash memory for storing application data, and the data will not be lost after power failure and can be stored for a long time. In this embodiment, a storage space is allocated from the Flash memory as a pre-defined storage unit area, and the demarcation method is to allocate space forward from the last address of the Flash memory to store important data of the ultrasonic water meter, thereby realizing the dual storage function of the external EEPROM chip and the Flash memory inside the microcontroller unit.

[0033] When the external EEPROM chip fails (partial or complete storage area of ​​the EEPROM chip fails), data can still be read and written from the Flash memory. This only affects the reading and writing of historical record information (due to the large amount of historical record information, it can only be stored in the EEPROM chip) and the frequency of saving data such as cumulative flow (the total number of storage times of the Flash memory is less, so the storage interval period is longer than that of the EEPROM chip). It does not affect the daily use of the ultrasonic water meter, does not increase any hardware cost, and can improve the utilization of hardware resources.

[0034] The present application embodiment provides an ultrasonic water meter data storage method, such as Figure 1 As shown, the method provided in the embodiment of the present application is executed by a micro control unit of an ultrasonic water meter, and the method includes steps S101 to S104, wherein: S101, receiving current frame data.

[0035] Specifically, the current frame data can be static configuration data or dynamic accumulation data. Static configuration data can be written manually, including data with little change such as meter number, caliber, range, flow correction coefficient, etc. Dynamic accumulation data can be data that needs to be automatically saved, such as accumulated flow.

[0036] S102: When the current frame data is static configuration data, the current frame data is stored in the EEPROM chip and the Flash memory of the ultrasonic water meter respectively.

[0037] Since the EEPROM chip and Flash memory of the ultrasonic water meter have a storage limit, especially when the storage times of the same storage unit exceed a certain value, the reliability of the storage unit will be reduced. For static configuration data, the static configuration data is stored in the fixed position of the EEPROM chip and Flash memory only when there is a write operation, and no operation is required in other cases.

[0038] S103: When the current frame data is dynamically accumulated data, the storage period of the current frame data in the EEPROM chip and the Flash memory is determined based on the value of the current frame data.

[0039] Specifically, a water use cycle can be set, and the cumulative flow rate of each water use cycle can be recorded as the value of the frame data. When the water use data collection in a water use cycle is completed, a frame data is generated. The value of the current frame data represents the cumulative flow rate of a water use cycle before the current moment. Based on the value of the current frame data, the storage cycle of the EEPROM chip and the Flash memory is dynamically adjusted to reduce the number of storage times.

[0040] S104 , based on the storage cycles determined by the EEPROM chip and the Flash memory respectively, the current frame data is stored in the EEPROM chip and the Flash memory using a multi-segment cyclic storage method.

[0041] Specifically, for the EEPROM chip and the Flash memory, a storage unit area is pre-demarcated thereon for storing water usage data. The storage unit area includes a plurality of storage units, and each storage unit stores one frame of data.

[0042] For the EEPROM chip, after the ultrasonic water meter is powered on, the first frame of data collected is stored in the first storage unit of the storage unit area of ​​the EEPROM chip, the second frame of data is stored in the second storage unit of the storage unit area of ​​the EEPROM chip, and so on, until a frame of data is stored in the last storage unit of the storage unit area of ​​the EEPROM chip, then the next frame of data is stored in the first storage unit of the storage unit area of ​​the EEPROM chip, covering the frame data stored in the previous cycle, and so on to achieve multi-segment cyclic storage.

[0043] For the Flash memory, the frame data is stored therein in the same manner as that of the EEPROM chip.

[0044] This embodiment uses dual-memory synchronous storage for static configuration data to ensure high-reliability backup of key parameters; for dynamic accumulated data, the storage frequency is intelligently adjusted according to the value size, which significantly reduces the write loss of EEPROM / Flash while ensuring data real-time performance; combined with the overwrite mechanism of multi-segment cyclic storage, it not only avoids the problem of storage space exhaustion, but also maintains the life of the storage medium through periodic data refresh, ultimately achieving a balance between storage efficiency, data security and hardware durability.

[0045] A possible implementation method of an embodiment of the present application is to store the current frame data in the EEPROM chip and Flash memory of the ultrasonic water meter respectively, including: storing the current frame data in fixed positions of the EEPROM chip and the Flash memory respectively; wherein the data format of the current frame data includes: a start identifier, an accumulated value of the frame storage times, ultrasonic water meter data, a sum check, a CRC check and an end identifier.

[0046] See also Figure 2 , which shows a storage flow chart of static configuration data provided by an embodiment of the present application. The fixed positions of the EEPROM chip and the Flash memory can be pre-determined. The following table shows the data format of each frame of data: Start mark Frame number Frame_Index Frame storage times accumulated value Frame_StorageCount Ultrasonic water meter data Sum check CRC Check End mark Fixed value 0x68 Indicates the storage number of the frame data in the designated storage unit area The total number of times this group of data is stored. Each time it is stored, the value increases by 1. Water meter data 1, 2… From the start mark to the last table data, the cumulative sum From the start mark to the CRC32 value of the sum check Fixed value 0x16

[0047] By adopting the framing method, the start identifier, frame number, accumulated value of frame storage times, ultrasonic water meter data, sum check, CRC check and end identifier are combined into one frame of data, which can realize the simultaneous storage of multiple data at one time. The double check method of sum check and CRC can improve the accuracy of each frame of data. Among them, each verification method has its own advantages and disadvantages, and technicians can flexibly combine them.

[0048] This embodiment uses EEPROM and Flash to synchronously store static configuration data in a fixed location to form a double backup to ensure data security and reliability; through a standardized frame structure including start / end identifiers and double checks (sum check + CRC), data integrity and error detection capabilities are significantly improved; the introduction of the accumulated value of the frame storage times facilitates data version management and latest status tracking.

[0049] A possible implementation of the embodiment of the present application is to determine the storage period of the current frame data in the EEPROM chip based on the value of the current frame data, including: When the value of the current frame data is greater than zero and less than a preset threshold, determine the storage period of the current frame data in the EEPROM chip as the first storage period; When the value of the current frame data is not less than the preset threshold, determine the storage period of the current frame data in the EEPROM chip as the second storage period; wherein, the first storage period is greater than the second storage period.

[0050] In this embodiment, the water usage period can be set to 10 min, and the water consumption V1 (cumulative flow) within this water usage period is recorded every 10 min. A preset threshold Vtd is preset, representing the water usage threshold for the water usage period. At the factory, each caliber has a default value, which can be modified to the preset threshold using the host computer software.

[0051] When V1 = 0, it indicates that there is no water usage, and the current frame data is not stored in the EEPROM chip nor in the Flash memory. It is not until V1 > 0 that the frame data starts to be stored in the EEPROM chip and the Flash memory according to the set storage period.

[0052] When 0 < V1 < Vtd, it indicates that there is water usage but it does not exceed the preset threshold. Set the storage period of the current frame data in the EEPROM chip as the first storage period. As long as V1 does not exceed the range of 0 - Vtd, the EEPROM chip continuously stores the frame data according to the first storage period. Optionally, the first storage period is 20 min, that is, the frame data is stored every 20 min.

[0053] When V1 ≥ Vtd, it indicates that there is water usage and it exceeds the preset threshold. Set the storage period of the current frame data in the EEPROM chip as the second storage period. As long as V1 is in the range exceeding Vtd, the EEPROM chip continuously stores the frame data according to the second storage period. Optionally, the second storage period is 10 min, that is, the frame data is stored every 10 min.

[0054] In this embodiment, when the data value is less than the preset threshold (such as in the small flow state), a longer first storage period is adopted, significantly reducing the write loss of low - frequency small data to the EEPROM; when the data value exceeds the threshold (such as in the large flow state), it automatically switches to a shorter second storage period to ensure the real - time nature of key data. This elastic storage strategy based on the data value not only avoids the resource waste of frequent small data writes but also ensures the data integrity under large flow conditions, maximizing the utilization of the limited erase - write life of the EEPROM and overall improving the efficiency and reliability of the storage system.

[0055] A possible implementation manner of the embodiment of the present application, determining the storage period of the current frame data in the Flash memory based on the value of the current frame data, includes: When the value of the current frame data is greater than zero, the storage period of the current frame data in the Flash memory is determined to be a third storage period; wherein the third storage period is greater than the first storage period.

[0056] Optionally, the third storage period may be set to 1 hour, that is, the frame data is stored in the Flash memory once every 1 hour.

[0057] For example, assuming that the number of storage times of the EEPROM chip is 1 million times, the number of storage times of the Flash memory is 100,000 times, the user continues to use water, and V1 ≥ Vtd, then the EEPROM chip stores once every 10 minutes, and the Flash memory stores once every 1 hour. Calculated based on 10 years (greater than the service life), the number of storage times of the EEPROM chip = (60 / 10) × 24 × 365 × 10 = 525,600 (times) = 525,600 (times), 525,600 < 1 million, which meets the storage times requirements of common EEPROM memory chips (common ones are generally in the millions). The number of storage times of the Flash memory = (60 / 60) × 24 × 365 × 10 = 87,600 (times) = 87,600 (times), 87,600 < 100,000, which meets the storage times requirements of common Flash memories (common ones are generally in the hundreds of thousands).

[0058] This embodiment sets a third storage cycle for the Flash memory that is longer than that of the EEPROM, and uses the large capacity characteristics of the Flash to achieve low-frequency but stable data backup. Storage is triggered when the data value is greater than zero, which not only avoids invalid zero values ​​from occupying space, but also ensures that valid data is persisted.

[0059] In a possible implementation manner of the embodiment of the present application, when the value of the current frame is equal to zero, the method further includes: the current frame data is not stored in the EEPROM chip or the Flash memory.

[0060] This embodiment effectively avoids the occupation of storage space by invalid data, improves storage resource utilization, significantly reduces unnecessary write operations, and reduces the erase and write loss of EEPROM and Flash memory.

[0061] A possible implementation of the embodiment of the present application is to store the current frame data in the EEPROM chip using a multi-segment cyclic storage method based on a storage period determined by the EEPROM chip, including: The frame data obtained in each storage cycle is sequentially stored in each storage unit of the storage unit area of ​​the EEPROM chip, wherein each storage unit is used to store one frame of data; When the previous frame data of the current frame data is stored in the last storage unit of the storage unit area, the current frame data is stored in the first storage unit of the storage unit area, overwriting the frame data stored in the first storage unit in the previous cycle; The next frame data of the current frame data is stored in the second storage unit in the storage unit area, overwriting the frame data stored in the second storage unit in the previous cycle, and so on, to achieve multi-segment cyclic storage.

[0062] In this embodiment, for the EEPROM chip, a storage unit area is pre-demarcated, and multiple data frames can be stored. Storage starts from the first storage unit in the storage unit area, and each storage unit stores one frame of data, and the storage continues until the last storage unit. When the group of data changes and needs to be stored, it is stored in the next storage unit of the previous frame data storage unit. When the storage position exceeds the designated storage unit area, it is stored again from the first storage unit (while covering the frame data stored in the previous round of circulation), and the storage is cyclical.

[0063] The use of multi-segment circular storage can not only reduce the number of repeated writes to a certain storage unit and increase the life of the chip, but also, when a frame of data fails to be written due to special reasons (strong electromagnetic interference, drastic voltage fluctuations, etc.), after the water meter is reset and restarted, the previous frame of data (falling back to the accumulated flow and other data stored last time) is read, and only the water consumption data of one storage cycle is lost, which can reduce the impact.

[0064] See also Figure 3 , which shows a storage flow chart of dynamic accumulated data provided by an embodiment of the present application, and the storage flow chart shows a process of adjusting the storage cycle of the EEPROM chip and the Flash memory based on V1 and a storage sub-flow chart. Storage sub-flow chart ( Figure 4 ) indicates the process of storing frame data in EEPROM chip and Flash memory using multi-segment cyclic storage.

[0065] Specifically, the ultrasonic water meter program runs and periodically determines whether the detection of a water use cycle is completed. If a water use cycle is completed, the water use data of the water use cycle is represented as V1, Vtd represents the preset threshold, EEPROM_20Min is the variable Save_EEPROM_20Min_Count, Flash_1Hour is the variable Save_Flash_1Hour_Count, and the variable Save_EEPROM_20Min_Count is set to 1, and the variable Save_EEPROM_10Min_Count is set to 0, indicating that the storage cycle of the EEPROM chip is adjusted to 20min; the variable Save_EEPROM_10Min_Count is set to 1, and the variable Save_EEPROM_20Min_Count is set to 0, indicating that the storage cycle of the EEPROM chip is adjusted to 10min. The variable Save_Flash_1Hour_Count is set to 1, indicating that the storage cycle of the Flash memory is set to 1h. After the storage cycle adjustment is completed, V1 is set to 0, and the measurement of a new water use cycle begins.

[0066] See also Figure 4 , which shows the sub-storage flow chart in the storage flow chart of dynamically accumulated data provided in an embodiment of the present application. Figure 4 The A in the Figure 3 Stores the connection location of the flowchart.

[0067] Specifically, in the timer, it is periodically determined whether 10 minutes, 20 minutes and 1 hour have been reached. When 10 minutes have been reached, it is determined whether Save_EEPROM_10Min_Count is greater than 0. If so, Save_EEPROM_10Min_Count is set to 0. If not, it continues to determine whether 10 minutes have been reached. When 20 minutes have been reached, it is determined whether Save_EEPROM_20Min_Count is greater than 0. If so, Save_EEPROM_20Min_Count is set to 0. If not, it continues to determine whether 20 minutes have been reached. When 1 hour has been reached, it is determined whether Save_Flash_1Hour_Count is greater than 0. If so, Save_Flash_1Hour_Count is set to 0. If not, it continues to determine whether 1 hour has been reached.

[0068] After setting Save_EEPROM_10Min_Count or Save_EEPROM_20Min_Count to 0, add 1 to the accumulated value of the frame storage times of the group of data, and determine whether the accumulated value of the frame storage times after adding 1 is equal to the maximum value 0xFFFFFFFF. If it is not equal to the maximum value, add 1 to the frame number EEPROM_Frame_Index (if the frame number exceeds the last frame position of the storage unit area designated by the EEPROM chip, set EEPROM_Frame_Index to 0 and start storage from the beginning), calculate the sum check and CRC32 check values ​​of the frame data, form a complete frame of data, and write it to the storage unit area designated by the EEPROM chip (write the position where the frame number is EEPROM_Frame_Index). If it is equal to the maximum value, set the accumulated value of the frame storage times to 0, calculate the sum check and CRC32 check values ​​of the frame data, form a complete frame of data, and write it to all positions of the storage unit area designated by the EEPROM chip and Flash memory.

[0069] After setting Save_Flash_1Hour_Count to 0, add 1 to the accumulated value of the frame storage times of this group of data, and determine whether the accumulated value of the frame storage times after adding 1 is equal to the maximum value 0xFFFFFFFF. If it is not equal to the maximum value, add 1 to the frame number Flash_Frame_Index (if the frame number exceeds the last frame position of the storage unit area designated by the Flash memory, set Flash_Frame_Index to 0 and start storage from the beginning), calculate the sum check and CRC32 check values ​​of the frame data, form a complete frame of data, and write it to the storage unit area designated by the Flash memory (write the position where the frame number is Flash_Frame_Index). If it is equal to the maximum value, set the accumulated value of the frame storage times to 0, calculate the sum check and CRC32 check values ​​of the frame data, form a complete frame of data, and write it to all positions of the storage unit area designated by the EEPROM chip and the Flash memory.

[0070] This embodiment adopts a sequential writing and cyclic overwriting mechanism to ensure the sustainable use of storage space and avoid the problem of storage area exhaustion; by evenly distributing write operations to all storage units and coordinating the storage cycle control of the EEPROM chip, dynamic wear leveling is achieved, which significantly extends the service life of the chip; the characteristic of keeping the latest data always overwriting the oldest data is maintained, and the timeliness of the data is automatically maintained within a limited storage space.

[0071] In a possible implementation manner of the embodiment of the present application, the method further includes: When the ultrasonic water meter is reset and restarted, all frame data in the storage unit area of ​​the EEPROM chip and the Flash memory are read, and all the obtained frame data are stored in a one-dimensional array; Check the validity of each frame of data in the one-dimensional array in turn to obtain several valid frame data; Determine a frame data with the largest accumulated value of frame storage times from a plurality of valid frame data as the latest frame data; Extract the ultrasonic water meter data in the latest frame data and assign the ultrasonic water meter data to the corresponding variables.

[0072] In this embodiment, after the ultrasonic water meter is reset and restarted, the meter parameters will be initialized and read. For a certain set of data, the microcontroller unit will read all the frame data of the set of data in the storage unit area defined by the EEPROM chip and the Flash memory, and store them in the one-dimensional array 1. The detection frame number CheckFrame_Index is set to 0, starting from the first frame data of the one-dimensional array 1, the validity of each frame data in the array 1 is judged in turn. After each frame data is judged, the detection frame number is increased by 1, and the next frame data in the array 1 is positioned to continue the judgment until the detection frame number is equal to the total number of frames in the array 1, thereby obtaining the judgment result of each frame data in the array 1, and the judgment result includes the mark of valid frame data or invalid frame data.

[0073] Then, all valid frame data are added to array 2, the detection frame number CheckFrame_Index is set to 0, starting from the first frame data of array 2, the size of the accumulated value of the frame storage times of each frame data in array 2 is judged in turn, and the frame data with the largest accumulated value of the frame storage times in array 2 is selected as the latest frame data, and each specific value in the latest frame data is extracted and assigned to the corresponding variable of the group of data. After the reading of this group of data is completed, the next group of data can be read.

[0074] This embodiment uses full data reading from dual memories to build a complete data set, avoids data loss due to single point failure, strictly screens valid data, ensures the integrity and accuracy of recovered data, identifies the latest data version by comparing the accumulated value of frame storage times, and ensures fast and reliable data recovery.

[0075] A possible implementation of the embodiment of the present application is to sequentially check the validity of each frame of data in the one-dimensional array, including: For each frame data in the one-dimensional array 1, the start identifier, end identifier, sum check and CRC check of the frame data are checked. When the start identifier, end identifier, sum check and CRC check of the frame data are all checked and passed, the frame data is determined to be valid frame data.

[0076] If any of the start mark, end mark, sum check and CRC check of the frame data fails to pass, the frame data is determined to be invalid frame data.

[0077] This embodiment uses a four-fold verification mechanism (start mark, end mark, sum check and CRC check) to achieve three-dimensional protection of data integrity.

[0078] The above are only some implementation methods of the present application. It should be pointed out that for ordinary technicians in this technical field, several improvements and modifications can be made without departing from the principles of the present application. These improvements and modifications should also be regarded as the scope of protection of the present application.

Claims

1. A method for storing ultrasonic water meter data, characterized in that: The method is performed by a micro control unit of an ultrasonic water meter, and the method comprises: Receive current frame data; When the current frame data is static configuration data, the current frame data is stored in the EEPROM chip and the Flash memory of the ultrasonic water meter respectively; When the current frame data is dynamically accumulated data, determining the storage period of the current frame data in the EEPROM chip and the Flash memory respectively based on the value of the current frame data; Based on storage cycles determined by the EEPROM chip and the Flash memory respectively, the current frame data is stored in the EEPROM chip and the Flash memory in a multi-segment cyclic storage manner.

2. The ultrasonic water meter data storage method according to claim 1, characterized in that: Determining a storage period of the current frame data in the EEPROM chip based on the value of the current frame data includes: When the value of the current frame data is greater than zero and less than a preset threshold, determining the storage period of the current frame data in the EEPROM chip as a first storage period; When the value of the current frame data is not less than the preset threshold, the storage period of the current frame data in the EEPROM chip is determined to be a second storage period; wherein the first storage period is greater than the second storage period.

3. The ultrasonic water meter data storage method according to claim 2, characterized in that: Determining a storage period of the current frame data in the Flash memory based on a value of the current frame data includes: When the value of the current frame data is greater than zero, the storage period of the current frame data in the Flash memory is determined to be a third storage period; wherein the third storage period is greater than the first storage period.

4. The ultrasonic water meter data storage method according to claim 2, characterized in that: When the value of the current frame is equal to zero, the method further includes: the current frame data is not stored in the EEPROM chip or the Flash memory.

5. The ultrasonic water meter data storage method according to claim 1, characterized in that: Based on the storage cycle determined by the EEPROM chip, the current frame data is stored in the EEPROM chip using a multi-segment cyclic storage method, including: The frame data obtained in each storage cycle is sequentially stored in each storage unit of the storage unit area of ​​the EEPROM chip, wherein each storage unit is used to store one frame of data; When the previous frame data of the current frame data is stored in the last storage unit of the storage unit area, the current frame data is stored in the first storage unit of the storage unit area, overwriting the frame data stored in the first storage unit in the previous cycle; The next frame data of the current frame data is stored in the second storage unit of the storage unit area, covering the frame data stored in the second storage unit in the previous cycle, and so on, to achieve multi-segment cyclic storage.

6. The ultrasonic water meter data storage method according to claim 1, characterized in that: The storing of the current frame data in the EEPROM chip and the Flash memory of the ultrasonic water meter respectively comprises: The current frame data is stored in fixed locations of the EEPROM chip and the Flash memory respectively; The data format of the current frame data includes: a start mark, an accumulated value of frame storage times, ultrasonic water meter data, a sum check, a CRC check and an end mark.

7. The ultrasonic water meter data storage method according to claim 1, characterized in that: The method further comprises: When the ultrasonic water meter is reset and restarted, all frame data in the storage unit area of ​​the EEPROM chip and the Flash memory are read, and all the obtained frame data are stored in a one-dimensional array; Checking the validity of each frame of data in the one-dimensional array in turn to obtain a number of valid frame data; Determine a frame data with the largest accumulated value of frame storage times from the plurality of valid frame data as the latest frame data; The ultrasonic water meter data in the latest frame data is extracted, and the ultrasonic water meter data is assigned to corresponding variables.

8. The ultrasonic water meter data storage method according to claim 7, characterized in that: The step of sequentially checking the validity of each frame of data in the one-dimensional array includes: For each frame data in the one-dimensional array, the start identifier, end identifier, sum check and CRC check of the frame data are checked. When the start identifier, end identifier, sum check and CRC check of the frame data are all checked and passed, the frame data is determined to be valid frame data.

9. An ultrasonic water meter, characterized in that: include: A micro control unit and an EEPROM chip, wherein the micro control unit includes a Flash memory; The micro control unit is used to receive current frame data and store the current frame data in the EEPROM chip and the Flash memory.

Citation Information

Patent Citations

  • Method for calibrating battery state of charge (SOC) of battery management system of electric automobile and device thereof

    CN102096048A

  • Electric energy meter data loading method, device and equipment and computer readable storage medium

    CN115188400A

  • Intelligent ultrasonic water meter

    CN115683252A

  • Battery management system data storage method and battery management system

    CN118535365A

  • Smant key device of external memory apparatus and using method

    CN1936842A

Cited By

  • Data storage method and device, electric energy meter and storage medium

    CN120723668A