A storage device, a data writing method thereof, and a motor device

CN114579038BActive Publication Date: 2026-09-25ZHEJIANG SANHUA INTELLIGENT CONTROLS CO LTD
View PDF 1 Cites 0 Cited by

Patent Information

Application Number
CN202011399940.4
Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
Filing Date
2020-12-02
Publication Date
2026-09-25
Estimated Expiration
2040-12-02

AI Technical Summary

Technical Problem

[0004]然而,现有NVRAM在存储时,是对整个内存进行写入,增加了非必要内存的写频率,造成读写寿命次数有限,增大了步进电机驱动产品成本

Benefits of technology

[0016]本发明实施例中,存储器包括多个物理页,一个物理页包括一控制信息单元和多个数据单元,控制信息单元存储有其所属物理页的在写数据单元信息,处理器在数据写入阶段确定待写入的第一物理页,根据第一物理页中控制信息单元存储的在写数据单元信息,确定待写入数据单元再执行写操作。由此可知,存储设备对其内存进行了分区,分为多个物理页,处理器进行数据写入时,并非是对整个内存进行写入,而是每次写操作时针对其中一个存储区域进行存储,通过控制信息单元中存储的在写数据单元信息来确定待写入数据单元,实现了依序存储,以此增加存储器的读写寿命。

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN114579038B_ABST
    Figure CN114579038B_ABST
Patent Text Reader

Abstract

The embodiment of the present application discloses a storage device, a data writing method thereof and a motor device. The storage device comprises a memory and a processor. The memory comprises a plurality of physical pages. Each physical page comprises a control information unit and a plurality of data units. The control information unit stores in-writing data unit information. The processor is electrically connected with the memory. When a write operation is performed, the processor determines a first physical page on which a last write operation is performed. According to the in-writing data unit information stored in the control information unit of the first physical page, the processor determines a data unit to be written, and then performs the write operation. In the embodiment of the present application, the data unit to be written is determined according to the in-writing data unit information stored in the control information unit, sequential storage is realized, and the read-write life of the memory is increased.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present invention relates to memory technology, and more particularly to a storage device and a data writing method thereof, as well as a motor device. Background Technology

[0002] In stepper motor drive products, initialization is required each time the product is powered on to determine the zero position of its travel stroke. Specifically, zero-point calibration is performed using an electronic ball valve within the stepper motor. Before initialization, the electronic ball valve is stopped in a partially closed position. A limit switch is installed in the fully closed direction of the electronic ball valve. During initialization, the electronic ball valve moves towards the fully closed direction and repeatedly impacts the limit switch (i.e., the striking end) to ensure that the electronic ball valve is always in the fully closed position, thus completing the initialization.

[0003] Initialization collisions can affect product operating logic / state, noise, efficiency, and lifespan. To reduce the frequency of initialization, a method of storing motor positions is adopted. NVRAM is set up within the product. Before power failure, the product saves the current position information to NVRAM. Upon the next power-on, the position only needs to be read from NVRAM, thus eliminating the need for initialization.

[0004] However, existing NVRAM writes to the entire memory during storage, increasing the write frequency of unnecessary memory, resulting in a limited read / write lifespan and increasing the cost of stepper motor drive products. Summary of the Invention

[0005] This invention provides a storage device, a data writing method thereof, and a motor device to improve the read / write lifespan of the memory.

[0006] This invention provides a storage device, including: a memory and a processor;

[0007] The memory includes multiple physical pages, each physical page including a control information unit and multiple data units, the control information unit storing information about the data units being written;

[0008] The processor is electrically connected to the memory and is used to determine the first physical page from which the write operation was last performed during a write operation. Based on the data unit information stored in the control information unit of the first physical page, the processor determines the data unit to be written and then performs the write operation.

[0009] Based on the same inventive concept, this embodiment of the invention also provides a data writing method for a storage device, wherein the storage device includes a memory, the memory includes a plurality of physical pages, the physical page includes a control information unit and a plurality of data units, and the control information unit stores information of the data unit being written.

[0010] The data writing method includes:

[0011] Determine the first physical page from which the last write operation was performed;

[0012] Based on the data unit information stored in the control information unit of the first physical page, the data unit to be written is determined, and then the write operation is performed.

[0013] Based on the same inventive concept, embodiments of the present invention also provide an electric motor device, the electric motor device including a motor, a motor controller and the storage device as described above;

[0014] When the motor device loses power, the motor controller triggers the storage device to enter the data writing stage to save the position data of the motor.

