Data processing method, controller, battery management system and vehicle
By storing data in the write order in the memory of the battery management system, the simultaneous reading of new data and historical data is solved, and the problems of large storage space occupied by the existing technology, short FLASH storage life and low data reading efficiency are improved, and the system operation efficiency and data integrity are improved.
Patent Information
- Application Number
- CN202510075905.3
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2025-01-16
- Publication Date
- 2025-05-02
- Estimated Expiration
- 2045-01-16
AI Technical Summary
When storing and reading frozen frame data, existing battery management systems have problems such as large storage space, short FLASH storage life, and low data reading efficiency.
By storing data in the write order in memory, the simultaneous reading of new data and historical data is realized without the need for specific algorithms, which simplifies the data reading process and improves the operating efficiency of the battery management system.
This method shortens the data reading time, improves the operating efficiency of the battery management system, ensures data integrity and consistency, and extends the memory life.
Smart Images

Figure CN119917026A_ABST
Abstract
Description
Technical Field
[0001] The present disclosure relates to the field of data processing technology, and in particular, to a data processing method, a controller, a battery management system and a vehicle. Background Art
[0002] When the battery management system is running, it is necessary to frequently power off to save key data, namely, freeze frames, for determining whether the battery management system is faulty.
[0003] At present, FLASH Memory (FLASH) is commonly used to simulate Electrically Erasable Programmable Read-Only Memory (EEPROM) storage to achieve flexible storage. Specifically, multiple critical data when a system failure occurs are stored as a group of data, which occupies a large storage space and shortens the life of FLASH. In addition, specific algorithms need to be formulated to read and write data, which reduces the operating efficiency of the battery management system. Summary of the invention
[0004] In order to solve the deficiencies of the prior art, the present disclosure provides a data processing method, a controller, a battery management system and a vehicle.
[0005] In order to achieve the above objectives, in a first aspect, the present disclosure provides a data processing method, the method comprising: In response to a data read instruction, multiple data are read in sequence from a memory to obtain a data group, wherein the data group includes new data and historical data, the new data is the data most recently written into the memory, and the historical data is the data written into the memory before the new data, and the data in the memory is arranged according to the order in which the data are written.
[0006] In a second aspect, the present disclosure provides a controller, comprising: a memory having a computer program stored thereon; A processor is used to execute the computer program in the memory to implement the method described in the first aspect.
[0007] In a third aspect, the present disclosure provides a battery management system, comprising the controller described in the second aspect.
[0008] In a fourth aspect, the present disclosure provides a vehicle, comprising the battery management system described in the third aspect.
[0009] In a fifth aspect, the present disclosure provides a computer-readable storage medium having a computer program stored thereon, which implements the method described in the first aspect when the computer program is executed by a processor.
[0010] In a sixth aspect, the present disclosure provides a computer program product, including a computer program, which implements the method described in the first aspect when executed by a processor.
[0011] Through the above technical solution, in response to the data read instruction, multiple data are read from the memory in sequence to obtain a data group, and the data group includes the new data written in the memory the most recently and the historical data written before the new data. New data and historical data can be read at the same time, and there is no need to formulate a specific algorithm for the reading process, which shortens the time required to read data, thereby improving the operating efficiency of the battery management system. The data in the memory is stored in the order of writing, and the new data and historical data are arranged in chronological order. There is no need to perform complex sorting or search processing when reading data. Reading data in the order of writing can ensure the integrity and consistency of the data, which helps to maintain the logical relationship of the data and business continuity. When a large amount of data needs to be processed, this sequential reading method can significantly improve the data processing efficiency. When backing up, restoring or migrating data, data can be processed more easily and efficiently, simplifying the data management process. In addition, the storage space occupied by each data in the memory is small, which extends the life of the memory.
[0012] Other features and advantages of the present disclosure will be described in detail in the following detailed description. BRIEF DESCRIPTION OF THE DRAWINGS
[0013] The accompanying drawings are used to provide a further understanding of the present disclosure and constitute a part of the specification. Together with the following specific embodiments, they are used to explain the present disclosure but do not constitute a limitation of the present disclosure. In the accompanying drawings: Figure 1 The diagram is a read-write diagram showing an existing data processing method.
[0014] Figure 2a is another reading and writing schematic diagram showing an existing data processing method.
[0015] Figure 2b is another reading and writing schematic diagram showing an existing data processing method.
[0016] Figure 3 is a flowchart showing a data processing method according to an exemplary embodiment of the present disclosure.
[0017] Figure 4 It is a read and write schematic diagram showing a data processing method according to an exemplary embodiment of the present disclosure.
[0018] Figure 5 is a schematic diagram showing storage partitions according to an exemplary embodiment of the present disclosure.
[0019] Figure 6ais another reading and writing schematic diagram showing a data processing method according to an exemplary embodiment of the present disclosure.
[0020] Figure 6b It is another reading and writing schematic diagram showing a data processing method according to an exemplary embodiment of the present disclosure.
[0021] Figure 6c It is a data writing schematic diagram showing a data processing method according to an exemplary embodiment of the present disclosure.
[0022] Figure 7 is another flow chart of a data processing method according to an exemplary embodiment of the present disclosure.
[0023] Figure 8a FIG. 4 is a data readout diagram showing a data processing method according to an exemplary embodiment of the present disclosure.
[0024] Figure 8b FIG. 4 is another data readout schematic diagram showing a data processing method according to an exemplary embodiment of the present disclosure.
[0025] Fig. 9 It is another data writing schematic diagram showing a data processing method according to an exemplary embodiment of the present disclosure.
[0026] Fig.10 is a block diagram of a controller according to an exemplary embodiment of the present disclosure. DETAILED DESCRIPTION
[0027] The specific implementation of the present disclosure is described in detail below in conjunction with the accompanying drawings. It should be understood that the specific implementation described herein is only used to illustrate and explain the present disclosure, and is not used to limit the present disclosure.
[0028] It is worth mentioning that there are two main types of storage media that can achieve power-off preservation: EEPROM and FLASH. EEPROM supports byte-by-byte reading and writing, and has a long erase life, but is expensive; FLASH only supports writing by page (usually a few bytes) and erasing by sector (hundreds or thousands of bytes), has a short erase life, but is much cheaper than EEPROM.
[0029] Based on the characteristics of EEPROM and FLASH, FLASH is currently widely used to store power-off data, and EEPROM storage is simulated by technical means to achieve flexible storage. Take a FLASH storage chip as an example (its page size is 8 bytes and sector size is 1024 bytes). Figure 1, divide the FLASH storage area into multiple blocks, each block is an integer multiple of 8 bytes; each time data needs to be recorded, write the new data directly to the free block of FLASH; each time data needs to be read, find the latest written data, that is, the new data; after the entire storage area is full, erase the entire sector and restart the above steps. However, this method can only read new data each time, and cannot read historical data. If new data and historical data are to be read at the same time, the new data to be read and the historical data need to be stored as a group of data, which takes up a large storage space and shortens the life of FLASH.
[0030] For the freeze frames that need to be saved when the battery management system is powered off, it is necessary to save the on-site information when the battery management system fails. At the same time, in order to prevent multiple failures from occurring, it is necessary to be able to store and read multiple failure information at the same time. The stored freeze frames can be the data when the battery management system's latest failure occurs. Figure 2a , according to the number of fault information groups to be saved, multiple data packets are defined. Whenever the freeze frame data needs to be updated, the packet location where the data needs to be stored is found through a specific algorithm. When data needs to be read, the latest data of each data packet is found.
[0031] The inventor discovered Figure 2a The storage method described has the following technical problems: 1. Multiple data packets need to be defined, which increases the complexity of the data structure in the memory; 2. The data reading order cannot be consistent with the data writing order. When reading and writing data, a specific algorithm needs to be added to determine the location of the data packet storing the data in order to read or write data, which reduces the efficiency of the battery management system and increases the processing code; 3. When the subsequent change requirements need to increase or decrease the number of read data, the code modification is large and does not conform to the program design principles. Figure 2b When changing from reading 3 sets of data to reading 4 sets of data, it is necessary to redefine the data packets and adjust the specific algorithm used to determine the location of the data packet storing the data.
[0032] In view of this, the present disclosure provides a data processing method, a controller, a battery management system and a vehicle, which can read new data and historical data at the same time without adding specific algorithms, shortening the time required for data reading and data writing, and improving the efficiency of the battery management system.
[0033] Figure 3 is a flow chart of a data processing method according to an exemplary embodiment of the present disclosure, and the data processing method can be applied to a controller such as Figure 3 As shown, the data processing method may include the following steps: In step S11, in response to a data read instruction, multiple data are read from the memory in sequence to obtain a data group, wherein the data group includes new data and historical data, the new data is the data most recently written into the memory, and the historical data is the data written into the memory before the new data, and the data in the memory is arranged according to the order in which the data are written.
[0034] For example, Figure 4 As shown, when one new data and two historical data are stored in the memory, the order of arrangement of the data in the memory is new data, historical data 1, and historical data 2. At this time, the new data, historical data 1, and historical data 2 are read from the memory in sequence to obtain a data group; continue to write new data to the memory, and the latest data written to the memory is taken as the new data, and the data written before the new data is the historical data. At this time, there is one new data and three historical data in the memory, and the order of arrangement of the data in the memory is new data, historical data 1, historical data 2, and historical data 3. The new data, historical data 1, historical data 2, and historical data 3 are read from the memory in sequence.
[0035] The present disclosure responds to a data read instruction by sequentially reading multiple data from a memory to obtain a data group, and the data group includes the new data most recently written in the memory and the historical data written before the new data. New data and multiple historical data can be read at the same time, and there is no need to formulate a specific algorithm for the reading process, which shortens the time required to read data, thereby improving the operating efficiency of the battery management system. In addition, the data in the memory is stored in the order of writing, and the new data and historical data are arranged in the order of writing time. When reading data, there is no need to perform complex sorting or search processing. Reading data in the order of writing can ensure the integrity and consistency of the data, which helps to maintain the logical relationship of the data and business continuity. When a large amount of data needs to be processed, this sequential reading method can significantly improve the data processing efficiency. For example, when performing data backup, recovery or migration, data can be processed more easily and efficiently, thereby simplifying the data management process.
[0036] In order to facilitate those skilled in the art to better understand the data processing method provided by the present disclosure, the steps of the data processing method are described in detail below.
[0037] In a feasible implementation manner, the data stored in the memory is a freeze frame when the battery management system is running.
[0038] It is worth noting that among the key data that the battery management system needs to save, there is a type of data called freeze frame, which refers to the vehicle operating status data at a specific moment recorded in the vehicle's Electronic Control Unit (ECU). For example, when the sensor's data stream is abnormal, the ECU will capture the moment the fault occurs and record the relevant data to form a freeze frame. The freeze frame includes but is not limited to the vehicle's operating status, sensor readings, system parameters, etc., which can be used for subsequent fault diagnosis and maintenance.
[0039] In a feasible implementation manner, the data processing method may further include: According to the preset data size required for writing, the storage address in the memory is divided into a second number of data blocks in the order of data writing, and the size of each data block is equal to the preset data size required for writing; According to the preset number of data required for reading, the second number of data blocks are divided into at least two storage partitions, the preset number of data required for reading is the first number carried in the data reading instruction, each storage partition includes a third number of data blocks, and the third number is less than or equal to the first number.
[0040] The size of the data block is the same as the data size of the preset write requirement. The number of historical data in the preset read requirement is greater than or equal to the number of data blocks in a storage partition. For example, if the number of historical data in the preset read requirement is 10, the number of data blocks in each storage partition is less than or equal to 10; or the number of historical data is an integer multiple of the number of data blocks in a storage partition. For example, if the number of historical data in the preset read requirement is 10, the number of data blocks in each storage partition is 2 or 5. By limiting the number of historical data to be read and the number of data blocks in each storage partition, the inability to determine new data and historical data due to data overflow in the memory is avoided.
[0041] It is worth noting that the memory may be FLASH, and the number of times FLASH can be stored is related to its lifespan. In the prior art, a FLASH address stores only one data. When the lifespan of FLASH is 500 times, a FLASH address can only store data 500 times. In the disclosed implementation, a FLASH address is divided into multiple data blocks, and multiple data blocks are divided into multiple storage partitions. When the FLASH address can be stored 500 times, each data block can be stored 500 times. When the storage space of FLASH is large enough, the total number of times FLASH can be stored can be increased by dividing the FLASH address into multiple data blocks, thereby extending the lifespan of FLASH. For example, when the lifespan of FLASH is 500 times, the FLASH address is divided into ten data blocks, and each data block can store data 500 times. Then, a FLASH address can store data 5000 times, thereby extending the lifespan of FLASH.
[0042] It should be understood that a data block refers to a specific data area for storing and managing data, such as a continuous space on a physical storage medium, or an area divided on a logical level for the convenience of management and operation. The disclosed embodiment may also divide the storage address in the memory into multiple data blocks according to the data writing order based on the life requirement of the memory.
[0043] For example, Figure 5 As shown, according to the preset data size required for writing, the FLASH address is divided into n data blocks according to the data writing order, and each data block corresponds to a storage address, which is storage address 1, storage address 2, ..., storage address n. With 6 data blocks as a storage partition, the n data blocks are divided into M storage partitions, and partition mapping is performed to obtain A storage partition, ..., M storage partition. Then, the storage addresses of the 6 data blocks in the A storage partition are storage address 1, ..., storage address 6, ..., and the storage addresses of the 6 data blocks in the M storage partition are storage address n-5, ..., storage address n.
[0044] In the embodiments of the present disclosure, the size of the storage space (i.e., data block) occupied by each data in the memory can be preset according to the size of the data to be written, and the life of the memory can be extended by adjusting the size of the storage space used to store each data, i.e., storage space is exchanged for life.
[0045] In a feasible implementation manner, the data processing method may further include: In response to the data write instruction, traverse the memory and determine the second storage state of each storage partition in the memory; According to the second storage state, the data carried by the data write instruction is written into the memory.
[0046] In the disclosed embodiment, in response to a data write instruction, by traversing the memory and determining the second storage state of each storage partition in the memory, the storage space can be managed more effectively, the generation of storage fragments can be avoided, and existing data will not be overwritten, thereby reducing the risk of data write conflicts and data loss, and can also ensure that data can be written to the target location in the memory quickly and accurately, thereby improving the response speed of the battery management system.
[0047] In a feasible implementation manner, writing the data carried by the data write instruction into the memory according to the second storage state may include: When the second storage state represents that there is a free data block in the storage partition where data was last written in the memory, writing the data carried by the data write instruction into the storage partition where data was last written; When the second storage state represents that there is no free data block in the storage partition where data was last written in the memory, the data carried by the data write instruction is written into the next storage partition adjacent to the storage partition where data was last written in the memory.
[0048] For example, the FLASH address is divided into 18 data blocks according to the data writing order, 6 data blocks are used as one storage partition, and the 18 data blocks are divided into 3 storage partitions, namely storage partition A, storage partition B and storage partition C. In response to the data writing instruction, the memory is instructed to determine the second storage state of each storage partition in the memory. Figure 6a As shown, when the second storage state indicates that there is an idle data block in the A storage partition where data was last written, the data carried by the data write instruction is written into the next idle data block in the A storage partition. Figure 6b As shown, when the second storage state represents that there is no free data block in the A storage partition where data was written last time, the data carried by the data write instruction is written into the first free data block in the B storage partition.
[0049] In the disclosed embodiment, when there are still free data blocks in the storage partition where data was written last time, the data is written to the storage partition first, thereby reducing storage fragmentation and improving the utilization rate of storage space, and there is no need to relocate to other storage areas in the memory, thereby reducing the addressing time. When there are no free data blocks in the storage partition where data was written last time, the next storage partition adjacent to it is selected for writing, thereby maintaining the continuity of data writing, helping to reduce the movement of the read / write head, and thus improving writing efficiency. The above two orderly writing strategies can simplify the data retrieval and recovery process.
[0050] In a feasible implementation manner, writing the data carried by the data write instruction into the memory according to the second storage state may include: When the second storage state represents that all storage partitions in the memory are full, the first storage partition in the memory is erased, and the data carried by the data write instruction is written into the first storage partition.
[0051] For example, Figure 6c As shown, when all storage partitions in the second storage state representation memory are full, all data in the A storage partition is erased, and the data carried by the data write instruction is written into the first free data block in the A storage partition.
[0052] In the embodiment of the present disclosure, when all storage partitions are full, the first storage partition is erased and data is written to the first storage partition. On the basis of being able to store new data, historical data in other storage intervals are retained. When subsequent data is read, new data and multiple historical data can be read at the same time.
[0053] The following is a complete implementation method to illustrate the above three data writing processes: Divide the FLASH address into 12 data blocks according to the data writing order, with 6 data blocks as one storage partition, and divide the 12 data blocks into 2 storage partitions, namely storage partition A and storage partition B. In response to the data writing instruction, write data to the blank data blocks in storage partition A in sequence; after all the data blocks in storage partition A are full, write data to the blank data blocks in storage partition B in sequence; after all the data blocks in storage partition B are full, erase all the data in storage partition A, and write data to the blank data blocks in storage partition A in sequence; after all the data blocks in storage partition A are full again, erase all the data in storage partition B, and write data to the blank data blocks in storage partition B in sequence. The above data writing process is repeated until the life of the memory reaches the upper limit.
[0054] In a possible implementation, if Figure 7 As shown, in step S11, in response to the data read instruction, multiple data are sequentially read from the memory to obtain a data group, which may include: In step S111, in response to a data read instruction, the first storage address of the new data most recently written into the memory is determined, and based on the first storage address, the first number of data to be read corresponding to the read instruction, and the number of write times to the memory, the second storage address of the historical data written into the memory before the new data is determined.
[0055] In step S112, a plurality of data are sequentially read from the memory according to the first storage address and the second storage address to obtain a data group.
[0056] It is worth noting that the number of times the memory is written can be counted by a counter. Each time data is written to the memory, the counter counts by one and is not affected by power failure.
[0057] For example, after determining the first storage address of the new data most recently written into the memory, the storage address of the first historical data adjacent to the new data can be determined according to the first storage address and the count of the counter, and then the storage address of the remaining historical data can be determined according to the first number of data to be read corresponding to the read instruction and the storage address of the first historical data, and the storage addresses of the first historical data and the remaining historical data are used as the second storage address. Accordingly, the new data is read according to the first storage address, and multiple historical data are read according to the second storage address.
[0058] In the disclosed embodiment, by directly locating the first storage address of the latest written data, the data reading process can be quickly started, reducing the need to scan the memory from the beginning, thereby improving the efficiency of data access. And according to the first number of data to be read and the number of write times of the memory, the second storage address of the historical data is accurately obtained to ensure that only the required data is read, avoid unnecessary data transmission and processing, and quickly locate and read the required data, thereby improving the response speed of the battery management system, and is suitable for scenarios where a large amount of data needs to be processed and the data is updated frequently.
[0059] In a feasible implementation, the memory includes a second number of data blocks and at least two storage partitions, each storage partition includes a third number of consecutive data blocks; In step S111, determining a second storage address of historical data written into the memory before new data according to the first storage address, the first amount of data to be read corresponding to the read instruction, and the number of write times of the memory may include: Determine a first storage state of the memory according to the number of write times of the memory and the second number, the first storage state representing whether the memory is full; A second storage address of historical data written into the memory before the new data is determined based on the first storage state, the first number and the first storage address, or the first storage state and the third number.
[0060] It is worth noting that the first storage state used to characterize whether the memory is full can be determined by comparing the number of write times of the memory with the second number, and then the second address of the historical data can be further determined according to the first storage state.
[0061] In a feasible implementation manner, determining the second storage address of the historical data written into the memory before the new data according to the first storage state and the first storage address, or the first storage state and the third quantity, may include: In a case where the first storage state represents that the number of write times of the memory is greater than the second number, determining a second storage address of historical data written to the memory before the new data based on a first difference between the number of write times and the second number, the first number, and the first storage address; When the first storage state indicates that the number of write times of the memory is less than the second number, a second storage address of the historical data written into the memory before the new data is determined according to the first number and the third number.
[0062] It is worth noting that when the number of write times to the memory is greater than the second number, it indicates that all data blocks in the memory have stored data. At this time, the second storage address of the historical data needs to be determined based on the first difference between the number of write times and the second number combined with the first storage address. When the number of write times to the memory is less than the second number, it indicates that there are data blocks in the memory that have never stored data. At this time, the second storage address of the historical data needs to be determined based on the first number and the third number.
[0063] For example, the FLASH address is divided into 18 data blocks according to the data writing order, 6 data blocks are used as one storage partition, and the 18 data blocks are divided into 3 storage partitions, namely, storage partition A, storage partition B, and storage partition C. Figure 8a As shown, when there is a data stored in the A storage partition and the count of the counter is 19, the count of the counter 19 is greater than the total number of data blocks in the memory 18. At this time, all data blocks in the memory have stored data. According to the difference between the count 19 of the counter and the total number of data blocks in the memory 18, and the first storage address of the new data, it is determined that the second storage address of the historical data is in the B storage partition and / or the C storage partition.
[0064] Accordingly, if Figure 6a As shown, when 4 data are stored in storage partition A and the count of the counter is 4, the count of the counter 4 is less than the total number of data blocks in the memory 18. At this time, there are data blocks in the memory that have never stored data. According to the count of the counter 4 and the number of data blocks in storage partition A 6, as well as the first storage address of the new data, it is determined that the second storage address of the historical data is in storage partition A.
[0065] In the embodiments of the present disclosure, the storage state of the memory is determined by comparing the number of write times of the memory with the total number of data blocks in the memory, and then the second storage address is determined in combination with the first storage address. This can avoid duplicate storage and invalid storage of data, thereby improving the utilization of the storage space and reducing the addressing time during data access. The required data can be quickly located in a large data set or a complex data structure, thereby improving the performance of the battery management system.
[0066] In a feasible implementation manner, determining the second storage address of the historical data written into the memory before the new data according to the first difference between the number of write times and the second number, the first number and the first storage address may include: comparing the first difference value with the third quantity to obtain a comparison result; A second storage address of historical data written into the memory before the new data is determined based on the comparison result, the first number, and the first storage address.
[0067] In the disclosed embodiment, when all data blocks in the memory have stored data, the second storage address of the historical data is determined by comparing the first difference with the number of data blocks in the storage partition and combining the first storage address, thereby improving the accuracy and reliability of the second storage address.
[0068] In a feasible implementation manner, determining the second storage address of the historical data written into the memory before the new data according to the comparison result, the first number and the first storage address may include: When the comparison result indicates that the first difference is less than or equal to the third quantity, it is determined that the first storage address is located in the first storage partition in the memory, the first difference is subtracted from the first quantity to obtain the fourth quantity, and all storage addresses before the first storage address in the first storage partition and the storage addresses after the fourth quantity in the last storage partition in the memory are determined as the second storage address of the historical data.
[0069] For example, the FLASH address is divided into 18 data blocks according to the data writing order, 6 data blocks are used as one storage partition, and the 18 data blocks are divided into 3 storage partitions, namely, storage partition A, storage partition B, and storage partition C. Figure 8a As shown, when the first difference between the count of the counter and the total number of data blocks in the memory is 1, the first difference 1 is less than the number of data blocks in the storage partition 6, indicating that the A storage partition in the memory has been erased and there are free data blocks in the A storage partition. At this time, it can be determined that the first storage address is located in the A storage partition. The first number of data to be read corresponding to the read instruction 7 is subtracted from the first difference 1 to obtain 6. It can be determined that the number of historical data stored in the C storage partition is 6, and the last 6 storage addresses in the C storage partition are determined as the second storage addresses of the historical data. At this time, a new data and 6 historical data are read out from the A storage partition and the C storage partition, which are new data, historical data 1, historical data 2, ..., historical data 6 in sequence.
[0070] In a feasible implementation manner, determining the second storage address of the historical data written into the memory before the new data according to the comparison result, the first number and the first storage address may include: In the case where the comparison result indicates that the first difference is greater than the third quantity, determining that the first storage address is located in a second storage partition outside the first storage partition in the memory, determining a second difference between the first difference and the third quantity, subtracting the second difference from the first quantity to obtain a fifth quantity, and determining all storage addresses before the first storage address in the second storage partition and the storage addresses before the fifth quantity in a previous storage partition adjacent to the second storage partition in the memory as the second storage address of the historical data For example, the FLASH address is divided into 18 data blocks according to the data writing order, 6 data blocks are used as one storage partition, and the 18 data blocks are divided into 3 storage partitions, namely, storage partition A, storage partition B, and storage partition C. Figure 8b As shown, when the first difference between the count 25 of the counter and the total number of data blocks 18 in the memory is 7, the first difference 7 is greater than the number of data blocks 6 in the storage partition, indicating that both the A storage partition and the B storage partition in the memory have been erased and the A storage partition is full again. At this time, it can be determined that the first storage address is located in the B storage partition, and the first difference 7 is subtracted from the number of data blocks 6 in the storage partition to obtain the second difference 1, and the first number of data to be read corresponding to the read instruction 7 is subtracted from the second difference 1 to obtain 6. It can be determined that the number of historical data stored in the A storage partition is 6, and the last 6 storage addresses in the A storage partition are determined as the second storage addresses of the historical data. At this time, one new data and 6 historical data are read out from the A storage partition and the B storage partition, which are the new data, historical data 1, historical data 2, ..., historical data 6 in sequence.
[0071] In a feasible implementation manner, determining, according to the third quantity, a second storage address of historical data written into the memory before the new data may include: When the number of write times of the memory is less than or equal to the third number, it is determined that the first storage address is located in the first storage partition in the memory, and all storage addresses before the first storage address in the first storage partition are determined as second storage addresses.
[0072] For example, the FLASH address is divided into 18 data blocks according to the data writing order, 6 data blocks are used as one storage partition, and the 18 data blocks are divided into 3 storage partitions, namely, storage partition A, storage partition B, and storage partition C. Figure 6a As shown, when the count 4 of the counter is less than the total number of data blocks 6 in the storage partition, it is determined that the first storage address of the new data is located in the A storage partition, and the first three storage addresses in the A storage partition are determined as the second storage addresses of the historical data. At this time, one new data and three historical data are read out from the A storage partition, which are new data, historical data 1, historical data 2, and historical data 3, respectively.
[0073] In a feasible implementation manner, determining, according to the third quantity, a second storage address of data written into the memory before the new data may include: When the number of write times to the memory is greater than a third number, determine that the first storage address is located in a target third storage partition outside the first storage partition in the memory, subtract the third number from the number of write times to obtain a third difference, and subtract the third difference from the first number to obtain a sixth number, and all storage addresses before the first storage address in the third storage partition and the first sixth number of storage addresses in the previous storage partition adjacent to the third storage partition in the memory are determined as the second storage addresses of data written to the memory before the new data.
[0074] For example, the FLASH address is divided into 18 data blocks according to the data writing order, 6 data blocks are used as one storage partition, and the 18 data blocks are divided into 3 storage partitions, namely, storage partition A, storage partition B, and storage partition C. Figure 6b As shown, when the count 7 of the counter is greater than the total number 6 of data blocks in the storage partition, it is determined that the first storage address of the new data is located in the B storage partition, the total number 6 of data blocks in the storage partition is subtracted from the count 7 of the counter to obtain the third difference 1, the first number 6 of data to be read corresponding to the read instruction is subtracted from the third difference 1 to obtain 5, the number of historical data stored in the A storage partition is determined to be 5, and the last 6 storage addresses in the A storage partition are determined as the second storage addresses of the historical data. At this time, one new data and 5 historical data are read out from the A storage partition and the B storage partition, which are the new data, historical data 1, historical data 2, ..., historical data 5 in sequence.
[0075] In a feasible implementation, when the requirement is changed and the number of data to be read each time needs to be increased, the program code does not need to be modified and can be read directly.
[0076] like Fig. 9As shown, the FLASH address is divided into 18 data blocks according to the data writing order, and 6 data blocks are used as one storage partition. The 18 data blocks are divided into 3 storage partitions, which are storage partition A, storage partition B and storage partition C, respectively, and the storage status in the memory is that storage partition A is full, 4 data are stored in storage partition B, and no data is stored in storage partition C. After responding to the data write instruction, new data is written to storage partition B. At this time, storage partition B stores 5 data. If a data read instruction is received at this time, and the first number carried in the data read instruction is 7, then respond to the data read instruction, read out a new data and 6 historical data from storage partition A and storage partition B to obtain a data group. After responding to the data write instruction again, new data is written to storage partition B. At this time, storage partition B is full. If a data read instruction is received at this time, and the first number carried in the data read instruction changes from 7 to 8, then respond to the data read instruction, read out a new data and 7 historical data from storage partition A and storage partition B to obtain a data group.
[0077] In the embodiments of the present disclosure, when the demand for reading data changes, such as increasing or decreasing the number of data to be read, it is only necessary to adjust the first quantity carried in the data read instruction to increase or decrease the number of historical data read, without modifying the code, and the data can be read quickly and accurately.
[0078] Based on the same inventive concept, the present disclosure also provides a controller, such as Fig.10 As shown, including: Memory 1001, on which a computer program is stored; The processor 1002 is used to execute the computer program in the memory to implement the above-mentioned data processing method.
[0079] The present disclosure responds to a data read instruction by sequentially reading multiple data from a memory to obtain a data group, and the data group includes the new data most recently written in the memory and the historical data written before the new data. New data and multiple historical data can be read at the same time, and there is no need to formulate a specific algorithm for the reading process, which shortens the time required to read data, thereby improving the operating efficiency of the battery management system. In addition, the data in the memory is stored in the order of writing, and the new data and historical data are arranged in the order of writing time. When reading data, there is no need to perform complex sorting or search processing. Reading data in the order of writing can ensure the integrity and consistency of the data, which helps to maintain the logical relationship of the data and business continuity. When a large amount of data needs to be processed, this sequential reading method can significantly improve the data processing efficiency. For example, when performing data backup, recovery or migration, data can be processed more easily and efficiently, thereby simplifying the data management process.
[0080] Based on the same inventive concept, the present disclosure also provides a battery management system, including the above-mentioned controller.
[0081] Based on the same inventive concept, the present disclosure also provides a vehicle, comprising the above-mentioned battery management system.
[0082] In another exemplary embodiment, a computer-readable storage medium including program instructions is also provided, and when the program instructions are executed by a processor, the steps of the above-mentioned data processing method are implemented.
[0083] In another exemplary embodiment, a computer program product is further provided. The computer program product includes a computer program executable by a processor. When the computer program is executed by the processor, the steps of the above data processing method are implemented.
[0084] The preferred embodiments of the present disclosure are described in detail above in conjunction with the accompanying drawings; however, the present disclosure is not limited to the specific details in the above embodiments. Within the technical concept of the present disclosure, a variety of simple modifications can be made to the technical solution of the present disclosure, and these simple modifications all fall within the protection scope of the present disclosure.
[0085] It should also be noted that the various specific technical features described in the above specific embodiments can be combined in any suitable manner without contradiction. In order to avoid unnecessary repetition, the present disclosure will not further describe various possible combinations.
[0086] In addition, various embodiments of the present disclosure may be arbitrarily combined, and as long as they do not violate the concept of the present disclosure, they should also be regarded as the contents disclosed by the present disclosure.
Claims
1. A data processing method, characterized in that: The method comprises: In response to a data read instruction, multiple data are read in sequence from a memory to obtain a data group, wherein the data group includes new data and historical data, the new data is the data most recently written into the memory, and the historical data is the data written into the memory before the new data, and the data in the memory is arranged according to the order in which the data are written.
2. The data processing method according to claim 1, characterized in that: The response data read instruction sequentially reads a plurality of data from the memory to obtain a data group, including: In response to a data read instruction, determine a first storage address of new data that has been written to the memory, and determine a second storage address of historical data that has been written to the memory before the new data according to the first storage address, a first amount of data to be read corresponding to the read instruction, and a number of write times to the memory; According to the first storage address and the second storage address, a plurality of data are sequentially read from the memory to obtain a data group.
3. The data processing method according to claim 2, characterized in that: The memory includes a second number of data blocks and at least two storage partitions, each of the storage partitions includes a third number of consecutive data blocks; The determining, according to the first storage address, a first amount of to-be-read data corresponding to the read instruction, and the number of write times of the memory, a second storage address of historical data written into the memory before the new data comprises: determining a first storage state of the memory according to the number of write times of the memory and the second quantity, wherein the first storage state indicates whether the memory is full; A second storage address of historical data written into the memory before the new data is determined according to the first storage state, the first number, and the first storage address, or the first storage state and the third number.
4. The data processing method according to claim 3, characterized in that: The determining, according to the first storage state, the first quantity and the first storage address, or the first storage state and the third quantity, a second storage address of the historical data written into the memory before the new data comprises: In a case where the first storage state indicates that the number of write times of the memory is greater than the second number, determining a second storage address of historical data written to the memory before the new data according to a first difference between the number of write times and the second number, the first number, and the first storage address; When the first storage state indicates that the number of write times of the memory is less than the second number, a second storage address of historical data written to the memory before the new data is determined according to the third number.
5. The data processing method according to claim 4, characterized in that: The determining, according to a first difference between the number of write times and the second number, the first number, and the first storage address, a second storage address of historical data written into the memory before the new data comprises: comparing the first difference with the third quantity to obtain a comparison result; A second storage address of historical data written into the memory before the new data is determined according to the comparison result, the first number and the first storage address.
6. The data processing method according to claim 5, characterized in that: The step of determining, according to the comparison result, the first number and the first storage address, a second storage address of the historical data written into the memory before the new data comprises: When the comparison result indicates that the first difference is less than or equal to the third quantity, it is determined that the first storage address is located in the first storage partition in the memory, the first difference is subtracted from the first quantity to obtain a fourth quantity, and all storage addresses before the first storage address in the first storage partition and the storage addresses after the fourth quantity in the last storage partition in the memory are determined as the second storage address of the historical data.
7. The data processing method according to claim 5, characterized in that: The step of determining, according to the comparison result, the first number and the first storage address, a second storage address of the historical data written into the memory before the new data comprises: When the comparison result indicates that the first difference is greater than the three quantities, determine that the first storage address is located in a second storage partition outside the first storage partition in the memory, determine a second difference between the first difference and the third quantity, subtract the second difference from the first quantity to obtain a fifth quantity, and determine all storage addresses before the first storage address in the second storage partition and the storage address of the fifth quantity in a previous storage partition adjacent to the second storage partition in the memory as the second storage address of the historical data.
8. The data processing method according to claim 4, characterized in that: The step of determining, according to the third quantity, a second storage address of historical data written into the memory before the new data comprises: When the number of write times of the memory is less than or equal to the third number, it is determined that the first storage address is located in a first storage partition in the memory, and all storage addresses before the first storage address in the first storage partition are determined as second storage addresses.
9. The data processing method according to claim 4, characterized in that: The step of determining, according to the third number, a second storage address of data written into the memory before the new data comprises: In a case where the number of write times to the memory is greater than the third quantity, determine that the first storage address is located in a target third storage partition outside the first storage partition in the memory, subtract the third quantity from the number of write times to obtain a third difference, subtract the third difference from the first quantity to obtain a sixth quantity, and determine all storage addresses before the first storage address in the third storage partition and the sixth quantity of storage addresses in a previous storage partition adjacent to the third storage partition in the memory as second storage addresses of data written to the memory before the new data.
10. The data processing method according to any one of claims 1 to 9, characterized in that: The method further comprises: According to the data size of the preset writing requirement, the storage address in the memory is divided into a second number of data blocks in the order of data writing, and the size of each data block is equal to the data size of the preset writing requirement; According to the preset number of data required for reading, the second number of data blocks are divided into at least two storage partitions, the preset number of data required for reading is the first number carried in the data reading instruction, each of the storage partitions includes a third number of data blocks, and the third number is less than or equal to the first number.
11. The data processing method according to claim 10, characterized in that: The method further comprises: In response to a data write instruction, traverse the memory to determine a second storage state of each storage partition in the memory; According to the second storage state, the data carried by the data write instruction is written into the memory.
12. The data processing method according to claim 11, characterized in that: Writing the data carried by the data write instruction into the memory according to the second storage state includes: When the second storage state indicates that there is a free data block in the storage partition where data was last written in the memory, writing the data carried by the data write instruction into the storage partition where data was last written; When the second storage state indicates that there is no free data block in the storage partition where data was last written in the memory, the data carried by the data write instruction is written into the next storage partition in the memory adjacent to the storage partition where data was last written.
13. The data processing method according to claim 11, characterized in that: Writing the data carried by the data write instruction into the memory according to the second storage state includes: When the second storage state indicates that all storage partitions in the memory are full, the first storage partition in the memory is erased, and the data carried by the data write instruction is written into the first storage partition.
14. The data processing method according to claim 1, characterized in that: The data stored in the memory are freeze frames when the battery management system is running.
15. A controller, characterized in that: include: a memory having a computer program stored thereon; A processor, configured to execute the computer program in the memory to implement the method according to any one of claims 1 to 14.
16. A battery management system, characterized in that: Includes the controller as claimed in claim 15.
17. A vehicle, characterized in that: Includes the battery management system as described in claim 16.
18. A computer-readable storage medium having a computer program stored thereon, characterized in that: When the computer program is executed by a processor, the method according to any one of claims 1 to 14 is implemented.
19. A computer program product, characterized in that The invention comprises a computer program, which implements the method according to any one of claims 1 to 14 when being executed by a processor.
Citation Information
Patent Citations
Recording device, recording method, recording medium
CN107615386A
Data playback method and device, storage medium and electronic equipment
CN113961539A
Data processing method, multi-input multi-output queue circuit and storage medium
CN116431099A
Apparatus and method for data storage, and computer product
US20060015680A1
Data storage method and apparatus, electronic device and storage medium
WO2024119746A1
Cited By
Computing power service data set storage method
CN120162223A
A storage method for a computing power service data set
CN120162223B