Phase compensation method, device and magnetic encoder

By periodically updating the phase compensation value of the magnetic encoder, the phase delay problem in magnetic encoder signal processing is solved, and accurate acquisition of real-time position signals is achieved.

CN116182924BActive Publication Date: 2026-01-13SEMIMENT TECH (SHANGHAI) CO LTD
View PDF 2 Cites 0 Cited by

Patent Information

Application Number
CN202211542765.9
Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
Filing Date
2022-12-02
Publication Date
2026-01-13
Estimated Expiration
2042-12-02

AI Technical Summary

Technical Problem

Existing magnetic encoders suffer from phase delay during signal processing, which affects the accurate acquisition of real-time position signals.

Method used

By comparing the difference between the first rotation angle acquired by the magnetic encoder and the second rotation angle stored in the register, the phase compensation value is updated periodically. After determining that the first rotation angle has been updated and the magnetic encoder has completed initialization, the first rotation angle is stored in the register. After waiting for one system clock cycle, the target compensation phase angle is determined to compensate for the first rotation angle.

Benefits of technology

It effectively eliminates the phase delay between the sensor output and the output after data processing, enabling accurate acquisition of real-time position signals.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN116182924B_ABST
    Figure CN116182924B_ABST
Patent Text Reader

Abstract

The application provides a phase compensation method, device and magnetic encoder. The method comprises the following steps: obtaining a first rotation angle based on a first digital sine wave signal and a first digital cosine wave signal collected according to a system clock cycle; updating a first phase compensation value based on the difference between the first rotation angle and a second rotation angle pre-stored by the magnetic encoder according to the system clock cycle; if the first rotation angle is updated and the magnetic encoder is initialized, storing the first rotation angle in a register and determining the first phase compensation value as a target compensation phase angle after waiting for a system clock cycle, and the target compensation phase angle is used for compensating the first rotation angle. By updating the first phase compensation value, the first phase compensation value is used as the target compensation phase angle in the case that the first rotation angle is updated, and the phase delay between the output result of the sensor and the output result after data processing is eliminated.
Need to check novelty before this filing date? Find Prior Art

Description

TECHNICAL FIELD

[0001] The present application relates to the field of electronic technology, and in particular to a phase compensation method, device and magnetic encoder. BACKGROUND

[0002] With the continuous development of Industry 4.0 and Internet of Things, the application of automation equipment is rapidly increasing. As an important part of the automation system, the stability and reliability of the servo motor system in extreme environments are increasingly required. The servo motor system needs to obtain accurate rotor position information to achieve high-precision control, and the position sensor is needed to obtain the rotor position information. As a feedback driving module in the servo motor system, the sensitivity and reliability of the position sensor directly determine the resolution, accuracy and performance of the entire servo drive system.

[0003] The mainstream position sensor mainly includes: a contact type position sensor, which is easy to produce wear on the contact surface in the impact, vibration and other environments, causing position acquisition distortion. In salt spray, low temperature and other environments, the contact surface is easy to produce redundant objects, and equipment failure is easy to occur. The photoelectric encoder as a non-contact position sensor can reduce the influence of physical impact, but the code disc is sensitive to dust and other redundant objects, resulting in poor adaptability. To meet the optical requirements, the structure is complex and the price is high. The magnetic encoder is based on the principle of magnetic induction, which uses the change of the magnetic field to sense the position change through the Hall sensor. There is no contact surface, and it is not sensitive to the redundant objects on the contact surface. It has the advantages of fast response speed, strong anti-shock ability, strong environmental adaptability, high reliability and gradually becomes the mainstream in the market.

[0004] The Hall sensor generates a sine signal, which is amplified by an amplifier and then sampled by an analog to digital converter (ADC). The obtained digital signal is sent to a digital signal processing (DSP) module for angle calculation. In order to improve the calculation accuracy, the magnetic encoder first processes the signal before actual decoding. The output result of the Hall sensor is filtered and processed. There is a certain phase delay between the output result of the sensor and the processed output result. Excessive phase delay will seriously affect the real-time performance of data processing, resulting in the inability to obtain accurate real-time position signals. SUMMARY

[0005] In view of the problems existing in the prior art, the present application provides a phase compensation method, device and magnetic encoder.

[0006] In a first aspect, the present application provides a phase compensation method applied to a magnetic encoder, comprising:

[0007] According to a system clock cycle, a first rotation angle is obtained based on a first digital sine wave signal and a first digital cosine wave signal collected by the magnetic encoder;

[0008] According to the system clock cycle, a first phase compensation value is periodically updated based on a difference between the first rotation angle and a second rotation angle pre-stored by the magnetic encoder;

[0009] If it is determined that the first rotation angle is updated and it is determined that the magnetic encoder is initialized, the first rotation angle is stored in a register, and after waiting for a system clock cycle, the first phase compensation value is determined as a target compensation phase angle, which is used to compensate the first rotation angle.

[0010] Optionally, according to the phase compensation method provided by the application, according to the system clock cycle, a first phase compensation value is periodically updated based on a difference between the first rotation angle and a second rotation angle pre-stored by the magnetic encoder, comprising:

[0011] A first difference between the first rotation angle and the second rotation angle is determined;

[0012] In the case of the current cycle being the first cycle, a second phase compensation value is determined to be 0; or, in the case of the current cycle being a non-first cycle, a second phase compensation value recorded by the magnetic encoder in the last cycle is obtained;

[0013] The first phase compensation value is updated based on the second phase compensation value;

[0014] A first variable is determined by performing a binary left shift multiplication operation on the first phase compensation value by N bits;

[0015] A second difference between the first variable and the first phase compensation value is determined;

[0016] A second variable is determined by performing a division by M and taking an integer operation based on the second difference;

[0017] The second phase compensation value is updated based on the first difference and the second variable;

[0018] Wherein, the N is 4 or 5 or 6, and the M is 2 raised to the power of N.

[0019] Optionally, according to the phase compensation method provided by the application, the determination that the magnetic encoder is initialized comprises:

[0020] It is determined whether a count value is greater than a preset value;

[0021] If it is determined that the count value is greater than the preset value, it is determined that the magnetic encoder is initialized.

[0022] The count value is used to represent the number of times the first rotation angle is updated.

