Method, apparatus, and storage medium for calibrating position of an encoder

By generating a zero-point marker matching signal and utilizing the edge information of the A-phase, B-phase, and Z-phase signals, the problem of inaccurate encoder position calibration was solved, achieving accurate and adaptive calibration of the encoder position.

CN119642882BActive Publication Date: 2026-05-29SPINTROL ELECTRONIC TECH (SHANGHAI) CO LTD +1

Patent Information

Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
SPINTROL ELECTRONIC TECH (SHANGHAI) CO LTD
Filing Date
2024-12-10
Publication Date
2026-05-29

AI Technical Summary

Technical Problem

Due to physical limitations of gratings and limitations of optical sensors, encoders are prone to line loss during rotation, resulting in discrepancies between the position count of the decoding unit and the actual position. In existing technologies, inconsistent Z-phase signal widths, line delays, and jitter issues lead to inaccurate calibration.

Method used

By generating a zero-point mark matching signal, and using the effective edges of the A-phase, B-phase, and Z-phase signals, the real-time rotation direction of the encoder, and the reference rotation direction, the reference zero point and phase difference are determined, and the encoder position is accurately calibrated.

Benefits of technology

It achieves accurate calibration of encoder position, can adapt to encoders of different specifications, resists line delay and jitter, and supports various motion states.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN119642882B_ABST
    Figure CN119642882B_ABST
Patent Text Reader

Abstract

Embodiments of the present disclosure relate to a method, device and storage medium for calibrating a position of an encoder. The method comprises determining a reference zero point and a reference phase corresponding to the reference zero point with respect to A-phase and B-phase signals from the encoder; generating a zero mark matching signal according to valid edges of the A-phase and B-phase signals, a real-time rotation direction of the encoder and a reference rotation direction when the reference zero point is determined during a valid period of the Z-phase signal; and calibrating a position counter with respect to the position of the encoder according to a phase difference between a real-time phase corresponding to the zero mark matching signal with respect to the A-phase and B-phase signals and the reference phase. The present disclosure can calibrate the position of the encoder accurately.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The embodiments of this disclosure generally relate to the control field of encoder calibration, and more specifically to a method, apparatus, and storage medium for calibrating the position of an encoder. Background Technology

[0002] Due to physical limitations of gratings and optical sensor limitations, encoders on motors often experience line loss during rotation, leading to a discrepancy between the decoder unit's position count and the actual position. Current technology introduces a Z-phase signal to facilitate decoder unit calibration, but the inconsistent specifications of encoders from different companies result in varying Z-phase signal widths. Furthermore, line delay and jitter issues prevent the Z-phase signal from accurately calibrating the encoder's counting position. Summary of the Invention

[0003] To address the aforementioned issues, this disclosure provides a method, apparatus, and storage medium for calibrating the position of an encoder, enabling accurate calibration of the encoder's position.

[0004] According to a first aspect of this disclosure, a method for calibrating the position of an encoder is provided. The method includes: determining a reference zero point and a reference phase corresponding to the reference zero point with respect to the A-phase and B-phase signals based on an A-phase signal, a B-phase signal, and a Z-phase signal from the encoder; generating a zero-point mark matching signal based on the valid edges of the A-phase and B-phase signals, the real-time rotation direction of the encoder, and the reference rotation direction when the reference zero point is determined; and calibrating a position counter for the encoder's position based on the phase difference between the real-time phase of the zero-point mark matching signal corresponding to the A-phase and B-phase signals and the reference phase.

[0005] In some embodiments, during the valid period of the Z-phase signal, generating a zero-point mark matching signal based on the valid edges of the A-phase and B-phase signals, the real-time rotation direction of the encoder, and the reference rotation direction when determining the reference zero point includes: in response to determining that the real-time rotation direction is the same as the reference rotation direction, generating a zero-point mark matching signal at a target valid edge of the A-phase and B-phase signals, wherein the target valid edge is the valid edge corresponding to the determination of the reference zero point.

[0006] In some embodiments, during the valid period of the Z-phase signal, generating a zero-point marker matching signal based on the valid edges of the A-phase and B-phase signals, the real-time rotation direction of the encoder, and the reference rotation direction when determining the reference zero point further includes: in response to determining that the real-time rotation direction is opposite to the reference rotation direction, generating a zero-point marker matching signal based on the matching relationship between the real-time phase corresponding to the valid edge and the reference phase, the real-time pulse width count value for the valid period of the Z-phase signal, and the pulse width of the Z-phase signal, wherein the pulse width of the Z-phase signal is the number of overlaps between the valid period of the Z-phase signal and the valid edge.

[0007] In some embodiments, in response to determining that the real-time rotation direction is opposite to the reference rotation direction, generating a zero-point marker matching signal based on the matching relationship between the real-time phase corresponding to the effective edge and the reference phase, the real-time pulse width count value for the effective period of the Z-phase signal, and the pulse width of the Z-phase signal includes: performing a real-time count based on the effective edge for the effective period of the Z-phase signal to obtain the real-time pulse width count value; and generating a zero-point marker matching signal at the point where the real-time phase corresponding to the effective edge matches the reference phase during the period when the difference between the real-time pulse width count value and the pulse width of the Z-phase signal is less than or equal to a predetermined value.

[0008] In some embodiments, calibrating a position counter for the encoder's position based on the phase difference between the real-time phase of the A-phase signal and the B-phase signal corresponding to the zero-point mark matching signal and the reference phase includes: determining a first reset value for the position counter for the encoder's position in response to determining that the real-time rotation direction is the same as the reference rotation direction, so as to reset the position counter at the zero-point mark matching signal, the first reset value being the phase difference; and determining a second reset value for the position counter for the encoder's position in response to determining that the real-time rotation direction is opposite to the reference rotation direction, so as to reset the position counter at the zero-point mark matching signal, the second reset value being the difference between a predetermined maximum position count and the phase difference.

[0009] In some embodiments, determining a reference zero point based on the A-phase signal, B-phase signal, and Z-phase signal from the encoder includes: determining the reference zero point at the location corresponding to a target valid edge of the A-phase signal and the B-phase signal during the valid period of the Z-phase signal, wherein the target valid edge is the first valid edge of the valid period of the Z-phase signal, and the valid edge is any one of the following: a transition edge of the A-phase signal; and a transition edge of the B-phase signal.

