A quadrature error compensation method based on sine-cosine position encoder
By detecting and sampling the voltage signal of the cosine encoder, fitting an ideal cosine waveform for orthogonal error compensation, it solves the problem of reduced position angle accuracy of low-cost cosine encoder in permanent magnet motors, and improves the control system Stability and accuracy.
Patent Information
- Application Number
- CN202211320364.9
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2022-10-26
- Publication Date
- 2024-11-08
- Estimated Expiration
- Not applicable · inactive patent
AI Technical Summary
The sinusoidal and cosine voltage waveforms generated by low-cost cosine position encoder in permanent magnet motors are not orthogonal, resulting in a reduced position angle accuracy. It is difficult for the prior art to effectively eliminate this error, affecting the accuracy and stability of motor control.
By detecting and sampling the voltage signal of the positive cosine encoder, calculating the amplitude and frequency of the positive cosine variable, fitting an ideal cosine waveform, performing orthogonal error compensation, reducing position errors using curve fitting method, and obtaining it through atan2 operation Compensated position angle, used for vector control interrupt PARK and IPark transformations.
It improves the position angle accuracy of the permanent magnet motor and the stability of the control system, reduces costs, and does not require motor parameters, only the voltage sampling value of the encoder is required, with good versatility and simple and efficient implementation method.
Smart Images

