Harmonic error compensation method and circuit of magnetic encoder
By setting a harmonic error compensation channel in the magnetic encoder and using the ridge regression algorithm to estimate the compensation coefficient, real-time harmonic error compensation of the magnetic encoder is realized, which solves the problem of accuracy degradation caused by harmonic noise interference and saves hardware resources.
Patent Information
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2025-12-11
- Publication Date
- 2026-04-03
AI Technical Summary
In existing technologies, magnetic encoders are subject to harmonic noise interference when measuring angles, resulting in decreased accuracy, and hardware lookup table compensation schemes consume a lot of resources.
By setting multiple harmonic error compensation channels in the magnetic encoder, the harmonic error compensation signals generated by the harmonic error compensation channels are used for real-time compensation. The ridge regression algorithm is used to estimate the harmonic compensation coefficients, and real-time harmonic error compensation is implemented in hardware.
It improves the accuracy of angle measurement while saving hardware resources and reducing the consumption of hardware resources.
Smart Images

Figure CN121783225A_ABST
Abstract
Description
[Technical Field]
[0001] This invention relates to the field of sensor signal processing, and specifically to a harmonic error compensation method and circuit for a magnetic encoder. [Background Technology]
[0002] During operation, magnetic encoders are often subject to harmonic noise interference related to rotational speed, which directly affects the accuracy of angle measurement. The characteristics of harmonic interference vary depending on the application scenario.
[0003] Common solutions to harmonic interference in existing technologies include:
[0004] 1) Ignoring harmonic noise and not performing any compensation will lead to a decrease in measurement accuracy;
[0005] 2) A hardware lookup table is set up inside the sensor to record the angle error during the calibration phase and perform interpolation compensation during runtime. However, this method has a significant drawback: the hardware lookup table consumes a lot of resources.
[0006] Therefore, it is necessary to propose an improved harmonic error compensation scheme. [Summary of the Invention]
[0007] One of the objectives of this invention is to provide a harmonic error compensation method and circuit for a magnetic encoder, which realizes real-time harmonic error compensation in hardware by estimating the harmonic compensation coefficient, thereby improving the angle measurement accuracy and saving hardware resources.
[0008] According to one aspect of the present invention, a harmonic error compensation circuit for a magnetic encoder is provided, comprising: a plurality of harmonic error compensation channels, wherein each harmonic error compensation channel receives an angle signal θ with harmonic noise and generates a harmonic error compensation signal based on the angle signal θ with harmonic noise, and the harmonic error compensation signal generated by the m-th harmonic error compensation channel is: a km *sin(km*θ)+b km *cos(km*θ), where m is the sequence number of the harmonic error compensation channel, m is greater than or equal to 1 and less than or equal to M, M is the number of the harmonic error compensation channels, M is a natural number greater than or equal to 1, a km b km is the compensation coefficient of the m-th harmonic error compensation channel, km is the order of the harmonic corresponding to the m-th harmonic error compensation channel, and km is one of 1, 2, 4 and 8; the compensation module is configured to add the harmonic error compensation signal generated by each harmonic error compensation channel to the angle signal θ with harmonic noise to obtain the compensated angle signal θ*.
[0009] According to another aspect of the present invention, a harmonic error compensation method for a magnetic encoder is provided, comprising: each of a plurality of harmonic error compensation channels receiving an angle signal θ with harmonic noise, and generating a harmonic error compensation signal based on the angle signal θ with harmonic noise, wherein the harmonic error compensation signal generated by the m-th harmonic error compensation channel is: a km *sin(km*θ)+b km *cos(km*θ), where m is the sequence number of the harmonic error compensation channel, m is greater than or equal to 1 and less than or equal to M, M is the number of the harmonic error compensation channels, M is a natural number greater than or equal to 1, a km b km is the compensation coefficient of the m-th harmonic error compensation channel, km is the order of the harmonic corresponding to the m-th harmonic error compensation channel, and km is one of 1, 2, 4 and 8; the compensation module adds the harmonic error compensation signal generated by each harmonic error compensation channel to the angle signal θ with harmonic noise to obtain the compensated angle signal θ*.
[0010] Compared with existing technologies, this invention achieves real-time harmonic error compensation in hardware by estimating the harmonic compensation coefficient, thereby improving the accuracy of angle measurement and saving hardware resources. [Attached Image Description]
[0011] To more clearly illustrate the technical solutions of the embodiments of the present invention, the drawings used in the description of the embodiments will be briefly introduced below. Obviously, the drawings described below are only some embodiments of the present invention. For those skilled in the art, other drawings can be obtained based on these drawings without creative effort. Wherein:
[0012] Figure 1 This is a structural diagram of the harmonic error compensation circuit of the magnetic encoder in one embodiment of the present invention;
[0013] Figure 2 The diagram shows the waveforms of the angle signal before and after harmonic error compensation using the harmonic error compensation circuit in this invention.
[0014] Figure 3 This is a flowchart of one embodiment of the harmonic error compensation method for the magnetic encoder in this invention.
Detailed Implementation Methods
[0015] To make the above-mentioned objects, features and advantages of the present invention more apparent and understandable, the present invention will be further described in detail below with reference to the accompanying drawings and specific embodiments.
[0016] The term "an embodiment" or "embodiment" as used herein refers to a specific feature, structure, or characteristic that may be included in at least one implementation of the invention. The phrase "in one embodiment" appearing in different places throughout this specification does not necessarily refer to the same embodiment, nor is it a single or selective embodiment that is mutually exclusive with other embodiments.
[0017] One of the objectives of this invention is to provide a harmonic error compensation method and circuit for a magnetic encoder, which realizes real-time harmonic error compensation in hardware by estimating the harmonic compensation coefficient, thereby improving the angle measurement accuracy and saving hardware resources.
[0018] Figure 1 This is a structural diagram of the harmonic error compensation circuit of the magnetic encoder in one embodiment of the present invention. Figure 1 As shown, the harmonic error compensation circuit of the magnetic encoder includes multiple harmonic error compensation channels 110 and a compensation module 120. The magnetic encoder is a sensor used to accurately measure rotation angle or position, and its core function is to convert mechanical rotational motion (angle) into an angle signal that can be read and processed by an electronic system.
[0019] The harmonic error compensation channel 110 can have M channels, where M is a natural number greater than or equal to 1. Figure 1 The image shows two harmonic error compensation channels 110, where M = 2 in this example. In other examples, M can be equal to 1, 3, or 4.
[0020] Each harmonic error compensation channel 110 receives an angle signal θ with harmonic noise output from the magnetic encoder and generates a harmonic error compensation signal based on the angle signal θ with harmonic noise. The harmonic error compensation signal generated by the m-th harmonic error compensation channel is:
[0021] a km *sin(km*θ)+b km *cos(km*θ),
[0022] Where m is the sequence number of the harmonic error compensation channel, m is greater than or equal to 1 and less than or equal to M, M is the number of the harmonic error compensation channels, M is a natural number greater than or equal to 1, a km b km Let M be the compensation coefficient for the m-th harmonic error compensation channel, and km be the order of the harmonic corresponding to the m-th harmonic error compensation channel, where km can be one of 1, 2, 4, or 8. The maximum value of M is 4. It should be noted that km is not k multiplied by m, but rather, when m is 1, 2, 3, or 4, km represents the collective name for k1, K2, k3, and K4, respectively. k1, K2, k3, and K4 are the orders of the harmonics corresponding to the 1st, 2nd, 3rd, and 4th harmonic error compensation channels, respectively.
[0023] like Figure 1 In the example shown, the harmonic error compensation signal generated by the first harmonic error compensation channel 110-1 is:
[0024] a k1 *sin(k1*θ)+b k1 *cos(k1*θ);
[0025] The harmonic error compensation signal generated by the second harmonic error compensation channel 110-2 is:
[0026] a k2 *sin(k2*θ)+b k2 *cos(k2*θ).
[0027] The compensation module 120 is configured to add the harmonic error compensation signal generated by each harmonic error compensation channel to the angle signal θ containing harmonic noise to obtain the compensated angle signal θ*. Preferably, the compensation module 120 is an adder.
[0028] like Figure 1 As shown, each harmonic error compensation channel 110 includes one sine / cosine generator module 111, two multiplier modules, and one adder module. Module 112 includes the two multiplier modules and the one adder module. The sine / cosine generator module 111 is used to obtain sin(km*θ) and cos(km*θ), and the two multiplier modules respectively obtain a. km *sin(km*θ) and b km *cos(km*θ), the adder module is used to obtain the harmonic error compensation signal a generated by the m-th harmonic error compensation channel. km *sin(km*θ)+b km *cos(km*θ).
[0029] In one embodiment, compensation coefficients a1 and b1 for the first harmonic of the angle signal θ with harmonic noise, compensation coefficients a2 and b2 for the second harmonic, compensation coefficients a4 and b4 for the fourth harmonic, and compensation coefficients a8 and b8 for the eighth harmonic are obtained based on the angle signal θ with harmonic noise. The compensation coefficients a1, a2, a4, and a8 for each harmonic are referred to as the compensation coefficients a for each harmonic, and the compensation coefficients b1, b2, b4, and b8 for each harmonic are referred to as the compensation coefficients b for each harmonic.
[0030] Calculate the amplitude of each harmonic;
[0031] Select the M harmonics with the largest amplitudes, and assign the compensation coefficient of the m-th harmonic to the m-th harmonic error compensation channel, i.e., the compensation coefficient 'a' of the m-th harmonic error compensation channel. kmThe compensation coefficient 'a' equals the amplitude of the m-th harmonic, and the compensation coefficient 'b' is the error compensation coefficient of the m-th harmonic channel. km The compensation coefficient b is equal to the m-th harmonic of amplitude, and km of the m-th harmonic error compensation channel is the order of the m-th harmonic of amplitude.
[0032] For example, assuming M=2, the first harmonic in amplitude is a second harmonic, and the second harmonic in amplitude is a fourth harmonic, then k1=2, k2=4, and the compensation coefficient a of the first harmonic error compensation channel is... k1 The compensation coefficient a2 equals the first harmonic (2nd harmonic) in amplitude, and the compensation coefficient b of the first harmonic error compensation channel. k1 The compensation coefficient b2 is equal to the amplitude of the first harmonic (2nd harmonic). The compensation coefficient a of the second harmonic error compensation channel. k2 The compensation coefficient a4 equals the second harmonic (4th harmonic) in amplitude, and the compensation coefficient b of the second harmonic error compensation channel. k2 The compensation coefficient b4 is equal to the second harmonic (4th harmonic) in amplitude.
[0033] Preferably, the amplitude R of each harmonic is... k for:
[0034] R k =a k 2 +b k 2
[0035] Where k∈{1,2,4,8}, k is the order of the harmonic.
[0036] In one embodiment, the compensation coefficients a1 and b1 for the first harmonic of the angle signal θ with harmonic noise, the compensation coefficients a2 and b2 for the second harmonic, the compensation coefficients a4 and b4 for the fourth harmonic, and the compensation coefficients a8 and b8 for the eighth harmonic are obtained based on the angle signal θ with harmonic noise.
[0037] a) The magnetic field rotates at a constant speed. The periodic angle signal output by the magnetic encoder is collected, and a complete sampling sequence of one cycle is extracted and denoted as {θ}. i}, where θ i Let be the i-th angle signal in the sequence (in radians), and let N be a natural number greater than or equal to 1. A linear fit is performed on this periodic angle signal to obtain the reference angle sequence {θ}. T i};Construct error signal {e i}={θ T i -θ i},in
[0038] e i=a1sin(θ) i )+b1cos(θ i )+a2sin(2θ i )+b2cos(2θ i )+a4sin(4θ i )+b4cos(4θ i )+a8sin(8θ i )+b8co s(8θ i );
[0039] b) Matrix construction:
[0040] iC = [a1,b1,a2,b2,a4,b4,a8,b8], where C is the objective function to be solved;
[0041] ii. For each sample point θ i Construct a row of observation vectors x i :
[0042] x i =[sin(θ)] i ),cos(θ i ),sin(2θ i ),cos(2θ i ),sin(4θ i ),cos(4θ i ),sin(8θ i ),cos(8θ i )]
[0043] iii. All observation vectors x i Arranged by rows, we obtain matrix X∈R N×8 That is, the dimension of the X matrix is
[0044] N*8, and X is obtained by standardizing each column of the X matrix. s ,in:
[0045] X s i,j =(X i,j -μ j ) / σ j i = 1, 2, ..., N, j = 1, 2, ..., 8
[0046] μ j σ is the mean of each column of matrix X. j The standard deviation of each column of matrix X;
[0047] iv. For the error vector E = [e1, e2, ..., e N ], centralize to obtain E c :
[0048] E c =E–μ e ,μ e Let E be the mean of the error vector.
[0049] v. Obtaining a linear model:
[0050] E c =X s C+ε, where ε is a random perturbation term;
[0051] c) Construction and solution of the ridge regression objective function:
[0052] 1) Construct Loss = ||E c –X s C|| 2 +λ||C|| 2 λ is the regularization coefficient (which can be set to 10). -3 ), |||| 2 The L2 norm of a vector is the square root of the sum of the squares of its components.
[0053] 2) Solving for the optimal solution in, For normalized X s transpose;
[0054] According to the optimal C * The compensation coefficients a1 and b1 for the first harmonic of the angle signal θ, the compensation coefficients a2 and b2 for the second harmonic, the compensation coefficients a4 and b4 for the fourth harmonic, and the compensation coefficients a8 and b8 for the eighth harmonic are obtained.
[0055] The harmonic error compensation circuit in this invention estimates harmonic parameters in software and performs real-time compensation in hardware, thereby improving the accuracy of angle measurement and saving hardware resources.
[0056] Figure 2 The diagram shows the waveforms of the angle signal before and after harmonic error compensation using the harmonic error compensation circuit in this invention. The horizontal axis represents the number of sample points collected after one rotation, and the vertical axis represents the angle difference between the angle signal with harmonic noise and the ideal angle. The angle signal θ before compensation has harmonic interference, and the angle signal θ* after compensation has been compensated for the harmonic interference.
[0057] According to another aspect of the present invention, the present invention provides a method for harmonic error compensation of a magnetic encoder. Figure 3 This is a flowchart of one embodiment of the harmonic error compensation method for the magnetic encoder in this invention. Figure 3 As shown, the harmonic error compensation method includes the following steps:
[0058] Step 310: Each of the multiple harmonic error compensation channels receives an angle signal θ with harmonic noise and generates a harmonic error compensation signal based on the angle signal θ with harmonic noise. The harmonic error compensation signal generated by the m-th harmonic error compensation channel is:
[0059] a km *sin(km*θ)+b km *cos(km*θ),
[0060] Where m is the sequence number of the harmonic error compensation channel, m is greater than or equal to 1 and less than or equal to M, M is the number of the harmonic error compensation channels, M is a natural number greater than or equal to 1, a km b km denoted as the compensation coefficient for the m-th harmonic error compensation channel, and km represents the order of the harmonic corresponding to the m-th harmonic error compensation channel, where km is one of 1, 2, 4, and 8.
[0061] Specifically, each harmonic error compensation channel includes one sine / cosine generator module, two multiplier modules, and one adder module. The sine / cosine generator module is used to obtain sin(km*θ) and cos(km*θ), and the two multiplier modules respectively obtain a. km *sin(km*θ) and b km *cos(km*θ), the adder module is used to obtain the harmonic error compensation signal a generated by the m-th harmonic error compensation channel. km *sin(km*θ)+b km *cos(km*θ).
[0062] Step 320: The compensation module adds the harmonic error compensation signal generated by each harmonic error compensation channel to the angle signal θ containing harmonic noise to obtain the compensated angle signal θ*. Preferably, the compensation module is an adder.
[0063] Before step 310, the harmonic error compensation method further includes:
[0064] Based on the angle signal θ with harmonic noise, the compensation coefficients a1 and b1 for the first harmonic, a2 and b2 for the second harmonic, a4 and b4 for the fourth harmonic, and a8 and b8 for the eighth harmonic are obtained. The compensation coefficients a1, a2, a4, and a8 for each harmonic are referred to as the compensation coefficients a for each harmonic, and the compensation coefficients b1, b2, b4, and b8 for each harmonic are referred to as the compensation coefficients b for each harmonic.
[0065] Calculate the amplitude of each harmonic;
[0066] Select the M harmonics with the largest amplitudes, and assign the compensation coefficient of the m-th harmonic to the m-th harmonic error compensation channel, i.e., the compensation coefficient 'a' of the m-th harmonic error compensation channel. km The compensation coefficient 'a' equals the amplitude of the m-th harmonic, and the compensation coefficient 'b' is the error compensation coefficient of the m-th harmonic channel. km The compensation coefficient b is equal to the m-th harmonic of amplitude, and km of the m-th harmonic error compensation channel is the order of the m-th harmonic of amplitude.
[0067] Preferably, the amplitude R of each harmonic is... k for:
[0068] R k =a k 2 +b k 2
[0069] Where k∈{1,2,4,8}, k is the order of the harmonic.
[0070] In one embodiment, the compensation coefficients a1 and b1 for the first harmonic of the angle signal θ with harmonic noise, the compensation coefficients a2 and b2 for the second harmonic, the compensation coefficients a4 and b4 for the fourth harmonic, and the compensation coefficients a8 and b8 for the eighth harmonic are obtained based on the angle signal θ with harmonic noise.
[0071] a) The magnetic field rotates at a constant speed. The periodic angle signal output by the magnetic encoder is collected, and a complete sampling sequence of one cycle is extracted and denoted as {θ}. i}, where θ i Let be the i-th angle signal in the sequence (in radians), and let N be a natural number greater than or equal to 1. A linear fit is performed on this periodic angle signal to obtain the reference angle sequence {θ}. T i};Construct error signal {e i}={θ T i -θ i},in
[0072] e i =a1sin(θ) i )+b1cos(θ i )+a2sin(2θ i )+b2cos(2θ i )+a4sin(4θ i )+b4cos(4θ i )+a8sin(8θ i )+b8co s(8θ i );
[0073] b) Matrix construction:
[0074] iC = [a1,b1,a2,b2,a4,b4,a8,b8], where C is the objective function to be solved;
[0075] ii. For each sample point θ i Construct a row of observation vectors x i :
[0076] x i =[sin(θ)] i ),cos(θ i ),sin(2θ i ),cos(2θ i ),sin(4θ i ),cos(4θ i ),sin(8θ i ),cos(8θ i )]
[0077] iii. All observation vectors x i Arranged by rows, we obtain matrix X∈R N×8 That is, the dimension of the X matrix is
[0078] N*8, and X is obtained by standardizing each column of the X matrix. s ,in:
[0079] X s i,j =(X i,j -μ j ) / σ j i = 1, 2, ..., N, j = 1, 2, ..., 8
[0080] μ j σ is the mean of each column of matrix X. j The standard deviation of each column of matrix X;
[0081] iv. For the error vector E = [e1, e2, ..., e N ], centralize to obtain E c :
[0082] E c =E–μ e ,μ e Let E be the mean of the error vector.
[0083] v. Obtaining a linear model:
[0084] E c =X s C+ε, where ε is a random perturbation term;
[0085] c) Construction and solution of the ridge regression objective function:
[0086] 1) Construct Loss = ||E c –X s C|| 2 +λ||C|| 2 λ is the regularization coefficient (which can be set to 10). -3 ), |||| 2 The L2 norm of a vector is the square root of the sum of the squares of its components.
[0087] 2) Solving for the optimal solution in, For normalized X s transpose;
[0088] According to the optimal C * The compensation coefficients a1 and b1 for the first harmonic of the angle signal θ, the compensation coefficients a2 and b2 for the second harmonic, the compensation coefficients a4 and b4 for the fourth harmonic, and the compensation coefficients a8 and b8 for the eighth harmonic are obtained.
[0089] In the description of this specification, the references to terms such as "one embodiment," "some embodiments," "example," "specific example," or "some examples," etc., indicate that a specific feature, structure, material, or characteristic described in connection with that embodiment or example is included in at least one embodiment or example of the present invention. In this specification, the illustrative expressions of the above terms do not necessarily refer to the same embodiment or example. Furthermore, the specific features, structures, materials, or characteristics described may be combined in any suitable manner in one or more embodiments or examples. In addition, those skilled in the art can combine and integrate the different embodiments or examples described in this specification.
[0090] Although embodiments of the present invention have been shown and described above, it is understood that the above embodiments are exemplary and should not be construed as limiting the present invention. Those skilled in the art can make changes, modifications and variations to the above embodiments within the scope of the present invention.
Claims
1. A harmonic error compensation circuit for a magnetic encoder, characterized in that, It includes: Multiple harmonic error compensation channels are provided. Each channel receives an angle signal θ with harmonic noise and generates a harmonic error compensation signal based on the angle signal θ with harmonic noise. The harmonic error compensation signal generated by the m-th harmonic error compensation channel is: a km *sin(km*θ)+b km *cos(km*θ), Where m is the sequence number of the harmonic error compensation channel, m is greater than or equal to 1 and less than or equal to M, M is the number of the harmonic error compensation channels, M is a natural number greater than or equal to 1, a km b km is the compensation coefficient of the m-th harmonic error compensation channel, km is the order of the harmonic corresponding to the m-th harmonic error compensation channel, and km is one of 1, 2, 4 and 8; The compensation module is configured to add the harmonic error compensation signal generated by each harmonic error compensation channel to the angle signal θ with harmonic noise to obtain the compensated angle signal θ*.
2. The harmonic error compensation circuit according to claim 1, characterized in that, Based on the angle signal θ with harmonic noise, the compensation coefficients a1 and b1 for the first harmonic, a2 and b2 for the second harmonic, a4 and b4 for the fourth harmonic, and a8 and b8 for the eighth harmonic are obtained. The compensation coefficients a1, a2, a4, and a8 for each harmonic are referred to as the compensation coefficients a for each harmonic, and the compensation coefficients b1, b2, b4, and b8 for each harmonic are referred to as the compensation coefficients b for each harmonic. Calculate the amplitude of each harmonic; Select the M harmonics with the largest amplitudes, and assign the compensation coefficient of the m-th harmonic to the m-th harmonic error compensation channel, i.e., the compensation coefficient 'a' of the m-th harmonic error compensation channel. km The compensation coefficient 'a' equals the amplitude of the m-th harmonic, and the compensation coefficient 'b' is the error compensation coefficient of the m-th harmonic channel. km The compensation coefficient b is equal to the m-th harmonic of amplitude, and km of the m-th harmonic error compensation channel is the order of the m-th harmonic of amplitude.
3. The harmonic error compensation circuit according to claim 2, characterized in that, Amplitude R of each harmonic k for: R k =a k 2 +b k 2 Where k∈{1,2,4,8}, k is the order of the harmonic.
4. The harmonic error compensation circuit according to claim 2, characterized in that, The compensation coefficients a1 and b1 for the first harmonic of the angle signal θ with harmonic noise, the compensation coefficients a2 and b2 for the second harmonic, the compensation coefficients a4 and b4 for the fourth harmonic, and the compensation coefficients a8 and b8 for the eighth harmonic are obtained based on the angle signal θ with harmonic noise, including: a) The magnetic field rotates at a constant speed. The periodic angle signal output by the magnetic encoder is collected, and a complete sampling sequence of one cycle is extracted and denoted as {θ}. i }, where θ i Let be the i-th angle signal in the sequence, and let N be a natural number greater than or equal to 1. Perform linear fitting on this periodic angle signal to obtain the reference angle sequence {θ}. T i };Construct error signal {e i }={θ T i -θ i },in e i =a1sin(θ i )+b1cos(θ i )+a2sin(2θ i )+b2cos(2θ i )+a4sin(4θ i )+b4cos(4θ i )+a8sin(8θ i )+b8co s(8θ i ); b) Matrix construction: iC = [a1,b1,a2,b2,a4,b4,a8,b8], where C is the objective function to be solved; ii. For each sample point θ i Construct a row of observation vectors x i : x i =[sin(θ i ),cos(θ i ),sin(2θ i ),cos(2θ i ),sin(4θ i ),cos(4θ i ),sin(8θ i ),cos(8θ i )] iii. All observation vectors x i Arranged by rows, we obtain matrix X∈R N×8 That is, the dimension of the X matrix is N*8. Then, standardize each column of the X matrix to obtain X. s ,in: X s i,j =(X i,j -m j ) / s j ,i=1,2,…N,j=1,2,…8, μ j Let σ be the mean of each column of matrix X. j The standard deviation of each column of matrix X; iv. For the error vector E = [e1, e2, ..., e N ], centralize to obtain E c : E c =E–μ e ,μ e Let E be the mean of the error vector. v. Obtaining a linear model: E c =X s C+ε, where ε is a random perturbation term; c) Construction and solution of the ridge regression objective function: 1) Construct Loss = ||E c –X s C|| 2 +λ||C|| 2 , where λ is the regularization coefficient, |||| 2 The L2 norm of a vector is the square root of the sum of the squares of its components. 2) Solve for the optimal C * =(X sT X s +λI)-1X s TE c , where X sT For normalized X s Transpose of; According to the optimal C * The compensation coefficients a1 and b1 for the first harmonic of the angle signal θ, the compensation coefficients a2 and b2 for the second harmonic, the compensation coefficients a4 and b4 for the fourth harmonic, and the compensation coefficients a8 and b8 for the eighth harmonic are obtained.
5. The harmonic error compensation circuit according to claim 1, characterized in that, Each harmonic error compensation channel includes one sine / cosine generator module, two multiplier modules, and one adder module. The sine and cosine generator module is used to obtain sin(km*θ) and cos(km*θ). The two multiplier modules respectively obtain a km *sin(km*θ) and b km *cos(km*θ), The adder module is used to obtain the harmonic error compensation signal a generated by the m-th harmonic error compensation channel. km *sin(km*θ)+b km *cos(km*θ), The compensation module is an adder.
6. A method for harmonic error compensation of a magnetic encoder, characterized in that, It includes: Each of the multiple harmonic error compensation channels receives an angle signal θ with harmonic noise and generates a harmonic error compensation signal based on the angle signal θ with harmonic noise. The harmonic error compensation signal generated by the m-th harmonic error compensation channel is: a km *sin(km*θ)+b km *cos(km*θ), Where m is the sequence number of the harmonic error compensation channel, m is greater than or equal to 1 and less than or equal to M, M is the number of the harmonic error compensation channels, M is a natural number greater than or equal to 1, a km b km is the compensation coefficient of the m-th harmonic error compensation channel, km is the order of the harmonic corresponding to the m-th harmonic error compensation channel, and km is one of 1, 2, 4 and 8; The compensation module adds the harmonic error compensation signal generated by each harmonic error compensation channel to the angle signal θ with harmonic noise to obtain the compensated angle signal θ*.
7. The harmonic error compensation method according to claim 6, characterized in that, Based on the angle signal θ with harmonic noise, the compensation coefficients a1 and b1 for the first harmonic, a2 and b2 for the second harmonic, a4 and b4 for the fourth harmonic, and a8 and b8 for the eighth harmonic are obtained. The compensation coefficients a1, a2, a4, and a8 for each harmonic are referred to as the compensation coefficients a for each harmonic, and the compensation coefficients b1, b2, b4, and b8 for each harmonic are referred to as the compensation coefficients b for each harmonic. Calculate the amplitude of each harmonic; Select the M harmonics with the largest amplitudes, and assign the compensation coefficient of the m-th harmonic to the m-th harmonic error compensation channel, i.e., the compensation coefficient 'a' of the m-th harmonic error compensation channel. km The compensation coefficient 'a' equals the amplitude of the m-th harmonic, and the compensation coefficient 'b' is the error compensation coefficient of the m-th harmonic channel. km The compensation coefficient b is equal to the m-th harmonic of amplitude, and km of the m-th harmonic error compensation channel is the order of the m-th harmonic of amplitude.
8. The harmonic error compensation method according to claim 7, characterized in that, Amplitude R of each harmonic k for: R k =a k 2 +b k 2 Where k∈{1,2,4,8}, k is the order of the harmonic.
9. The harmonic error compensation method according to claim 7, characterized in that, The compensation coefficients a1 and b1 for the first harmonic of the angle signal θ with harmonic noise, the compensation coefficients a2 and b2 for the second harmonic, the compensation coefficients a4 and b4 for the fourth harmonic, and the compensation coefficients a8 and b8 for the eighth harmonic are obtained based on the angle signal θ with harmonic noise, including: a) The magnetic field rotates at a constant speed. The periodic angle signal output by the magnetic encoder is collected, and a complete sampling sequence of one cycle is extracted and denoted as {θ}. i }, where θ i Let be the i-th angle signal in the sequence, and let N be a natural number greater than or equal to 1. Perform linear fitting on this periodic angle signal to obtain the reference angle sequence {θ}. T i };Construct error signal {e i }={θ T i -θ i },in e i =a1sin(θ i )+b1cos(θ i )+a2sin(2θ i )+b2cos(2θ i )+a4sin(4θ i )+b4cos(4θ i )+a8sin(8θ i )+b8co s(8θ i ); b) Matrix construction: iC = [a1,b1,a2,b2,a4,b4,a8,b8], where C is the objective function to be solved; ii. For each sample point θ i Construct a row of observation vectors x i : x i =[sin(θ i ),cos(θ i ),sin(2θ i ),cos(2θ i ),sin(4θ i ),cos(4θ i ),sin(8θ i ),cos(8θ i )] iii. All observation vectors x i Arranged by rows, we obtain matrix X∈R N×8 That is, the dimension of the X matrix is N*8. Then, standardize each column of the X matrix to obtain X. s ,in: X s i,j =(X i,j -m j ) / s j ,i=1,2,…N,j=1,2,…8, μ j Let σ be the mean of each column of matrix X. j The standard deviation of each column of matrix X; iv. For the error vector E = [e1, e2, ..., e N ], centralize to obtain E c : E c =E–μ e ,μ e Let E be the mean of the error vector. v. Obtaining a linear model: E c =X s C+ε, where ε is a random perturbation term; c) Construction and solution of the ridge regression objective function: 1) Construct Loss = ||E c –X s C|| 2 +λ||C|| 2 , where λ is the regularization coefficient, |||| 2 The L2 norm of a vector is the square root of the sum of the squares of its components. 2) Solve for the optimal C * =(X sT X s +λI)-1X s TE c , where X sT For normalized X s Transpose of; According to the optimal C * The compensation coefficients a1 and b1 for the first harmonic of the angle signal θ, the compensation coefficients a2 and b2 for the second harmonic, the compensation coefficients a4 and b4 for the fourth harmonic, and the compensation coefficients a8 and b8 for the eighth harmonic are obtained.
10. The harmonic error compensation method according to claim 6, characterized in that, Each harmonic error compensation channel includes one sine / cosine generator module, two multiplier modules, and one adder module. The sine and cosine generator module is used to obtain sin(km*θ) and cos(km*θ). The two multiplier modules respectively obtain a km *sin(km*θ) and b km *cos(km*θ), The adder module is used to obtain the harmonic error compensation signal a generated by the m-th harmonic error compensation channel. km *sin(km*θ)+b km *cos(km*θ), The compensation module is an adder.
Citation Information
Cited By
Harmonic compensation method for angle error of magnetic encoder
CN121994281A