[0010] In some embodiments, the method further includes: sequentially determining phase information corresponding to each of the effective edges to determine the phase difference; and determining the real-time zero point of the encoder based on the calibrated position counter.

[0011] According to a second aspect of this disclosure, an electronic device is provided. The electronic device includes: at least one processor; and a memory communicatively connected to the at least one processor; the memory stores instructions executable by the at least one processor, which, when executed by the at least one processor, enable the at least one processor to perform the method of the first aspect of this disclosure.

[0012] According to a third aspect of this disclosure, a computer-readable storage medium is provided. The computer-readable storage medium stores a computer program that, when executed by a machine, implements the method according to a first aspect of this disclosure.

[0013] According to a fourth aspect of this disclosure, a computer program product is provided, which is tangibly stored on a non-transient computer-readable medium and includes machine-executable instructions that, when executed, cause a machine to perform the steps of the method according to a first aspect of this disclosure.

[0014] According to the technical solution of this disclosure, after determining the reference zero point and the reference phase corresponding to the reference zero point, during the effective period of the Z phase signal, a zero point mark matching signal is generated based on the effective edges of the A phase signal and the B phase signal, the real-time rotation direction of the encoder, and the reference rotation direction when the reference zero point is determined; and based on the phase difference between the real-time phase of the A phase signal and the B phase signal corresponding to the zero point mark matching signal and the reference phase, the position counter for the encoder position is calibrated, which can accurately calibrate the encoder position.

[0015] It should be understood that the description in this section is not intended to identify key or essential features of the embodiments of this disclosure, nor is it intended to limit the scope of this disclosure. Other features of this disclosure will become readily apparent from the following description. Attached Figure Description

[0016] The above and other features, advantages, and aspects of the embodiments of this disclosure will become more apparent from the accompanying drawings and the following detailed description. In the drawings, the same or similar reference numerals denote the same or similar elements.

[0017] Figure 1 A schematic diagram of an encoder according to an embodiment of the present disclosure is shown.

[0018] Figure 2 A schematic diagram illustrating several states of encoder rotation according to embodiments of the present disclosure is shown.

[0019] Figure 3 The diagram shows waveforms of phase A, phase B, and phase Z signals according to an embodiment of the present disclosure.

[0020] Figure 4A schematic diagram of an electronic device for calibrating the position of an encoder, which can be used to implement embodiments of the present disclosure, is shown.

[0021] Figure 5 A flowchart illustrating a method for calibrating the position of an encoder according to an embodiment of the present disclosure is shown.

[0022] Figure 6 A schematic diagram showing the phases of the A-phase signal and the B-phase signal according to an embodiment of the present disclosure is shown.

[0023] Figure 7 A schematic diagram showing the phases of the A-phase signal and the B-phase signal according to an embodiment of the present disclosure is shown.

[0024] Figure 8 The diagram shows a waveform corresponding to an electronic device performing a method for calibrating the position of an encoder according to an embodiment of the present disclosure.

[0025] Figure 9 A schematic block diagram of an example electronic device is shown, illustrating a method for calibrating the position of an encoder that can be used to implement embodiments of the present disclosure. Detailed Implementation

[0026] The exemplary embodiments of this disclosure are described below with reference to the accompanying drawings, including various details of the embodiments to aid understanding, and should be considered merely exemplary. Therefore, those skilled in the art will recognize that various changes and modifications can be made to the embodiments described herein without departing from the scope and spirit of this disclosure. Similarly, for clarity and brevity, descriptions of well-known functions and structures are omitted in the following description.

[0027] The term "comprising" and its variations as used herein signify open inclusion, i.e., "including but not limited to". Unless otherwise stated, the term "or" means "and / or". The term "based on" means "at least partially based on". The terms "one example embodiment" and "one embodiment" mean "at least one example embodiment". The term "another embodiment" means "at least one additional embodiment". The terms "first", "second", etc., may refer to different or the same objects. Other explicit and implicit definitions may also be included below.

[0028] As mentioned earlier, in the existing technology, the encoder introduces a Z-phase signal to facilitate calibration by the decoding unit. However, due to the inconsistent specifications of encoders produced by different companies, the width of the Z-phase signal is inconsistent. Furthermore, due to line delay and jitter issues, the Z-phase signal cannot be used to calibrate the encoder's counting position very accurately.

[0029] To at least partially address one or more of the aforementioned problems and other potential issues, exemplary embodiments of this disclosure provide a method, apparatus, and storage medium for calibrating the position of an encoder. In this scheme, after determining a reference zero point and a corresponding reference phase, during the valid period of the Z-phase signal, a zero-point mark matching signal is generated based on the valid edges of the A-phase and B-phase signals, the real-time rotation direction of the encoder, and the reference rotation direction when the reference zero point is determined. A position counter is calibrated for the encoder's position based on the phase difference between the real-time phases of the A-phase and B-phase signals corresponding to the zero-point mark matching signal and the reference phase, enabling accurate calibration of the encoder's position.

[0030] Figure 1 A schematic diagram of an encoder 100 according to an embodiment of the present disclosure is shown. The encoder 100 includes, for example, a code disk 102 and a plurality of gratings disposed on the code disk 102. The plurality of gratings includes, for example, an A-phase grating 104, a B-phase grating 106, and a Z-phase grating 108. For ease of explanation, the location of the sensor is also indicated by line 110 in the figure. It should be understood that the sensor is used to detect the A-phase grating 104, the B-phase grating 106, and the Z-phase grating 108 to generate corresponding A-phase signals EQEP_A, B-phase signals EQEP_B, and Z-phase signals EQEP_Z. Taking the A-phase signal EQEP_A as an example, when the sensor does not detect the A-phase grating 104 (e.g., line 110 is aligned with the outside of the A-phase grating 104), the generated A-phase signal EQEP_A is, for example, low. When the sensor detects the A-phase grating 104 (e.g., line 110 is aligned with the inside of the A-phase grating 104), the generated A-phase signal EQEP_A is, for example, high. Therefore, the rising and falling edges of the A-phase signal EQEP_A are generated corresponding to the edges of the A-phase grating 104. It should be understood that in some embodiments, the polarity of the generated A-phase signal EQEP_A may be reversed. The B-phase signal EQEP_B and the Z-phase signal EQEP_Z can be referred to in relation to the A-phase signal EQEP_A, and will not be repeated here. The A-phase signal EQEP_A, B-phase signal EQEP_B, and Z-phase signal EQEP_Z generated by the encoder 100 are sent to the control unit, for example. The control unit determines the position of the encoder based on the A-phase signal EQEP_A, B-phase signal EQEP_B, and Z-phase signal EQEP_Z in order to control the motor.