[0023] Optionally, the phase compensation method provided by the present application further comprises:

[0024] The sum of the target compensation phase angle and the first rotation angle is calculated, and the sum is determined as the output of the magnetic encoder.

[0025] Optionally, the phase compensation method provided by the present application, the first rotation angle is obtained based on the first digital sine wave signal and the first digital cosine wave signal collected by the magnetic encoder according to the system clock cycle, comprising:

[0026] Based on the first digital sine wave signal and the first digital cosine wave signal, low-pass filtering is performed to generate a second digital sine wave signal and a second digital cosine wave signal;

[0027] Based on the second digital sine wave signal and the second digital cosine wave signal, the first rotation angle and a trigger signal are generated through arctangent calculation, and the trigger signal is used to indicate that the first rotation angle is updated.

[0028] Optionally, the phase compensation method provided by the present application, the first rotation angle is generated through arctangent calculation, comprising:

[0029] Based on the second digital sine wave signal and the second digital cosine wave signal, a tangent quantity is obtained through division and absolute value calculation;

[0030] Based on the tangent quantity, an initial angle is obtained through arctangent calculation;

[0031] Based on a preset arctangent correction table, the initial angle is corrected to generate the first rotation angle;

[0032] The preset arctangent correction table is used to adjust the initial angle to 0-2π.

[0033] Secondly, the present application further provides a phase compensation device applied to a magnetic encoder, comprising a rotation angle determination module and a phase compensation module, the output end of the rotation angle determination module is connected with the input end of the phase compensation module.

[0034] The rotation angle determination module is used to obtain a first rotation angle based on a first digital sine wave signal and a first digital cosine wave signal collected by the magnetic encoder according to a system clock cycle.

[0035] The phase compensation module is configured to periodically update a first phase compensation value based on a difference between the first rotation angle and a second rotation angle according to a system clock cycle, the second rotation angle being a rotation angle stored in a register of the magnetic encoder.

[0036] If the first rotation angle is stored in the register and one system clock cycle is waited for after determining that the first rotation angle is updated and determining that the magnetic encoder is initialized, the first phase compensation value is determined as a target compensation phase angle, and the target compensation phase angle is used to compensate the first rotation angle.

[0037] In a third aspect, the present application further provides a magnetic encoder comprising a memory, a processor, and a computer program stored in the memory and executable on the processor, and the processor implements the phase compensation method according to any one of the above aspects when executing the program.

[0038] The phase compensation method, device, and magnetic encoder provided by the present application can determine the difference between the first rotation angle and the second rotation angle by comparing the first rotation angle and the second rotation angle, the first rotation angle being a rotation angle determined in real time based on a sine wave signal and a cosine wave signal, and the second rotation angle being a rotation angle stored in a register of the magnetic encoder, the difference between the two can reflect the degree of phase delay between the sensor output result and the output result after data processing, and then the first phase compensation value can be periodically updated based on the difference between the two, and then in the case of determining that the first rotation angle is updated and determining that the magnetic encoder is initialized, the first rotation angle can be stored in the register and one system clock cycle is waited for (so as to analyze the difference between the first rotation angle and the second rotation angle in the subsequent system clock cycle) after which the current first phase compensation value is determined as a target compensation phase angle, and the target compensation phase angle can be used to compensate the first rotation angle, thereby eliminating the phase delay between the sensor output result and the output result after data processing, and accurately obtaining a real-time position signal. BRIEF DESCRIPTION OF DRAWINGS

[0039] In order to more clearly illustrate the technical solutions of the present application or the prior art, the following will briefly introduce the drawings needed to be used in the embodiments or prior art description. Obviously, the drawings described below are some embodiments of the present application, and those skilled in the art can obtain other drawings according to these drawings without creative labor.

[0040] Figure 1 is a structural schematic diagram of a magnetic encoder provided by the related art;

[0041] Figure 2is a schematic diagram of the working principle of a Hall sensor provided by the related art;

[0042] Figure 3 is a schematic diagram of a sine and cosine wave collected by a Hall sensor provided by the related art;

[0043] Figure 4 is a flowchart of a phase compensation method provided by the present application;

[0044] Figure 5 is a flowchart of periodically updating a phase compensation value after the system output is stabilized provided by the present application;

[0045] Figure 6 is a flowchart of periodically updating a phase compensation value in a system initialization stage provided by the present application;

[0046] Figure 7 is a structural schematic diagram of a phase compensation device provided by the present application;

[0047] Figure 8 is a schematic diagram of the working principle of a phase compensation device provided by the present application;

[0048] Figure 9 is a structural schematic diagram of a magnetic encoder provided by the present application. DETAILED DESCRIPTION

[0049] In order to facilitate a clearer understanding of the embodiments of the present application, some related background knowledge is first introduced as follows.

[0050] Figure 1 is a structural schematic diagram of a magnetic encoder provided by the related art, as shown in Figure 1 , can include a magnetic sensor 101, two low-noise amplifiers (including a first amplifier 102 and a second amplifier 103), two ADCs (including a first ADC 104 and a second ADC 105), two gain adjustment modules (including a first gain adjustment module 106 and a second gain adjustment module 107), and a digital processing module 108 for decoding.

[0051] Figure 2 is a schematic diagram of the working principle of a Hall sensor provided by the related art, as shown in Figure 2As shown, the magnetic sensor 101 comprises a magnetic rotor 201 and two-way Hall sensors (including a first Hall sensor 202 and a second Hall sensor 203), the axis of the magnetic rotor 201 is perpendicular to the plane where the Hall sensors are located, and according to the Hall effect, the magnetic field of the magnetic rotor 201 will make the Hall sensors output corresponding voltage values. The two-way Hall sensors are placed at an angle of 90°, and when the magnetic rotor 201 rotates at a constant speed for one revolution, the voltage waveforms sensed by the two-way Hall sensors are sinusoidal waves with a phase difference of 90°. The output of the first Hall sensor 202 is defined as sinθ, and the output of the second Hall sensor 203 is defined as cosθ. Wherein, θ is the rotation angle of the magnetic rotor 201 relative to the Hall sensor.

