Motor angle compensation method, motor controller and storage medium for single-core processor
By introducing an interrupt mechanism into the single-core processor, detecting interrupt requests for resolver signals and three-phase currents, calculating the angle and angular velocity of the motor rotor, and performing angle compensation, the problem of reduced angle compensation accuracy in single-core processors is solved. Improved motor control accuracy and stability.
Patent Information
- Application Number
- CN202311806448.8
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2023-12-25
- Publication Date
- 2024-10-11
- Estimated Expiration
- 2043-12-25
AI Technical Summary
In single-core processors, the resolver soft decoding method has the problem of reduced angle compensation accuracy due to the difference in time stamps of the resolver signal and motor control.
By introducing an interrupt mechanism, the resolver signal and the interrupt request of the three-phase current are detected, the corresponding service routine is triggered, the angle and angular velocity of the motor rotor are calculated, and the angle compensation is performed based on the timestamp difference to ensure that the calculation is completed within a short time window. , reduce calculation delay.
It improves the accuracy and real-time performance of angle compensation, ensures accurate operation at critical moments, and enhances the stability and safety of motor control.
Smart Images

Figure CN117767824B_ABST
Abstract
Description
Technical Field
[0001] The present invention relates to the field of motor control technology, and in particular to a motor angle compensation method for a single-core processor, a motor and a computer-readable storage medium. Background Art
[0002] Motor control refers to the process of controlling the motor to achieve the desired torque, speed or position. The goal of motor control is to accurately adjust the input quantity of the motor to achieve the desired output performance. In motor control, resolver soft decoding provides key rotor position information that can be used to achieve accurate motor drive and control. Soft decoding calculates the precise position of the rotor by sampling, decoding and position compensation of the resolver signal.
[0003] When a motor based on a single-core processor uses a soft decoding method, the update frequency of the resolver soft decoding based on the DSADC (Delta-sigma ADC, Delta-sigma analog-to-digital converter) is different from the PWM (Pulse Width Modulation) frequency of the motor control. As a result, the timestamp difference between the motor control and decoding keeps changing, and the time difference between them cannot be accurately compensated and calculated, which leads to a problem of reduced accuracy of angle compensation.
[0004] The above contents are only used to assist in understanding the technical solution of the present invention and do not constitute an admission that the above contents are prior art. Summary of the invention
[0005] The main purpose of this application is to provide a motor angle compensation method for a single-core processor, a motor and a computer-readable storage medium, aiming to solve the problem of how to perform accurate angle compensation when performing variable frequency control on the motor in a soft decoding solution when using a single-core processor.
[0006] To achieve the above object, the present application provides a motor angle compensation method for a single-core processor, and the motor angle compensation method for a single-core processor comprises the following steps:
[0007] Detecting an interrupt request of a first interrupt generated by completing conversion of a resolver sin signal and a resolver cos signal, triggering the first interrupt;
[0008] Calculate the angle and angular velocity of the motor rotor based on the service routine of the first interrupt;
[0009] Detecting an interrupt request of a second interrupt generated by completing current sampling of the three-phase current, triggering the second interrupt;
[0010] Based on the service routine of the second interrupt, angle compensation is performed according to the angle and the angular velocity.
[0011] Optionally, the step of calculating the angle and angular velocity of the motor rotor based on the service routine of the first interrupt includes:
[0012] Obtain signal processing results of the resolver sin signal and the resolver cos signal output by the sine channel and the cosine channel;
[0013] The angle and angular velocity of the motor rotor are calculated according to the signal processing result by using an inverse tangent function and a third-order phase-locked loop algorithm.
[0014] Optionally, the service routine based on the second interrupt, the step of performing angle compensation according to the angle and the angular velocity comprises:
[0015] Disable global interrupts;
[0016] Acquire a first timestamp of a signal processing result of generating the resolver sin signal and the resolver cos signal and a second timestamp of a sampling result of generating the three-phase current;
[0017] Enable global interrupts;
[0018] Based on the angle and the angular velocity, an angle compensation value is calculated according to a difference between the first timestamp and the second timestamp, and angle compensation is performed.
[0019] Optionally, after the step of detecting the interrupt request of the second interrupt generated by completing current sampling of the three-phase current and triggering the second interrupt, the step further includes:
[0020] An interrupt request of the first interrupt is detected, and the second interrupt is suspended based on a preset interrupt arbitration mechanism.
[0021] Optionally, after the step of performing angle compensation according to the angle and the angular velocity, the service routine based on the second interrupt further includes:
[0022] Obtaining sampling results of the three-phase current;
[0023] Based on the compensated angle and the sampling result, a vector control algorithm is processed.
[0024] Optionally, after the step of suspending the second interrupt based on a preset interrupt arbitration mechanism, the method further includes:
[0025] Acquire a first timestamp of a signal processing result of generating the resolver sin signal and the resolver cos signal and a second timestamp of a sampling result of generating the three-phase current;
[0026] Based on the angle and the angular velocity, if the difference between the first timestamp and the second timestamp is negative, an angle compensation value is calculated and angle compensation is performed.
[0027] Optionally, before the step of detecting the interrupt request of the second interrupt generated by completing current sampling of the three-phase current and triggering the second interrupt, the step further includes:
[0028] The three-phase current is sampled in a master-slave mode, with the U phase being the master and the V phase and the W phase being the slaves;
[0029] The U-phase current sampling conversion is completed to generate the sampling result and the interrupt request of the second interrupt;
[0030] The V-phase current sampling conversion completion record generates a second timestamp of the sampling result.
[0031] Optionally, the detecting of the interrupt request of the first interrupt generated by completing the conversion of the resolver sin signal and the resolver cos signal, before the step of triggering the first interrupt, further comprises:
[0032] Demodulating the resolver sin signal and the resolver cos signal to obtain an initial sine signal and an initial cosine signal;
[0033] Perform envelope extraction on the initial sine signal and the initial cosine signal, generate the signal processing result and record a first timestamp of generating the signal processing result;
[0034] An interrupt request for the first interrupt is generated.
[0035] In addition, to achieve the above-mentioned purpose, the present application also provides a motor controller, which includes: a memory, a processor, and a motor angle compensation program based on a single-core processor stored in the memory and executable on the processor, wherein the motor angle compensation program based on the single-core processor is configured to implement the steps of the motor angle compensation method of the single-core processor as described above.
[0036] In addition, to achieve the above-mentioned purpose, the present application also provides a computer-readable storage medium, on which a motor angle compensation program based on a single-core processor is stored. When the motor angle compensation program based on a single-core processor is executed by the processor, the steps of the motor angle compensation method of the single-core processor as described above are implemented.
[0037] This application introduces an interrupt mechanism, which can interrupt the current execution process in time when a specific event occurs, and jump to the corresponding service routine for processing, effectively utilizing the limited computing power of a single-core processor to ensure that necessary operations are performed at critical moments. By separating the calculation and compensation steps, the angle compensation calculation is completed in a time window as short as possible, reducing the calculation delay and ultimately improving the compensation accuracy. BRIEF DESCRIPTION OF THE DRAWINGS
[0038] Figure 1 This is a flow chart of the first embodiment of the motor angle compensation method of the single-core processor of the present application;
[0039] Figure 2 This is a schematic diagram of performing angle compensation when the second interruption is not interrupted or the interruption service is not suspended in the first embodiment of the present application;
[0040] Figure 3 This is a schematic diagram of performing angle compensation after the second interruption is interrupted by the first interruption in the first embodiment of the present application;
[0041] Figure 4 This is a functional architecture diagram of the technical solution disclosed in the first embodiment of the present application;
[0042] Figure 5 This is a flow chart of a second embodiment of a motor angle compensation method for a single-core processor of the present application;
[0043] Figure 6 This is a schematic diagram of the second interrupt being suspended for angle compensation in the second embodiment of the present application;
[0044] Figure 7 It is a structural diagram of a motor controller in a hardware operating environment involved in an embodiment of the present application.
[0045] The realization of the purpose, functional features and advantages of this application will be further explained in conjunction with embodiments and with reference to the accompanying drawings. DETAILED DESCRIPTION
[0046] It should be understood that the specific embodiments described herein are only used to explain the present application and are not used to limit the present application.
[0047] This application introduces two interrupts to calculate the angle and angular velocity and compensate the angle respectively, so that the motor based on a single-core processor can complete the angle compensation in the shortest possible time, reducing the calculation delay. At the same time, through the interrupt mechanism, the current execution process can be interrupted in time to ensure that the necessary operations are performed at the critical moment, thereby improving the accuracy of angle compensation.
[0048] In order to better understand the above technical solution, exemplary embodiments of the present application will be described in more detail below with reference to the accompanying drawings. Although exemplary embodiments of the present application are shown in the accompanying drawings, it should be understood that the present application can be implemented in various forms and should not be limited by the embodiments described herein. On the contrary, these embodiments are provided in order to enable a more thorough understanding of the present application and to fully convey the scope of the present application to those skilled in the art.
[0049] First embodiment
[0050] A motor is a device that converts electrical energy into mechanical energy. It usually consists of a rotor and a stator. The position information of the rotor is critical to the control of the motor and can be used to determine parameters such as the position, speed, and acceleration of the motor. However, in practical applications, due to various factors, the angle of the motor rotor will have certain errors and changes. The purpose of angle compensation is to correct these errors so that the actual angle is consistent with the desired angle.
[0051] When a motor based on a single-core processor uses a soft decoding method to obtain the angle information of the motor rotor for angle compensation, due to the limited computing power of the single-core processor, it is unable to process a large number of computing tasks in real time, and current sampling and position sampling cannot be completed at the same time, thereby reducing the accuracy of angle compensation. Therefore, this application introduces two interrupts, and performs angle calculation and angle compensation based on the interrupt service routine, thereby ultimately improving the accuracy of angle compensation.
[0052] It should be noted that the interrupt controller is usually tightly integrated with the processor or microcontroller and is responsible for detecting and responding to interrupt requests from external devices or internal events. Once the interrupt controller determines that an interrupt request is to be triggered, it generates an interrupt signal and sends it to the processor or microcontroller. The interrupt signal interrupts the current task being executed by the processor and guides the processor to execute the corresponding interrupt service routine. The interrupt signal provides an identifier for distinguishing and handling different interrupt sources, usually called an interrupt vector. After the processor receives the interrupt signal, it jumps to the corresponding interrupt service routine according to the interrupt vector.
[0053] In this embodiment, based on Figure 1 The flow chart shown further explains the motor angle compensation method of the single-core processor proposed in this application.
[0054] Reference Figure 1 , the motor angle compensation method of the single-core processor comprises the following steps:
[0055] Step S100: detecting an interrupt request of a first interrupt generated by completing conversion of a resolver sin signal and a resolver cos signal, and triggering the first interrupt;
[0056] In this embodiment, based on the preset interrupt request generation configuration, when the resolver sin (sine) signal and the resolver cos (cosine) signal complete the conversion process of carrier elimination and envelope extraction, an interrupt request for the first interrupt will be generated. When the interrupt request for the first interrupt is detected, the interrupt controller will respond to the request and trigger the first interrupt by generating a corresponding interrupt signal.
[0057] As an optional implementation for detecting interrupt requests, an event mechanism is used to synchronize and trigger interrupt requests. When the resolver sin signal and resolver cos signal conversion are completed, an event signal is generated to indicate the event has occurred, and then a specific thread or task in the main program will wait for the signal or event. Once the signal or event is received, the corresponding task will be executed.
[0058] Furthermore, as an optional implementation scheme for generating an interrupt request for a first interrupt, after the resolver sin signal and the resolver cos signal complete the signal conversion steps of carrier elimination and envelope extraction, an interrupt request corresponding to the first interrupt can be generated based on a preset interrupt request generation configuration.
[0059] In this embodiment, the resolver sin signal and the resolver cos signal need to be demodulated first to obtain an initial sine signal and an initial cosine signal. Envelope extraction is performed based on the initial sine signal and the initial cosine signal to obtain the signal processing result. While generating the signal processing result, the time of generating the result is recorded based on the pre-configured timer input module. Based on the preset request generation configuration, when the signal processing is completed, an interrupt request is generated to trigger the corresponding interrupt.
[0060] As an optional implementation scheme for signal processing, the signal processing can be implemented by a digital signal processing method. The carrier frequency and phase are extracted from the initial sine signal and the initial cosine signal by a digital signal processing algorithm, such as discrete Fourier transform, fast Fourier transform or complex multiplication, and phase compensation is performed to eliminate the carrier. The signal after the carrier elimination is filtered by a low-pass filter, such as an infinite impulse response filter or a finite impulse response filter, to extract its envelope.
[0061] Optionally, digital signal processing can be performed by tools such as DSADC (Delta-sigma ADC, Delta-sigma analog-to-digital converter), general-purpose digital signal processor or embedded processor, field programmable gate array, ASIC (Application Specific Integrated Circuit, dedicated application specific integrated circuit) and the like.
[0062] As another optional implementation for signal processing, signal processing can be implemented through a demodulator chip. Use a dedicated demodulator chip, such as a digital phase-locked loop chip or a single demodulator chip. These chips have carrier recovery and phase compensation functions for extracting the multiplication carrier in the sine and cosine signals. Using a dedicated envelope detector chip or amplifier chip, the envelope of the input signal can be directly extracted and output.
[0063] Step S200: Calculating the angle and angular velocity of the motor rotor based on the service routine of the first interrupt;
[0064] In this embodiment, after the first interrupt is triggered, the program will jump to the service routine corresponding to the first interrupt to calculate the angle and angular velocity of the motor rotor.
[0065] As an optional implementation scheme for calculating angles and angular velocities, the corresponding angles and angular velocities are obtained based on the envelope phase. First, the signal processing results of the resolver sin signal and resolver cos signal output by the sine channel and the cosine channel are obtained; using this result, the instantaneous phase difference can be calculated. This can be calculated by the inverse tangent function (such as the arctan2 function) of the phase difference between the two signals. The phase difference reflects the rotor angle. The angular velocity of the rotor is calculated based on the time period of the angle update. The angular velocity is equal to the phase difference divided by the time period, which can be converted into radians / second or degrees / second.
[0066] It should be noted that the time period can be a fixed value or dynamically adjusted according to the characteristics and speed of the rotor motor.
[0067] In this embodiment, the phase information of the envelope is used to calculate the angle of the rotor, which can reduce the calculation complexity of the phase difference.
[0068] Optionally, peak detection may be performed on the signal in the signal processing result to obtain the peak points of the sine waveform and the cosine waveform of each cycle for phase difference calculation.
[0069] Step S300: detecting an interrupt request of a second interrupt generated by completing current sampling of the three-phase current, and triggering the second interrupt;
[0070] In this embodiment, based on the preset interrupt request generation configuration, when the three-phase current completes current sampling, an interrupt request for the second interrupt is generated. When the interrupt request for the second interrupt is detected, the interrupt controller responds to the request and triggers the second interrupt by generating a corresponding interrupt signal. When the current sampling is completed, an event signal is generated to indicate the occurrence of the event, and then a specific thread or task in the main program waits for the signal or event, and once the signal or event is received, the corresponding task is executed.
[0071] Further, as an optional implementation scheme for generating an interrupt request for a second interrupt, after the three-phase current completes the current sampling step based on the master-slave mode, an interrupt request corresponding to the second interrupt can be generated based on a preset interrupt request generation configuration.
[0072] In this embodiment, the three-phase current is first sampled through the master-slave mode, the master device includes an ADC channel for sampling and converting the U-phase current, and the slave device includes an ADC channel for sampling and converting the V-phase and W-phase currents. After the master device generates the current sampling result, it generates an interrupt request based on a preset request generation configuration to trigger a corresponding interrupt; based on the master-slave mode, while generating the current sampling result, the slave device records the time of generating the sampling result as a second timestamp based on a pre-configured timer input module.
[0073] Optionally, current sampling of the three-phase current can be performed through tools such as an analog-to-digital converter, a current sensor, and a pulse counter.
[0074] Step S400: Based on the service routine of the second interrupt, perform angle compensation according to the angle and the angular velocity.
[0075] In this embodiment, after the second interrupt is triggered, the program will jump to the service routine corresponding to the second interrupt to achieve compensation of the motor angle.
[0076] As an optional implementation scheme for angle compensation, first obtain a first timestamp of the signal processing results of the resolver sin signal and the resolver cos signal and a second timestamp of the sampling results of the three-phase current; secondly, based on the angle and the angular velocity, calculate the angle compensation value according to the difference between the first timestamp and the second timestamp and perform angle compensation.
[0077] In this embodiment, the angle compensation value can be calculated in a variety of ways.
[0078] As an optional implementation scheme for calculating the angle compensation value, the time difference between two samples is obtained by calculating the difference between the first timestamp and the second timestamp. The angle compensation value is obtained by multiplying the angle value and the angular velocity value, and the angle compensation value is compensated to the current rotor angle.
[0079] Optionally, based on Kalman filtering theory, the angle and angular velocity can be used as inputs to obtain a more accurate compensated angle value by fusing the measured value and the predicted value; or the angle and angular velocity can be input into a filter and the high-pass and low-pass filtering characteristics can be used to combine the frequency domain response of the angular velocity and the static response of the angle to obtain the compensated angle value.
[0080] refer to Figure 2 , Figure 2 The schematic diagram of angle compensation when the second interrupt is not interrupted or the interrupt service is not suspended. When the second interrupt is not interrupted by the first interrupt, the timestamp difference is a positive value, which is used for angle compensation, because the timestamp difference is the second timestamp minus the first timestamp in the second interrupt service routine.
[0081] Furthermore, when the second interrupt service routine is interrupted by the first interrupt service during execution, because the interruption time can be any time during the execution of the second interrupt service routine, it is possible that the second interrupt service routine is about to read the angle and timestamp variables written by the last first interrupt and is then interrupted by a new first interrupt request and reassigned, resulting in the angle and timestamp read in the second interrupt being different from those read in the same first interrupt, that is, the read angle and timestamp are not at the same time. Using such a timestamp difference to compensate the angle will bring an angle error of one cycle time.
[0082] In this embodiment, in order to solve the above problem, the following optional implementation scheme is proposed: disable the global interrupt at the beginning of the second interrupt service routine, and then enable the global interrupt after reading the angle, rotation speed and timestamp.
[0083] In this embodiment, referring to Figure 3 , Figure 3 The diagram is a diagram of the angle compensation after the second interrupt service routine is interrupted by the first interrupt. By disabling the global interrupt at the start of the second interrupt service function, and then enabling the global interrupt after reading the angle, rotation speed and timestamp, even if the first interrupt service request occurs during this time, it is necessary to wait for the angle, angular velocity and timestamp to be read before starting the first interrupt service routine. This ensures that no matter when the second interrupt service routine is interrupted by the first interrupt, the angle, rotation speed and timestamp read in the second interrupt are the values written in the same first interrupt, and the difference between the second timestamp and the first timestamp is still a positive value for angle compensation.
[0084] Furthermore, after the angle compensation is performed, the sampling results of the three-phase current are obtained; and based on the compensated angle and the sampling results, the vector control algorithm is processed.
[0085] As an optional implementation for processing a vector control algorithm, a rotation matrix or transformation matrix required for vector control is calculated based on the compensated angle value. This matrix is usually called "Park transform" or "Clarke-Park transform" and can transform the current from a three-phase coordinate system to a rotating vector coordinate system. The current sampling results are applied to the vector control algorithm, such as vector control using current-based feedback. Based on the results output by the vector control algorithm, a control signal (such as current or voltage) is generated to drive the motor or actuator.
[0086] Optionally, the vector control algorithm can be a current control algorithm, such as FOC (Field-Oriented Control), DTC (Direct Torque Control), or a flux-oriented control algorithm, such as FCC (Flux Control and Current Control), ROCOF (Rate of Change of Frequency), etc.
[0087] Reference Figure 4 , Figure 4 This is a functional architecture diagram of the technical solution disclosed in this embodiment. This technical solution uses DSADC to perform carrier elimination and envelope extraction on the original sine and cosine signals of the resolver, and uses ADC to sample the three-phase current. The three-phase current adopts a master-slave mode, and the U-phase configuration completes its conversion to generate a service request that triggers the motor control interrupt, and the V-phase is used to generate a service request for recording a timestamp. Configure two timer input module channels and record the moment when the DSADC sine conversion is completed and the moment when the U-phase current sampling is completed. By configuring two interrupts on the same processor, an interrupt triggered by the DSADC result, in which the results of the sine channel or cosine channel processed by the DSADC and the timestamp of the moment when the result is generated are read, and the angle and angular velocity are calculated by the inverse tangent and phase-locked loop algorithm. The other interrupt is used for the main phase current sampling conversion completion interrupt for motor vector control. In this interrupt, the angle compensation is completed according to the difference between the angle, angular velocity and the timestamp, and the vector control algorithm is processed.
[0088] It should be noted that the V-phase current sampling ADC channel and the resolver sine DSADC channel use the same time base module and can share the same high-precision clock signal to ensure that the clock frequencies of the timer input channels of the two remain consistent.
[0089] In the technical solution disclosed in this embodiment, two interrupts are introduced, and angle calculation is performed in the first interrupt to ensure high precision and accuracy. In the second interrupt service, the global interrupt is turned off to achieve real-time angle compensation and avoid interference from other interrupts. In this way, fast response and stable angle compensation can be achieved, the stability and security of the system can be improved, and the smooth execution of key tasks can be ensured.
[0090] Second embodiment
[0091] Based on the same inventive concept, this solution also provides a second embodiment. In this embodiment, based on Figure 5 The flow chart shown further explains the motor angle compensation method of the single-core processor of the present application.
[0092] Reference Figure 5 , after the step of detecting the interrupt request of the second interrupt generated by the completion of current sampling of the three-phase current and triggering the second interrupt, the step further includes:
[0093] Step S310: detecting an interrupt request of the first interrupt, and suspending the second interrupt based on a preset interrupt arbitration mechanism.
[0094] In this embodiment, the priority of the first interrupt is higher than that of the second interrupt, ensuring that the second interrupt can be interrupted by the first interrupt when interrupt nesting is allowed. The first interrupt can be responded to and processed in time, thereby ensuring the real-time performance and reliability of the system.
[0095] As an optional implementation scheme for interrupt suspension, it can be implemented through a software flag. In the service routine of the second interrupt, a software flag is set to indicate the status of the second interrupt. When the interrupt request of the first interrupt is detected, this flag is set to "suspended". In the service routine of the second interrupt, this flag is first checked. If the flag is "suspended", the service routine is exited immediately. When the flag is "not suspended", subsequent processing is performed.
[0096] Optionally, interrupt suspension may be implemented through hardware functions such as an interrupt masking controller or a hierarchical interrupt controller.
[0097] Further, refer to Figure 6 , Figure 6 This is a schematic diagram of angle compensation when the second interrupt service request is suspended. In the figure, since the first interrupt trigger occurs after the second interrupt trigger, according to the interrupt priority, the second interrupt will be suspended and the first interrupt will be processed first. Therefore, when the timestamp difference is calculated, the second timestamp minus the first timestamp will be negative. Therefore, a negative timestamp difference is needed to compensate the angle.
[0098] In the technical solution disclosed in this embodiment, by suspending the second interrupt, it is ensured that the high-priority first interrupt can be responded to and processed in time, which helps to ensure the real-time performance of the angle compensation value. By compensating the timestamp of the suspended interrupt, the time of occurrence of the event can be recorded more accurately, which helps to improve the accuracy of the angle compensation.
[0099] Reference Figure 7 , Figure 7 A schematic diagram of the motor controller structure of the hardware operating environment involved in the embodiment of the present application.
[0100] like Figure 7As shown, the motor controller may include: a processor 1001, such as a central processing unit (CPU), a communication bus 1002, a user interface 1003, a network interface 1004, and a memory 1005. Among them, the communication bus 1002 is used to realize the connection and communication between these components. The user interface 1003 may include a display screen (Display), an input unit such as a keyboard (Keyboard), and the optional user interface 1003 may also include a standard wired interface and a wireless interface. The network interface 1004 may optionally include a standard wired interface and a wireless interface (such as a wireless fidelity (WIreless-FIdelity, WI-FI) interface). The memory 1005 may be a high-speed random access memory (Random Access Memory, RAM) memory, or a stable non-volatile memory (Non-Volatile Memory, NVM), such as a disk memory. The memory 1005 may also be a storage device independent of the aforementioned processor 1001.
[0101] Those skilled in the art will understand that Figure 7 The structure shown in the figure does not constitute a limitation on the motor controller, and may include more or less components than shown in the figure, or combine certain components, or arrange the components differently.
[0102] like Figure 7 As shown, the memory 1005 as a storage medium may include an operating system, a data storage module, a network communication module, a user interface module, and a motor angle compensation program based on a single-core processor.
[0103] exist Figure 7 In the motor controller shown, the network interface 1004 is mainly used for data communication with other devices; the user interface 1003 is mainly used for data interaction with the user; the processor 1001 and the memory 1005 in the motor controller of the present application can be set in the motor controller, and the motor calls the motor angle compensation program based on the single-core processor stored in the memory 1005 through the processor 1001, and executes the motor angle compensation method of the single-core processor provided in the embodiment of the present application.
[0104] In addition, the present application also provides a computer-readable storage medium, on which is stored a motor angle compensation program based on a single-core processor. When the motor angle compensation program based on a single-core processor is executed by the processor, the steps of the motor angle compensation method of the single-core processor as described above are implemented.
[0105] It should be noted that, in this article, the terms "include", "comprises" or any other variations thereof are intended to cover non-exclusive inclusion, so that a process, method, article or system including a series of elements includes not only those elements, but also other elements not explicitly listed, or also includes elements inherent to such process, method, article or system. In the absence of further restrictions, an element defined by the sentence "comprises a ..." does not exclude the existence of other identical elements in the process, method, article or system including the element.
[0106] The serial numbers of the above-mentioned embodiments of the present application are for description only and do not represent the advantages or disadvantages of the embodiments.
[0107] Through the description of the above implementation methods, those skilled in the art can clearly understand that the above-mentioned embodiment methods can be implemented by means of software plus a necessary general hardware platform, and of course by hardware, but in many cases the former is a better implementation method. Based on such an understanding, the technical solution of the present application is essentially or the part that contributes to the prior art can be embodied in the form of a software product, which is stored in a storage medium (such as ROM / RAM, disk, CD) as described above, and includes a number of instructions for a terminal device to execute the methods described in each embodiment of the present application.
[0108] The above are only preferred embodiments of the present application, and are not intended to limit the patent scope of the present application. Any equivalent structure or equivalent process transformation made using the contents of the present application specification and drawings, or directly or indirectly applied in other related technical fields, are also included in the patent protection scope of the present application.
Claims
1. A motor angle compensation method for a single-core processor, characterized in that: The motor angle compensation method of the single-core processor comprises the following steps: Detecting an interrupt request of a first interrupt generated by completing conversion of a resolver sin signal and a resolver cos signal, triggering the first interrupt; Based on the service routine of the first interrupt, the step of calculating the angle and angular velocity of the motor rotor includes: Obtain signal processing results of the resolver sin signal and the resolver cos signal output by the sine channel and the cosine channel; Calculate the angle and angular velocity of the motor rotor according to the signal processing result by using an inverse tangent function and a third-order phase-locked loop algorithm; Detecting an interrupt request of a second interrupt generated by completing current sampling of three-phase current, triggering the second interrupt; detecting an interrupt request of the first interrupt, and suspending the second interrupt based on a preset interrupt arbitration mechanism; Based on the service routine of the second interrupt, the step of performing angle compensation according to the angle and the angular velocity comprises: Disable global interrupts; Acquire a first timestamp of a signal processing result of generating the resolver sin signal and the resolver cos signal and a second timestamp of a sampling result of generating the three-phase current; Enable global interrupts; Based on the angle and the angular velocity, an angle compensation value is calculated according to a difference between the first timestamp and the second timestamp, and angle compensation is performed.
2. The motor angle compensation method of a single-core processor according to claim 1, characterized in that: The service routine based on the second interrupt, after the step of performing angle compensation according to the angle and the angular velocity, further includes: Obtaining sampling results of the three-phase current; Based on the compensated angle and the sampling result, a vector control algorithm is processed.
3. The motor angle compensation method of a single-core processor according to claim 1, characterized in that: After the step of suspending the second interrupt based on the preset interrupt arbitration mechanism, the method further includes: Acquire a first timestamp of a signal processing result of generating the resolver sin signal and the resolver cos signal and a second timestamp of a sampling result of generating the three-phase current; Based on the angle and the angular velocity, the difference between the first timestamp and the second timestamp is negative, and an angle compensation value is calculated and angle compensation is performed.
4. The motor angle compensation method of a single-core processor according to claim 1, characterized in that: Before the step of detecting the interrupt request of the second interrupt generated by completing current sampling of the three-phase current and triggering the second interrupt, the method further includes: The three-phase current is sampled in a master-slave mode, with the U phase being the master and the V phase and the W phase being the slaves; The U-phase current sampling conversion is completed to generate the sampling result and the interrupt request of the second interrupt; The V-phase current sampling conversion completion record generates a second timestamp of the sampling result.
5. The motor angle compensation method of a single-core processor according to claim 1, characterized in that: Before the step of detecting an interrupt request of a first interrupt generated by completing the conversion between the resolver sin signal and the resolver cos signal and triggering the first interrupt, the method further comprises: Demodulating the resolver sin signal and the resolver cos signal to obtain an initial sine signal and an initial cosine signal; Perform envelope extraction on the initial sine signal and the initial cosine signal, generate the signal processing result and record a first timestamp of generating the signal processing result; An interrupt request for the first interrupt is generated.
6. A motor controller, characterized in that: The motor controller includes: a memory, a processor, and a motor angle compensation program based on a single-core processor stored in the memory and executable on the processor, wherein the motor angle compensation program based on the single-core processor is configured to implement the steps of the motor angle compensation method of the single-core processor as described in any one of claims 1 to 5.
7. A computer-readable storage medium, characterized in that: The computer-readable storage medium stores a motor angle compensation program based on a single-core processor, and when the motor angle compensation program based on a single-core processor is executed by the processor, the steps of the motor angle compensation method for a single-core processor as described in any one of claims 1 to 5 are implemented.