[0031] Figure 2 A schematic diagram illustrating several states of encoder rotation according to embodiments of the present disclosure is shown.

[0032] The diagram shows eight states, from state 1 to state 8. For simplification, only the code disk 102 and the Z-phase grating 108 are shown in the encoder. It should be understood that the encoder's rotation is not limited to the eight states shown in the diagram.

[0033] Figure 3 The diagram illustrates waveforms of the A-phase, B-phase, and Z-phase signals according to embodiments of this disclosure. Here, EQEP_ZS represents the desired standard Z-phase signal. However, due to factors such as signal jitter and line delay, the actual Z-phase signal received by the control unit may sometimes be as shown in EQEP_Z1, or sometimes as shown in EQEP_Z2. For example, near time T1, the rising edge of EQEP_Z1 precedes the rising edge of the standard Z-phase signal EQEP_ZS; and near time T2, the falling edge of EQEP_Z1 precedes the falling edge of the standard Z-phase signal EQEP_ZS. As another example, near time T1, the rising edge of EQEP_Z2 lags behind the rising edge of the standard Z-phase signal EQEP_ZS; and near time T2, the falling edge of EQEP_Z1 lags behind the falling edge of the standard Z-phase signal EQEP_ZS. It should be understood that these leading or lagging conditions will affect the calibration of the encoder's position.

[0034] Figure 4 A schematic diagram of an electronic device 400 for implementing a method for calibrating the position of an encoder, as shown in embodiments of the present disclosure, is illustrated. The electronic device 400 receives A-phase signal EQEP_A, B-phase signal EQEP_B, and Z-phase signal EQEP_Z from an encoder 100, calibrates a position counter relating to the encoder's position, and sends the calibrated position counter value to a control unit 404. The control unit 404 controls a motor 402 based on the calibrated position counter value.

[0035] Figure 5 A flowchart illustrating a method 500 for calibrating the position of an encoder, according to an embodiment of this disclosure, is shown. Method 500 may be derived from, for example... Figure 4 The electronic device 400 shown can perform this action, and can also be used in... Figure 9 The method is performed at the illustrated electronic device 900. It should be understood that method 500 may also include additional steps not shown and / or the steps shown may be omitted, and the scope of this disclosure is not limited in this respect.

[0036] In step 502, a reference zero point and a reference phase corresponding to the reference zero point with respect to the A-phase signal and the B-phase signal are determined based on the A-phase signal, B-phase signal and Z-phase signal from the encoder.

[0037] At step 504, during the valid period of the Z-phase signal, a zero-point mark matching signal is generated based on the valid edges of the A-phase and B-phase signals, the real-time rotation direction of the encoder, and the reference rotation direction when determining the reference zero point.

[0038] In step 506, the position counter for the encoder position is calibrated based on the phase difference between the real-time phase of the A-phase signal and the B-phase signal corresponding to the zero-point mark matching signal and the reference phase.

[0039] In some embodiments, at step 502, a target valid edge of the A-phase and B-phase signals during the valid period of the Z-phase signal is used as a reference zero, and the corresponding phase (or "state") of the A-phase and B-phase signals at that point is used as a reference phase. In some embodiments, the target valid edge is, for example, the first valid edge of the A-phase and B-phase signals during the valid period of the Z-phase signal. It should be understood that the target valid edge may also be the second or third valid edge of the A-phase and B-phase signals during the valid period of the Z-phase signal, etc.

[0040] Figure 6 A schematic diagram of the phases of the A-phase and B-phase signals according to an embodiment of this disclosure is shown. For example, the diagram shows the A-phase and B-phase signals generated when the encoder 100 rotates in the positive direction. At time T0, the A-phase signal EQEP_A transitions from a low level to a high level, i.e., a rising edge; therefore, the phase (or "state") SA of the A-phase signal EQEP_A is characterized by "↑". At time T0, the B-phase signal EQEP_B is at a low level; therefore, the phase of the B-phase signal EQEP_B is characterized by "0". Accordingly, at time T0, the phase SAB of both the A-phase and B-phase signals is characterized by "↑0". Furthermore, during the period from time T0 to time T1, the phase SAB of both the A-phase and B-phase signals remains "↑0".

[0041] At time T1, phase A signal EQEP_A is at a high level, and its phase SA is represented by "1". Also at time T1, phase B signal EQEP_B transitions from a low level to a high level (rising edge), therefore, its phase (or "state") SB is represented by "↑". Correspondingly, at time T1, the phase SAB of both phase A and phase B signals is represented by "1↑". Furthermore, during the period from time T1 to time T2, the phase SAB of both phase A and phase B signals remains "1↑".

[0042] At time T2, the A-phase signal EQEP_A transitions from a high level to a low level, i.e., a falling edge. Therefore, the phase (or "state") SA of the A-phase signal EQEP_A is represented by "↓". Also at time T2, the B-phase signal EQEP_B is at a high level; therefore, the phase of the B-phase signal EQEP_B is represented by "1". Correspondingly, at time T1, the phase SAB of both the A-phase and B-phase signals is represented by "↓1". Furthermore, during the period from time T2 to time T3, the phase SAB of both the A-phase and B-phase signals remains "↓1".

[0043] At time T3, the A-phase signal EQEP_A is at a low level; therefore, the phase SA of the A-phase signal EQEP_A is represented by "0". Also at time T3, the B-phase signal EQEP_B changes from a high level to a low level; therefore, the phase of the B-phase signal EQEP_B is represented by "↓". Correspondingly, at time T3, the phase SAB of both the A-phase and B-phase signals is represented by "0↓". Furthermore, during the period from time T3 to time T4, the phase SAB of both the A-phase and B-phase signals is "0↓".