[0052] Figure 3 is a schematic diagram of the sine and cosine waves collected by the Hall sensor provided by the related art, as shown in Figure 1 、 Figure 2 and Figure 3 As shown, the output sinθ of the first Hall sensor 202 is connected to the first amplifier 102, and the amplified analog signal is sent to the first ADC 104 for sampling and converted into a digital signal Dig_sinθ. At the same time, the first ADC 104 changes the DC bias voltage of the first amplifier 102 and adjusts its gain through the first gain adjustment module 106 according to the current input signal analog quantity; Similarly, the output cosθ of the second Hall sensor 203 is connected to the second amplifier 103, and the amplified analog signal is sent to the second ADC 105 for sampling and converted into a digital signal Dig_cosθ. At the same time, the second ADC 105 changes the DC bias voltage of the second amplifier 103 and adjusts its gain through the second gain adjustment module 107 according to the current input signal analog quantity.

[0053] As shown in Figure 1 The two-way digital signal outputs Dig_sinθ and Dig_cosθ are connected to the digital processing module 108 for subsequent decoding.

[0054] In order to overcome the above defects, the present application provides a phase compensation method, device and magnetic encoder, through phase compensation, the phase delay between the sensor output result and the output result after data processing can be eliminated.

[0055] In order to make the purpose, technical scheme and advantages of the present application more clear, the technical scheme in the present application will be described clearly and completely below in combination with the drawings in the present application. Obviously, the described embodiments are part of the embodiments of the present application, rather than all the embodiments. Based on the embodiments in the present application, all other embodiments obtained by those skilled in the art without creative labor fall within the scope of protection of the present application.

[0056] Figure 4This is a schematic flowchart of the phase compensation method provided by the present invention, as shown below. Figure 4 As shown, the entity executing the phase compensation method can be a magnetic encoder. The method includes:

[0057] Step 401: Based on the system clock cycle, obtain the first rotation angle based on the first digital sine wave signal and the first digital cosine wave signal collected by the magnetic encoder.

[0058] Specifically, the magnetic encoder can acquire analog sine wave signals and analog cosine wave signals through the magnetic rotor 201 and Hall sensor. After amplification and ADC sampling, it can acquire the first digital sine wave signal corresponding to the analog sine wave signal and the first digital cosine wave signal corresponding to the analog cosine wave signal. Then, based on the first digital sine wave signal and the first digital cosine wave signal, it can acquire the first rotation angle in real time according to the system clock cycle.

[0059] Step 402: Based on the system clock cycle, the first phase compensation value is periodically updated according to the difference between the first rotation angle and the second rotation angle pre-stored by the magnetic encoder.

[0060] Specifically, in order to achieve phase compensation of the magnetic encoder, a pre-stored second rotation angle can be read. By comparing the first rotation angle and the second rotation angle, the difference between the first rotation angle and the second rotation angle can be determined. The difference between the two can reflect the phase delay between the sensor output and the output after data processing. Then, the first phase compensation value can be periodically updated based on the difference between the two.

[0061] Understandably, the second rotation angle can be pre-stored in a register. This pre-stored second rotation angle can be the first rotation angle at a historical moment, which could be the moment when the first rotation angle was last determined to have been updated. The rotation angle stored in the register can be used as the second rotation angle. The initial value stored in the register can be 0.

[0062] It is understandable that the magnetic encoder can execute steps 401 and 402 based on the system clock cycle, that is, the magnetic encoder can execute steps 401 and 402 in parallel.

[0063] Step 403: If it is determined that the first rotation angle has been updated and the magnetic encoder has completed initialization, then the first rotation angle is stored in the register and after waiting for one system clock cycle, the first phase compensation value is determined as the target compensation phase angle, which is used to compensate for the first rotation angle.

[0064] Specifically, the system can monitor in real time whether the first rotation angle is updated. If the first rotation angle is updated and the magnetic encoder is confirmed to have completed initialization, the first rotation angle can be stored in a register (the value stored in the register in subsequent system clock cycles will be used as the pre-stored second rotation angle). After waiting for one system clock cycle (in order to analyze the difference between the first rotation angle and the second rotation angle in subsequent system clock cycles), the current first phase compensation value can be used as the target compensation phase angle, which can be used to compensate for the first rotation angle.

[0065] Understandably, the magnetic encoder can execute step 402 based on the system clock cycle. After each execution of step 402, it can monitor whether the first rotation angle has been updated. If an update to the first rotation angle is detected and the magnetic encoder has completed initialization, step 403 can be executed, storing the first rotation angle in the register and waiting for one system clock cycle before determining the first phase compensation value as the target compensation phase angle. After executing step 402, the magnetic encoder can continue to execute step 402 based on the system clock cycle until the first rotation angle is updated again, and so on.

[0066] Understandably, a magnetic encoder can generate a rotation angle (i.e., the first rotation angle) based on sine wave signals and cosine wave signals by calculating the rotation angle in real time. Generating a rotation angle means that the first rotation angle is updated once.

[0067] It is understandable that the operation of a magnetic encoder is divided into two stages. The first stage is the system initialization stage from the magnetic encoder being reset until the system output is stable. After the system output is stable, the second stage begins. Therefore, in order to ensure stable phase compensation, it is a prerequisite for the magnetic encoder to complete its initialization.

[0068] The phase compensation method provided by this invention can determine the difference between a first rotation angle and a second rotation angle by comparing the first rotation angle and the second rotation angle. The first rotation angle is a rotation angle determined by real-time rotation angle calculation based on sine wave and cosine wave signals. The second rotation angle is the rotation angle stored in the register of the magnetic encoder. The difference between the two can reflect the degree of phase delay between the sensor output and the output after data processing. Therefore, the first phase compensation value can be periodically updated based on the difference between the two. Then, when it is determined that the first rotation angle has been updated and the magnetic encoder has completed initialization, the first rotation angle can be stored in the register and wait for one system clock cycle (so that the difference between the first rotation angle and the second rotation angle can be analyzed in subsequent system clock cycles). After that, the current first phase compensation value is used as the target compensation phase angle. The target compensation phase angle can be used to compensate for the first rotation angle, thereby reducing the phase delay between the sensor output and the output after data processing, and accurately acquiring the real-time position signal.