[0015] When the motor is powered on, the motor controller retrieves the position data saved before the power failure from the storage device, and controls the motor to initialize when the position data is detected to be invalid, or controls the motor to run to the position corresponding to the position data when the position data is detected to be valid.

[0016] In this embodiment of the invention, the memory includes multiple physical pages. Each physical page includes a control information unit and multiple data units. The control information unit stores the data unit information to be written for its respective physical page. During the data writing phase, the processor determines the first physical page to be written to, and based on the data unit information to be written stored in the control information unit of the first physical page, determines the data unit to be written before performing the write operation. Thus, the storage device partitions its memory into multiple physical pages. When the processor writes data, it does not write to the entire memory, but rather stores data in one specific storage area each time a write operation is performed. The data unit to be written is determined by the data unit information to be written, achieving sequential storage and thereby increasing the read / write lifespan of the memory. Attached Figure Description

[0017] To more clearly illustrate the technical solutions in the embodiments of the present invention or the prior art, the drawings used in the description of the embodiments or the prior art will be briefly introduced below. Obviously, although the drawings described below are some specific embodiments of the present invention, those skilled in the art can extend and extend the basic concepts of the device structure, driving method and manufacturing method disclosed and indicated by various embodiments of the present invention to other structures and drawings. Undoubtedly, these should all be within the scope of the claims of the present invention.

[0018] Figure 1 This is a schematic diagram of a storage device provided in an embodiment of the present invention;

[0019] Figure 2This is a schematic diagram of a memory provided in an embodiment of the present invention;

[0020] Figure 3 This is a schematic diagram of a data writing method for a storage device provided in an embodiment of the present invention;

[0021] Figure 4 This is a schematic diagram of another data writing method for a storage device provided in an embodiment of the present invention;

[0022] Figure 5 This is a schematic diagram of a motor device provided in an embodiment of the present invention;

[0023] Figure 6 This is a schematic diagram of a driving method for an electric motor device provided in an embodiment of the present invention. Detailed Implementation

[0024] To make the objectives, technical solutions, and advantages of this invention clearer, the technical solutions of this invention will be clearly and completely described below with reference to the accompanying drawings in the embodiments of this invention. Obviously, the described embodiments are only some embodiments of this invention, not all embodiments. Based on the basic concepts disclosed and indicated in the embodiments of this invention, all other embodiments obtained by those skilled in the art are within the scope of protection of this invention.

[0025] refer to Figure 1 The diagram shown is a schematic representation of a storage device provided in an embodiment of the present invention. The storage device provided in this embodiment includes: a memory 10 and a processor 20; as shown... Figure 2 The memory 10 shown includes multiple physical pages. Each physical page includes a control information unit 11 and multiple data units 12. The control information unit 11 stores information about data units being written. The processor 20 is electrically connected to the memory 10 and is used to determine the first physical page from which the write operation was last performed during a write operation. Based on the information about data units being written stored in the control information unit 11 of the first physical page, the processor determines the data unit to be written and then performs the write operation.

[0026] In this embodiment, the optional memory is non-volatile memory, such as NVRAM, but is not limited to this. Figure 2As shown, the memory 10 includes multiple physical pages, which are sequentially labeled page1, page2, page3, ... For example, a 512-byte memory can be divided into 10 pages, each page containing 32 bytes. Within a page, every four bytes are divided into a data unit. It can be understood that the control information unit 11 is essentially also composed of a data unit. The difference is that the control information unit 11 is fixedly used to store the control information of its respective page, while other data units 12 within a physical page, excluding the control information unit 11, can be used to store external data. It should be noted that the storage capacity of the multiple physical pages divided in the memory 20 can be the same or different, and the storage capacity of the data units 12 within different physical pages can be the same or different. Within the same page, the storage capacity of the data units 12 is the same, but the storage capacities of the control information unit 11 and the data units 12 within a page can be different.

[0027] The physical page of memory 20 includes a control information unit 11 and multiple data units 12. The control information unit 11 includes a current scatter cell for writing data units, meaning the control information unit 11 includes at least one storage area. A storage area 11a is fixedly used to store the address information of its writing data unit, which can be its number. It can be understood that the physical page is divided into multiple sub-units. The first sub-unit can be used as the control information unit 11, and each subsequent sub-unit can be used as a data unit 12. Therefore, the data units 12 following the control information unit 11 can be sequentially encoded, i.e., the data unit 12 adjacent to the control information unit 11 is numbered 1, and so on. Based on this, the writing data unit information stored in the control information unit 11 can be optionally the number of the writing data unit. In other embodiments, the writing data unit information stored in the control information unit can also be optionally the logical address of the writing data unit.