[0044] It should be understood that if the encoder 100 continues to rotate in the positive direction, it will generate the same A-phase signal and B-phase signal at time T4 as at time T0. Accordingly, in subsequent time intervals, the phase SAB of the A-phase signal and the B-phase signal will also cycle in the aforementioned order.

[0045] It is worth noting that any transition edge of either phase A or phase B is a valid edge of both phase A and phase B. For example, a rising edge of phase A signal EQEP_A at time T0 is a valid edge of both phase A and phase B; a rising edge of phase B signal EQEP_B at time T1 is a valid edge of both phase A and phase B; a falling edge of phase A signal EQEP_A at time T3 is a valid edge of both phase A and phase B; and a falling edge of phase B signal EQEP_B at time T3 is a valid edge of both phase A and phase B.

[0046] Therefore, the period from time T0 to time T4 can be considered as one cycle. It should be understood that within the same cycle, the phase difference between phase A and phase B signals can be determined based on the phase SAB values ​​for the A and B signals at each of the two times. This phase difference corresponds to the number of effective edges of the A and B signals experienced between these two times. For example, the phase difference between the phase SAB "1↑" for phase A and phase B signals at time T1 and the phase SAB "↑0" for phase A and phase B signals at time T0 is 1. Therefore, the number of effective edges of the A and B signals experienced between time T1 and time T0 is 1.

[0047] Figure 7 A schematic diagram of the phases of the A-phase and B-phase signals according to an embodiment of the present disclosure is shown. For example, the diagram shows the A-phase and B-phase signals generated when the encoder 100 rotates in the opposite direction. At time T0, the A-phase signal EQEP_A is at a low level, therefore, the phase SA of the A-phase signal EQEP_A is represented as "0". Also, at time T0, the B-phase signal EQEP_B jumps from a low level to a high level, i.e., a rising edge, therefore, the phase SB of the B-phase signal EQEP_B is represented as "↑". Accordingly, at time T0, the phase SAB of both the A-phase and B-phase signals is represented as "0↑". Furthermore, during the period from time T0 to time T1, the phase SAB of both the A-phase and B-phase signals is "0↑".

[0048] At time T1, the A-phase signal EQEP_A transitions from low to high (rising edge), therefore, the phase SA of the A-phase signal EQEP_A is represented by "↑". Also at time T1, the B-phase signal EQEP_B is high, and its phase SB is represented by "1". Correspondingly, at time T1, the phase SAB of both the A-phase and B-phase signals is represented by "↑1". Furthermore, during the period from time T1 to time T2, the phase SAB of both the A-phase and B-phase signals remains "↑1".

[0049] At time T2, phase A signal EQEP_A is at a high level; therefore, its phase is represented by "1". Also at time T2, phase B signal EQEP_B transitions from a high level to a low level (falling edge); therefore, its phase SB is represented by "↓". Correspondingly, at time T1, the phase SAB of both phase A and phase B signals is represented by "1↓". Furthermore, during the period from time T2 to time T3, the phase SAB of both phase A and phase B signals remains "1↓".

[0050] At time T3, the A-phase signal EQEP_A transitions from a high level to a low level; therefore, the phase of the A-phase signal EQEP_A is represented by "↓". Also at time T3, the B-phase signal EQEP_B is at a low level; therefore, the phase SB of the B-phase signal EQEP_B is represented by "0". Correspondingly, at time T3, the phase SAB of both the A-phase and B-phase signals is represented by "↓0". Furthermore, during the period from time T3 to time T4, the phase SAB of both the A-phase and B-phase signals remains "↓0".

[0051] It should be understood that if encoder 100 continues to rotate in the opposite direction, it will generate the same A-phase signal and B-phase signal at time T4 as at time T0. Accordingly, in subsequent time intervals, the phase SAB of the A-phase signal and the B-phase signal will also cycle in the aforementioned order.

[0052] Figure 8 The diagram shows waveforms corresponding to an electronic device performing a method for calibrating the position of an encoder according to an embodiment of the present disclosure. Here, clk represents the operating clock (high-frequency clock) signal of the electronic device 400. A positive pulse of the QEVT signal indicates the capture of valid edges with respect to both phase A and phase B signals. QDIR is used to represent the rotation direction of the encoder 100, where a high level QDIR indicates a positive rotation direction and a low level QDIR indicates a negative rotation direction. Regarding the ZHIT signal, during the determination of the reference zero point, its valid pulse (e.g., a positive pulse) represents the corresponding point as the reference zero point; after the reference zero point is determined, its valid pulse (e.g., a positive pulse) represents the zero-point mark matching signal. ZWCNT represents the real-time pulse width count value. QPOSCNT represents the count value of the position counter. SAB represents the phase with respect to both phase A and phase B signals. QEPSTS.ZW represents the pulse width of the Z-phase signal. QEPSTS.FZDIR represents the reference rotation direction, i.e., the rotation direction of the encoder 100 when the reference zero point is determined. A high level for QEPSTS.FZDIR indicates that the reference rotation direction is positive; a low level for QEPSTS.FZDIR indicates that the reference rotation direction is negative. QEPSTS.FZDET represents the flag indicating the determination of the reference zero point. A high level for QEPSTS.FZDET indicates that the reference zero point has been determined. While QEPSTS.FZDET is high, the position counter for the encoder position can be calibrated based on the determined reference zero point.

[0053] At time 804, due to factors such as signal jitter and line delay, there is a deviation between the Z-phase signal actually received by the control unit (indicated by a solid line) and the standard Z-phase signal (indicated by a dashed line). Similarly, at time 802, due to factors such as signal jitter and line delay, there is a deviation between the Z-phase signal actually received by the control unit (indicated by a solid line) and the standard Z-phase signal (indicated by a dashed line).