[0069] Optionally, according to a phase compensation method provided by the present invention, a first phase compensation value is periodically updated based on the difference between the first rotation angle and the second rotation angle pre-stored by the magnetic encoder, according to the system clock cycle, including:

[0070] Determine the first difference between the first rotation angle and the second rotation angle;

[0071] If this cycle is the first cycle, the second phase compensation value is determined to be 0; or, if this cycle is not the first cycle, the second phase compensation value recorded by the magnetic encoder in the previous cycle is obtained.

[0072] Update the first phase compensation value based on the second phase compensation value;

[0073] The first phase compensation value is multiplied by shifting it left by N bits to determine the first variable;

[0074] Determine the second difference between the first variable and the first phase compensation value;

[0075] Based on the second difference, divide by M and round to the nearest integer to determine the second variable;

[0076] Based on the first difference and the second variable, update the second phase compensation value;

[0077] Wherein, N is 4, 5, or 6, and M is 2 to the power of N.

[0078] Specifically, Figure 5This is a schematic diagram of the process of periodically updating the phase compensation value after the system output stabilizes, as provided by the present invention. Figure 5 As shown, when the magnetic encoder is operating in the second stage (system output is stable), periodically updating the first phase compensation value may include steps 501 to 505:

[0079] Step 501: Calculate the difference between the current variable θ_pre (i.e., the second rotation angle) and the tangent operation result θ (i.e., the first rotation angle), and assign the result to the variable θ_diff (i.e., the first difference).

[0080] Step 502: Update the variable avg_acc (i.e., the first phase compensation value) and assign the variable next_avg_acc (i.e., the second phase compensation value) to the variable avg_acc;

[0081] Step 503: After performing a left shift of 5 bits (i.e., N is 5) on the variable avg_acc based on binary, subtract it from the original variable avg_acc and assign the result to the variable fab_acc (i.e., the second difference).

[0082] Step 504: Divide the variable fab_acc by 32 (that is, M is 2 to the power of 5) and round it to the nearest integer to obtain the variable fab_acc_round (that is, the second variable).

[0083] It is understandable that if step 503 is "a left shift of binary by 4 bits and multiplication", then step 504 is "divided by 16 and rounded to the nearest integer"; if step 503 is "a left shift of binary by 5 bits and multiplication", then step 504 is "divided by 32 and rounded to the nearest integer"; if step 503 is "a left shift of binary by 6 bits and multiplication", then step 504 is "divided by 64 and rounded to the nearest integer".

[0084] It is understandable that steps 503 and 504 are for calculating decimal values ​​and rounding the variable fab_acc.

[0085] Step 505: Update the variable next_avg_acc by adding the variable θ_diff to the variable fab_acc_round and assigning the result to the variable next_avg_acc.

[0086] By following the steps above, based on the difference θ between two similar arctangent operations, the real-time phase delay avg_acc of the current system can be estimated and output.

[0087] Specifically, such as Figure 5As shown, when the magnetic encoder is operating in the second stage, it can monitor in real time whether the first rotation angle has been updated. For example, the magnetic encoder can configure an enable signal θ_vaild for the first rotation angle update event, and determine whether the first rotation angle has been updated by judging the level of the enable signal θ_vaild. If an update of the first rotation angle is detected, the first rotation angle is stored in the register, and after waiting for one system clock cycle, the first phase compensation value is determined as the target compensation phase angle. Specifically, the following steps can be executed:

[0088] Step 500: Monitor in real time whether the first rotation angle has been updated (the enable signal θ_vaild is set to 1, that is, a high level indicates that an update has occurred);

[0089] Step 506: If an update to the first rotation angle is detected, the current arctangent result θ (i.e., the first rotation angle) is sent to the register, and a system clock cycle is waited.

[0090] Step 507: Assign the value in the register to the variable θ_pre (i.e., the second rotation angle);

[0091] Step 508: Output the value of the current variable avg_acc (i.e., the first phase compensation value) for phase compensation.

[0092] Therefore, based on the difference between the first rotation angle and the second rotation angle, the phase delay between the sensor output and the output after data processing can be analyzed, the first phase compensation value can be updated periodically, the real-time phase delay of the current system can be estimated and output, and real-time phase compensation can be achieved for the arctangent calculation result θ.

[0093] Optionally, according to a phase compensation method provided by the present invention, determining that the magnetic encoder has completed initialization includes:

[0094] Determine if the count value is greater than a preset value;

[0095] If the count value is determined to be greater than the preset value, then the magnetic encoder is determined to have completed initialization.

[0096] The count value is used to represent the number of times the first rotation angle has been updated.

[0097] Specifically, in order to determine the stage of operation of the magnetic encoder, a counter can be configured to record the number of times the first rotation angle is updated. Then, it can be determined whether the count value is greater than a preset value. If the count value is greater than the preset value, it is determined that the magnetic encoder has completed initialization.

[0098] It is understandable that the operation of a magnetic encoder is divided into two stages. The first stage is the system initialization stage, from the time the magnetic encoder is reset until the system output stabilizes. After the system output stabilizes, it enters the second stage. Therefore, to ensure stable phase compensation, ensuring that the magnetic encoder has completed initialization is a prerequisite for performing phase compensation. The aforementioned preset values ​​can be obtained through experimental testing of the magnetic encoder to ensure that the magnetic encoder has entered the second stage after the number of times the first rotation angle is updated reaches the preset value.

[0099] Optionally, when the magnetic encoder is reset, the internal counter of the module will be reset.

[0100] Optionally, Figure 6 This is a schematic diagram of the process for periodically updating phase compensation values ​​during the system initialization phase provided by the present invention, as shown below. Figure 6 As shown, when the magnetic encoder is operating in the first stage, it can track the current arctangent calculation result θ and periodically update the first phase compensation value, which may include the following steps 601 to 605:

[0101] Step 601: Calculate the difference between the current variable θ_pre (i.e., the second rotation angle) and the tangent operation result θ (i.e., the first rotation angle), and assign the result to the variable θ_diff (i.e., the first difference).

[0102] Step 602: Perform a left shift 5-bit multiplication operation on the variable θ_diff based on binary, and assign the result to the variable avg_acc (i.e. the first phase compensation value);