[0028] In this embodiment, the storage device includes a processor 20, which is electrically connected to the memory 10. The processor 20 is used to determine the first physical page to be written during the data writing phase. Based on the data unit information stored in the control information unit 11 of the first physical page, it determines the data unit to be written and then performs the write operation. The specific process is as follows: When performing the current data write operation, the processor 20 first determines the physical page from which the previous write operation was performed, i.e., the first physical page, for example, page1. The processor 20 reads the Current scatter cell from the storage area 11a of the control information unit 11 of page1. For example, if Current scatter cell = 1, it indicates that the data unit to be written corresponding to the current write operation is the first group of count+data modules 12 of page1. Then, the processor 20 writes the data to be written into the first group of count+data modules 12.

[0029] In this embodiment, the memory includes multiple physical pages. Each physical page includes a control information unit and multiple data units. The control information unit stores the data units to be written for its respective physical page. During the data writing phase, the processor determines the first physical page to be written to. Based on the data units to be written stored in the control information unit of the first physical page, it determines the data unit to be written and then performs the write operation. Therefore, the storage device partitions its memory into multiple physical pages. When the processor writes data, it does not write to the entire memory, but rather stores data in one specific storage area each time a write operation is performed. The data unit to be written is determined by the data units to be written using the data units to be written stored in the control information unit, achieving sequential storage and thus increasing the read / write lifespan of the memory.

[0030] For example, based on the above technical solution, the optional control information unit further stores the maximum number of writes, and the data unit stores the number of writes; the processor is further configured to obtain the number of writes stored in the data unit corresponding to the write data unit information, and compare the number of writes with the maximum number of writes; if the number of writes is less than the maximum number of writes, the data unit corresponding to the write data unit information is determined as the data unit to be written, and the number of writes of the data unit to be written is updated; or, if the number of writes is equal to the maximum number of writes, the next data unit sequentially set after the data unit corresponding to the write data unit information is determined as the data unit to be written, and the number of writes in the write data unit information and the data unit to be written is updated.

[0031] In this embodiment, the control information unit 11 stores the maximum number of writes (scatter count max), and the data unit 12 stores the number of writes (count). Specifically, the control information unit 11 includes at least two storage areas: one storage area 11a is fixedly used to store the number information of the data unit being written, and the other storage area 11b is fixedly used to store the maximum number of times the data unit 12 in the page can be written in one round of scatter writing. The data unit 12 includes a counting area 12a and a data storage area 12b. The counting area 12a is used to store the number of times the data unit has been written, i.e., the number of writes, and the data storage area 12b is used to store external data (data).

[0032] It can be understood that the counting area 12a of data unit 12 can be regarded as a read / write counter, which updates the number of times data unit 12 has been written when data is written to the data storage area 12b of its corresponding data unit 12. The external data stored in the data storage area 12b is variable-length data that needs to be recorded. For example, when the storage device is installed in a stepper motor drive product, the external data data can be the position information of the electronic expansion valve.

[0033] In this embodiment, the processor 20 is electrically connected to the memory 10 and is used to locate the data unit 12 in the first physical page corresponding to the data unit information being written, based on the data unit information being written stored in the control information unit 11 in the first physical page, and read the number of times it has been written from the data unit 12. The processor 20 compares the read number of times it has been written with the maximum number of times it has been written stored in the control information unit in the first physical page.

[0034] If the number of writes to the data unit corresponding to the write data unit information is less than the maximum number of writes stored in the control information unit of the first physical page, it means that the data unit corresponding to the write data unit information has not yet reached the maximum number of writes. In this case, the data to be written can be directly written to the data unit corresponding to the write data unit information. Then, the number of writes stored in the data unit corresponding to the write data unit information will be incremented by 1.

[0035] If the number of writes to the data unit corresponding to the write data unit information is equal to the maximum number of writes stored in the control information unit of the first physical page, it means that the data unit corresponding to the write data unit information has reached the maximum number of writes in the current write operation and cannot be written further. In this case, the next data unit after the data unit corresponding to the write data unit information will be identified as the data unit to be written. At this time, the data to be written can be directly written into this identified data unit. Then, the write data unit information will be updated to the number of the data unit to be written, and the number of writes to the data unit to be written will be incremented by 1.

[0036] In existing technologies, memory writes are performed on the entire memory, increasing the write frequency of unnecessary memory and thus preventing the total number of writes from reaching the ideal number. In this invention, each data unit is read and written as an independent sub-unit, using a distributed storage approach to increase the number of read and write operations.