[0054] It is worth noting that the electronic device 400 uses a high-frequency clock clk as its operating clock. For example, the electronic device 400 samples the A-phase signal EQEP_A, the B-phase signal EQEP_B, and the Z-phase signal EQEP_Z based on the high-frequency clock clk in order to determine the level state and transition edges of the A-phase signal EQEP_A, the B-phase signal EQEP_B, and the Z-phase signal EQEP_Z.

[0055] In the figure, the positive pulse representation of QEVT is based on sampling the A-phase signal EQEP_A and the B-phase signal EQEP_B using a high-frequency clock clk, capturing the effective edges of the A-phase and B-phase signals. In some embodiments, pulse QEVT1 is considered the first effective edge of the A-phase and B-phase signals during the period when the Z-phase signal is active (e.g., when the Z-phase signal is high). However, the rising edge of the preceding pulse of QEVT1 is aligned with the rising edge of the Z-phase signal; therefore, this pulse is not considered the first effective edge of the A-phase and B-phase signals during the period when the Z-phase signal is active.

[0056] Therefore, corresponding to pulse QEVT1, a positive pulse ZHIT1 is generated in the ZHIT signal to characterize and determine that point as the reference zero. Furthermore, the reference phase corresponding to the reference zero (positive pulse ZHIT1) is "↓1".

[0057] In some embodiments, a reference rotation direction of the encoder 100 is further determined when determining the reference zero point. As previously described, according to Figure 6 as well as Figure 7 The phase variation of the A-phase signal and the B-phase signal is related to the rotation direction of the encoder 100. Therefore, in some embodiments, the rotation direction of the encoder 100 can be determined based on the phase variation of the A-phase signal and the B-phase signal corresponding to two adjacent effective edges of the A-phase signal and the B-phase signal.

[0058] At step 504, during the valid period of the Z-phase signal, a zero-point mark matching signal is generated based on the valid edges of the A-phase and B-phase signals, the real-time rotation direction of the encoder, and the reference rotation direction when determining the reference zero point.

[0059] In some embodiments, step 504 includes: in response to determining that the real-time rotation direction is the same as the reference rotation direction, generating a zero-point mark matching signal at a target effective edge with respect to the A-phase signal and the B-phase signal, wherein the target effective edge is the effective edge corresponding to the determination of the reference zero point.

[0060] It should be understood that the real-time rotation direction can also be determined based on the phase changes of the A-phase signal and the B-phase signal corresponding to the effective edges of two adjacent A-phase signals and the B-phase signal.

[0061] The pulse width of the Z-phase signal can be determined by counting the effective period of the Z-phase signal based on the effective edges of the A-phase and B-phase signals during the rotation of the encoder 100 in the same direction. It is worth noting that the pulse width of the Z-phase signal is determined, for example, during the determination of the reference zero point in step 502. For example, after determining the reference zero point in the positive direction, if the encoder 100 continues to rotate in the positive direction, the pulse width counter continues counting forward based on the effective edges of the A-phase and B-phase signals (i.e., the count value increases by 1 each time an effective edge of the A-phase and B-phase signals occurs). This continues until a complete count in the positive direction is completed for the effective period of the Z-phase signal. It should be understood that if the encoder 100 rotates in the opposite direction, the pulse width counter continues counting backward based on the effective edges of the A-phase and B-phase signals (i.e., the count value decreases by 1 each time an effective edge of the A-phase and B-phase signals occurs).

[0062] It is worth noting that, such as Figure 8 As shown, the reference zero point is actually determined at pulse ZHIT1. As an example only, QEPSTS.FZDET is set high after the pulse width of the Z-phase signal is determined. It should be understood that in some embodiments, QEPSTS.FZDET may also be set high after pulse ZHIT1.

[0063] During the valid period of the Z-phase signal, in the process of generating a zero-point mark matching signal based on the valid edges of the A-phase and B-phase signals, the real-time rotation direction of the encoder, and the reference rotation direction when determining the reference zero point, if the real-time rotation direction is the same as the reference rotation direction, then the zero-point mark matching signal is generated at the target valid edges of the A-phase and B-phase signals. For example, the zero-point mark matching signal is generated at the first valid edge of the A-phase and B-phase signals during the valid period of the Z-phase signal (i.e., the valid edge corresponding to the determination of the reference zero point).

[0064] For example, during PE1, encoder 100 rotates in the positive direction. At time 804, due to factors such as signal jitter and line delay, there is a deviation between the Z-phase signal actually received by the control unit (indicated by solid line) and the standard Z-phase signal (indicated by dashed line). Therefore, the positive pulse QEVT2 represents the capture of the target effective edges of the A-phase and B-phase signals, and thus, the zero-point mark matching signal ZHIT2 is generated.

[0065] Accordingly, at step 506, in response to determining that the real-time rotation direction is the same as the reference rotation direction, a first reset value for the position counter with respect to the encoder position is determined so that the position counter is reset at the zero-point mark matching signal. When the phase difference is negative, the first reset value is the sum of the predetermined maximum position count value, 1, and the aforementioned phase difference. When the phase difference is non-negative, the first reset value is the aforementioned phase difference.

[0066] For example, at the positive pulse QEVT2, the real-time phase of the zero-point mark matching signal QEVT2 corresponding to the A-phase and B-phase signals is determined to be "1↑". Furthermore, the real-time rotation direction is determined to be the positive direction, the same as the reference rotation direction (positive direction). The phase difference between the aforementioned real-time phase ("1↑") and the reference phase ("↓1") is "-1". That is, the target effective edges of the A-phase and B-phase signals corresponding to the zero-point mark matching signal ZHIT2 are "one counting pulse" earlier in phase than the target effective edges of the A-phase and B-phase signals corresponding to the positive pulse ZHIT1 (i.e., the reference zero point). In other words, the target effective edges of the A-phase and B-phase signals corresponding to the zero-point mark matching signal ZHIT2 are "one effective edge" earlier in phase than the target effective edges of the A-phase and B-phase signals corresponding to the positive pulse ZHIT1 (i.e., the reference zero point). Therefore, at the positive pulse QEVT2, the encoder's position counter is reset to "125". The maximum value of the position counter for the encoder's position is "125".