[0103] Step 603: After performing a left shift of 5 bits on the variable avg_acc based on binary, subtract the result from the original variable avg_acc and assign the result to the variable fab_acc (i.e., the second difference).

[0104] Step 604: Divide the variable fab_acc by 32 and round it to the nearest integer to obtain the variable fab_acc_round (i.e., the second variable);

[0105] Step 605: Determine if θ is stable, that is, determine if the magnetic encoder has been initialized.

[0106] Optionally, such as Figure 6 As shown, if it is determined that the magnetic encoder has completed its initialization, then the tracking ends, that is, the tracking of the current arctangent calculation result θ stops. Then the magnetic encoder enters the second stage from the first stage. When the magnetic encoder is operating in the second stage (system output is stable), the periodic update of the first phase compensation value may include the aforementioned steps 501 to 505.

[0107] Optionally, such as Figure 6As shown, when the magnetic encoder is operating in its first stage, it can monitor in real time whether the first rotation angle has been updated. For example, the encoder can configure an enable signal θ_vaild for the first rotation angle update event, and determine whether the first rotation angle has been updated by judging the level of the enable signal θ_vaild. If an update of the first rotation angle is detected, the first rotation angle is stored in a register, and the second rotation angle is updated after waiting for one system clock cycle. Specifically, the following steps can be executed:

[0108] Step 600: Monitor in real time whether the first rotation angle has been updated (the enable signal θ_vaild is 1, that is, a high level indicates that an update has occurred);

[0109] Step 606: If an update to the first rotation angle is detected, the current arctangent result θ (i.e., the first rotation angle) is sent to the register, and a system clock cycle is waited.

[0110] Step 607: Assign the value in the register to the variable θ_pre (i.e., the second rotation angle).

[0111] Therefore, by recording the number of times the first rotation angle is updated through the count value, it is possible to determine whether the magnetic encoder output is stable by judging whether the count value is greater than the preset value.

[0112] Optionally, a phase compensation method according to the present invention further includes:

[0113] Calculate the sum of the target compensation phase angle and the first rotation angle, and determine the sum as the output of the magnetic encoder.

[0114] Specifically, an adder can be used to calculate the sum of the target compensation phase angle and the first rotation angle, and this sum can be used as the output of the magnetic encoder to eliminate the phase delay between the sensor output and the output after data processing, thereby enabling accurate acquisition of real-time position signals.

[0115] Understandably, if the first rotation angle is detected to be updated and the magnetic encoder is confirmed to have completed initialization, then after waiting for one system clock cycle, the first phase compensation value is determined as the target compensation phase angle, and the target compensation phase angle is updated.

[0116] Optionally, according to a phase compensation method provided by the present invention, obtaining a first rotation angle based on a first digital sine wave signal and a first digital cosine wave signal acquired by the magnetic encoder according to the system clock cycle includes:

[0117] Based on the first digital sine wave signal and the first digital cosine wave signal, low-pass filtering is performed to generate a second digital sine wave signal and a second digital cosine wave signal.

[0118] Based on the second digital sine wave signal and the second digital cosine wave signal, the first rotation angle and a trigger signal are generated by arctangent calculation, and the trigger signal is used to indicate that the first rotation angle is updated.

[0119] Specifically, in order to generate the first rotation angle, the magnetic encoder can digitize the acquired sine wave signal to obtain a first digital sine wave signal, the magnetic encoder can digitize the acquired cosine wave signal to obtain a first digital cosine wave signal, the first digital sine wave signal can be low-pass filtered to generate a second digital sine wave signal, the first digital cosine wave signal can be low-pass filtered to obtain a second digital cosine wave signal, and then the first rotation angle can be generated by arctangent calculation and a trigger signal can be output.

[0120] Optionally, the magnetic encoder may include a Hall sensor, an amplifier, and an ADC. The Hall sensor can generate sine and cosine signals, which are amplified by the amplifier, sampled by the ADC, and the resulting digital signal is sent to the DSP module. Obtaining the first digital sine wave signal can be done by receiving the digitized sine wave signal output by the ADC, and obtaining the first digital cosine wave signal can be done by receiving the digitized cosine wave signal output by the ADC.

[0121] Optionally, the magnetic encoder can be configured with an enable signal θ_vaild for the update event of the first rotation angle. The trigger signal can be that the enable signal θ_vaild is set high for one clock cycle and then returns to low.

[0122] Optionally, the first digital sine wave signal and the first digital cosine wave signal can be filtered by a digital filter. The digital filter can have a refresh period and perform low-pass filtering according to the refresh period to generate the second digital sine wave signal and the second digital cosine wave signal.

[0123] Optionally, the arctangent can be calculated according to the refresh cycle of the digital filter to generate the first rotation angle, that is, the first rotation angle is updated once in each refresh cycle.

[0124] Therefore, by filtering the digitized sine and cosine signals and calculating the arctangent, a first rotation angle can be generated and a trigger signal can be output, which can indicate that the first rotation angle is updated.

[0125] Optionally, according to a phase compensation method provided by the present invention, generating the first rotation angle through arctangent calculation includes:

[0126] Based on the second digital sine wave signal and the second digital cosine wave signal, the tangent is obtained by dividing the two signals and taking the absolute value.

[0127] Based on the tangent, the initial angle is obtained by calculating the arctangent;

[0128] Based on a preset arctangent correction table, the initial angle is corrected to generate the first rotation angle;

[0129] The preset arctangent correction table is used to adjust the initial angle to 0 to 2π.

[0130] Specifically, the tangent can be obtained using the following formula:

[0131]

[0132] Where, tanθ ′ θ represents the tangent, sinθ represents the second digital sine wave signal, and cosθ represents the second digital cosine wave signal.

[0133] Specifically, the initial angle can be obtained through the following arctangent calculation:

[0134]

[0135] Where, θ ′ Indicates the initial angle. It represents the tangent.

[0136] Specifically, the initial angle can be corrected using Table 1 to generate the first rotation angle. Table 1 is used to adjust the initial angle to 0 to 2π.

[0137] Table 1 Preset Arctangent Correction Table

[0138]

[0139]

[0140] Therefore, based on the digitized sine wave signal, the rotation angle can be generated through tangent calculation, arctangent calculation, and angle correction.