[0037] In this embodiment, during a distributed write cycle, data units are stored sequentially, and the next data unit is only written after the previous data unit has reached its maximum write count. This ensures that each written data unit reaches its maximum write count in the current cycle, until the last data unit in the memory reaches its maximum write count. Therefore, in each distributed write cycle, the total number of writes to the memory can reach the memory's ideal maximum total write count, improving efficiency and extending read / write lifespan.

[0038] The optional control information unit also stores information on the total number of page scatter units; the processor is also used to determine, based on the information on the total number of page scatter units stored in the control information unit, whether the data unit corresponding to the data unit information being written is the last data unit of the first physical page, and if so, to determine the first data unit of the next physical page that is sequentially set after the first physical page as the next data unit.

[0039] In this embodiment, the control information unit 11 of each physical page stores the total number of scatter cells information of the page. Specifically, the control information unit 11 also includes a storage area 11d, which is used to fix the total number of data units 12 of the page to which the memory belongs. The total number of scatter cells information of the page represents the total number of scattered data units of the page to which it belongs. For example, if a page includes 1 control information unit and 10 data units, then the total number of scatter cells information of the page stored in its control information unit is 10.

[0040] In a distributed write cycle, if the number of times a data unit corresponding to the write data unit information has been written equals its maximum write count, it indicates that the data unit has reached its maximum write count in this distributed write cycle, and the data can then be written to the next data unit in sequence. If the data unit corresponding to the write data unit information is not the last data unit of its physical page, then the next data unit can be identified as the data unit to be written. If the data unit corresponding to the write data unit information is the last data unit of its physical page, it indicates that each data unit in the current physical page has reached its maximum write count in the current cycle, and the data can be written to the next physical page in sequence, specifically to the first data unit of the next physical page, thus achieving sequential storage between physical pages and sequential storage of data units within a physical page.

[0041] The optional processor is also used to reset the write count of a data unit to zero when it detects that the write count stored in the data unit corresponding to the write data unit information equals the maximum write count. Resetting the write count of data units that have reached the maximum write count allows the data unit to be rewritten in the next write cycle. It can be understood that the maximum write count is the maximum number of times a data unit can be written in one write cycle; using a reasonable maximum write count for each write cycle, and performing periodic read and write operations on each data unit, can improve its lifespan.

[0042] The optional control information unit also stores a data length value; the processor is also used to write the data to be written into the data to be written unit according to the data length value stored in the control information unit, wherein the length of the data written into the data to be written unit is equal to the data length value stored in the control information unit.

[0043] The optional control information unit 11 also includes two storage areas: one storage area 11c is fixed to store the data length to be written in the current write operation, and the other storage area 11d is fixed to store the scatter cell information of the total number of scatter cells in the page. The four storage areas of each optional control information unit 11 are arranged in the order of 11c, 11d, 11a, and 11b, and their logical addresses are sequentially adjacent. For example, if the first physical page determined by the current write operation is page1, in the control block of page1, Data length = 2, indicating that the data to be stored is 2 bytes; Scatter cell = 3, indicating that page1 contains 3 data units 12, that is, there are 3 groups of count+data modules 12 after control block 11; Current scatter cell = 1, indicating that the data unit currently being written is the first group of count+data modules; Scatter count max = 5, indicating that the maximum number of writes for each data unit 12 is 5. It can be understood that the storage capacity of the data storage area in each group of count+data modules 12 is greater than or equal to 2 bytes.

[0044] In this embodiment, the storage device includes a processor 20, which is electrically connected to the memory 10. The processor 20 is used to determine the first physical page from which the last write operation was performed during a write operation. When the number of writes to the data unit corresponding to the write data unit information in the first physical page is less than the maximum number of writes, the write count of the data unit corresponding to the write data unit information is incremented by 1, and the data to be written is written to that data unit. The specific process is as follows:

[0045] When the processor 20 performs the current data write operation, it first determines the physical page of the previous write operation, i.e., the first physical page, for example, the first physical page of the previous write operation is page1;

[0046] The processor 20 writes the data length of the data to be written into the storage area 11c of the control information unit 11 of page 1. For example, if the data length of the data to be written is 2 bytes, then data length = 2.

[0047] The processor 20 reads the Current scatter cell from the storage area 11a of the control information unit 11 of page 1. For example, if Current scatter cell = 1, it means that the data unit corresponding to the data unit information being written in the current write operation is the first group of count+data module 12 of page 1.

[0048] The processor 20 reads the number of times the data has been written in the counting area 12a of the first group count+data module 12, and also reads the maximum number of writes, Scatter count max, in the storage area 11b of the control information unit 11 of page 1. For example, if count = 2 and Scatter count max = 5, then count is less than scatter count max, so 2 bytes of data to be written are written into the data storage area 12b of the first group count+data module 12.