[0067] It is worth noting that, with Figure 8For example, due to factors such as encoder malfunction, the A-phase signal EQEP_A / B-phase signal EQEP_ABI may receive fewer pulses, causing the real-time count value QPOSCNT of the position counter to count less, resulting in an error in the position counter regarding the encoder's position. For instance, before the positive pulse ZHIT2 appears, QPOSCNT only counts to 122. The appearance of the positive pulse ZHIT2 (i.e., the zero-point mark matching signal) resets the count value of the position counter regarding the encoder's position to a reasonable value, calibrating the position counter and correcting the aforementioned error. It should be understood that during the forward rotation of encoder 100, the position counter regarding the encoder's position counts in the forward direction.

[0068] It should be understood that if the phase difference between the real-time phase and the reference phase is "1", it means that the target effective edges of the A-phase and B-phase signals corresponding to the zero-point mark matching signal ZHIT2 lag behind the target effective edges of the A-phase and B-phase signals corresponding to the positive pulse ZHIT1 (i.e., the reference zero point) by "one counting pulse" in phase. In other words, the target effective edges of the A-phase and B-phase signals corresponding to the zero-point mark matching signal ZHIT2 lag behind the target effective edges of the A-phase and B-phase signals corresponding to the positive pulse ZHIT1 (i.e., the reference zero point) by "one effective edge" in phase. Accordingly, the first reset value is "1".

[0069] For example, if the phase difference between the real-time phase and the reference phase is "0", that is, the real-time phase at the zero-point mark matching signal matches the reference zero point, then the position counter of the encoder is reset to "0".

[0070] In some embodiments, step 504 further includes: in response to determining that the real-time rotation direction is opposite to the reference rotation direction, generating a zero-point marker matching signal based on the matching relationship between the real-time phase corresponding to the effective edge and the reference phase, the real-time pulse width count value for the effective period of the Z-phase signal, and the pulse width of the Z-phase signal, wherein the pulse width of the Z-phase signal is the number of overlaps between the effective period of the Z-phase signal and the effective edge.

[0071] During the effective period of the Z-phase signal, in the process of generating the zero-point mark matching signal based on the effective edges of the A-phase and B-phase signals, the real-time rotation direction of the encoder, and the reference rotation direction when determining the reference zero point, if the real-time rotation direction is opposite to the reference rotation direction, then the zero-point mark matching signal is generated based on the matching relationship between the real-time phase corresponding to the effective edge and the reference phase, the real-time pulse width count value for the effective period of the Z-phase signal, and the pulse width of the Z-phase signal.

[0072] Specifically, the process includes: performing real-time counting based on the effective edge for the effective period of the Z-phase signal to obtain a real-time pulse width count value; and generating a zero-point marker matching signal at the point where the real-time phase corresponding to the effective edge matches the reference phase during the period when the difference between the real-time pulse width count value and the pulse width of the Z-phase signal is less than or equal to a predetermined value.

[0073] For example, QDIR shown in the figure is used to characterize the rotation direction of encoder 100. When QDIR is high, the rotation direction of encoder 100 is positive; when QDIR is low, the rotation direction of encoder 100 is negative. ZWCNT shown in the figure represents the real-time pulse width count value. The predetermined value is, for example, 2. Taking the figure as an example, the pulse width of the Z-phase signal is, for example, "2".

[0074] For example, during PE2, encoder 100 rotates in the opposite direction. At time 802, due to factors such as signal jitter and line delay, there is a deviation between the Z-phase signal actually received by the control unit (shown as a solid line) and the standard Z-phase signal (shown as a dashed line). During the valid period of the Z-phase signal, a pulse width counter is used to count the valid period of the Z-phase signal based on the valid edges of the A-phase and B-phase signals to obtain the real-time pulse width count value QPOSCNT of the valid period of the Z-phase signal. During the period when the real-time pulse width count value QPOSCNT is "0", "1", or "2", that is, during the period when the difference between the real-time pulse width count value and the pulse width of the Z-phase signal is less than or equal to a predetermined value, at each valid edge, it is determined whether the corresponding real-time phase matches the reference phase. A zero-point mark matching signal is generated where the real-time phase corresponding to the valid edge matches the reference phase. For example, at the positive pulse QEVT3, the real-time phase "1↑" corresponding to the effective edges of the A-phase signal and the B-phase signal matches the reference phase "1↑", thus generating the zero-point mark matching signal ZHIT3 at this location.

[0075] Accordingly, at step 506, in response to determining that the real-time rotation direction is opposite to the reference rotation direction, a second reset value for the position counter with respect to the encoder position is determined so that the position counter is reset at the zero-point mark matching signal. The second reset value is the difference between the predetermined maximum position count and the phase difference.

[0076] Taking the maximum value of the predetermined position count as "125" as an example, the real-time phase corresponding to the zero-point mark matching signal ZHIT3 is the same as the reference phase (i.e., matched), so the phase difference between the two is 0. Accordingly, the second reset value is "125", which is the difference between the maximum value of the predetermined position count and the above phase difference.

[0077] It is worth noting that, with Figure 8For example, due to factors such as encoder malfunction, the A-phase signal EQEP_A / B-phase signal EQEP_ABI may receive fewer pulses, causing the real-time count value QPOSCNT of the position counter to count less, resulting in an error in the position counter regarding the encoder's position. For instance, before the positive pulse ZHIT3 appears, QPOSCNT has only counted to 7 and has not yet decremented to 0. The appearance of the positive pulse ZHIT3 (i.e., the zero-point mark matching signal) resets the count value of the position counter regarding the encoder's position to a reasonable value, calibrating the position counter and correcting the aforementioned error. It should be understood that during the reverse rotation of encoder 100, the position counter regarding the encoder's position counts in reverse.

[0078] In some embodiments, when the pulse width of the Z-phase signal is 0 or 1, in step 504, after the rising edge of the Z-phase signal (i.e., the transition edge corresponding to the Z-phase signal changing from an invalid state to an valid state), at the first valid edge with respect to the A-phase and B-phase signals (i.e., the target valid edge with respect to the A-phase and B-phase signals), the real-time rotation direction of the encoder is determined. If the real-time rotation direction is the same as the reference rotation direction, a zero-point mark matching signal is generated at the valid edge with respect to the A-phase and B-phase signals; if the real-time rotation direction is opposite to the reference rotation direction, no zero-point mark matching signal is generated.