[0141] The phase compensation method provided by this invention can determine the difference between a first rotation angle and a second rotation angle by comparing the first rotation angle and the second rotation angle. The first rotation angle is a rotation angle determined by real-time rotation angle calculation based on sine wave and cosine wave signals. The second rotation angle is the rotation angle stored in the register of the magnetic encoder. The difference between the two can reflect the degree of phase delay between the sensor output and the output after data processing. Therefore, the first phase compensation value can be periodically updated based on the difference between the two. Then, when it is determined that the first rotation angle has been updated and the magnetic encoder has completed initialization, the first rotation angle can be stored in the register and wait for one system clock cycle (so that the difference between the first rotation angle and the second rotation angle can be analyzed in subsequent system clock cycles). After that, the current first phase compensation value is used as the target compensation phase angle. The target compensation phase angle can be used to compensate for the first rotation angle, thereby reducing the phase delay between the sensor output and the output after data processing, and accurately acquiring the real-time position signal.

[0142] The phase compensation device provided by the present invention is described below. The phase compensation device described below and the phase compensation method described above can be referred to in correspondence.

[0143] Figure 7 This is a schematic diagram of the phase compensation device provided by the present invention, as shown below. Figure 7 As shown, the device is applied to a magnetic encoder and includes: a rotation angle determination module 701 and a phase compensation module 702. The output terminal of the rotation angle determination module 701 is connected to the input terminal of the phase compensation module 702, wherein:

[0144] The rotation angle determination module 701 is used to obtain the first rotation angle based on the first digital sine wave signal and the first digital cosine wave signal collected by the magnetic encoder according to the system clock cycle.

[0145] The phase compensation module 702 is used to periodically update the first phase compensation value based on the difference between the first rotation angle and the second rotation angle pre-stored by the magnetic encoder according to the system clock cycle.

[0146] Upon determining that the first rotation angle has been updated and that the magnetic encoder has completed initialization, the first rotation angle is stored in a register and after waiting for one system clock cycle, the first phase compensation value is determined as the target compensation phase angle, which is used to compensate for the first rotation angle.

[0147] The phase compensation device provided by this invention can determine the difference between a first rotation angle and a second rotation angle by comparing the first rotation angle and the second rotation angle. The first rotation angle is a rotation angle determined by real-time rotation angle calculation based on sine wave and cosine wave signals. The second rotation angle is the rotation angle stored in the register of the magnetic encoder. The difference between the two can reflect the degree of phase delay between the sensor output and the output after data processing. Therefore, the first phase compensation value can be periodically updated based on the difference between the two. Then, when it is determined that the first rotation angle has been updated and the magnetic encoder has completed initialization, the first rotation angle can be stored in the register and wait for one system clock cycle (so that the difference between the first rotation angle and the second rotation angle can be analyzed in subsequent system clock cycles). After that, the current first phase compensation value is used as the target compensation phase angle. The target compensation phase angle can be used to compensate for the first rotation angle, thereby reducing the phase delay between the sensor output and the output after data processing, and accurately acquiring the real-time position signal.

[0148] Optionally, the phase compensation module 702 is specifically used for:

[0149] Determine the first difference between the first rotation angle and the second rotation angle;

[0150] If this cycle is the first cycle, the second phase compensation value is determined to be 0; or, if this cycle is not the first cycle, the second phase compensation value recorded by the magnetic encoder in the previous cycle is obtained.

[0151] Update the first phase compensation value based on the second phase compensation value;

[0152] The first phase compensation value is multiplied by shifting it left by N bits to determine the first variable;

[0153] Determine the second difference between the first variable and the first phase compensation value;

[0154] Based on the second difference, divide by M and round to the nearest integer to determine the second variable;

[0155] Based on the first difference and the second variable, update the second phase compensation value;

[0156] Wherein, N is 4, 5, or 6, and M is 2 to the power of N.

[0157] Optionally, the phase compensation module 702 is specifically used for:

[0158] Determine if the count value is greater than a preset value;

[0159] If the count value is determined to be greater than the preset value, then the magnetic encoder is determined to have completed initialization.

[0160] The count value is used to represent the number of times the first rotation angle has been updated.

[0161] Optionally, the device further includes an addition module, the first input terminal of which is connected to the output terminal of the phase compensation module 702, and the second input terminal of which is connected to the output terminal of the rotation angle determination module 701. The addition module is used for:

[0162] Calculate the sum of the target compensation phase angle and the first rotation angle, and determine the sum as the output of the magnetic encoder.

[0163] Optionally, the rotation angle determination module 701 includes a filtering unit and an arctangent calculation unit. The output terminal of the filtering unit is connected to the input terminal of the arctangent calculation unit, and the output terminal of the arctangent calculation unit is the output terminal of the rotation angle determination module 701.

[0164] The filtering unit is used to perform low-pass filtering based on the first digital sine wave signal and the first digital cosine wave signal to generate a second digital sine wave signal and a second digital cosine wave signal.

[0165] The arctangent calculation unit is used to generate the first rotation angle and output a trigger signal based on the second digital sine wave signal and the second digital cosine wave signal through arctangent calculation. The trigger signal is used to indicate that the first rotation angle has been updated.

[0166] Optionally, the arctangent calculation unit is specifically used for:

[0167] Based on the second digital sine wave signal and the second digital cosine wave signal, the tangent is obtained by dividing the two signals and taking the absolute value.

[0168] Based on the tangent, the initial angle is obtained by calculating the arctangent;

[0169] Based on a preset arctangent correction table, the initial angle is corrected to generate the first rotation angle;

[0170] The preset arctangent correction table is used to adjust the initial angle to 0 to 2π.