[0049] The processor 20 increments the value in the count of the first count+data module 12 by 1, that is, count = 2.

[0050] As described above, before each data write, the processor 20 identifies the data unit to be written, writes the data to be written into the identified data unit, and increments the count of the written data unit by 1. For example, the identified data unit to be written is the first group of count+data modules on page 1. After multiple write operations, when the processor detects that the count of the first group of count+data modules on page 1 equals the scatter count max, the processor 20 updates the Current scatter cell in the control unit of page 1 to 2, writes the data to be written into the second group of count+data modules, and then clears the count of the first group of count+data modules to zero. This process continues until a data unit has been written a maximum of the scatter count, at which point the processor 20 moves on to write the next group of count+data modules on the current page, until the last data unit on the current page is written, and then moves on to the first group of count+data modules on the next page. This write operation is repeated continuously. In this way, each page's data unit can reach the maximum number of writes within one round of scatter write cycle.

[0051] Any two data units 12 located within the same physical page can have equal storage capacities. The first byte of each data unit 12 is a counting area 12a, used to store the number of times this data unit has been written in one cycle. The bytes following the counting area 12a are all data storage areas 12b. Therefore, the storage capacity of each data unit 12 can be selected as the data length of the data storage area plus 1. This means that a data unit resides within one page and cannot span two pages. Based on this, the distribution principle for a page with a capacity of m bytes is scatter cell * (data length + 1) + 4 ≤ m. For example, if m = 32 bytes, the data storage area capacity of a data unit is data length = 2, and the control block capacity is 4 bytes, then the total number of data units in a page is less than or equal to 9.

[0052] Optionally, the logical addresses of two adjacent data units 12 located within the same physical page are adjacent, and the logical address of the control information unit 11 within the physical page is adjacent to the logical address of its first data unit 12. For example, if a page is divided into 32 bytes and each four bytes form a data unit, then the first data unit is essentially a control information unit 11 used to store the control information of this page, and from the second data unit onwards, all are data units 12 that can store external data within this page. Therefore, the second data unit is the first data unit 12 of the physical page.

[0053] In this embodiment, before each data storage operation, the processor identifies the data unit to be written, writes the data to be written in the current write operation to the data unit, and increments the write count of the data unit by 1. If, after multiple write operations, the write count of a data unit equals the maximum write count for the current page's data unit, the processor then writes the next data unit according to the set order, updates the write information of the control information unit, and resets the write count of data units that have reached the maximum write count to zero. Therefore, each page's data unit can reach the maximum write count within a single distributed write cycle, enabling the memory to meet its designed read / write cycle requirements and increasing the memory's read / write lifespan.

[0054] Based on the same inventive concept, embodiments of the present invention also provide a data writing method for a storage device. The storage device is the storage device described in any of the above embodiments. The storage device includes a memory, which includes multiple physical pages. Each physical page includes a control information unit and multiple data units. The control information unit stores information about the data units being written. The data writing method provided in this embodiment can be executed using a data writing device, which can be implemented in software and / or hardware and configured for use in the processor described in any of the above embodiments. Figure 3 The data writing method shown includes:

[0055] Step S1: Determine the first physical page from which the write operation was last performed;

[0056] Step S2: Based on the data unit information stored in the control information unit in the first physical page, determine the data unit to be written, and then perform the write operation.

[0057] The optional control information unit also stores the maximum number of writes, and the data unit stores the number of writes; based on the data unit information being written stored in the control information unit of the first physical page, the data unit to be written is determined, including:

[0058] Get the number of writes stored in the data unit corresponding to the write data unit information, and compare the number of writes with the maximum number of writes;

[0059] If the number of writes is less than the maximum number of writes, the data unit corresponding to the write data unit information will be identified as the data unit to be written, and the number of writes for the data unit to be written will be updated; or,

[0060] If the number of writes equals the maximum number of writes, the next data unit sequentially set after the data unit corresponding to the write data unit information will be determined as the data unit to be written, and the number of writes in the write data unit information and the data unit to be written will be updated.

[0061] The optional control information unit also stores information on the total number of page distribution units; based on the data unit information being written stored in the control information unit of the first physical page, the data units to be written are determined, including:

[0062] Based on the total number of page distribution units stored in the control information unit, determine whether the data unit corresponding to the write data unit information is the last data unit of the first physical page.

[0063] If so, the first data unit of the next physical page set sequentially after the first physical page is determined as the next data unit.

[0064] Optionally, it may also include: when it is detected that the number of writes stored in the data unit corresponding to the write data unit information is equal to the maximum number of writes, the number of writes for that data unit is cleared to zero.