[0079] It should be understood that the technical solution of this disclosure allows the Z-phase signal pulse width of the encoder 100 to have a very wide range, for example, covering a pulse width range of 0 to 29, which can be adapted to the vast majority of encoders. Furthermore, this technology has strong resistance to line delay and jitter, and can accurately calibrate the encoder position. Moreover, this technical solution can support various motion states of the encoder.

[0080] Figure 9 A schematic block diagram of an example electronic device 900, which can be used to implement embodiments of the present disclosure, of a method for calibrating the position of an encoder. As shown, the electronic device 900 includes a central processing unit (i.e., CPU 901), which can perform various appropriate actions and processes according to computer program instructions stored in a read-only memory (i.e., ROM 902) or loaded from a storage unit 908 into a random access memory (i.e., RAM 903). Various programs and data required for the operation of the electronic device 900 may also be stored in the RAM 903. The CPU 901, ROM 902, and RAM 903 are interconnected via a bus 904. An input / output interface (i.e., I / O interface 905) is also connected to the bus 904.

[0081] Multiple components in electronic device 900 are connected to I / O interface 905, including: input unit 906, such as keyboard, mouse, microphone, etc.; output unit 907, such as various types of monitors, speakers, etc.; storage unit 908, such as disk, optical disk, etc.; and communication unit 909, such as network card, modem, wireless transceiver, etc. Communication unit 909 allows electronic device 900 to exchange information / data with other devices through computer networks such as the Internet and / or various telecommunications networks.

[0082] The various processes and procedures described above, such as method 500, can be executed by CPU 901. For example, in some embodiments, method 500 can be implemented as a computer software program tangibly contained in a machine-readable medium, such as storage unit 908. In some embodiments, part or all of the computer program can be loaded and / or installed on electronic device 900 via ROM 902 and / or communication unit 909. When the computer program is loaded into RAM 903 and executed by CPU 901, one or more actions of method 500 described above can be performed.

[0083] This disclosure relates to methods, apparatus, systems, electronic devices, computer-readable storage media, and / or computer program products. A computer program product may include computer-readable program instructions for performing various aspects of this disclosure.

[0084] In some embodiments, the method 500 described above can be implemented as a computer program product. The computer program product may include a computer-readable storage medium having computer-readable program instructions loaded thereon for performing various aspects of this disclosure.

[0085] Computer-readable storage media can be tangible devices capable of holding and storing instructions for use by an instruction execution device. Computer-readable storage media can be, for example—but not limited to—electrical storage devices, magnetic storage devices, optical storage devices, electromagnetic storage devices, semiconductor storage devices, or any suitable combination thereof. More specific examples (a non-exhaustive list) of computer-readable storage media include: portable computer disks, hard disks, random access memory (RAM), read-only memory (ROM), erasable programmable read-only memory (EPROM or flash memory), static random access memory (SRAM), portable compact disc read-only memory (CD-ROM), digital multifunction disc (DVD), memory sticks, floppy disks, mechanical encoding devices, such as punch cards or recessed protrusions storing instructions thereon, and any suitable combination thereof. The computer-readable storage media used herein are not to be construed as transient signals themselves, such as radio waves or other freely propagating electromagnetic waves, electromagnetic waves propagating through waveguides or other transmission media (e.g., light pulses through fiber optic cables), or electrical signals transmitted through wires.

[0086] The computer-readable program instructions described herein can be downloaded from computer-readable storage media to various computing / processing devices, or downloaded via a network, such as the Internet, local area network, wide area network, and / or wireless network, to an external computer or external storage device. The network may include copper transmission cables, fiber optic transmission, wireless transmission, routers, firewalls, switches, gateway computers, and / or edge computing devices. A network adapter card or network interface in each computing / processing device receives the computer-readable program instructions from the network and forwards them to computer-readable storage media within the respective computing / processing device.

[0087] Computer program instructions used to perform the operations of this disclosure may be assembly instructions, instruction set architecture (ISA) instructions, machine instructions, machine-dependent instructions, microcode, firmware instructions, status setting data, or source code or object code written in any combination of one or more programming languages, including object-oriented programming languages ​​such as Smalltalk, C++, etc., and conventional procedural programming languages ​​such as the "C" language or similar programming languages. The computer-readable program instructions may execute entirely on the user's computer, partially on the user's computer, as a standalone software package, partially on the user's computer and partially on a remote computer, or entirely on a remote computer or server. In cases involving a remote computer, the remote computer may be connected to the user's computer via any type of network—including a local area network (LAN) or a wide area network (WAN)—or may be connected to an external computer (e.g., via the Internet using an Internet service provider). In some embodiments, electronic circuitry, such as programmable logic circuitry, field-programmable gate arrays (FPGAs), or programmable logic arrays (PLAs), is personalized by utilizing the status information of the computer-readable program instructions to implement various aspects of this disclosure.

[0088] Various aspects of this disclosure are described herein with reference to flowchart illustrations and / or block diagrams of methods, apparatus (systems), and computer program products according to embodiments of this disclosure. It should be understood that each block of the flowchart illustrations and / or block diagrams, and combinations of blocks in the flowchart illustrations and / or block diagrams, can be implemented by computer-readable program instructions.

[0089] These computer-readable program instructions can be provided to a processing unit of a general-purpose computer, a special-purpose computer, or other programmable data processing apparatus to produce a machine such that, when executed by the processing unit of the computer or other programmable data processing apparatus, they create means for implementing the functions / actions specified in one or more blocks of the flowchart and / or block diagram. These computer-readable program instructions can also be stored in a computer-readable storage medium that causes a computer, programmable data processing apparatus, and / or other device to operate in a particular manner. Thus, the computer-readable medium storing the instructions comprises an article of manufacture that includes instructions for implementing aspects of the functions / actions specified in one or more blocks of the flowchart and / or block diagram.

[0090] Computer-readable program instructions may also be loaded onto a computer, other programmable data processing apparatus, or other device to cause a series of operational steps to be performed on the computer, other programmable data processing apparatus, or other device to produce a computer-implemented process, thereby causing the instructions executed on the computer, other programmable data processing apparatus, or other device to perform the functions / actions specified in one or more boxes of a flowchart and / or block diagram.