Figure CN115589180B_ABST
Abstract
Description
Technical Field
[0001] The invention belongs to the technical field of motor control, and in particular relates to an orthogonal error compensation method based on a sine-cosine position encoder. Background Art
[0002] Permanent magnet motors have a simple structure, high efficiency and a wide range of applications. Permanent magnet motors require position feedback for effective control. However, the cost of using high-precision position sensors is too high, so lower-cost encoder solutions are often used in actual products. Usually, high-precision position sensors, such as photoelectric encoders and resolvers, can cost hundreds of dollars, and the cost in mass production is almost unacceptable. In contrast, low-cost sine and cosine encoders have a simple structure and usually only require a Hall sensor with related conditioning circuits to achieve a cost of tens or even less. In addition, sine and cosine encoders can output absolute position, and are even more convenient to use than more expensive incremental photoelectric encoders. Compared with ordinary Hall sensors that can only achieve partition judgment accuracy, the accuracy is greatly improved, so they are often used in corporate products that require sine wave control of permanent magnet motors.
[0003] The sine and cosine position encoder usually generates two mutually orthogonal sine and cosine voltage waveforms. After AD sampling, the MCU scales and offsets the amplitude of the sine and cosine voltage to between -π and π, and obtains the current mechanical position angle through atan2 operation. However, the sine and cosine waveforms generated by low-cost sine and cosine encoders in actual applications are usually not accurate. The main errors include unequal sine and cosine amplitudes, median offset, harmonics, and non-orthogonality. Among them, the unequal amplitudes and median offset can be basically eliminated by scaling and offsetting after sampling. The harmonic problem can be reduced by adding a follower circuit to the sampling circuit, software and hardware filtering, etc., but the problem caused by the non-orthogonality of the sine and cosine waveforms is relatively difficult to eliminate. The phase difference between the sine and cosine voltage waveforms of high-precision sine and cosine encoders is basically π / 2, and the error is generally less than ±0.5°, but the phase difference between the sine and cosine voltage waveforms of low-cost sine and cosine encoders is much different from π / 2. The actual low-cost sine and cosine encoder products that have been used can even have an error of 3.77°. The accuracy of the position angle calculated when using such low-cost encoders is greatly reduced. Summary of the invention
[0004] In view of the deficiencies in the prior art, an object of the present invention is to provide an orthogonal error compensation method based on a sine-cosine position encoder to solve the problems raised in the above background technology.
[0005] The purpose of the present invention can be achieved through the following technical solutions:
[0006] A quadrature error compensation method based on a sine-cosine position encoder comprises the following steps:
[0007] Step 1: Detect and sample the sine-cosine encoder voltage signal:
[0008] Detect the sine and cosine voltage signal u output by the position encoder sin5 and u cos5 , the amplitude is scaled by the level conversion chip or operational amplifier to obtain the sine and cosine voltage signal u that can be sampled by the MCU sin3 and u cos3 The voltage signal is converted into a digital variable D through the AD sampling module of the MCU. sindata and D cosdata ;
[0009] Step 2: Perform amplitude scaling and zero point offset of sine and cosine digital variables:
[0010] Take the sine and cosine digital variable D obtained in step 1 sindata and D cosdata , calculate the maximum, minimum and median of the two variables, and obtain the standard sine and cosine variables D with a range of -π to π and a median of 0 by scaling and offsetting the amplitude and midpoint sincorr and D coscorr ;
[0011] Step 3: Calculate the orthogonal error of the sine and cosine variables:
[0012] The sine and cosine variables D when the motor rotates at a constant speed sincorr and D coscorr Record the values at each moment and calculate the amplitude A of these two variables corresponding to the current speed sin , A cos , frequency f sin , f cos and the first phase The expression D of sine and cosine variables with respect to time can be obtained sincorr (t) and D coscorr (t), confirm that the amplitude and frequency are consistent and Do the difference to get the real sine and cosine phase difference
[0013] Step 4: Calculate the ideal cosine variable:
[0014] The actual sine and cosine phase difference calculated in step 3 The quadrature error is obtained by subtracting the ideal quadrature phase difference of π / 2. Expression D based on the sampled cosine variable coscorr (t) Calculate an expression D that is consistent with the sine variable sincorr(t) Orthogonal ideal cosine variable expression D cosideal (t), amplitude and frequency with D coscorr (t) is the same, and the initial phase is
[0015] Step 5: Calculate the position angle after orthogonal error compensation:
[0016] Use the D obtained in step 3 sincorr (t) and D coscorr (t) De-fit the D obtained in step 4 cosideal (t), we get D cosideal With D sincorr and D coscorr Relational expression, so that the real-time ideal cosine signal can be obtained through the real-time sampled sine and cosine signals, and the real sine variable D sincorr Compared with the calculated D cosideal The compensated position angle is obtained by performing atan2 operation and used for vector control interrupt PARK and IPark transformation to improve the accuracy and effect of permanent magnet motor vector control and ensure the stable operation of the permanent magnet motor.
[0017] Preferably, the sine-cosine voltage signal u output by the encoder in step 1 is sin5 and u cos5 The voltage changes sinusoidally between 0 and 5 V, and the sine and cosine voltage signals u can be sampled by the MCU. sin3 and u cos3 The amplitude range is 0~3V.
[0018] Preferably, the expression D of the sine and cosine variables with respect to time in step 3 is sincorr (t) and D coscorr (t) is shown in the following formula:
[0019]
[0020] In the formula, A sin , A cos D sincorr (t) and D coscorr (t) amplitude, ideally A sin =A cos =π,f sin , f cos D sincorr (t) and D coscorr The frequency of (t) is ideally equal to the mechanical angular frequency corresponding to the current uniform speed.
[0021] Preferably, in step 3, when the sine and cosine variables have orthogonal errors and have not been compensated, the relationship between the position angle and the existing orthogonal errors is as follows:
[0022] θ err =θ-θ comp
[0023]
[0024] In the formula, θ err It is the theoretical error of the mechanical position angle when it is not compensated.
[0025] Preferably, the ideal cosine variable expression D in step 4 is cosideal (t) is shown in the following formula:
[0026]
[0027] Preferably, the position angle calculation expression after orthogonal error compensation in step 5 is as follows:
[0028] θ comp = atan2(D sincorr (t),D cosideal (t))
[0029] In the formula, θ comp is the mechanical position angle after compensation;
[0030] The position angle calculation expression before orthogonal error compensation is as follows:
[0031] θ=atan2(D sincorr (t),D coscorr (t))
[0032] Where θ is the uncompensated mechanical position angle;
[0033] By D sincorr (t) and D coscorr (t) Fitting D cosideal The expression of (t) is as follows:
[0034] D cosideal (t) = p00 + p10D sincorr (t)+p01D coscorr (t)
[0035] Where p00, p10 and p01 are the coefficients obtained by curve fitting.
[0036] Beneficial effects of the present invention:
[0037] 1. The present invention uses a curve fitting method to fit an ideal cosine waveform according to the sampled sine and cosine waveforms with orthogonal errors, so as to reduce the problem of excessive position error caused by the orthogonal error. While using a low-cost sine and cosine encoder to reduce costs, the stability of the control system is improved;
[0038] 2. The present invention does not require motor parameters, but only requires the voltage sampling value of the original sine-cosine encoder to be implemented. The correction object only involves the encoder and has nothing to do with the motor. Therefore, the present invention has good versatility and is easy to use. Compared with direct compensation of the position angle error, the present invention has higher accuracy, better effect and easier implementation method.
[0039] 3. The present invention adopts an offline curve fitting method, which does not need to occupy too much computing power of the MCU. Only two additional trigonometric function operations are required in the MCU. For MCUs with a trigonometric math unit (TMU) (such as DSP 280049C, DSP28075), fewer instruction cycles are required. BRIEF DESCRIPTION OF THE DRAWINGS
[0040] In order to more clearly illustrate the embodiments of the present invention or the technical solutions in the prior art, the drawings required for use in the embodiments or the description of the prior art will be briefly introduced below. Obviously, for ordinary technicians in this field, other drawings can be obtained based on these drawings without paying any creative work.
[0041] Figure 1 is a flow chart of the orthogonal error compensation method of the present invention;
[0042] Figure 2 is a graph of theoretical error values of mechanical position angles when orthogonal errors exist in the present invention;
[0043] Figure 3 It is a waveform diagram of the mechanical angle error actually measured by the low-cost sine-cosine encoder in the present invention;
[0044] Figure 4 It is a comparison diagram of the sine and cosine waveforms sampled in the present invention and the ideal cosine waveform;
[0045] Figure 5 It is a schematic diagram of the ideal cosine waveform curve fitting in the present invention. DETAILED DESCRIPTION
[0046] The following will be combined with the drawings in the embodiments of the present invention to clearly and completely describe the technical solutions in the embodiments of the present invention. Obviously, the described embodiments are only part of the embodiments of the present invention, not all of the embodiments. Based on the embodiments of the present invention, all other embodiments obtained by ordinary technicians in this field without creative work are within the scope of protection of the present invention.
[0047] See also Figure 1 As shown, the present invention is an orthogonal error compensation method based on a sine-cosine position encoder. First, a sine-cosine waveform with an orthogonal error directly generated by the sine-cosine encoder is sampled through AD, and the sine-cosine waveform is scaled to between -π and π through operations such as amplitude scaling and zero point offset. The motor is rotated at a constant speed to record the values of the sine-cosine variables and calculate the corresponding sine-cosine phases. An ideal cosine waveform function is established and an expression of the ideal cosine waveform is obtained by curve fitting. Then, the compensated position angle is calculated based on the sampled sine waveform and the ideal cosine waveform to eliminate the position error caused by non-orthogonality.
[0048] The orthogonal error compensation method of the present invention comprises the following steps:
[0049] Step 1: Detection and sampling of sine-cosine encoder voltage signals:
[0050] Detect the sine and cosine voltage signal u output by the position encoder sin5 and u cos5 (usually a sinusoidal voltage between 0 and 5V), which is scaled by a level conversion chip or op amp to obtain a sine-cosine voltage signal u with an amplitude range of 0 to 3V for MCU sampling. sin3 and u cos3 The voltage signal is converted into a digital variable of 0 to 4095 through the AD sampling module of the MCU (taking the 12-bit AD sampling port with an AD sampling reference voltage of 3V as an example) sindata and D cosdata ;
[0051] Step 2: Amplitude scaling and zero offset of sine and cosine digital variables:
[0052] Take the sine and cosine digital variable D obtained in step 1 sindata and D cosdata , calculate the maximum, minimum and median of the two variables, and obtain the standard sine and cosine variables D with a range of -π to π and a median of 0 by scaling and offsetting the amplitude and midpoint sincorr and D coscorr ;
[0053] Step 3: Calculation of orthogonal errors of sine and cosine variables:
[0054] The sine and cosine variables D when the motor rotates at a constant speed sincorr and D coscorr Record the values at each moment (record at least two complete cycles to reduce random errors), and calculate the amplitude A of these two variables corresponding to the current speed. sin , A cos , frequency f sin , f cos and the first phase The expression D of sine and cosine variables with respect to time can be obtained sincorr (t) and D coscorr (t), confirm that the amplitude and frequency are consistent and Do the difference to get the real sine and cosine phase difference
[0055] Among them, the expression of sine and cosine variables with respect to time is D sincorr (t) and D coscorr (t) are:
[0056]
[0057] In the formula, A sin , A cos D sincorr (t) and D coscorr (t) amplitude, ideally A sin =A cos =π,f sin , f cos D sincorr (t) and D coscorr The frequency of (t) is ideally equal to the mechanical angular frequency corresponding to the current uniform speed;
[0058] When there is an orthogonal error in the sine and cosine variables and they are not compensated, the relationship between the position angle and the existing orthogonal error is:
[0059] θ err =θ-θ comp
[0060]
[0061] In the formula, θ err It is the theoretical error of the mechanical position angle when it is not compensated.
[0062] Step 4: Calculation of ideal cosine variables:
[0063] Take the actual sine and cosine phase difference calculated in step 3 The quadrature error is obtained by subtracting the ideal quadrature phase difference of π / 2. Expression D based on sampled cosine variables coscorr (t) Calculate an expression D that is consistent with the sine variable sincorr (t) Orthogonal ideal cosine variable expression D cosideal (t), amplitude and frequency with D coscorr (t) is the same, and the initial phase is
[0064] Among them, the ideal cosine variable expression D cosideal (t) can be expressed as:
[0065]
[0066] Step 5: Position angle calculation after orthogonal error compensation:
[0067] Use the D obtained in step 3 sincorr (t) and D coscorr (t) De-fit the D obtained in step 4 cosideal (t), we get D cosideal With D sincorr and D coscorr Relational expression, so that the real-time ideal cosine signal can be obtained through the real-time sampled sine and cosine signals, and the real sine variable D sincorr Compared with the calculated D cosideal The compensated position angle is obtained by performing atan2 operation, which is used for vector control interruption PARK and IPark transformation, thereby improving the accuracy and effect of permanent magnet motor vector control and ensuring the stable operation of the permanent magnet motor.
[0068] Among them, the calculation expression of the position angle after orthogonal error compensation is:
[0069] θ comp = atan2(D sincorr (t),D cosideal (t))
[0070] In the formula, θ comp is the mechanical position angle after compensation.
[0071] The position angle calculation expression before orthogonal error compensation is:
[0072] θ=atan2(D sincorr (t),D coscorr (t))
[0073] Where θ is the uncompensated mechanical position angle.
[0074] By D sincorr (t) and D coscorr (t) Fitting D cosideal The expression of (t) is:
[0075] D cosideal (t) = p00 + p10D sincorr (t)+p01D coscorr (t)
[0076] Where p00, p10 and p01 are the coefficients obtained by curve fitting.
[0077] It can be seen that when there is an uncompensated orthogonal error, the position angle error is not a constant value, but changes with twice the mechanical angular frequency, which also makes it difficult to directly compensate the position angle error. Therefore, compensating the error before atan2 calculation is a better solution.
[0078] An ideal cosine waveform is fitted based on the sampled sine-cosine waveform with orthogonal error, and then an atan2 operation is performed, which can significantly reduce the mechanical position angle error. When a low-cost sine-cosine encoder is used, a good permanent magnet motor vector control effect can be achieved. The present invention is also applicable to other sine-cosine functions with orthogonal errors for error correction.
[0079] Figure 2 The figure is the mechanical position angle error diagram when the theoretical orthogonal error is 3.77°. At this time, the maximum mechanical position angle error is about 0.065rad, that is, 3.724°. Taking a 5-pole permanent magnet motor as an example, the maximum electrical angle error can reach about 18.6° at this time, which seriously affects the normal vector control operation of the motor.
[0080] Figure 3 The waveform diagram of the measured mechanical angle error of a low-cost sine-cosine encoder with a measured quadrature error of about 3.77°. The dynamic position angle error range caused by the quadrature error is about 0.065rad (the rest of the error is the static error caused by other reasons), which is basically consistent with the theoretical value. This figure verifies the source of the dynamic position error of the low-cost sine-cosine encoder.
[0081] Figure 4 This is a comparison chart of the sine and cosine waveforms sampled when the motor runs at a constant speed of 240rpm and the fitted ideal cosine waveforms.
[0082] Figure 5 The figure is a curve fitting diagram for fitting an ideal cosine waveform using the sampled sine and cosine waveforms.
[0083] In the description of this specification, the description with reference to the terms "one embodiment", "example", "specific example", etc. means that the specific features, structures, materials or characteristics described in conjunction with the embodiment or example are included in at least one embodiment or example of the present invention. In this specification, the schematic representation of the above terms does not necessarily refer to the same embodiment or example. Moreover, the specific features, structures, materials or characteristics described can be combined in any one or more embodiments or examples in a suitable manner.
[0084] The above shows and describes the basic principles, main features and advantages of the present invention. Those skilled in the art should understand that the present invention is not limited to the above embodiments, and the above embodiments and descriptions are only for explaining the principles of the present invention. Without departing from the spirit and scope of the present invention, the present invention may have various changes and improvements, and these changes and improvements all fall within the scope of the present invention to be protected.
Claims
1. A quadrature error compensation method based on a sine-cosine position encoder, characterized in that: The following steps are involved: Step 1: Detect and sample the sine-cosine encoder voltage signal: Detect the sine and cosine voltage signal u output by the position encoder sin5 and u cos5 , the amplitude is scaled by the level conversion chip or operational amplifier to obtain the sine and cosine voltage signal u that can be sampled by the MCU sin3 and u cos3 The voltage signal is converted into a digital variable D through the AD sampling module of the MCU. sindata and D cosdata ; Step 2: Perform amplitude scaling and zero point offset of sine and cosine digital variables: Take the sine and cosine digital variable D obtained in step 1 sindata and D cosdata , calculate the maximum, minimum and median of the two variables, and obtain the standard sine and cosine variables D with a range of -π to π and a median of 0 by scaling and offsetting the amplitude and midpoint sincorr and D coscorr ; Step 3: Calculate the orthogonal error of the sine and cosine variables: The sine and cosine variables D when the motor rotates at a constant speed sincorr and D coscorr Record the values at each moment and calculate the amplitude A of these two variables corresponding to the current speed sin , A cos , frequency f sin , f cos and the first phase The expression D of sine and cosine variables with respect to time can be obtained sincorr (t) and D coscorr (t), confirm that the amplitude and frequency are consistent and Do the difference to get the real sine and cosine phase difference Step 4: Calculate the ideal cosine variable: The actual sine and cosine phase difference calculated in step 3 The quadrature error is obtained by subtracting the ideal quadrature phase difference of π / 2. Expression D based on the sampled cosine variable coscorr (t) Calculate an expression D that is consistent with the sine variable sincorr (t) Orthogonal ideal cosine variable expression D cosideal (t), amplitude and frequency with D coscorr (t) is the same, and the initial phase is Step 5: Calculate the position angle after orthogonal error compensation: Use the D obtained in step 3 sincorr (t) and D coscorr (t) De-fit the D obtained in step 4 cosideal (t), we get D cosideal With D sincorr and D coscorr Relational expression, so that the real-time ideal cosine signal can be obtained through the real-time sampled sine and cosine signals, and the real sine variable D sincorr Compared with the calculated D cosideal The compensated position angle is obtained by performing atan2 operation and used for vector control interrupt PARK and IPark transformation to improve the accuracy and effect of permanent magnet motor vector control and ensure the stable operation of the permanent magnet motor.
2. The orthogonal error compensation method based on the sine-cosine position encoder according to claim 1 is characterized in that: The sine and cosine voltage signal u output by the encoder in step 1 sin5 and u cos5 The voltage changes sinusoidally between 0 and 5 V, and the sine and cosine voltage signals u can be sampled by the MCU. sin3 and u cos3 The amplitude range is 0~3V.
3. The orthogonal error compensation method based on the sine-cosine position encoder according to claim 1 is characterized in that: The expression D of the sine and cosine variables with respect to time in step 3 is sincorr (t) and D coscorr (t) is shown in the following formula: In the formula, A sin , A cos D sincorr (t) and D coscorr (t) amplitude, ideally A sin =A cos =π,f sin , f cos D sincorr (t) and D coscorr The frequency of (t) is ideally equal to the mechanical angular frequency corresponding to the current uniform speed.
4. The orthogonal error compensation method based on the sine-cosine position encoder according to claim 1 is characterized in that: In step 3, when the sine and cosine variables have orthogonal errors and have not been compensated, the relationship between the position angle and the existing orthogonal errors is as follows: i err =θ-θ comp In the formula, θ err It is the theoretical error of the mechanical position angle when it is not compensated.
5. The orthogonal error compensation method based on the sine-cosine position encoder according to claim 1, characterized in that: The ideal cosine variable expression D in step 4 cosideal (t) is shown in the following formula:
6. The orthogonal error compensation method based on the sine-cosine position encoder according to claim 1, characterized in that: The position angle calculation expression after orthogonal error compensation in step 5 is as follows: θ comp =atan2(D sincorr (t),D cosideal (t)) In the formula, θ comp is the mechanical position angle after compensation; The position angle calculation expression before orthogonal error compensation is as follows: θ=atan2(D sincorr (t),D coscorr (t)) Where θ is the uncompensated mechanical position angle; By D sincorr (t) and D coscorr (t) Fitting D cosideal The expression of (t) is as follows: D cosideal (t)=p00+p10D sincorr (t)+p01D coscorr (t) Where p00, p10 and p01 are the coefficients obtained by curve fitting.
7. The orthogonal error compensation method based on the sine-cosine position encoder according to claim 1, characterized in that: The orthogonal error compensation method can also be used for other sine and cosine functions with orthogonal errors to perform error correction.