[0065] The optional control information unit also stores a data length value; performing a write operation includes: writing the data to be written into the data unit to be written according to the data length value stored in the control information unit, wherein the length of the data written into the data unit to be written is less than or equal to the data length value stored in the control information unit.

[0066] In this embodiment, during the current data write operation, the data write device first determines the first physical page from the previous write operation. The control information unit of the found first physical page stores the data unit information being written for that page. The data write device then compares the maximum number of writes stored in the control information unit of the first physical page with the number of writes stored in the count area of ​​the data unit corresponding to the write data unit information to see if the number of writes for that data unit is less than the maximum number of writes.

[0067] If the number of times a data unit has been written is less than the maximum number of times it can be written, it means that the data unit has not yet reached the maximum number of times it can be written. At this time, the data to be written can be written to the data unit and the number of times it has been written can be incremented by 1. The control information of the control information unit on this page does not need to be changed.

[0068] If the write count of a data unit equals the maximum write count, it indicates that the data unit has reached the maximum write count in the current cycle. The write count of that data unit is then reset to zero, and the next data unit following it is designated as the data unit to be written, and data is written into that data unit. Subsequently, the write count of the data unit actually written and the control information in the control information unit on this page will both change accordingly.

[0069] The data writing method for the storage device provided in this embodiment stores the length of the data to be stored, the number of distributed data units on the page, the data unit currently being written, and the maximum number of writes for each data unit within one cycle in the control information unit of each page. When the data writing device controls the writing of data to a physical page, it starts writing data from the first data unit of the page. After each data unit has been written to the maximum number of writes required by the control information unit, it starts writing again from the first data unit of the next page. During each write operation, the information of the data unit being written is recorded in the control information unit. This distributed storage can meet the write count requirements of the memory design.

[0070] Specifically, if two adjacent pages have logically adjacent addresses, and the data unit information being written to the first physical page is the last data unit of that page and its write count equals the maximum write count, then the next physical page is determined as the physical page to be written. The data unit information being written in the control information of this physical page is the target data unit for the current write operation. At this time, the data unit information being written in the control information of the first physical page is updated to the number or address of the first data unit within that page, so that data can be written starting from the first data unit within that page in the next cycle.

[0071] Optionally, after writing the data to be written to a specific data unit, the write count of that data unit is incremented by 1, and the number or address of that data unit is written into the control information unit of the page where it is located, so that the next write operation can start writing from that data unit.

[0072] It is understood that in the current write operation, at least the following control information needs to be updated: If the write count of the data unit corresponding to the write data unit information is less than the maximum write count, the write count of the data unit actually being written is incremented by 1. If the write count of the data unit corresponding to the write data unit information is equal to the maximum write count, the write count of the data unit is cleared to zero, and the data to be stored is written to the next data unit. The write count of the data unit actually being written is incremented by 1, and the number of the data unit actually being written is written into the control information unit of its page. If the data unit whose write count is cleared and the data unit actually being written are located on different physical pages, the write data unit information in the control information of the page to which the write count of the data unit whose write count is cleared is updated to the information of the first data unit in the page.

[0073] The optional memory is NVRAM. This storage device is used in electronic expansion valve products, and the data to be stored is the position information of the electronic expansion valve when power is lost, such as... Figure 4 The optional data writing method based on this memory specifically includes the following steps:

[0074] S01, Start, meaning the storage device is always in a working state;

[0075] S02. The processor obtains the data to be saved. The optional data to be written is the position data of the electronic expansion valve when it is powered off.

[0076] S03. The processor checks whether the NVRAM is valid for writing. If yes, proceed to S04. If no, it indicates a memory error and proceed to S13.

[0077] S04. The processor obtains the scatter of the current data unit to be written.

[0078] S05. Check if the number of times the current scatter plot has been written is the maximum number of writes. If yes, proceed to S06; otherwise, proceed to S09.

[0079] S06. Check if the scatter to be written is the last data unit of this page. If yes, execute S07; otherwise, execute S08.

[0080] S07. The current scatter plot is set as the first data cell on the next page, and step S09 is executed.

[0081] S08. The current scatter plot is determined to be the next data unit on this page, and step S09 is executed.

[0082] S09. Increment the number of times the current scatter plot has been written by 1.

[0083] S10. Write the data to be written into the current scatter plot.

[0084] S11. Check whether the write operation was successful. If yes, execute S12; otherwise, execute S13.

[0085] S12. Current location data is saved successfully, and S14 is executed.

[0086] S13, Current location data failed to be saved, and S14 is executed;