[0171] Optionally, Figure 8 This is a schematic diagram illustrating the working principle of the phase compensation device provided by the present invention, as shown below. Figure 8As shown, the phase compensation device includes a rotation angle determination module 701, a phase compensation module 702, and an addition module 703. The rotation angle determination module 701 includes a filtering unit 7011 and an arctangent calculation unit 7012. The filtering unit 7011 includes a first digital low-pass filter 7013 and a second digital low-pass filter 7014. The arctangent calculation unit 7012 and the phase compensation module 702 are controlled by the system clock signal Clk. The digital signal Dig_sinθ (i.e., the first digital sine wave signal) input from the previous stage is processed by the first digital low-pass filter 7013 and output to the first input terminal of the arctangent calculation unit 7012. The digital signal Dig_cosθ (i.e., the first digital cosine wave signal) input from the previous stage is processed by the second digital low-pass filter 7014 and output to the second input terminal of the arctangent calculation unit 7012. The system clock signal is output to the third input terminal of the arctangent calculation unit 7012 and the third input terminal of the phase compensation module 702. The first output of the arctangent calculation unit 7012 is the arctangent calculation result θ (i.e., the first rotation angle), which is output to the second input of the adder module 703 and the first input of the phase compensation module 702. The first input of the adder module 703 and the output of the phase compensation module 702 are connected. The second output of the arctangent calculation unit 7012 is an enable signal θ_vaild, which is output to the second input of the phase compensation module 702. The adder module 703 calculates the sum θ_out of avg_acc_out (i.e., the target compensation phase angle) and θ, and determines the sum as the output of the magnetic encoder.

[0172] It is understood that the phase compensation module 702 adaptively compensates for the phase delay introduced by the position analysis during the above data processing, thereby improving the angle calculation accuracy and the dynamic accuracy of the system. Moreover, this invention is an adaptive compensation system for the phase delay introduced by the position analysis, regardless of the cause of the phase delay generated by the system itself, and is easy to be ported and implemented in various magnetic encoder systems based on the arctangent algorithm.

[0173] The phase compensation device provided by this invention can determine the difference between a first rotation angle and a second rotation angle by comparing the first rotation angle and the second rotation angle. The first rotation angle is a rotation angle determined by real-time rotation angle calculation based on sine wave and cosine wave signals. The second rotation angle is the rotation angle stored in the register of the magnetic encoder. The difference between the two can reflect the degree of phase delay between the sensor output and the output after data processing. Therefore, the first phase compensation value can be periodically updated based on the difference between the two. Then, when it is determined that the first rotation angle has been updated and the magnetic encoder has completed initialization, the first rotation angle can be stored in the register and wait for one system clock cycle (so that the difference between the first rotation angle and the second rotation angle can be analyzed in subsequent system clock cycles). After that, the current first phase compensation value is used as the target compensation phase angle. The target compensation phase angle can be used to compensate for the first rotation angle, thereby reducing the phase delay between the sensor output and the output after data processing, and accurately acquiring the real-time position signal.

[0174] Figure 9 This is a schematic diagram of the magnetic encoder provided by the present invention, as shown below. Figure 9 As shown, the magnetic encoder may include a processor 910, a communication interface 920, a memory 930, and a communication bus 940. The processor 910, communication interface 920, and memory 930 communicate with each other via the communication bus 940. The processor 910 can call logical instructions from the memory 930 to execute a phase compensation method, such as the method including:

[0175] Based on the system clock cycle, the first rotation angle is obtained from the first digital sine wave signal and the first digital cosine wave signal collected by the magnetic encoder.

[0176] Based on the system clock cycle, the first phase compensation value is periodically updated according to the difference between the first rotation angle and the second rotation angle pre-stored by the magnetic encoder;

[0177] If it is determined that the first rotation angle has been updated and the magnetic encoder has completed initialization, then the first rotation angle is stored in the register and after waiting for one system clock cycle, the first phase compensation value is determined as the target compensation phase angle, which is used to compensate for the first rotation angle.

[0178] Furthermore, the logical instructions in the aforementioned memory 930 can be implemented as software functional units and, when sold or used as independent products, can be stored in a computer-readable storage medium. Based on this understanding, the technical solution of the present invention, essentially, or the part that contributes to the prior art, or a part of the technical solution, can be embodied in the form of a software product. This computer software product is stored in a storage medium and includes several instructions to cause a computer device (which may be a personal computer, server, or network device, etc.) to execute all or part of the steps of the methods described in the various embodiments of the present invention. The aforementioned storage medium includes various media capable of storing program code, such as USB flash drives, portable hard drives, read-only memory (ROM), random access memory (RAM), magnetic disks, or optical disks.

[0179] On the other hand, the present invention also provides a computer program product, the computer program product comprising a computer program that can be stored on a non-transitory computer-readable storage medium, and when the computer program is executed by a processor, the computer is able to perform the phase compensation method provided by the above methods, for example, the method comprising:

[0180] Based on the system clock cycle, the first rotation angle is obtained from the first digital sine wave signal and the first digital cosine wave signal collected by the magnetic encoder.

[0181] Based on the system clock cycle, the first phase compensation value is periodically updated according to the difference between the first rotation angle and the second rotation angle pre-stored by the magnetic encoder;

[0182] If it is determined that the first rotation angle has been updated and the magnetic encoder has completed initialization, then the first rotation angle is stored in the register and after waiting for one system clock cycle, the first phase compensation value is determined as the target compensation phase angle, which is used to compensate for the first rotation angle.

[0183] In another aspect, the present invention also provides a non-transitory computer-readable storage medium having a computer program stored thereon, which, when executed by a processor, is implemented to perform the phase compensation methods provided by the methods described above, for example, the method comprising:

[0184] Based on the system clock cycle, the first rotation angle is obtained from the first digital sine wave signal and the first digital cosine wave signal collected by the magnetic encoder.

[0185] Based on the system clock cycle, the first phase compensation value is periodically updated according to the difference between the first rotation angle and the second rotation angle pre-stored by the magnetic encoder;

[0186] If it is determined that the first rotation angle has been updated and the magnetic encoder has completed initialization, then the first rotation angle is stored in the register and after waiting for one system clock cycle, the first phase compensation value is determined as the target compensation phase angle, which is used to compensate for the first rotation angle.

[0187] The device embodiments described above are merely illustrative. The units described as separate components may or may not be physically separate. The components shown as units may or may not be physical units; that is, they may be located in one place or distributed across multiple network units. Some or all of the modules can be selected to achieve the purpose of this embodiment according to actual needs. Those skilled in the art can understand and implement this without any creative effort.