[0091] The flowcharts and block diagrams in the accompanying drawings illustrate the architecture, functionality, and operation of possible implementations of systems, methods, and computer program products according to various embodiments of the present disclosure. In this regard, each block in a flowchart or block diagram may represent a module, segment, or portion of an instruction, which contains one or more executable instructions for implementing a specified logical function. In some alternative implementations, the functions marked in the blocks may occur in a different order than those marked in the drawings. For example, two consecutive blocks may actually be executed substantially in parallel, and they may sometimes be executed in reverse order, depending on the functions involved. It should also be noted that each block in the block diagrams and / or flowcharts, and combinations of blocks in the block diagrams and / or flowcharts, may be implemented using a dedicated hardware-based system that performs the specified function or action, or using a combination of dedicated hardware and computer instructions.

[0092] The various embodiments of this disclosure have been described above. These descriptions are exemplary and not exhaustive, nor are they limited to the disclosed embodiments. Many modifications and variations will be apparent to those skilled in the art without departing from the scope and spirit of the described embodiments. The terminology used herein is chosen to best explain the principles, practical application, or technical improvements to the embodiments in the market, or to enable others skilled in the art to understand the embodiments disclosed herein.

[0093] The above are merely optional embodiments of this disclosure and are not intended to limit this disclosure. Various modifications and variations can be made to this disclosure by those skilled in the art. Any modifications, equivalent substitutions, improvements, etc., made within the spirit and principles of this disclosure should be included within the scope of protection of this disclosure.

Claims

1. A method for calibrating the position of an encoder, characterized in that, include: The reference zero point and the corresponding reference phase of the reference zero point with respect to the A-phase signal and the B-phase signal are determined based on the A-phase signal, B-phase signal and Z-phase signal from the encoder. During the effective period of the Z-phase signal, a zero-point mark matching signal is generated based on the effective edges of the A-phase and B-phase signals, the real-time rotation direction of the encoder, and the reference rotation direction when determining the reference zero point. as well as The position counter for the encoder position is calibrated based on the phase difference between the real-time phase of the A-phase signal and the B-phase signal corresponding to the zero-point mark matching signal and the reference phase. The method further includes: sequentially determining the phase information corresponding to each of the effective edges, in order to determine the phase difference; as well as The real-time zero point of the encoder is determined based on the calibrated position counter.

2. The method according to claim 1, characterized in that, During the effective period of the Z-phase signal, based on the effective edges of the A-phase and B-phase signals, the real-time rotation direction of the encoder, and the reference rotation direction when determining the reference zero point, a zero-point mark matching signal is generated, including: In response to determining that the real-time rotation direction is the same as the reference rotation direction, a zero-point mark matching signal is generated at the target effective edge of the A-phase signal and the B-phase signal, wherein the target effective edge is the effective edge corresponding to the determination of the reference zero point.

3. The method according to claim 2, characterized in that, During the effective period of the Z-phase signal, the generation of the zero-point mark matching signal, based on the effective edges of the A-phase and B-phase signals, the real-time rotation direction of the encoder, and the reference rotation direction when determining the reference zero point, also includes: In response to determining that the real-time rotation direction is opposite to the reference rotation direction, a zero-point marker matching signal is generated based on the matching relationship between the real-time phase corresponding to the effective edge and the reference phase, the real-time pulse width count value for the effective period of the Z-phase signal, and the pulse width of the Z-phase signal. The pulse width of the Z-phase signal is the number of overlaps between the effective period of the Z-phase signal and the effective edge.

4. The method according to claim 3, characterized in that, In response to determining that the real-time rotation direction is opposite to the reference rotation direction, generating a zero-point marker matching signal based on the matching relationship between the real-time phase corresponding to the effective edge and the reference phase, the real-time pulse width count value for the effective period of the Z-phase signal, and the pulse width of the Z-phase signal includes: Real-time counting is performed based on the effective edge of the Z-phase signal during its effective period to obtain the real-time pulse width count value; and During the period when the difference between the real-time pulse width count value and the pulse width of the Z-phase signal is less than or equal to a predetermined value, a zero-point marker matching signal is generated at the point where the real-time phase corresponding to the effective edge matches the reference phase.

5. The method according to claim 1, characterized in that, The calibration of the position counter for the encoder's position, based on the phase difference between the real-time phase of the A-phase and B-phase signals corresponding to the zero-point mark matching signal and the reference phase, includes: In response to determining that the real-time rotation direction is the same as the reference rotation direction, a first reset value for the position counter regarding the encoder's position is determined so as to reset the position counter at the zero-point mark matching signal. When the phase difference is negative, the first reset value is the sum of a predetermined maximum position count, 1, and the phase difference; when the phase difference is non-negative, the first reset value is the phase difference. In response to determining that the real-time rotation direction is opposite to the reference rotation direction, a second reset value for the position counter with respect to the encoder position is determined so as to reset the position counter at the zero-point mark matching signal. The second reset value is the difference between a predetermined maximum position count and the phase difference.

6. The method according to claim 1, characterized in that, Determining the reference zero point based on the A-phase signal, B-phase signal, and Z-phase signal from the encoder includes: The reference zero is defined as the point corresponding to the target valid edge of the effective period of the Z-phase signal with respect to the A-phase and B-phase signals. The target valid edge is the first valid edge of the effective period of the Z-phase signal, and the valid edge is any one of the following: The transition edge of phase A signal; and The transition edge of the B-phase signal.

7. An electronic device, characterized in that, include: At least one processor; as well as A memory that is communicatively connected to the at least one processor; The memory stores instructions that can be executed by the at least one processor to enable the at least one processor to perform the method of any one of claims 1 to 6.

8. A computer-readable storage medium, characterized in that, A computer-readable storage medium stores a computer program that, when executed by a machine, implements the method according to any one of claims 1 to 6.

9. A computer program product tangibly stored on a non-transient computer-readable medium and comprising machine-executable instructions that, when executed, cause a machine to perform the steps of the method according to any one of claims 1 to 6.