[0087] S14. End the current write operation.

[0088] For example:

[0089] Before the motor equipment loses power, the host computer or the host computer sends a current position save command to the storage device. The command position information is stored in a page of memory1, where the logical address of the target page starts from 0x50000040.

[0090] The data content starting from logical address 0x50000040 in the target page is shown in the table below.

[0091] 0x50000040:

[0092] Among them, the first four data This is the control information for the control information unit. The first data 02 indicates that the length of the data to be written is 2 bytes. The second data 04 indicates that the page is divided into 4 data units, which are numbered 0, 1, 2, and 3 in sequence. The third data 00 indicates that the first data unit is currently being written. The fourth data 05 indicates that each data unit is written 5 times per round.

[0093] The first data unit: 01 89 59, where 01 indicates that this group has been written once, and the written data is 89 and 59. The next data to be written will still be this group, and the count will increment by 1 after each write. When the first data is 05, indicating that it has been written 5 times, the second data unit begins to be written, and the current group to be written in the control information is updated from 00 to 01. After the second data unit has been written 5 times, the third data unit, the fourth data unit, and so on, until all four data units have been written 5 times, then the next physical page begins to be written. When a new cycle begins, if the current page is determined to be the target page again, it will start writing again from the first data unit. This writing method is continuously used in a loop. It should be noted that the minimum data unit within a page is 4 bytes each time a page is written. It can be understood that the number of bytes in the position information remains consistent.

[0094] In this embodiment, when writing data to be written, such as location data, into a non-volatile memory such as NVRAM, the data writing method can meet the read and write cycle requirements of the memory within its design life, thereby achieving the required number of read and write cycles, reducing the frequency of writing to unnecessary memory within the memory, and increasing the efficiency of memory usage.

[0095] Based on the same inventive concept, embodiments of the present invention also provide a motor device, such as... Figure 5 The motor device shown includes a motor 100, a motor controller 200, and a storage device 300 as described in any of the above embodiments. Optionally, the motor device can be a stepper motor drive product; in this case, the motor 100 is a stepper motor, the data to be written can be the running position of the stepper motor when power is off, and the storage device 300 can optionally include non-volatile random access memory (NVRAM).

[0096] When the motor equipment loses power, the motor controller 200 triggers the storage device 300 to enter the data writing stage in order to save the position data of the motor 100;

[0097] When the motor device is powered on, the motor controller 200 retrieves the position data saved before the power failure from the storage device 300, and controls the motor 100 to initialize when the position data is detected to be invalid, or controls the motor 100 to run to the position corresponding to the position data when the position data is detected to be valid.

[0098] After power-on, motor-driven equipment requires initialization to determine the zero position of the stepper motor's travel. This initialization process affects the equipment's operating logic / state, system noise, operating efficiency, and lifespan. To reduce the frequency of initialization, a current position save command is sent proactively or by the host computer before power-off. The motor saves its current position information to NVRAM. Upon the next power-on, the position information only needs to be read from NVRAM, thus eliminating the need for a power-on position initialization process. Figure 4 The flowchart shown is a process for saving position information of a motor device before power failure. As described above, the storage device 300 uses the data writing method provided in any of the above embodiments to save position information after power failure, which can meet the requirements of the motor device for the number of times the position is remembered by the memory, and make the read and write life requirements of the memory meet the needs of the motor device.

[0099] As described above, in this embodiment... Figure 6 The driving method of the motor device shown specifically includes the following steps:

[0100] S201, Begin;

[0101] S202, The motor is powered on;

[0102] S203, The motor controller reads the position data saved in the storage device before the power failure;

[0103] S204. The motor controller determines whether the position data is valid. If yes, execute S205; otherwise, execute S206.

[0104] S205, The motor device drives the stepper motor to the position corresponding to the valid position data in the NVRAM, and then executes S207;

[0105] S206, The motor device drives the stepper motor to execute the initialization process;

[0106] S207. The motor equipment initialization is complete and it has entered normal operating status.

[0107] S208, The operation of the motor equipment has ended.

[0108] It is understandable that before a power outage, the motor equipment can actively or passively drive the storage device to store initialization location information, which can be retrieved for initialization upon the next power-on. Clearly, if the motor equipment determines that the location data saved before the power outage is valid, it uses this valid location data to locate its position after power-on, eliminating the need for an initialization process after power-on. This reduces system noise, improves equipment efficiency and lifespan, and minimizes the impact of each power-on initialization process on the motor equipment.

[0109] The driving method for motor equipment provided in this embodiment can reduce the initialization process, reduce the impact and noise of stepper motor initialization on the equipment, save equipment initialization time, and reduce the impact of initialization on product lifespan.