[0188] Through the above description of the embodiments, those skilled in the art can clearly understand that each embodiment can be implemented by means of software plus necessary general-purpose hardware platforms, and of course, it can also be implemented by hardware. Based on this understanding, the above technical solutions, in essence or the part that contributes to the prior art, can be embodied in the form of a software product. This computer software product can be stored in a computer-readable storage medium, such as ROM / RAM, magnetic disk, optical disk, etc., and includes several instructions to cause a computer device (which may be a personal computer, server, or network device, etc.) to execute the methods described in the various embodiments or some parts of the embodiments.

[0189] Finally, it should be noted that the above embodiments are only used to illustrate the technical solutions of the present invention, and not to limit them; although the present invention has been described in detail with reference to the foregoing embodiments, those skilled in the art should understand that modifications can still be made to the technical solutions described in the foregoing embodiments, or equivalent substitutions can be made to some of the technical features; and these modifications or substitutions do not cause the essence of the corresponding technical solutions to deviate from the spirit and scope of the technical solutions of the embodiments of the present invention.

Claims

1. A method of phase compensation, characterized by, Applied to a magnetic encoder, comprising: According to the system clock cycle, based on the first digital sine wave signal and the first digital cosine wave signal collected by the magnetic encoder, a first rotation angle is obtained; According to the system clock cycle, based on the difference between the first rotation angle and the second rotation angle pre-stored by the magnetic encoder, the first phase compensation value is periodically updated, and the second rotation angle is the first rotation angle at a historical time pre-stored in the register; If it is determined that the first rotation angle is updated and it is determined that the magnetic encoder is initialized, the first rotation angle is stored in the register, and after waiting for a system clock cycle, the first phase compensation value is determined as a target compensation phase angle, and the target compensation phase angle is used to compensate the first rotation angle.

2. The phase compensation method of claim 1, wherein, According to the system clock cycle, based on the difference between the first rotation angle and the second rotation angle pre-stored by the magnetic encoder, the first phase compensation value is periodically updated, comprising: Determine the first difference between the first rotation angle and the second rotation angle; In the case of the first cycle, the second phase compensation value is determined to be 0; or, in the case of the non-first cycle, the second phase compensation value recorded by the magnetic encoder in the last cycle is obtained; Based on the second phase compensation value, the first phase compensation value is updated; The first phase compensation value is subjected to a binary left shift multiplication operation of N bits to determine a first variable; Determine the second difference between the first variable and the first phase compensation value; Based on the second difference, divide by M and take the integer part to determine a second variable; Based on the first difference and the second variable, the second phase compensation value is updated; Wherein, the N is 4 or 5 or 6, and the M is 2 raised to the power of N.

3. The phase compensation method of claim 1, wherein, The determination that the magnetic encoder is initialized includes: Judge whether the count value is greater than the preset value; If it is determined that the count value is greater than the preset value, it is determined that the magnetic encoder is initialized; The count value is used to represent the number of times the first rotation angle is updated.

4. The phase compensation method of claim 1, wherein, Also includes: Calculate the sum of the target compensation phase angle and the first rotation angle, and determine the sum as the output of the magnetic encoder.

5. The method of phase compensation according to any one of claims 1 to 4, characterized in that, According to the system clock cycle, based on the first digital sine wave signal and the first digital cosine wave signal collected by the magnetic encoder, a first rotation angle is obtained, comprising: Based on the first digital sine wave signal and the first digital cosine wave signal, low-pass filtering is performed to generate a second digital sine wave signal and a second digital cosine wave signal; Based on the second digital sine wave signal and the second digital cosine wave signal, an inverse tangent calculation is performed to generate the first rotation angle and a trigger signal, and the trigger signal is used to indicate that the first rotation angle is updated.

6. The phase compensation method of claim 5, wherein, The inverse tangent calculation is performed to generate the first rotation angle, comprising: Based on the second digital sine wave signal and the second digital cosine wave signal, a tangent quantity is obtained by division and absolute value calculation; Based on the tangent quantity, an initial angle is obtained by inverse tangent calculation; The initial angle is corrected based on a preset arctangent correction table to generate the first rotation angle. The preset arctangent correction table is used to adjust the initial angle to 0-2π.

7. A phase compensation device, characterized by, The application is applied to a magnetic encoder, which comprises a rotation angle determination module and a phase compensation module, and the output end of the rotation angle determination module is connected with the input end of the phase compensation module. The rotation angle determination module is used to acquire a first rotation angle based on a first digital sine wave signal and a first digital cosine wave signal collected by the magnetic encoder according to a system clock cycle. The phase compensation module is used to periodically update a first phase compensation value based on the difference between the first rotation angle and a second rotation angle pre-stored in the magnetic encoder according to the system clock cycle, and the second rotation angle is a first rotation angle at a historical time pre-stored in a register. In the case that the first rotation angle is determined to be updated and the magnetic encoder is determined to be initialized, the first rotation angle is stored in the register, and after waiting for a system clock cycle, the first phase compensation value is determined as a target compensation phase angle, and the target compensation phase angle is used to compensate the first rotation angle.

8. The phase compensation device of claim 7, wherein, The application further comprises an addition module, the first input end of the addition module is connected with the output end of the phase compensation module, the second input end of the addition module is connected with the output end of the rotation angle determination module, and the addition module is used to: calculate the sum of the target compensation phase angle and the first rotation angle, and determine the sum as the output of the magnetic encoder.

9. The phase compensation device of claim 8, wherein, The rotation angle determination module comprises a filter unit and an arctangent calculation unit, the output end of the filter unit is connected with the input end of the arctangent calculation unit, and the output end of the arctangent calculation unit is the output end of the rotation angle determination module. The filter unit is used to perform low-pass filtering based on the first digital sine wave signal and the first digital cosine wave signal to generate a second digital sine wave signal and a second digital cosine wave signal. The arctangent calculation unit is used to generate the first rotation angle and a trigger signal by arctangent calculation based on the second digital sine wave signal and the second digital cosine wave signal, and the trigger signal is used to indicate that the first rotation angle is updated.

10. A magnetic encoder comprising a memory, a processor, and a computer program stored on the memory and executable on the processor, characterized in that, The processor implements the phase compensation method according to any one of claims 1-6 when executing the program.

Citation Information

Patent Citations

  • Motion error compensation method and apparatus for rotary transformer

    CN108981758A

  • Magnetic encoder with function of adaptive compensation

    CN109579880A