MCU-based resolver software decoding method and device thereof
By using a software decoding method based on MCU and employing signal conversion and oversampling techniques, the problem of high hardware decoding cost for rotary transformers was solved, high-precision shaft angle calculation was achieved, circuit design was simplified, and decoding efficiency was improved.
Patent Information
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- NANJING WEIFU JINNING
- Filing Date
- 2024-12-10
- Publication Date
- 2026-05-29
AI Technical Summary
Existing hardware decoding solutions for rotary transformers are costly, and high-precision motion control systems place new demands on shaft angle calculation.
A software decoding method based on MCU is adopted. The sine data table is transmitted to the DAC module through the timer in the MCU for signal conversion and demodulation. Combined with a four-quadrant analog multiplier and a low-pass filter, the envelope signal of rotor position information is obtained, and the sampling accuracy of the ADC is improved by oversampling technology.
It reduces the cost of the rotary transformer shaft angle calculation system, simplifies circuit design, improves decoding accuracy, avoids communication delays in the decoding chip, and saves decoding time.
Smart Images

Figure CN119761270B_ABST
Abstract
Description
Technical Field
[0001] This invention relates to the field of motor control technology, and more specifically, to a software decoding method and apparatus for a resolver based on an MCU. Background Technology
[0002] like Figure 1 As shown, the rotary transformer, as a high-precision and interference-resistant position sensor, is widely used in the electronic control systems of new energy vehicles. The rotary transformer requires a corresponding decoder to obtain rotor position information. Currently, the mainstream decoding solution is hardware decoding based on dedicated decoding chips, but these chips are expensive. Furthermore, high-precision motion control systems also place new demands on the rotary transformer shaft angle calculation technology.
[0003] To address the aforementioned issues, given the rapid advancements in microprocessor performance, implementing software-based computation of rotary transformers using microprocessors is a feasible solution. Summary of the Invention
[0004] The present invention aims to solve at least one of the technical problems existing in the prior art, and provides a software decoding method and apparatus for a rotary transformer based on an MCU, which can reduce the cost of the rotary transformer shaft angle calculation system and achieve high-precision shaft angle calculation.
[0005] As a first aspect of the present invention, a software decoding method for a rotary transformer based on an MCU is provided, comprising:
[0006] Step S1: The sine wave data table is transmitted to the DAC module via a timer in the MCU. The DAC module then converts the digital high-frequency sine wave signal D from the sine wave data table into a digital signal. exc Converted to an analog high-frequency sinusoidal signal Usinωt;
[0007] Step S2: The analog high-frequency sinusoidal signal Usinωt is amplified by the excitation amplifier circuit to output the excitation signal U. exc and the excitation signal U exc The first and second secondary windings of the rotary transformer are applied to the primary winding, and then the first and second secondary windings of the rotary transformer respectively output the first induced signal KUsinωtsinθ and the second induced signal KUsinωtcosθ.
[0008] Step S3: The excitation signal U excThe first induced signal KUsinωtsinθ is input to a first four-quadrant analog multiplier for modulation to output a first modulated signal. This first modulated signal is then input to a first low-pass filter for demodulation to output a first analog envelope signal KUsinθ containing the actual position angle θ of the motor rotor. Simultaneously, the excitation signal U... exc The second induced signal KUsinωtcosθ is input into the second four-quadrant analog multiplier for modulation to output the second modulated signal, and the second modulated signal is input into the second low-pass filter for demodulation to output the second analog envelope signal KUcosθ containing the actual position angle θ of the motor rotor.
[0009] Step S4: The first analog envelope signal KUsinθ is input to the first conditioning circuit for level adjustment to output the level-adjusted first analog envelope signal KUsinθ. The level-adjusted first analog envelope signal KUsinθ is then converted into a first digital envelope signal KUsinθ by the first ADC module. Simultaneously, the second analog envelope signal KUcosθ is input to the second conditioning circuit for level adjustment to output the level-adjusted second analog envelope signal KUcosθ. The level-adjusted second analog envelope signal KUcosθ is then converted into a second digital envelope signal KUcosθ by the second ADC module.
[0010] Step S5: Obtain the decoded position angle of the motor rotor at the previous moment. And based on the motor rotor decoding position angle at the previous moment The first digital envelope signal KUsinθ at the current moment T and the second digital envelope signal KUcosθ at the current time T Calculate the current motor rotor decoded position angle.
[0011] Furthermore, the step of triggering the transmission of the sine wave data table to the DAC module via a timer in the MCU also includes:
[0012] The sine wave data table in the MCU is transferred to the DAC module via DMA.
[0013] Furthermore, step S5 also includes:
[0014] Step S51: Decode the motor rotor position angle at the previous moment. As the instantaneous phase, the digital sinusoidal signal of the previous moment is generated by looking up the table. The digital cosine signal from the previous moment
[0015]
[0016] Step S52: Convert the first digital envelope signal KUsinθ at the current moment. T The digital cosine signal of the previous moment Multiplying them together yields the first product. The second digital envelope signal KUcosθ at the current moment T The digital sinusoidal signal from the previous moment Multiply to get the second product Then the first product Subtract the second product The product difference is obtained, and the formula for calculating the product difference is as follows:
[0017]
[0018] Where K is the effective turns ratio of the rotary transformer, and U is the amplitude of the excitation signal;
[0019] Step S53: Perform trigonometric function calculations on the product difference, based on the current actual rotor position angle θ of the motor. T Decoded position angle of motor rotor at the previous moment Calculate the deviation signal Δθ at the current time. * ,Right now According to L'Hôpital's rule for trigonometric functions, when Δθ * When it approaches 0, then sin△θ * ≈△θ * The deviation signal Δθ at the current moment * Perform PI control calculations to obtain the current motor rotor speed ω. c The calculation formula is as follows:
[0020]
[0021] Among them, K p K is the magnification factor. i The integral coefficient;
[0022] Step S54: Calculate the current motor rotor speed ω c Perform integration to calculate the current motor rotor decoded position angle. The calculation formula is as follows:
[0023]
[0024] As a second aspect of the present invention, a software decoding device for a resolver based on an MCU is provided. The MCU-based resolver software decoding device includes an MCU, an excitation amplifier circuit, a first conditioning circuit, a second conditioning circuit, a first four-quadrant analog multiplier, a second four-quadrant analog multiplier, a first low-pass filter, and a second low-pass filter. The MCU includes a timer, a DAC module, a first ADC module, and a second ADC module. The DAC module is connected to the excitation amplifier circuit. The excitation amplifier circuit is connected to the primary winding of the resolver, the first input terminal of the first four-quadrant analog multiplier, and the first input terminal of the second four-quadrant analog multiplier. The first secondary winding of the resolver is connected to the second input terminal of the first four-quadrant analog multiplier, and the second secondary winding of the resolver is connected to the second input terminal of the second four-quadrant analog multiplier. The output terminal of the first four-quadrant analog multiplier is connected to the first ADC module through the first low-pass filter and the first conditioning circuit. The output terminal of the second four-quadrant analog multiplier is connected to the second ADC module through the second low-pass filter and the second conditioning circuit.
[0025] Furthermore, the MCU also includes a memory, in which the sine data table is stored.
[0026] Furthermore, the MCU is model STM32G431.
[0027] The MCU-based software decoding method and apparatus for resolver provided by this invention have the following advantages: It eliminates the need for a dedicated decoding chip, leveraging the high computing power and rich peripherals of a microprocessor to achieve software decoding of the resolver, thus avoiding the secondary delay caused by communication with the decoding chip, simplifying the circuit, and saving design costs. A four-quadrant analog signal multiplication circuit and a low-pass filter circuit built with discrete components are used to synchronously demodulate the resolver output signal to obtain the envelope signal containing rotor position information, simplifying the software decoding computation and saving decoding time. Simultaneously, without increasing hardware costs, oversampling technology is used to improve the sampling rate and increase the effective sampling accuracy of the ADC, thereby improving the accuracy of the resolver shaft angle calculation. Attached Figure Description
[0028] The accompanying drawings are provided to further illustrate the invention and form part of the specification. They are used together with the following detailed description to explain the invention, but do not constitute a limitation thereof.
[0029] Figure 1 This is the electrical schematic diagram of a rotary transformer.
[0030] Figure 2The flowchart shows the MCU-based software decoding method for rotary transformers provided by this invention.
[0031] Figure 3 This is a schematic diagram illustrating the modulation and demodulation of the first induced signal KUsinωtsinθ provided by the present invention.
[0032] Figure 4 The structural diagram of the MCU-based resolver software decoding device provided by the present invention is shown. Detailed Implementation
[0033] To further illustrate the technical means and effects adopted by the present invention to achieve the intended purpose, the following, in conjunction with the accompanying drawings and preferred embodiments, details the specific implementation, structure, features, and effects of the MCU-based rotary transformer software decoding method and apparatus proposed according to the present invention. Obviously, the described embodiments are only some, not all, of the embodiments of the present invention. All other embodiments obtained by those skilled in the art based on the embodiments of the present invention without creative effort are within the protection scope of the present invention.
[0034] This embodiment provides a software decoding method for a resolver based on an MCU, such as... Figure 2 As shown, the MCU-based software decoding method for the resolver includes:
[0035] Step S1: The sine wave data table is transmitted to the DAC module via a timer in the MCU. The DAC module then converts the digital high-frequency sine wave signal D from the sine wave data table into a digital signal. exc Converted to an analog high-frequency sinusoidal signal Usinωt;
[0036] Preferably, the step of triggering the transmission of the sine wave data table to the DAC module via a timer in the MCU further includes:
[0037] The sine wave data table in the MCU is transferred to the DAC module via DMA.
[0038] Step S2: The analog high-frequency sinusoidal signal Usinωt is amplified by the excitation amplifier circuit to output the excitation signal U. exc and the excitation signal U exc The first and second secondary windings of the rotary transformer, acting on the primary winding, output a first induced signal KUsinωtsinθ and a second induced signal KUsinωtcosθ respectively, according to the principle of electromagnetic induction.
[0039] Step S3: As Figure 3 As shown, the excitation signal U excThe first induced signal KUsinωtsinθ is input to a first four-quadrant analog multiplier for modulation to output a first modulated signal. This first modulated signal is then input to a first low-pass filter for demodulation to output a first analog envelope signal KUsinθ containing the actual position angle θ of the motor rotor. Simultaneously, the excitation signal U... exc The second induced signal KUsinωtcosθ is input into the second four-quadrant analog multiplier for modulation to output the second modulated signal, and the second modulated signal is input into the second low-pass filter for demodulation to output the second analog envelope signal KUcosθ containing the actual position angle θ of the motor rotor.
[0040] Step S4: The first analog envelope signal KUsinθ is input to the first conditioning circuit for level adjustment to output the level-adjusted first analog envelope signal KUsinθ. The level-adjusted first analog envelope signal KUsinθ is then converted into a first digital envelope signal KUsinθ by the first ADC module. Simultaneously, the second analog envelope signal KUcosθ is input to the second conditioning circuit for level adjustment to output the level-adjusted second analog envelope signal KUcosθ. The level-adjusted second analog envelope signal KUcosθ is then converted into a second digital envelope signal KUcosθ by the second ADC module.
[0041] It should be noted that after the first ADC module and the second ADC module have completed their conversion, the 4 consecutively sampled... 4 The data is accumulated, and the accumulated result is shifted 4 bits to the right for extraction to improve the resolution of the 4-bit ADC and improve the accuracy of the angle resolution.
[0042] Step S5: Obtain the decoded position angle of the motor rotor at the previous moment. And based on the motor rotor decoding position angle at the previous moment The first digital envelope signal KUsinθ at the current moment T and the second digital envelope signal KUcosθ at the current time T Calculate the current motor rotor decoded position angle.
[0043] Preferably, step S5 further includes:
[0044] Step S51: Decode the motor rotor position angle at the previous moment. As the instantaneous phase, the digital sinusoidal signal of the previous moment is generated by looking up the table. The digital cosine signal from the previous moment
[0045]
[0046] Step S52: Convert the first digital envelope signal KUsinθ at the current moment. T The digital cosine signal of the previous moment Multiplying them together yields the first product. The second digital envelope signal KUcosθ at the current moment T The digital sinusoidal signal from the previous moment Multiply to get the second product Then the first product Subtract the second product The product difference is obtained, and the formula for calculating the product difference is as follows:
[0047]
[0048] Where K is the effective turns ratio of the rotary transformer, and U is the amplitude of the excitation signal;
[0049] Step S53: Perform trigonometric function calculations on the product difference, based on the current actual rotor position angle θ of the motor. T Decoded position angle of motor rotor at the previous moment Calculate the deviation signal Δθ at the current time. * ,Right now According to L'Hôpital's rule for trigonometric functions, when Δθ * When it approaches 0, then sin△θ * ≈△θ * The deviation signal Δθ at the current moment * Perform PI control calculations to obtain the current motor rotor speed ω. c The calculation formula is as follows:
[0050]
[0051] Among them, K p K is the magnification factor. i The integral coefficient;
[0052] Step S54: Calculate the current motor rotor speed ω c Perform integration to calculate the current motor rotor decoded position angle. The calculation formula is as follows:
[0053]
[0054] As another embodiment of the present invention, such as Figure 4As shown, a software decoding device for a resolver based on an MCU is provided. The MCU-based resolver software decoding device includes an MCU, an excitation amplifier circuit, a first conditioning circuit, a second conditioning circuit, a first four-quadrant analog multiplier, a second four-quadrant analog multiplier, a first low-pass filter, and a second low-pass filter. The MCU includes a timer, a DAC module, a first ADC module, and a second ADC module. The DAC module is connected to the excitation amplifier circuit. The excitation amplifier circuit is connected to the primary winding of the resolver, the first input terminal of the first four-quadrant analog multiplier, and the first input terminal of the second four-quadrant analog multiplier. The first secondary winding of the resolver is connected to the second input terminal of the first four-quadrant analog multiplier, and the second secondary winding of the resolver is connected to the second input terminal of the second four-quadrant analog multiplier. The output terminal of the first four-quadrant analog multiplier is connected to the first ADC module through the first low-pass filter and the first conditioning circuit. The output terminal of the second four-quadrant analog multiplier is connected to the second ADC module through the second low-pass filter and the second conditioning circuit.
[0055] Preferably, the MCU further includes a memory, in which the sine data table is stored.
[0056] Preferably, the MCU is an STM32G431.
[0057] The working principle of the MCU-based resolver software decoding device provided by this invention is described in the previous description of the MCU-based resolver software decoding method, and will not be repeated here.
[0058] The MCU-based software decoding method for resolver provided in this invention eliminates the need for a dedicated decoding chip. Leveraging the high computing power and rich peripherals of a microprocessor, it achieves software decoding of the resolver, eliminating the secondary delay caused by communication with a decoding chip, simplifying the circuit, and saving design costs. A four-quadrant analog signal multiplication circuit and a low-pass filter circuit built with discrete components synchronously demodulate the resolver output signal to obtain the envelope signal containing rotor position information, simplifying the software decoding computation and saving decoding time. Simultaneously, without increasing hardware costs, oversampling technology is used to improve the sampling rate and increase the effective sampling accuracy of the ADC, thereby improving the accuracy of the resolver shaft angle calculation.
[0059] The above description is merely a preferred embodiment of the present invention and is not intended to limit the present invention in any way. Although the present invention has been disclosed above with reference to preferred embodiments, it is not intended to limit the present invention. Any person skilled in the art can make some modifications or alterations to the above-disclosed technical content to create equivalent embodiments without departing from the scope of the present invention. Any simple modifications, equivalent changes, and alterations made to the above embodiments based on the technical essence of the present invention without departing from the scope of the present invention shall still fall within the scope of the present invention.
Claims
1. A software decoding method for a resolver based on an MCU, characterized in that, Includes the following steps: Step S1: The sine wave data table is transmitted to the DAC module via a timer in the MCU. The DAC module then converts the digital high-frequency sine wave signal D from the sine wave data table into a digital signal. exc Converted to an analog high-frequency sinusoidal signal Usinωt; Step S2: The analog high-frequency sinusoidal signal Usinωt is amplified by the excitation amplifier circuit to output the excitation signal U. exc and the excitation signal U exc The first and second secondary windings of the rotary transformer are applied to the primary winding, and then the first and second secondary windings of the rotary transformer respectively output the first induced signal KUsinωtsinθ and the second induced signal KUsinωtcosθ. Step S3: The excitation signal U exc The first induced signal KUsinωtsinθ is input to a first four-quadrant analog multiplier for modulation to output a first modulated signal. This first modulated signal is then input to a first low-pass filter for demodulation to output a first analog envelope signal KUsinθ containing the actual position angle θ of the motor rotor. Simultaneously, the excitation signal U... exc The second induced signal KUsinωtcosθ is input into the second four-quadrant analog multiplier for modulation to output the second modulated signal, and the second modulated signal is input into the second low-pass filter for demodulation to output the second analog envelope signal KUcosθ containing the actual position angle θ of the motor rotor. Step S4: The first analog envelope signal KUsinθ is input to the first conditioning circuit for level adjustment to output the level-adjusted first analog envelope signal KUsinθ. The level-adjusted first analog envelope signal KUsinθ is then converted into a first digital envelope signal KUsinθ by the first ADC module. Simultaneously, the second analog envelope signal KUcosθ is input to the second conditioning circuit for level adjustment to output the level-adjusted second analog envelope signal KUcosθ. The level-adjusted second analog envelope signal KUcosθ is then converted into a second digital envelope signal KUcosθ by the second ADC module. Step S5: Obtain the decoded position angle of the motor rotor at the previous moment. And based on the motor rotor decoding position angle at the previous moment The first digital envelope signal KUsinθ at the current moment T and the second digital envelope signal KUcosθ at the current time T Calculate the current motor rotor decoded position angle.
2. The MCU-based software decoding method for rotary transformers according to claim 1, characterized in that, The step of transmitting the sine wave data table to the DAC module via a timer in the MCU also includes: The sine wave data table in the MCU is transferred to the DAC module via DMA.
3. The MCU-based software decoding method for rotary transformers according to claim 1, characterized in that, Step S5 further includes: Step S51: Decode the motor rotor position angle at the previous moment. As the instantaneous phase, the digital sinusoidal signal of the previous moment is generated by looking up the table. The digital cosine signal from the previous moment Step S52: Convert the first digital envelope signal KUsinθ at the current moment. T The digital cosine signal of the previous moment Multiply to get the first product The second digital envelope signal KUcosθ at the current moment T The digital sinusoidal signal from the previous moment Multiply to get the second product Then the first product Subtract the second product The product difference is obtained, and the formula for calculating the product difference is as follows: Where K is the effective turns ratio of the rotary transformer, and U is the amplitude of the excitation signal; Step S53: Perform trigonometric function calculations on the product difference, based on the current actual rotor position angle θ of the motor. T Decoded position angle of motor rotor compared to the previous moment Calculate the deviation signal Δθ at the current time. * ,Right now According to L'Hôpital's rule for trigonometric functions, when Δθ * If it approaches 0, then sin△θ * ≈△θ * The deviation signal Δθ at the current moment * Perform PI control calculations to obtain the current motor rotor speed ω. c The calculation formula is as follows: Among them, K p K is the magnification factor. i The integral coefficient; Step S54: Calculate the current motor rotor speed ω c Perform integration to calculate the current motor rotor decoded position angle. The calculation formula is as follows:
4. A MCU-based software decoding device for a resolver, used to implement the MCU-based software decoding method for a resolver as described in any one of claims 1-3, characterized in that, The MCU-based resolver software decoding device includes an MCU, an excitation amplifier circuit, a first conditioning circuit, a second conditioning circuit, a first four-quadrant analog multiplier, a second four-quadrant analog multiplier, a first low-pass filter, and a second low-pass filter. The MCU includes a timer, a DAC module, a first ADC module, and a second ADC module. The DAC module is connected to the excitation amplifier circuit. The excitation amplifier circuit is connected to the primary winding of the resolver, the first input terminal of the first four-quadrant analog multiplier, and the first input terminal of the second four-quadrant analog multiplier. The first secondary winding of the resolver is connected to the second input terminal of the first four-quadrant analog multiplier, and the second secondary winding of the resolver is connected to the second input terminal of the second four-quadrant analog multiplier. The output terminal of the first four-quadrant analog multiplier is connected to the first ADC module through the first low-pass filter and the first conditioning circuit. The output terminal of the second four-quadrant analog multiplier is connected to the second ADC module through the second low-pass filter and the second conditioning circuit.
5. The MCU-based resolver software decoding device according to claim 4, characterized in that, The MCU also includes a memory, and the sine data table is stored in the memory.
6. The MCU-based resolver software decoding device according to claim 4, characterized in that, The MCU is an STM32G431.