[0110] Note that the above description is merely a preferred embodiment of the present invention and the technical principles employed. Those skilled in the art will understand that the present invention is not limited to the specific embodiments described herein, and various obvious changes, readjustments, combinations, and substitutions can be made without departing from the scope of protection of the present invention. Therefore, although the present invention has been described in detail through the above embodiments, the present invention is not limited to the above embodiments, and may include many other equivalent embodiments without departing from the concept of the present invention, the scope of which is determined by the scope of the appended claims.

Claims

1. A storage device, characterized in that, include: Memory and processor; The memory includes multiple physical pages, each physical page including a control information unit and multiple data units. The control information unit stores information about data units being written. The control information unit includes at least one storage area, which is fixedly used to store the address information of the data units being written within the physical page. The processor is electrically connected to the memory and is used to determine the first physical page from which the write operation was last performed during a write operation. Based on the data unit information stored in the control information unit of the first physical page, the processor determines the data unit to be written and then performs the write operation.

2. The storage device according to claim 1, characterized in that, The control information unit also stores the maximum number of writes, and the data unit stores the number of writes already performed; The processor is further configured to obtain the number of writes stored in the data unit corresponding to the write data unit information, and compare the number of writes with the maximum number of writes. If the number of writes is less than the maximum number of writes, the data unit corresponding to the data unit information being written is determined as the data unit to be written, and the number of writes of the data unit to be written is updated. or, If the number of writes equals the maximum number of writes, the next data unit sequentially set after the data unit corresponding to the data unit information being written is determined as the data unit to be written, and the data unit information being written and the number of writes of the data unit to be written are updated.

3. The storage device according to claim 2, characterized in that, The control information unit also stores information on the total number of page distribution units; The processor is further configured to determine, based on the total number of page distribution units stored in the control information unit, whether the data unit corresponding to the data unit being written is the last data unit of the first physical page. If so, the first data unit of the next physical page sequentially set after the first physical page is determined as the next data unit.

4. The storage device according to claim 3, characterized in that, The processor is further configured to clear the write count of the data unit to zero when it detects that the number of writes stored in the data unit corresponding to the write data unit information is equal to the maximum number of writes.

5. The storage device according to claim 1, characterized in that, The control information unit also stores a data length value; The processor is further configured to write the data to be written into the data unit to be written according to the data length value stored in the control information unit, wherein the length of the data written into the data unit to be written is equal to the data length value stored in the control information unit.

6. The storage device according to claim 1, characterized in that, Any two data units located on the same physical page have the same storage capacity.

7. The storage device according to claim 1, characterized in that, The logical addresses of two adjacent data units located on the same physical page are adjacent, and the logical address of the control information unit in the physical page is adjacent to the logical address of its first data unit.

8. A method for writing data to a storage device, characterized in that, The storage device includes a memory, which includes multiple physical pages. Each physical page includes a control information unit and multiple data units. The control information unit stores information about data units being written. The control information unit includes at least one storage area, which is fixedly used to store address information of data units being written within the physical page. The data writing method includes: Determine the first physical page from which the last write operation was performed; Based on the data unit information stored in the control information unit of the first physical page, the data unit to be written is determined, and then the write operation is performed.

9. The data writing method according to claim 8, characterized in that, The control information unit also stores the maximum number of writes, and the data unit stores the number of writes already performed; Based on the data unit information being written stored in the control information unit of the first physical page, the data unit to be written is determined, including: Obtain the number of times the data has been written stored in the data unit corresponding to the data unit information, and compare the number of times the data has been written with the maximum number of times the data has been written. If the number of writes is less than the maximum number of writes, the data unit corresponding to the data unit information being written is determined as the data unit to be written, and the number of writes for the data unit to be written is updated; or, If the number of writes equals the maximum number of writes, the next data unit sequentially set after the data unit corresponding to the data unit information being written is determined as the data unit to be written, and the data unit information being written and the number of writes of the data unit to be written are updated.

10. A motor device, characterized in that, The motor device includes a motor, a motor controller, and a storage device as described in any one of claims 1-7; When the motor device loses power, the motor controller triggers the storage device to enter the data writing stage to save the position data of the motor. When the motor is powered on, the motor controller retrieves the position data saved before the power failure from the storage device, and controls the motor to initialize when the position data is detected to be invalid, or controls the motor to run to the position corresponding to the position data when the position data is detected to be valid.

Citation Information

Patent Citations

  • Memory controller, nonvolatile memory system provided with memory controller, and method for controlling nonvolatile memory

    JP2012037971A