A data storage method, device and control system
By dividing the memory into regions and performing data verification, the problem of incomplete data writing during power failure is solved, improving the accuracy of data storage and the control precision of the control system.
Patent Information
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- FANJI TECH (SUZHOU) CO LTD
- Filing Date
- 2026-03-03
- Publication Date
- 2026-06-05
AI Technical Summary
Existing data storage methods are prone to data not being fully written to the memory when power is lost, resulting in the control system being unable to accurately control the motor operation and the accuracy of stored data being low.
The memory is divided into a first region and a second region. Data is verified when it is written, and the data is transferred to different memories based on the verification results when the control system is powered on again, so as to ensure data integrity.
It improves the accuracy of stored data, ensures that the control system can accurately control the motor operation, and achieves complete data recovery in the event of power failure.
Smart Images

Figure CN122152594A_ABST
Abstract
Description
Technical Field
[0001] This invention relates to the field of data storage technology, and in particular to a data storage method, apparatus and control system. Background Technology
[0002] With the rapid development of battery technology, electric vehicles are being used more and more widely. Electric vehicles include a control system that controls the operation of the motors within the vehicle. This control system includes a memory that stores operating status data, control algorithm parameters, and fault information.
[0003] Existing control systems often use EEPROM (Electrically Erasable Programmable Read-Only Memory) as their storage. However, if data is written to this memory during a short power outage, incomplete data writing may occur. When the memory is read again upon power restoration, incorrect data may be stored, and the correct data cannot be retrieved, leading to inaccurate motor control by the control system. In other words, existing data storage methods result in low accuracy, causing the control system to fail to accurately control motor operation. Summary of the Invention
[0004] This invention provides a data storage method, apparatus, and control system, which solves the problem that existing data storage methods result in low accuracy of stored data, leading to the inability of the control system to accurately control the operation of the motor.
[0005] According to one aspect of the present invention, a data storage method is provided, the data storage method comprising: When writing first type data to the first memory, the operation of writing first type data to the first memory and reading first type data from the first memory is performed at least once; wherein, the first type data is single-byte data; If the first type of data read is different from the corresponding first type of data written, a prompt message will be issued; When writing second type data to the first memory, if the writing occurs when the control system containing the first memory is powered off, and the writing conditions meet the first preset conditions, then the first memory is divided into a first region and a second region, and the second type data to be written and the initial verification value are written to the first region and the second region in sequence; wherein, the second type data includes at least two bytes of data; When the control system is powered on again, if the second type of data in the first area passes the verification, the second type of data in the first area is transferred to the second memory; if the second type of data in the first area fails the verification, the second type of data in the second area is transferred to the second memory.
[0006] Optionally, after transferring the second type of data from the first region to the second memory, the method further includes: When the second type of data in the second region is inconsistent with the second type of data in the first region, the second type of data in the first region is transferred to the second region; After transferring the second type of data from the second region to the second memory, the process further includes: The second type of data from the second region is transmitted to the first region.
[0007] Optionally, the writing condition satisfying the first preset condition includes: The number of bytes included in a second type of data is greater than a first preset value, and / or the ratio of the power failure sustaining time of the control system to the writing time of a byte of data is less than a second preset value.
[0008] Optionally, the second type of data in the first region is validated, including: Perform cyclic redundancy check on the second type of data in the first region to obtain the first check value; If the first check value is the same as the initial check value in the first region, then the second type of data in the first region passes the check. The second type of data in the first region failed validation, including: Perform cyclic redundancy check on the second type of data in the first region to obtain the first check value; If the first check value is different from the initial check value in the first region, then the second type of data in the first region fails the check.
[0009] Optionally, writing the first type of data into the first memory includes: If the write conditions meet the second preset conditions, the first memory is divided into at least two storage areas; According to the preset storage order, the first type of data to be written is written to the corresponding storage area in turn, and the area flag bit is updated according to the storage area currently being written; When the control system containing the first memory loses power, the region flag bit is stored in the first memory; Upon power-on again, the first type of data to be written continues to be written to the corresponding storage area according to the area flag bit stored in the first memory and the preset storage order.
[0010] Optionally, the writing condition satisfies a second preset condition, including: The data write frequency is greater than a third preset value, and / or the rated lifespan of the first memory is less than a fourth preset value.
[0011] Optionally, the region flag bit is updated based on the currently written storage region, including: Update the region flag bit according to the position of the currently written storage region in the preset storage order.
[0012] Optionally, the method further includes: When the control system is powered on, the current tag data in the first memory is acquired; If the current tag data is different from the preset tag data, a prompt message will be issued.
[0013] According to another aspect of the present invention, a data storage device is provided, which is used to perform the data storage method described in any embodiment of the present invention; The data storage device includes: The read / write module is used to perform the operation of writing the first type of data to the first memory and reading the first type of data from the first memory at least once when writing the first type of data to the first memory; wherein the first type of data is single-byte data; The prompt module is used to issue a prompt message if the read first type of data is different from the corresponding written first type of data; The writing module is configured to, when writing second type data to the first memory, divide the first memory into a first region and a second region if the writing occurs when the control system containing the first memory is powered off and the writing conditions meet a first preset condition, and then sequentially write the second type data to be written and the initial verification value to the first region and the second region; wherein, the second type data includes at least two bytes of data; The transmission module is configured to, when the control system is powered on again, transmit the second type data of the first region to the second memory if the second type data of the first region passes the verification, and transmit the second type data of the second region to the second memory if the second type data of the first region fails the verification.
[0014] According to another aspect of the present invention, a control system is provided, the control system including the data storage device described in any embodiment of the present invention.
[0015] The technical solution of this invention, when writing first type data to the first memory, performs the operation of writing first type data to the first memory and reading first type data from the first memory at least once. If the first type data read each time is the same as the corresponding first type data written, it is determined that the first type data written to the first memory is correct and the writing is normal. If the first type data read is different from the corresponding first type data written, a prompt message is issued to prompt the user or staff that a storage error has occurred. In this way, the accuracy of data storage in the first memory can be improved, making it easier to control the motor based on accurate data, so that the control system can accurately control the motor operation. When writing second type data to the first memory, if the writing is performed when the control system where the first memory is located is powered off, and the writing conditions meet the first preset conditions, it indicates that the number of bytes of the second type data to be written is large, and / or, the power outage duration of the control system is short, and / or, the writing frequency is low, that is, the writing is slow, indicating that writing during power outage is prone to incomplete writing. In this case, the first memory is divided into a first region and a second region. Then, the data to be written (i.e., the second type of data to be written) and the initial check value are sequentially written to the first and second regions. When the control system is powered on again, the second type of data in the first region is checked based on the read second type of data and the initial check value. If the second type of data in the first region passes the check, the second type of data in the first region is transferred to the second memory. If the second type of data in the first region fails the check, it indicates that the second type of data to be written has not been completely written to the first region, and the second type of data has not yet been written to the second region. In this case, the second type of data stored in the second region is transferred to the second memory, and the control voltage is operated according to the second type of data written last time. In this way, the correct data can be retrieved even if the writing is incomplete. Thus, it is possible to accurately write a large amount of data into the first memory at once, and the correct data can be retrieved even if the writing is incomplete, improving the accuracy of the data stored in the first memory and facilitating more accurate control of motor operation.
[0016] It should be understood that the description in this section is not intended to identify key or essential features of the embodiments of the present invention, nor is it intended to limit the scope of the invention. Other features of the invention will become readily apparent from the following description. Attached Figure Description
[0017] To more clearly illustrate the technical solutions in the embodiments of the present invention, the accompanying drawings used in the description of the embodiments will be briefly introduced below. Obviously, the accompanying drawings described below are only some embodiments of the present invention. For those skilled in the art, other drawings can be obtained based on these drawings without creative effort.
[0018] Figure 1 This is a flowchart of a data storage method provided in an embodiment of the present invention; Figure 2 This is a flowchart of another data storage method provided in an embodiment of the present invention; Figure 3 This is a flowchart of another data storage method provided in an embodiment of the present invention; Figure 4 This is a schematic diagram of the structure of a data storage device provided in an embodiment of the present invention. Detailed Implementation
[0019] To enable those skilled in the art to better understand the present invention, the technical solutions of the present invention will be clearly and completely described below with reference to the accompanying drawings of the embodiments of the present invention. Obviously, the described embodiments are only some embodiments of the present invention, and not all embodiments. Based on the embodiments of the present invention, all other embodiments obtained by those skilled in the art without creative effort should fall within the scope of protection of the present invention.
[0020] It should be noted that the terms "first," "second," etc., in the specification, claims, and accompanying drawings of this invention are used to distinguish similar objects and are not necessarily used to describe a specific order or sequence. It should be understood that such data can be interchanged where appropriate so that the embodiments of the invention described herein can be implemented in orders other than those illustrated or described herein. Furthermore, the terms "comprising" and "having," and any variations thereof, are intended to cover non-exclusive inclusion; for example, a process, method, system, product, or apparatus that comprises a series of steps or units is not necessarily limited to those steps or units explicitly listed, but may include other steps or units not explicitly listed or inherent to such processes, methods, products, or apparatus.
[0021] This invention provides a data storage method, which can be executed by a data storage device. This method can be applied to the data storage of a control system for an electric vehicle. The electric vehicle can include electric off-road vehicles, such as electric forklifts, electric unmanned delivery vehicles, and aerial work platforms. The electric unmanned delivery vehicle is an electric unmanned logistics vehicle, which can include single-cage and double-cage unmanned logistics vehicles for carrying crates. The control system can be connected to the motor of the electric vehicle to control its operation. The control system can include a data storage device. The control system can also include a voltage conversion circuit and a control circuit. The voltage conversion circuit converts the direct current from the battery into alternating current to power the motor. The control circuit controls the conduction timing of the power devices in the voltage conversion circuit, thereby controlling the output power, output voltage, and output current of the voltage conversion circuit. The control circuit can include a microcontroller, a central processing unit, or a data processor.
[0022] Figure 1 This is a flowchart of a data storage method provided in an embodiment of the present invention, see reference. Figure 1 Data storage methods include: S110. When writing first type data to the first memory, the operation of writing first type data to the first memory and reading first type data from the first memory is performed at least once; wherein, the first type data is single-byte data.
[0023] The first type of data can include the electric vehicle's operating status data, control algorithm parameters, and fault information. Operating status data may include mileage and remaining battery power, but this is not limited to these. The first type of data is single-byte data, meaning one byte corresponds to one piece of data, and one byte contains eight bits of data. The first memory can be an EEPROM memory. EEPROM memory can perform read and write operations on individual bytes, avoiding the problem of flash memory, which can only read and write one sector at a time and cannot perform read and write operations on individual bytes. Furthermore, EEPROM memory does not require erasure, has rich interfaces, and strong real-time performance, allowing read and write operations to be performed on the EEPROM memory when the control system is powered on.
[0024] Specifically, when writing first type data to the first memory, the operation of writing first type data to the first memory and reading first type data from the first memory is performed at least once. That is, after each piece of first type data is written to the first memory, the currently written first type data is read. For example, the operation of writing first type data to the first memory and reading first type data from the first memory can be performed three times to facilitate accurate determination of whether the writing is normal.
[0025] When writing the first type of data to the first memory, it can be done when the control system is powered on or when the control system is powered off; there is no limitation on this.
[0026] S120. If the first type of data read is different from the corresponding first type of data written, a prompt message is issued.
[0027] Specifically, for each piece of first-type data written, a corresponding piece of first-type data is read from the first memory; that is, one piece of first-type data written corresponds to one piece of first-type data read. The first-type data read each time is compared with the corresponding first-type data written. If the read first-type data is the same as the written first-type data, the first-type data written to the first memory is considered correct, and the write operation is confirmed to be normal. If the read first-type data differs from the written first-type data, a prompt message is issued to alert the user or staff that a storage error has occurred. This improves the accuracy of data storage in the first memory, facilitating motor control based on accurate data and enabling the control system to accurately control motor operation.
[0028] S130. When writing second type data to the first memory, if the writing is performed when the control system where the first memory is located is powered off, and the writing conditions meet the first preset conditions, then the first memory is divided into a first region and a second region, and the second type data to be written and the initial verification value are written to the first region and the second region in sequence; wherein, the second type data includes at least two bytes of data.
[0029] The write condition meeting the first preset condition can be either that the number of bytes in the second type of data to be written is greater than the first preset value, meaning the number of bytes in the second type of data to be written is relatively large; or that the ratio of the power-down duration of the control system to the write time of one byte of data is less than the second preset value, meaning the power-down duration of the control system is short and the number of bytes of data that can be written to the first memory is small; or that the write frequency to the first memory is less than a preset threshold, meaning the write frequency is low and the write speed is slow.
[0030] Specifically, when writing second-type data to the first memory, if the writing occurs during a power outage in the control system containing the first memory, and the writing conditions meet the first preset condition, it indicates that the second-type data to be written includes a large number of bytes, and / or, the power outage duration of the control system is short, and / or, the writing frequency is low, i.e., the writing is slow. This indicates that writing during a power outage may result in incomplete writing. Therefore, the first memory is divided into a first region and a second region. Then, the data to be written (i.e., the second-type data to be written) and the initial check value are written sequentially to the first region and the second region. That is, after writing the second-type data to be written and the corresponding initial check value to the first region, the second-type data to be written and the corresponding initial check value are written to the second region. When both the first and second regions are completely written and the writing is normal, the content in the first region is the same as the content in the second region.
[0031] Furthermore, by writing an initial check value, it is easy to determine whether the written second type of data is correct based on the initial check value, which helps to improve the accuracy of data storage in the first memory, facilitates motor control based on accurate data, and enables the control system to accurately control motor operation.
[0032] If the data is not written during a power outage, when transferring data to the first memory, it is not necessary to divide it into a first region and a second region, or it can be divided into a first region and a second region; this is not a limitation here.
[0033] It should be noted that step S130 can be executed after step S120, or simultaneously with step S110, or step S130 can be executed first and then step S110. No limitation is imposed here.
[0034] S140. When the control system is powered on again, if the second type of data in the first area passes the verification, the second type of data in the first area is transferred to the second memory; if the second type of data in the first area fails the verification, the second type of data in the second area is transferred to the second memory.
[0035] The second memory can be random access memory (RAM) in the control system.
[0036] Specifically, when the control system is powered on again (i.e., after a power outage), the second type of data to be written and the initial verification value are sequentially written to the first and second areas. When the control system is powered on again, it reads the second type of data from the first area and verifies the second type of data in the first area based on the read second type of data and the initial verification value. For example, the read second type of data from the first area is calculated according to a preset algorithm or preset verification method. The calculated value is compared with the initial verification value. If they are the same, the second type of data in the first area is determined to have passed the verification; if they are different, the second type of data in the first area is determined to have failed the verification. The preset algorithm can be at least one of the following: XOR, addition, subtraction, multiplication, or division, etc., performed between the second type of data and preset data. The preset verification method can be cyclic redundancy check, etc., and is not limited here.
[0037] If the second type of data in the first region passes verification, it indicates that the second type of data in the first region is correct. The second type of data in the first region is then transferred to the second memory, allowing the control circuit in the control system to control the motor based on the second type of data in the second memory. If the second type of data in the first region fails verification, it indicates that the second type of data in the first region has not been completely transferred, meaning the second type of data to be written has not been completely written to the first region. Data is stored in the order of the first and second regions; data is written to the first region first, then to the second region. If the second type of data in the first region is not completely written, it means that the second type of data has not been written to the second region, and the second type of data in the second region has not been overwritten. The second region retains the previously written second type of data, and the second type of data stored in the second region (the previously written second type of data) is transferred to the second memory. The control voltage is then operated according to the previously written second type of data. In this way, correct data can be retrieved even if the writing process is incomplete. This achieves accurate writing of large amounts of data into the first memory at once, and allows for retrieval of correct data even if the writing process is incomplete, improving the accuracy of the data stored in the first memory and facilitating more accurate control of motor operation.
[0038] In this embodiment, when writing first type data to the first memory, the operation of writing first type data to the first memory and reading first type data from the first memory is performed at least once. If the first type data read each time is the same as the corresponding first type data written, it is determined that the first type data written to the first memory is correct and the writing is normal. If the first type data read is different from the corresponding first type data written, a prompt message is issued to alert the user or staff that a storage error has occurred. This improves the accuracy of data storage in the first memory, facilitating motor control based on accurate data, and enabling the control system to accurately control motor operation. When writing second type data to the first memory, if the writing occurs when the control system containing the first memory is powered off, and the writing conditions meet the first preset condition, it indicates that the second type data to be written includes a large number of bytes, and / or, the power outage duration of the control system is short, and / or, the writing frequency is low, i.e., the writing is slow. This indicates that writing during a power outage may result in incomplete writing. Therefore, the first memory is divided into a first region and a second region. Then, the data to be written (i.e., the second type of data to be written) and the initial check value are sequentially written to the first and second regions. When the control system is powered on again, the second type of data in the first region is checked based on the read second type of data and the initial check value. If the second type of data in the first region passes the check, the second type of data in the first region is transferred to the second memory. If the second type of data in the first region fails the check, it indicates that the second type of data to be written has not been completely written to the first region, and the second type of data has not yet been written to the second region. In this case, the second type of data stored in the second region is transferred to the second memory, and the control voltage is operated according to the second type of data written last time. In this way, the correct data can be retrieved even if the writing is incomplete. Thus, it is possible to accurately write a large amount of data into the first memory at once, and the correct data can be retrieved even if the writing is incomplete, improving the accuracy of the data stored in the first memory and facilitating more accurate control of motor operation.
[0039] Based on the above technical solutions, Figure 2 This is a flowchart of another data storage method provided in an embodiment of the present invention. Optionally, refer to... Figure 2 Data storage methods include: S210. When writing first type data to the first memory, the operation of writing first type data to the first memory and reading first type data from the first memory is performed at least once; wherein, the first type data is single-byte data.
[0040] S220. If the read first type of data is different from the corresponding written first type of data, a prompt message is issued.
[0041] S230. When writing second type data to the first memory, if the writing is performed when the control system where the first memory is located is powered off, and the writing conditions meet the first preset conditions, then the first memory is divided into a first region and a second region, and the second type data to be written and the initial verification value are written to the first region and the second region in sequence; wherein, the second type data includes at least two bytes of data.
[0042] S240. When the control system is powered on again, determine whether the second type of data in the first area has passed the verification. If yes, proceed to step S250; otherwise, proceed to step S270.
[0043] S250: Transfer the second type of data from the first region to the second memory.
[0044] S260. When the second type of data in the second region is inconsistent with the second type of data in the first region, the second type of data in the first region is transferred to the second region.
[0045] Specifically, after the second type of data in the first region passes verification, the second type of data in the second region is compared with the second type of data in the first region. If the second type of data in the second region is inconsistent with the second type of data in the first region, it indicates that the second type of data in the second region has not been completely written, that is, the second type of data to be written and the initial verification value have not been completely transmitted. In this case, the second type of data in the first region is transferred to the second region. This achieves data synchronization between the first and second regions, ensuring that the correct data is stored in the second region. This facilitates the retrieval of the correct data when the second type of data in the first region fails verification again, by transferring the second type of data in the second region to the second memory.
[0046] S270, Transfer the second type of data from the second region to the second memory.
[0047] S280, Transfer the second type of data from the second area to the first area.
[0048] Specifically, when the second type of data in the first region fails the verification, the second type of data in the second region is transferred to the first region, thereby synchronizing the data between the first and second regions and ensuring that the correct data is also stored in the first region.
[0049] Based on the above technical solutions, optionally, the writing conditions satisfying the first preset condition include: The number of bytes included in a second type of data is greater than the first preset value, and / or the ratio of the power failure sustaining time of the control system to the writing time of a byte of data is less than the second preset value.
[0050] Specifically, if the number of bytes in a second-type data is greater than the first preset value, it indicates that the number of bytes in the second-type data to be written is large. Therefore, writing the second-type data to the first memory during a power outage may result in incomplete writing. If the ratio of the power outage duration of the control system to the writing time of one byte of data is less than the second preset value, it indicates that the power outage duration of the control system is short, and the number of bytes of data that can be written to the first memory is small. Therefore, writing the second-type data to the first memory during a power outage may also result in incomplete writing. Therefore, when the writing conditions meet the first preset condition, the first memory is divided into a first region and a second region. Then, the data to be written (i.e., the second-type data to be written) and the initial check value are written sequentially to the first region and the second region. If the data is not completely written in the first region, the second-type data in the second region can be used, making it easier to retrieve the correct second-type data.
[0051] Based on the above technical solutions, optionally, the second type of data in the first region is verified, including: Perform cyclic redundancy check on the second type of data in the first region to obtain the first check value; If the first check value is the same as the initial check value in the first region, then the second type of data in the first region passes the check.
[0052] Cyclic Redundancy Check (CRC) is an error detection coding method based on polynomial division, used to verify the integrity of data transmission or storage. CRC treats the original data as a large binary number, divides it by another pre-defined binary number (called the "generator polynomial"), and the remainder is the check value. Therefore, CRC can be used to verify whether the second type of data in the first region has been transmitted successfully.
[0053] Specifically, before transferring the second type of data to the first memory, the second type of data to be written is subjected to cyclic redundancy check (CRC) to obtain an initial check value. During power failure, the second type of data to be written, along with the corresponding initial check value, is transferred to the first memory. Upon power-up after a power failure, the second type of data in the first area is read, and the read second type of data is subjected to CRC to obtain a first check value. The first check value is compared with the initial check value. If the first check value is the same as the initial check value, the second type of data in the first area passes the check.
[0054] Optionally, the second type of data in the first region failed validation, including: Perform cyclic redundancy check on the second type of data in the first region to obtain the first check value; If the first check value is different from the initial check value in the first region, then the second type of data in the first region fails the check.
[0055] Specifically, when power is restored after a power outage, the second type of data in the first area is read, and the read second type of data is subjected to cyclic redundancy check to obtain a first check value. The first check value is compared with the initial check value. If the first check value is different from the initial check value, the second type of data in the first area has failed the check.
[0056] Based on the above technical solutions, optionally, writing the first type of data into the first memory includes: Step a1: If the writing conditions meet the second preset conditions, then the first memory is divided into at least two storage areas.
[0057] The writing condition can be either a second preset condition or a third preset condition. The second preset condition can be that the data writing frequency is greater than the third preset value, indicating a higher data writing frequency and more writes to the first memory, easily reaching the write count that the first memory can handle. Alternatively, the first memory's rated lifespan can be less than the fourth preset value, indicating fewer writes to the first memory, easily reaching the write count that the first memory can handle.
[0058] The rated lifespan refers to the number of times data can be written to the first memory.
[0059] Specifically, when writing first type data to the first memory, if the writing conditions meet the second preset conditions, the first memory is divided into at least two storage areas, each of which can store first type data. This ensures that the number of writes to different locations in the first memory is the same, rather than writing first type data from the first address in the first memory every time, which would reduce the number of writes (lifespan) of the first few address bits too much and cause the service life (lifespan) of the first memory to decrease too quickly.
[0060] Step a2: According to the preset storage order, write the first type of data to be written to the corresponding storage area in turn, and update the area flag bit according to the storage area currently being written.
[0061] The preset storage order is the storage order of the storage area, that is, the order in which the storage area receives the first type of data, i.e., the order in which it is written to the storage area.
[0062] Specifically, by writing the first type of data to be written to the corresponding storage area in turn, the number of writes to the same storage location is reduced, thus extending the lifespan of the first memory, by writing the first type of data to different storage areas instead of writing to the same location in the first memory every time. Each storage area corresponds to a region flag bit, which is used to indicate the storage area currently being written to. This allows the first type of data to be written to the next storage area in a preset storage order after power failure, ensuring that the remaining lifespan of different storage areas is close to or equal to that of the first memory.
[0063] For example, the first memory can be divided into three storage regions: a first storage region, a second storage region, and a third storage region. The preset order is, for example, the first storage region, the second storage region, and the third storage region; that is, first type of data is written to the first storage region, then to the second storage region, and then to the third storage region. In the first write cycle, the first type of data to be written in the current write cycle is written to the first storage region, and the region flag is set to 1; in the second write cycle, the first type of data to be written in the current write cycle is written to the second storage region, and the region flag is updated to 2; in the third write cycle, the first type of data to be written in the current write cycle is written to the third storage region, and the region flag is updated to 3; in the fourth write cycle, the first type of data to be written in the current write cycle is written to the first storage region, and the region flag is updated to 1… and so on, thus achieving the sequential writing of first type of data to all storage regions.
[0064] Step a3: When the control system containing the first memory loses power, the area flag bit is stored in the first memory.
[0065] Specifically, when the control system where the first memory is located loses power, the current region flag is stored in the first memory. That is, the first memory stores which storage region has been written to the first type of data, so as to make it clear which storage region should be written to the first type of data in the next write cycle, which helps to ensure that the remaining lifespan of different storage regions is the same or close.
[0066] By storing the region flag only when power is off, the amount of data stored can be reduced, which helps extend the lifespan of the first memory.
[0067] Step a4: Upon power-on again, continue writing the current first type of data to be written to the corresponding storage area according to the area flag bit stored in the first memory and the preset storage order.
[0068] Specifically, when power is restored after a power outage, the region flag bit stored in the first memory is read. When the next write cycle arrives, the first type of data to be written is written to the next storage region in the storage region corresponding to the region flag bit stored in the first memory according to the preset storage order. This enables the first type of data to continue to be stored in the preset storage order, so that the number of writes to different storage regions is close or the same, which helps to ensure that the remaining lifespan of different storage regions is the same or close.
[0069] For example, the first memory can be divided into three storage regions: a first storage region, a second storage region, and a third storage region. The preset order is, for example, the first storage region, the second storage region, and the third storage region. In the first write cycle, the first type of data to be written corresponding to the current write cycle is written to the first storage region, and the region flag is set to 1. In the second write cycle, the first type of data to be written corresponding to the current write cycle is written to the second storage region, and the region flag is updated to 2. In the third write cycle, the first type of data to be written corresponding to the current write cycle is written to the third storage region, and the region flag is updated to 3. In the fourth write cycle, the first type of data to be written corresponding to the current write cycle is written to the first storage region, and so on. For example, if the control system loses power when the region flag is 2, the region flag 2 is stored in the first memory. After power is restored, the region flag stored in the first memory is read, and when the next write cycle arrives, the first type of data to be written corresponding to the current write cycle is written to the third storage region, and the region flag is updated to 3. In the fourth write cycle, the first type of data to be written in the current write cycle is written to the first storage area, and the area flag is updated to 1...
[0070] Based on the above technical solution, optionally, the writing conditions satisfy a second preset condition, including: The data writing frequency is greater than the third preset value, and / or the rated lifespan of the first memory is less than the fourth preset value.
[0071] The data writing frequency is the frequency of the writing cycle. The data writing frequency is greater than the third preset value, for example, greater than 1Hz, which means that the first type of data is written once every 1 second, but it is not limited.
[0072] Specifically, a data write frequency greater than the third preset value indicates a high data write frequency, meaning more writes are made to the first memory, easily reaching the write count that the first memory can withstand. A first memory's rated lifespan less than the fourth preset value indicates fewer writes, easily reaching the write count that the first memory can withstand. Therefore, when the data write frequency is greater than the third preset value and / or the first memory's rated lifespan is less than the fourth preset value, dividing the first memory into at least two storage areas and writing the currently pending first-type data to the corresponding storage area in a preset storage order can reduce the number of writes to the same storage location, thereby extending the lifespan of the first memory.
[0073] Optionally, the region flag bit is updated based on the currently written storage region, including: Update the region flag bit according to the position of the currently written storage region in the preset storage order.
[0074] Specifically, the position of the currently written storage region within the preset storage order, i.e., which position the currently written storage region is in the preset storage order. For example, if the currently written storage region is the m-th position in the preset storage order, then the updated region flag is m. Here, m is a positive integer.
[0075] Based on the above technical solutions, Figure 3 This is a flowchart of another data storage method provided in an embodiment of the present invention. Optionally, refer to... Figure 3 Data storage methods include: S310. When writing first type data to the first memory, the operation of writing first type data to the first memory and reading first type data from the first memory is performed at least once; wherein, the first type data is single-byte data.
[0076] S320. If the first type of data read is different from the corresponding first type of data written, a prompt message is issued.
[0077] S330. When writing second type data to the first memory, if the writing is performed when the control system where the first memory is located is powered off, and the writing conditions meet the first preset conditions, then the first memory is divided into a first region and a second region, and the second type data to be written and the initial verification value are written to the first region and the second region in sequence; wherein, the second type data includes at least two bytes of data.
[0078] S340. When the control system is powered on, the current tag data in the first memory is obtained.
[0079] Specifically, during the initial power-on initialization of the control system, or before leaving the factory, the preset tag data is transferred to the first memory, where the preset tag data is stored in a fixed tag storage location. Upon subsequent power-on, the current tag data is read from the fixed tag storage location in the first memory.
[0080] S350. Determine whether the current marker data is the same as the preset marker data. If not, proceed to step S360; if yes, proceed to step S370.
[0081] Specifically, the current marker data read during this power-on is compared with the preset marker data. If the current marker data is the same as the preset marker data, it indicates that the first memory can be used normally, and then proceed to the subsequent operation, such as transferring the data to the second memory, so that the control circuit can control the motor operation according to the data in the second memory.
[0082] S360, issue a prompt message.
[0083] Specifically, when the current tag data differs from the preset tag data, it indicates that the first memory may have a firmware error, or the first memory has been replaced, or the tag storage bit is damaged. In this case, a prompt message is issued to indicate the fault, and data transmission is prohibited. A stop signal can also be sent to the motor control circuit to prevent the motor from running, thus avoiding the use of incorrect data to control the motor.
[0084] S370. Determine whether the second type of data in the first region passes the verification. If yes, proceed to step S380; otherwise, proceed to step S391.
[0085] S380, Transfer the second type of data from the first region to the second memory.
[0086] S390. When the second type of data in the second region is inconsistent with the second type of data in the first region, the second type of data in the first region is transferred to the second region.
[0087] S391. Transfer the second type of data from the second region to the second memory.
[0088] S392. Transfer the second type of data from the second area to the first area.
[0089] This invention also provides a data storage device for executing the data storage method provided in any embodiment of this invention. Figure 4 This is a schematic diagram of the structure of a data storage device provided in an embodiment of the present invention, with reference to... Figure 4 The data storage device includes: The read / write module 101 is used to perform the operation of writing the first type of data to the first memory and reading the first type of data from the first memory at least once when writing the first type of data to the first memory; wherein the first type of data is single-byte data; The prompt module 102 is used to issue a prompt message if the read first type of data is different from the corresponding written first type of data; The writing module 103 is used to divide the first memory into a first region and a second region when writing second type data to the first memory, if the writing is performed when the control system where the first memory is located is powered off, and the writing conditions meet the first preset conditions, and the second type data to be written and the initial verification value are written to the first region and the second region in sequence; wherein, the second type data includes at least two bytes of data; The transmission module 104 is used to transmit the second type data of the first area to the second memory when the control system is powered on again, if the second type data of the first area passes the verification, and if the second type data of the first area fails the verification, the second type data of the second area is transmitted to the second memory.
[0090] The data storage device provided in the embodiments of the present invention can execute the data storage method provided in any embodiment of the present invention, and has the corresponding functional modules and beneficial effects of executing the method.
[0091] This invention also provides a control system, which includes a data storage device provided in any embodiment of this invention. The control system further includes a first memory, and the data storage device is connected to the first memory to realize read and write operations on the first memory. Since the control system includes the data storage device provided in any embodiment of this invention, the control system of this embodiment has the same beneficial effects as the data storage device provided in any embodiment of this invention, and will not be described again here.
[0092] This invention also provides a vehicle that includes a control system provided in any embodiment of the invention. The vehicle in this embodiment has the same beneficial effects as the control system provided in any embodiment of the invention, and will not be described again here.
[0093] It should be understood that the various forms of processes shown above can be used, with steps reordered, added, or deleted. For example, the steps described in this invention can be executed in parallel, sequentially, or in different orders, as long as the desired result of the technical solution of this invention can be achieved, and this is not limited herein.
[0094] The specific embodiments described above do not constitute a limitation on the scope of protection of this invention. Those skilled in the art should understand that various modifications, combinations, sub-combinations, and substitutions can be made according to design requirements and other factors. Any modifications, equivalent substitutions, and improvements made within the spirit and principles of this invention should be included within the scope of protection of this invention.
Claims
1. A data storage method, characterized in that, include: When writing first type data to the first memory, the operation of writing first type data to the first memory and reading first type data from the first memory is performed at least once; wherein, the first type data is single-byte data; If the first type of data read is different from the corresponding first type of data written, a prompt message will be issued; When writing second type data to the first memory, if the writing occurs when the control system containing the first memory is powered off, and the writing conditions meet the first preset conditions, then the first memory is divided into a first region and a second region, and the second type data to be written and the initial verification value are written to the first region and the second region in sequence; wherein, the second type data includes at least two bytes of data; When the control system is powered on again, if the second type of data in the first area passes the verification, the second type of data in the first area is transferred to the second memory; if the second type of data in the first area fails the verification, the second type of data in the second area is transferred to the second memory.
2. The method according to claim 1, characterized in that, After transferring the second type of data from the first region to the second memory, the process further includes: When the second type of data in the second region is inconsistent with the second type of data in the first region, the second type of data in the first region is transferred to the second region; After transferring the second type of data from the second region to the second memory, the process further includes: The second type of data from the second region is transmitted to the first region.
3. The method according to claim 1, characterized in that, The write conditions satisfying the first preset condition include: The number of bytes included in a second type of data is greater than a first preset value, and / or the ratio of the power failure sustaining time of the control system to the writing time of a byte of data is less than a second preset value.
4. The method according to claim 1, characterized in that, The second type of data in the first region passed the verification, including: Perform cyclic redundancy check on the second type of data in the first region to obtain the first check value; If the first check value is the same as the initial check value in the first region, then the second type of data in the first region passes the check. The second type of data in the first region failed validation, including: Perform cyclic redundancy check on the second type of data in the first region to obtain the first check value; If the first check value is different from the initial check value in the first region, then the second type of data in the first region fails the check.
5. The method according to claim 1, characterized in that, Writing the first type of data to the first memory includes: If the write conditions meet the second preset conditions, the first memory is divided into at least two storage areas; According to the preset storage order, the first type of data to be written is written to the corresponding storage area in turn, and the area flag bit is updated according to the storage area currently being written; When the control system containing the first memory loses power, the region flag bit is stored in the first memory; Upon power-on again, the first type of data to be written continues to be written to the corresponding storage area according to the area flag bit stored in the first memory and the preset storage order.
6. The method according to claim 5, characterized in that, The write conditions satisfy the second preset conditions, including: The data write frequency is greater than a third preset value, and / or the rated lifespan of the first memory is less than a fourth preset value.
7. The method according to claim 5, characterized in that, Update the region flag bit based on the currently written storage region, including: Update the region flag bit according to the position of the currently written storage region in the preset storage order.
8. The method according to claim 1, characterized in that, The method further includes: When the control system is powered on, the current tag data in the first memory is acquired; If the current tag data is different from the preset tag data, a prompt message will be issued.
9. A data storage device, characterized in that, Used to perform the data storage method according to any one of claims 1-8; The data storage device includes: The read / write module is used to perform the operation of writing the first type of data to the first memory and reading the first type of data from the first memory at least once when writing the first type of data to the first memory; wherein the first type of data is single-byte data; The prompt module is used to issue a prompt message if the read first type of data is different from the corresponding written first type of data; The writing module is configured to, when writing second type data to the first memory, divide the first memory into a first region and a second region if the writing occurs when the control system containing the first memory is powered off and the writing conditions meet a first preset condition, and then sequentially write the second type data to be written and the initial verification value to the first region and the second region; wherein the second type data includes at least two bytes of data; The transmission module is configured to, when the control system is powered on again, transmit the second type data of the first region to the second memory if the second type data of the first region passes the verification, and transmit the second type data of the second region to the second memory if the second type data of the first region fails the verification.
10. A control system, characterized in that it includes the data storage device as described in claim 9.