Motor control device and timestamp compensation method thereof

By introducing a timestamp compensation method into the motor control device, the problem of inaccurate control caused by the inconsistency between the angle and current sampling periods is solved, and the accuracy and stability of current control are achieved. The angle parameter is compensated by the judgment mechanism of timestamp and flag interval.

CN121602889APending Publication Date: 2026-03-03DELTA ELECTRONICS INC(CN)
View PDF 0 Cites 0 Cited by

Patent Information

Application Number
CN202411174772.7
Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
Filing Date
2024-08-26
Publication Date
2026-03-03

AI Technical Summary

Technical Problem

In the control of permanent magnet synchronous motors, the inconsistency between the angle and current sampling period leads to inaccurate control, affecting the stability and accuracy of current control.

Method used

By introducing a timestamp compensation method into the motor control device, the control module counts specific cycles and sets a flag interval. Combined with angle sensing and current sensing devices, the timing of timestamps and interrupt programs is determined, and angle parameters are compensated to ensure synchronization.

Benefits of technology

It achieves accurate and stable current control under different actuation conditions, avoiding control instability caused by inaccurate angle parameters.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN121602889A_ABST
    Figure CN121602889A_ABST
Patent Text Reader

Abstract

A motor control device and a timestamp compensation method thereof are provided, the motor control device is used for controlling a drive circuit to drive a motor to operate, and the motor control device comprises a control module, an angle sensing device and a current sensing device. The control module counts a plurality of first specific periods and a plurality of second specific periods to provide a count value increasing along with time in each first specific period, and sets a timestamp, a specific flag interval and a specific interrupt program. The angle sensing device is used for sampling an angle parameter of the motor according to a solution angle interruption program at a first time of each first specific period, and the current sensing device is used for sampling a current parameter of the driving circuit according to a current interruption program at a second time of each second specific period. The control module compensates the angle parameters according to the interrupt programs and the timestamps.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] This invention relates to a motor control device and its operating method, and more particularly to a motor control device with timestamp compensation and its timestamp compensation method. Background Technology

[0002] Induction motors are widely used due to their simple construction, easy maintenance, and low cost. However, under the same power conditions, permanent magnet synchronous motors (PMSMs) have advantages such as small size, light weight, and high efficiency. Currently, most electric vehicles use PMSMs. However, to control PMSMs more accurately, it is generally necessary to continuously sample the angle and current of the PMSM to precisely control it. Therefore, the shaft angle position feedback and current sampling parts play a crucial role in the entire motor control system architecture. Because in the entire motor control system, to achieve vector control of the drive circuit, the sampling of the motor shaft angle position and current must be synchronized. If asynchrony occurs, poor overall control performance is likely to result.

[0003] Therefore, typical motor control devices first need to analyze these feedback signals to obtain the angle. However, due to the limitations of the internal controller's hardware, the calculation cycle during angle calculation differs from the current sampling cycle. This discrepancy between the angle calculation cycle and the current sampling cycle prevents them from being acquired synchronously, resulting in a difference between the current angle at the current sampling point and the angle obtained during the original angle sampling cycle. Consequently, the motor control device cannot provide precise current control.

[0004] Therefore, how to design a motor control device and its timestamp compensation method to provide a judgment mechanism to identify the electrical angle algorithm corresponding to various situations, so as to avoid the motor current being unable to be accurately controlled or being unstable, is a major research topic that the creators of this case intend to conduct. Summary of the Invention

[0005] To address the aforementioned problems, the present invention provides a motor control device to overcome the limitations of known technologies. Therefore, the motor control device of the present invention is used to control a drive circuit to drive a motor, and the motor control device includes a control module, an angle sensing device, and a current sensing device. The control module counts a plurality of first specific cycles and a plurality of second specific cycles, and provides a count value that increases over time in each first specific cycle, wherein the control module sets a specific flag interval. The angle sensing device samples the angle parameters of the motor rotor according to an angle resolution interruption procedure at a first time in each first specific cycle. The current sensing device samples the current parameters provided by the drive circuit according to a current interruption procedure at a second time in each second specific cycle, and the control module sets a timestamp at the trigger point of each second specific cycle, thereby initiating the specific flag interval. The control module compensates for the angle parameters based on the specific flag interval in which the current interruption procedure is located, the timestamp, and the timing of the angle resolution interruption procedure, the current interruption procedure, and the specific interruption procedure.

[0006] To address the aforementioned problems, the present invention provides a timestamp compensation method for a motor control device, overcoming the limitations of known technologies. Therefore, the motor control device of the present invention is used to control a drive circuit to drive a motor, and the motor control device includes an angle sensing device and a current sensing device. The timestamp compensation method includes the following steps: counting a plurality of first specific cycles and a plurality of second specific cycles, providing a count value that increases over time in each first specific cycle, and setting a specific flag interval. At a first time in each first specific cycle, controlling the angle sensing device to sample the angle parameters of the motor rotor according to an angle resolution interruption procedure. At a second time in each second specific cycle, controlling the current sensing device to sample the current parameters provided by the drive circuit according to a current interruption procedure, setting a timestamp at the trigger point of each second specific cycle, and initiating the specific flag interval accordingly. Compensating the angle parameters based on the specific flag interval where the current interruption procedure is located, the timestamp, and the timing of the angle resolution interruption procedure, the current interruption procedure, and the specific interruption procedure.

[0007] The main purpose and effect of this disclosure is that the control module of this disclosure determines whether the count value corresponding to the second time triggered after the timestamp is greater than the count value corresponding to the timestamp, and performs corresponding control accordingly. In this way, the electric angle algorithm corresponding to the motor system in various situations can be identified, avoiding the situation where the current of the motor cannot be accurately controlled or the control is unstable due to the current angle parameters obtained by the control module being inaccurate.

[0008] To gain a deeper understanding of the techniques, means, and effects employed by this invention to achieve its intended purpose, please refer to the following detailed description and accompanying drawings. It is believed that the purpose, features, and characteristics of this invention can be understood in a thorough and specific manner from these drawings. However, the accompanying drawings are provided for reference and illustration only and are not intended to limit this invention. Attached Figure Description

[0009] Figure 1A This is a circuit block diagram of the motor system disclosed herein;

[0010] Figure 1B This is a schematic diagram of the angle signal conversion method disclosed in this paper;

[0011] Figure 1C This is a timing diagram of the actual operation of the control module disclosed in this paper;

[0012] Figure 2A This is a timing diagram of the operation of the motor system under a specific situation.

[0013] Figure 2B This is a timing diagram of the operation of the motor system in another specific scenario.

[0014] Figure 2C This is a schematic diagram of the current waveform of the motor system under another specific situation.

[0015] Figure 3A This is a timing diagram of the motor system's operation in the first scenario.

[0016] Figure 3B This is a timing diagram of the motor system's operation in the second scenario.

[0017] Figure 3C This is a timing diagram of the motor system's operation in the third scenario.

[0018] Figure 3D This is a timing diagram of the motor system's operation in the fourth scenario.

[0019] Figure 3E This is a timing diagram of the motor system's operation in the fifth scenario.

[0020] Figure 4A This is a schematic diagram illustrating the interruption process of this disclosure.

[0021] Figure 4B This is a flowchart of the first embodiment of the timestamp compensation method for the motor control device disclosed herein; and

[0022] Figure 4C This is a flowchart of the second embodiment of the timestamp compensation method for the motor control device disclosed herein.

[0023] [Symbol Explanation]

[0024] 100: Motor System

[0025] 200: Motor

[0026] 300: Drive circuit

[0027] 400: Motor control device

[0028] 1: Control Module

[0029] ADC1, ADC2: Analog-to-Digital Converters

[0030] 10: Control Unit

[0031] 2: Angle sensing device

[0032] 3: Current sensing device

[0033] Pin: Input power

[0034] Po: Output power

[0035] St: Angle signal

[0036] PWM: Pulse Width Modulation Signal

[0037] Si: Current signal

[0038] Pt, Pt1~Pt3: Angular parameters

[0039] Pt1', Pt2': Current angle parameters

[0040] Ia, Ib, Ic, Ia1~Ia3, Ib1~Ib3, Ic1~Ic3: Current parameters

[0041] R-ISR: Angle Resolution Interruption Procedure

[0042] A-ISR, A-ISR': Current interruption procedure

[0043] ISR: Specific Interrupt Procedure

[0044] TC1, TC1-1 to TC1-3, TC1_A: First specific period

[0045] CV: Count value

[0046] TC1_t: Triggering time point

[0047] TC2, TC2-1 to TC2-3: Second specific period

[0048] T1, T1-1~T1-3: First Time

[0049] T2, T2-1~T2-3: Second time

[0050] TP, TP~TP3: Timestamps

[0051] Td, Td1~Td3: Time difference

[0052] t0~t1: Operation period Detailed Implementation

[0053] The technical content and detailed description of the present invention are explained below with reference to the accompanying drawings:

[0054] Please see Figure 1A This is a circuit block diagram of the motor system disclosed herein. The motor system 100 includes a motor 200, a drive circuit 300, and a motor control device 400, and the motor control device 400 is mainly used to control the drive circuit 300 to drive the motor 200 to operate. Specifically, the motor control device 400 includes a control module 1, an angle sensing device 2, and a current sensing device 3. One end of the drive circuit 300 receives an input power supply Pin, and the other end is coupled to the motor 200. The angle sensing device 2 samples the angle parameter Pt of the rotor of the motor 200 to provide an angle signal St to the control module 1 based on the angle parameter Pt. The current sensing device 3 samples the current parameters Ia, Ib, and Ic (i.e., the currents of phases A, B, and C) provided to the motor 200 by the drive circuit 300 to provide a current signal Si to the control module 1 based on the current parameters Ia, Ib, and Ic. The control module 1 receives the angle signal St and the current signal Si, and provides a pulse width modulation (PWM) signal to the drive circuit 300 based on the angle signal St and the current signal Si. The drive circuit 300 converts the input power supply Pin into the output power supply Po according to the pulse width modulation signal PWM, so as to provide the output power supply Po to control the operation of the motor 200.

[0055] The drive circuit 300 is preferably an inverter to convert the DC input power Pin into the AC output power Po. The angle sensing device 2 is preferably a deflector or similar device for sensing the angle of the motor 200, and the control module 1 may include, for example, but not limited to, an analog-to-digital converter (ADC1) to convert the angle signal St into a suitable format. Therefore, the control module 1 can sample the angle signal St through, for example, but not limited to, a deflection interrupt routine (R-ISR), and provide it to the control unit 10 inside the control module 1 for interpretation and calculation, so that the control unit 10 can know the angle parameter Pt. When the angle sensing device 2 is a deflector, the deflector is axially connected to the shaft of the motor 200, so as to sample the angle parameter Pt by driving the shaft of the motor 200. Similarly, the current signal Si provided by the current sensing device 3 can be converted into a suitable format by, for example, but not limited to, an analog-to-digital converter ADC 2. The control module 1 can sample the current signal Si by, for example, but not limited to, a current interrupt program, and provide it to the control unit 10 inside the control module 1 for interpretation and calculation, so that the control unit 10 can know the current parameters Ia, Ib, and Ic. Among them, the obtained angle parameter Pt may differ from the actual angle of the motor 200 at present. This disclosure mainly compensates for this error by means of compensation so that the result calculated by the control unit 10 is close to the actual value (more details will be provided later, and will not be repeated here).

[0056] Among them, the analog-to-digital converters ADC1 and ADC2 are preferably Delta-Sigma analog-to-digital converters (DSADCs) for more precise signal conversion, but are not limited to this. Therefore, the control unit 10 can generate a pulse width modulation signal PWM based on the angle signal St and the current signal Si, and adjust the pulse width modulation signal PWM accordingly (e.g., but not limited to frequency, pulse width, etc.) based on the changes in the angle signal St and the current signal Si. Therefore, the control module can control the drive circuit 300 by providing the pulse width modulation signal PWM, so as to drive the motor 200 to operate and adjust the speed of the motor 200.

[0057] See also Figure 1BThis diagram illustrates the angle signal conversion method disclosed herein. When the analog-to-digital converter ADC1 completes one full carrier cycle (Time count; TC1), an interrupt event is generated to trigger the angle resolution interrupt routine R-ISR to process the Sin and Cos signals for a single full cycle. A full Sin and Cos carrier cycle, after processing, yields an angle parameter Pt (i.e., a point on the envelope). Due to limitations of control module 1, the frequency of a full carrier cycle cannot be an integer (e.g., but not limited to, 32*64 / 20M = 102.4µs, approximately 9.765kHz). Therefore, the frequency processed by the angle resolution interrupt routine R-ISR cannot be synchronized with or be a multiple of the operating frequency of control unit 10.

[0058] See also Figure 1C This is a timing diagram of the actual operation of the control module disclosed herein. Control module 1 counts multiple first specific cycles TC1 (i.e., one complete carrier cycle), and provides a count value CV that increases over time in each first specific cycle TC1. The first specific cycle TC1 primarily triggers the analog-to-digital converter ADC1 to complete conversion to the output signal during the angle control cycle. At the first time T1-1 to T1-3 after the trigger point of the first specific cycle TC1 (i.e., one complete carrier cycle, for example, but not limited to 9.765kHz), an interrupt event is generated to trigger the angle interrupt routine R-ISR, and the angle parameters Pt1 to Pt3 of the rotor of motor 200 are sampled in the angle interrupt routine R-ISR. Furthermore, control unit 10 also has multiple self-counting second specific cycles TC2. The second specific cycles TC2 primarily trigger the analog-to-digital converter ADC2 to complete conversion to the output signal during the PWM control cycle, and control unit 10 primarily uses the PWM control cycle to periodically adjust the pulse width modulation signal PWM. When the time reaches the second specific period TC2 (e.g., but not limited to 10kHz) trigger point, the second time T2-1 to T2-3 is generated to trigger the current interruption program A-ISR, and the current parameters Ia1 to Ia3, Ib1 to Ib3, and Ic1 to Ic3 are provided to the motor 200 by the current interruption program A-ISR sampling drive circuit 300.

[0059] The angle parameters Pt1~Pt3 and the current parameters Ia1~Ia3, Ib1~Ib3, Ic1~Ic3 cannot be synchronized due to their different sampling frequencies (i.e., 9.765kHz and 10kHz). This is mainly because the frequencies of the angle interruption program R-ISR and the current interruption program A-ISR are not equal or multiples of each other, resulting in an unstable time relationship between the two interrupt programs. Therefore, the angle parameters Pt1~Pt3 obtained at the time points when acquiring the current parameters Ia1~Ia3, Ib1~Ib3, Ic1~Ic3 are actually deviated angles, thus causing the current supplied to the motor 200 (i.e., current parameters Ia, Ib, Ic) to be unable to be accurately controlled or to be unstable. The following will use... Figure 2A , 2B As an illustrative example. In Figure 2A In certain scenarios, because the frequencies of the angle interruption procedure R-ISR and the current interruption procedure A-ISR are not equal or not multiples of each other, the current interruption procedure A-ISR is executed twice during a certain first specific cycle TC1_A. This will result in not only an angle lag problem, but also that during the second second time T2-2 of the first specific cycle TC1_A, the current angle parameter obtained by the control unit 10 is still the angle parameter Pt1 from the first time T1-1, meaning the angle has not been updated. Consequently, this will cause the current of the motor 200 to be inaccurately controlled or to be unstable.

[0060] To avoid this situation, this disclosure estimates the angular displacement Δθ = ω * Δt by measuring the time difference between the rotational speed and the time of asynchrony, with the time difference obtained using a timestamp (TP). That is, see reference [link to relevant documentation]. Figure 1C A timestamp TP is set at the trigger point of each second specific cycle TC2, and this timestamp TP is saved to the temporary register (not shown) of control module 1 for reference during each current interrupt procedure A-ISR. Therefore, although the first specific cycle TC1 and the second specific cycle TC2 are not exactly the same (i.e., 9.765kHz and 10kHz) and cannot be synchronized, the current angle parameter Pt1' under timestamp TP can be estimated by the time difference Td between the angle parameter Pt1 and the timestamp TP. In this way, the current current parameters Ia2, Ib2, Ic2 and the current angle parameter Pt1' at the same time point can be obtained, and precise current control can be provided accordingly.

[0061] In addition, this disclosure provides a judgment mechanism to identify the electrical angle algorithm corresponding to various scenarios. Specifically, since the control module 1, besides sampling the angle and current when the motor 200 is running, may also have other specific interrupt procedures (such as, but not limited to, external communication, data transmission, etc., which can be preset by the control module 1) during the operation of the motor 200. These occasional specific interrupt procedures may happen to be triggered before or after the angle resolution interrupt procedure R-ISR or the current interrupt procedure A-ISR, causing them to overlap with the angle resolution interrupt procedure R-ISR or the current interrupt procedure A-ISR that should have been executed.

[0062] Specifically, such as Figure 2B In another specific scenario, when a specific interrupt routine (ISR) is being processed and it overshadows the current interrupt routine (A-ISR) and the de-interrupt routine (R-ISR) that were originally scheduled to execute, the current interrupt routine (A-ISR) will be delayed. Therefore, after the specific interrupt routine (ISR) finishes, the overshadowed current interrupt routine (A-ISR) should then execute, but because the de-interrupt routine (R-ISR) has also been generated and is waiting for the specific interrupt routine (ISR) to finish, it will be delayed.

[0063] Generally, the angle interrupt routine R-ISR has higher priority than the current interrupt routine A-ISR, and the current interrupt routine A-ISR has higher priority than other specific interrupt routines (e.g., but not limited to, external communication, data transmission, etc.). Therefore, when the above interrupt routines occur simultaneously, the priority is, in order, angle interrupt routine R-ISR, current interrupt routine A-ISR, and other specific interrupt routines. Conversely, when the above interrupt routines do not occur simultaneously, the one that occurs first is executed first. Therefore, when angle interrupt routine R-ISR and current interrupt routine A-ISR occur simultaneously, control module 1 executes angle interrupt routine R-ISR first, causing current interrupt routine A-ISR to be delayed until after angle interrupt routine R-ISR ends (i.e., delayed until the position of A-ISR'). When current interrupt routine A-ISR' is executed, the current angle parameter Pt2' it obtains may be incorrect. That is, the time difference Td between the angle parameter Pt2 and the timestamp TP incorrectly estimates the current angle parameter Pt2' under the timestamp TP. Therefore, please refer to [reference needed]. Figure 2C The current waveform diagram shows that the current angle parameter Pt2' and current parameters Ia2, Ib2, and Ic2 obtained by A-ISR' will cause the current waveform provided by the drive circuit 300 to the motor 200 to be distorted as shown in the dashed box, resulting in unstable control.

[0064] Therefore, this disclosure provides a judgment mechanism to identify the electrical angle algorithm corresponding to various situations in order to avoid occurrences such as Figures 2A-2BThe main judgment mechanism is that the control module 1 determines whether the count value CV corresponding to the second time T2 is greater than the count value corresponding to the timestamp TP of the trigger time of the previous second specific cycle TC2, and performs corresponding control accordingly. Furthermore, this judgment mechanism is mainly based on the control module 1 summarizing 5 possible scenarios during the operation of the motor 200, which will be described one by one below.

[0065] Among them, Figures 3A-3E In this process, control module 1 can set a first specific flag interval 0 from the end of the second time T2 to the end of the next first time T1, and set a second specific flag interval 1 from the end of the first time T1 to the end of the next second time T2. Therefore, in addition to setting a timestamp TP at the trigger point of each second specific cycle TC2, control module 1 can also start the first specific flag interval 0 according to the timestamp TP. Before control module 1 determines whether the count value CV corresponding to the second time T2 is greater than the count value corresponding to the previous timestamp TP, control module 1 can first determine whether the second time T2 is triggered in the first specific flag interval 0. When control module 1 determines that the second time T2 is triggered in the first specific flag interval 0, it means that the current interrupt program A-ISR is executed twice between the two angle interrupt programs R-ISR. This means that the period from the end of the current interruption procedure A-ISR to the beginning of the corner-breaking interruption procedure R-ISR is the first specific flag interval 0. If the current interruption procedure A-ISR is encountered in the first specific flag interval 0, it will not change to the second specific flag interval 1, but will remain in the first specific flag interval 0. Conversely, the period from the beginning of the corner-breaking interruption procedure R-ISR to the end of the current interruption procedure A-ISR is the second specific flag interval 1. If the corner-breaking interruption procedure R-ISR is encountered in the second specific flag interval 1, it will not change to the first specific flag interval 0, but will remain in the second specific flag interval 1.

[0066] Therefore, by marking specific flag intervals, the control module 1 can accurately determine whether the current angle parameters Pt1' and Pt2' under the timestamp TP are outdated or updated to the wrong point, and can compensate to the correct point to improve the accuracy of angle estimation. Furthermore, because this disclosure uses specific flag interval markings, the control module 1 can primarily compensate for the angle parameter Pt based on the specific flag interval (0 or 1) where the current interrupt procedure A-ISR is located, the timestamp TP, and the timing of the angle resolution interrupt procedure R-ISR, the current interrupt procedure A-ISR, and the specific interrupt procedure ISR, thereby improving the accuracy of angle estimation.

[0067] like Figure 3A This is the timing diagram of the motor system's operation in the first scenario, and can be consulted in conjunction with other relevant documents. Figures 1A-2C.exist Figure 3A The above describes the most common scenario encountered by control module 1 during the operation of motor 200. Each first specific cycle TC1 includes the trigger point of the second specific cycle TC2, and is marked with a timestamp TP. When control module 1 determines that the count value CV corresponding to the second time T2 is greater than the count value corresponding to the timestamp TP of the trigger point of the previous second specific cycle TC2, control module 1 calculates the current angle parameter as the previous angle parameter Pt of the second time T2 plus the angle displacement parameter. Furthermore, the angle displacement parameter is the angle displacement amount corresponding to the time difference Td (i.e., the second time difference) between the trigger point of the first specific cycle TC1 where the previous angle parameter Pt is located and the timestamp TP of the same first specific cycle TC1.

[0068] by Figure 3A For example, the current angle parameter obtained at the second time T2-2 is the sum of the previous angle parameter Pt1 and the angle displacement parameter. Furthermore, the two second times T2-1 and T2-2 include a first time T1-1, and the timestamp TP2 is triggered in the second specific flag interval 1, so its current angle parameter Pt1' should lag behind the angle parameter Pt1. Therefore, the angle displacement parameter is the angle displacement corresponding to the time difference Td2 between the trigger point TC1_t of the first specific period TC1-2 where the previous angle parameter Pt1 is located and the timestamp TP2 of the same first specific period TC1-2. The angle displacement can be obtained by converting the time difference Td2 using Δθ = ω * Δt, and Δt can be obtained by dividing the time difference Td2 by the clock of the control unit 10 itself. Therefore, at the second time T2-2, the current angle parameter Pt1' and the current current parameters Ia2, Ib2, and Ic2 can be obtained. Based on the current angle parameter Pt1' and the current parameters Ia2, Ib2, and Ic2, the pulse width modulation signal PWM provided to the drive circuit 300 is adjusted so as to control the motor 200 through the pulse width modulation signal PWM.

[0069] like Figure 3B This is the timing diagram of the motor system's operation in the second scenario, and can be consulted in conjunction with other relevant documents. Figures 1A-3A .exist Figure 3B In the process, control module 1 further determines whether the count value CV is reset during the operation period t0~t1 of the second time T2. When the count value CV is reset, control module 1 calculates the current angle parameter as the sum of the previous angle parameter Pt of the second time T2 and the angle displacement parameter. Furthermore, the angle displacement parameter is the angle displacement amount corresponding to the time difference Td between the trigger time of the first specific period TC1 where the previous angle parameter Pt is located and the timestamp TP of the same first specific period TC1.

[0070] by Figure 3BFor example, when the counter value CV is reset, it signifies the end of the first specific cycle TC1-2. This situation typically occurs because a timestamp TP3 is generated during the execution of a specific interrupt routine (ISR) (i.e., a specific interrupt period). However, because the ISR has not yet completed, the triggering of the second time period T2-3 is delayed until the ISR is finished. Then, when the ISR finishes (i.e., the specific interrupt period ends), the first specific cycle TC1-2 happens to end. Therefore, control module 1 will set the trigger point TC1_t for the first specific cycle TC1-3 within a short period, causing the second time period T2-3 to execute just before the trigger point TC1_t is generated. Thus, as soon as the second time period T2-3 begins, the trigger point TC1_t set by control module 1 can be read immediately (meaning that the counter value CV is reset during the operation period t0~t1 of the second time period T2-3), and the first time period T1-3 only begins execution after the second time period T2-3 ends.

[0071] Therefore, the current angle parameter obtained at the second time T2-3 is the sum of the previous angle parameter Pt2 and the angle displacement parameter. Furthermore, the two second times T2-2 and T2-3 include a first time T1-2, and the timestamp TP3 is triggered in the second specific flag interval 1, so the current angle parameter Pt2' should lag behind the angle parameter Pt2. Therefore, the angle displacement parameter is the angle displacement corresponding to the time difference Td2 between the trigger point TC1_t of the first specific period TC1-2 where the previous angle parameter Pt2 is located and the timestamp TP3 of the same first specific period TC1-2. Thus, at the second time T2-3, the current angle parameter Pt2' and the current current parameters Ia3, Ib3, and Ic3 can be obtained, and the pulse width modulation (PWM) signal provided to the drive circuit 300 can be adjusted according to the current angle parameter Pt2' and the current parameters Ia3, Ib3, and Ic3 to control the motor 200.

[0072] like Figure 3C This is the timing diagram of the motor system's operation in the third scenario, and can be consulted in conjunction with other relevant documents. Figures 1A-3B .exist Figure 3CIn the process, when control module 1 determines that the count value CV corresponding to the second time T2 is not greater than the count value CV corresponding to the timestamp TP of the trigger point of the previous second specific period TC2, control module 1 calculates the current angle parameter as the previous angle parameter Pt of the second time T2 minus the angle displacement parameter. Furthermore, the angle displacement parameter is the angle displacement amount corresponding to the time difference Td (i.e., the first time difference) between the total time of the previous first specific period TC1 and the time difference Td between the trigger point TC1_t of the previous first specific period TC1 and the timestamp TP of the trigger point of the previous second specific period TC2. It is worth noting that in one embodiment, the difference between the first time difference and the second time difference is that the second time difference is the difference between the trigger point TC1_t of the first specific period TC1 and the timestamp TP, while the first time difference is exactly the opposite; therefore, they are distinguished as "first" and "second".

[0073] It will happen Figure 3C The reason for this situation is usually that during the execution of a specific interrupt routine (ISR) (i.e., a specific interrupt period), a timestamp TP2 is generated first, and then the trigger point TC1_t is reached. When the specific ISR completes (i.e., the specific interrupt period ends), the first time T1-2 with higher priority begins execution, causing the second time T2-2 to be continuously delayed until the first time T1-2 ends. Therefore, the count value CV corresponding to the second time T2 is not greater than the count value CV corresponding to the timestamp TP. Therefore, the current angle parameter obtained by the second time T2-2 is the previous angle parameter Pt2 minus the angle displacement parameter. Furthermore, the two second times T2-1 and T2-2 include two first times T1-1 and T1-2, and the timestamp TP2 is triggered in the second specific flag interval 1, so its current angle parameter Pt2' should precede the angle parameter Pt2. Therefore, the angular displacement parameter is the angular displacement corresponding to the total time of the previous first specific cycle TC1-2 and the time difference Td2 between the trigger point TC1_t of the previous first specific cycle TC1-2 and the previous timestamp TP2. Thus, at the second time T2-2, the current angle parameter Pt2' and the current current parameters Ia2, Ib2, and Ic2 can be obtained, and the pulse width modulation signal PWM provided to the drive circuit 300 can be adjusted according to the current angle parameter Pt2' and the current parameters Ia2, Ib2, and Ic2, so as to control the motor 200 through the pulse width modulation signal PWM.

[0074] like Figure 3D This is the timing diagram of the motor system's operation in the fourth scenario, and can be consulted in conjunction with other relevant documents. Figures 1A-3C It will happen. Figure 3DThe reason for this situation is usually that the second time T2-2 is the position where the analog-to-digital converter ADC1 completes its conversion, and at this time, the current interrupt routine A-ISR just generates a trigger event. Due to the processing mechanism of the control unit 10, the trigger point TC1_t of the first specific cycle TC1-2 has not yet been generated for a short period of time, causing the low-priority second time T2-2 to be inserted and start execution first. If the judgment mechanism disclosed in this invention is not used, the second time T2-2 at this time will only be able to obtain the old angle parameter Pt1 and the just-reset timestamp TP2 because the electrical angle has not been updated, thus calculating an incorrect electrical angle. Therefore, this invention can identify various situations by introducing the first specific flag interval 0 and the second specific flag interval 1, plus the angle resolution interrupt routine R-ISR, the current interrupt routine A-ISR, the count value CV, and the timestamp TP, and provide a corresponding electrical angle algorithm to correct the angle parameter Pt according to each situation. In this way, the control module 1 can achieve the effect of precise control.

[0075] Therefore, with Figure 3D For example, when control module 1 determines that the second time T2-2 is triggered in the first specific flag interval 0 and the count value CV is reset, it indicates that the first specific cycle TC1-1 has ended. Therefore, control module 1 calculates the current angle parameter as the angle parameter Pt1 before the second time T2-2 plus the angle displacement parameter. Furthermore, the first time is not included in the two second times T2-1 and T2-2, and the timestamp TP2 is triggered in the first specific flag interval 0, so its current angle parameter Pt1' should lag behind the angle parameter Pt1. Therefore, the angle displacement parameter is the angle displacement corresponding to the total time of the previous specific cycle TC1-1. Thus, in the second time T2-2, the current angle parameter Pt1' and the current current parameters Ia2, Ib2, and Ic2 can be obtained, and the pulse width modulation signal PWM provided to the drive circuit 300 is adjusted according to the current angle parameter Pt1' and the current parameters Ia2, Ib2, and Ic2 to control the motor 200 through the pulse width modulation signal PWM.

[0076] like Figure 3E This is the timing diagram of the motor system's operation in the fifth scenario, and can be consulted in conjunction with other relevant documents. Figures 1A-3D .exist Figure 3E In the middle, control module 1 also determines that the second time T2 is triggered in the first specific flag interval 0, which means that the current interrupt procedure A-ISR is executed twice between the two angle interrupt procedures R-ISR. However, Figure 3E and Figure 3D The difference is that, Figure 3EWhen the count value CV is not reset, it means that the first specific period TC1-1 has not yet ended. Therefore, control module 1 does not need to use the total time of the previous specific period TC1-1 to calculate the current angle parameter. Therefore, when control module 1 determines that the second time T2-2 is triggered in the first specific flag interval 0 and the count value CV is not reset, control module 1 calculates the current angle parameter as the angle parameter Pt1 before the second time T2-2 plus the angle displacement parameter. Furthermore, the first time is not included in the two second times T2-1 and T2-2, and the timestamp TP2 is triggered in the first specific flag interval 0, so its current angle parameter Pt1' should lag behind the angle parameter Pt1. Therefore, the angle displacement parameter is the angle displacement amount corresponding to the time difference Td1 between the trigger time TC1_t of the first specific period TC1-1 where the previous angle parameter Pt1 is located and the timestamp TP2 of the same first specific period TC1-1. Thus, at the second time T2-2, the current angle parameter Pt1' and the current current parameters Ia2, Ib2, and Ic2 can be obtained, and the pulse width modulation signal PWM provided to the drive circuit 300 can be adjusted according to the current angle parameter Pt1' and the current parameters Ia2, Ib2, and Ic2, so as to control the motor 200 through the pulse width modulation signal PWM.

[0077] Please see Figure 4A This diagram illustrates the interruption process and pushback situation disclosed herein. Please refer to Figures 1-3E for further details. Figure 4A This situation primarily arises because the control module 1 inserts a specific interrupt event (i.e., a specific interrupt ISR), causing the specific interrupt period to push aside the corner interrupt routine R-ISR and the current interrupt routine A-ISR. Furthermore, the corner interrupt routine R-ISR or the current interrupt routine A-ISR is triggered only after the specific interrupt period ends, resulting in a situation where the corner interrupt routine R-ISR and the current interrupt routine A-ISR largely overlap. One such situation is that when the corner interrupt routine R-ISR and the current interrupt routine A-ISR nearly overlap, the control module 1 must wait for the analog-to-digital converter ADC1 to convert before generating the corner interrupt routine R-ISR. However, during this process, the current interrupt routine A-ISR completes its setup and triggers slightly faster than the corner interrupt routine R-ISR. Therefore, the specific interrupt ISR slightly pushes aside the current interrupt routine A-ISR, and the current interrupt routine A-ISR in turn pushes aside the corner interrupt routine R-ISR (as shown in the dashed box). On the other hand, the situation where the angle interrupt routine R-ISR is pushed to the current interrupt routine A-ISR is similar, and will not be elaborated on here.

[0078] The aforementioned pushing and shoving situation mainly occurs as follows: Figure 3B The second situation and Figure 3DThe fourth scenario is primarily caused by the control module 1 inserting a specific interrupt event (i.e., a specific interrupt ISR), resulting in a near overlap between the decoupling interrupt routine R-ISR and the current interrupt routine A-ISR. However, the control module 1 can prevent this overlap by configuring the specific interrupt ISR. Therefore, in conjunction with... Figures 3A-3E The following can be summarized: Figure 4B and Figure 4C Flowcharts of two different timestamp compensation methods for motor control devices.

[0079] Specifically, in Figure 4B In this context, control module 1 can configure the aforementioned interrupt ISR to enable... Figure 4A The pushing or shoving situation will not occur and can be ruled out. Figure 3B and Figure 3D The situation. Therefore, Figure 4B The process includes the second time being triggered (S100). When the second time T2 is triggered, it means that the control module 1 wants to obtain the angle parameter Pt and current parameters Ia, Ib, and Ic at the previous timestamp TP. Therefore, it proceeds to step (S200) to determine whether the count value corresponding to the second time is greater than the count value corresponding to the previous timestamp. When the determination result of step (S200) is "yes", then the corresponding... Figure 3A and 3E The operation method is as follows: The current angle parameter is calculated by adding the angle displacement parameter to the previous angle parameter at the second time (S400). Furthermore, the angle displacement parameter is the angle displacement amount corresponding to the time difference Td between the trigger time of the first specific period TC1 where the previous angle parameter Pt is located and the timestamp TP of the same first specific period TC1.

[0080] Conversely, if the judgment result of step (S200) is "no", then the corresponding Figure 3C The operation method is as follows: The current angle parameter is calculated by subtracting the angle displacement parameter from the previous angle parameter at the second time (S420). Furthermore, the angle displacement parameter is the angle displacement amount corresponding to the time difference Td between the total time of the previous first specific period TC1 and the timestamp TP between the trigger point TC1_t of the previous first specific period TC1 and the trigger point TP of the previous second specific period TC2.

[0081] On the other hand, Figure 4C In the middle, control module 1 may generate the above-mentioned [problem] if it is not configured according to the specific interrupt ISR. Figure 4A The pushing and shoving situation. Therefore, Figure 4C In summary Figures 3A-3EThe process is summarized into five scenarios, including triggering a second time (S100). Then, it is determined whether the second time is triggered within a first specific flag interval (S120). If the determination result of step (S120) is "yes," it means that the current interrupt procedure A-ISR is executed twice between the two corner interrupt procedures R-ISR. Therefore, proceed to step (S140) to determine whether the count value is reset during the operation period of the second time. If the determination result of step (S140) is "yes," then... Figure 3D The operation method is as follows: That is, the current angle parameter is calculated by adding the angle displacement parameter to the previous angle parameter at the second time (S440). Furthermore, the angle displacement parameter is the angle displacement corresponding to the total time of the previous specific period TC1-1. Conversely, if the judgment result of step (S140) is "no", then the corresponding... Figure 3E The operation method is as follows: That is, the current angle parameter is calculated by adding the angle displacement parameter to the previous angle parameter at the second time point (S400). The specific details are already provided in [the original text]. Figure 4B The description is already provided and will not be repeated here.

[0082] On the other hand, if the judgment result of step (S120) is "No", it means that the current interruption program A-ISR is executed only once between the two interruption programs R-ISR. Therefore, proceed to step (S200) to determine whether the count value corresponding to the second time is greater than the count value corresponding to the previous timestamp. If the judgment result of step (S200) is "Yes", then the corresponding Figure 3A The operation proceeds to step (S400) if the operation method is correct. Conversely, if the judgment result of step (S200) is "no", then step (S160) is entered to determine whether the count value was reset during the operation period of the second time. If the judgment result of step (S160) is "yes", then the corresponding operation proceeds to step (S400). Figure 3B The operation proceeds to step (S400) according to the specified method. Conversely, if the judgment result of step (S160) is "no", then the corresponding operation proceeds to step (S400). Figure 3C The operation proceeds to step (S420), the details of which have been described in [the original text]. Figure 4B The description is already provided and will not be repeated here.

[0083] However, the above description is only a detailed description and accompanying drawings of preferred embodiments of the present invention, but the features of the present invention are not limited thereto and are not intended to limit the present invention. The scope of the present invention should be determined by the claims. All embodiments that conform to the spirit of the claims of the present invention and similar variations thereof should be included in the scope of the present invention. Any variations or modifications that can be easily conceived by those skilled in the art within the field of the present invention can be covered by the scope of the claims of this application.

Claims

1. A motor control device, characterized in that, A device for controlling a drive circuit to drive a motor, wherein the motor control device includes: A control module counts multiple first specific cycles and multiple second specific cycles, and provides a count value that increases over time in each first specific cycle, wherein the control module sets a specific flag interval; An angle sensing device is used to sample an angle parameter of the motor according to an angle interruption procedure at a first time in each first specific cycle; A current sensing device is used to sample a current parameter provided by the drive circuit according to a current interruption procedure at a second time in each second specific cycle, and the control module sets a timestamp at the trigger point of each second specific cycle to start the specific flag interval accordingly; and The control module compensates for the angle parameter based on the specific flag interval where the current interruption procedure is located, the timestamp, and the timing of the angle interruption procedure, the current interruption procedure, and a specific interruption procedure.

2. The motor control device according to claim 1, characterized in that, The control module determines whether the count value corresponding to the second time is greater than the count value corresponding to the timestamp of the trigger point of the previous second specific cycle. When the determination result is no, the control module calculates a current angle parameter of the motor as the previous angle parameter of the second time minus an angle displacement parameter, and the angle displacement parameter is the angle displacement amount corresponding to a total time of the previous first specific cycle and a first time difference between the trigger point of the previous first specific cycle and the previous timestamp.

3. The motor control device according to claim 1, characterized in that, When the judgment result is yes, the control module calculates a current angle parameter as the previous angle parameter of the second time plus an angle displacement parameter, and the angle displacement parameter is the angle displacement amount corresponding to a second time difference between the trigger time point of the first specific period in which the previous angle parameter is located and the timestamp of the same first specific period.

4. The motor control device according to claim 1, characterized in that, When the judgment result is negative, the control module further determines whether the count value is reset during the operation period of the second time. When the count value is reset, the control module calculates a current angle parameter as the previous angle parameter of the second time plus an angle displacement parameter, and the angle displacement parameter is the angle displacement amount corresponding to a second time difference between the trigger time point of the first specific cycle in which the previous angle parameter is located and the timestamp of the same first specific cycle.

5. The motor control device according to claim 1, characterized in that, The control module sets the specific flag interval from the end of the second time to the end of the next first time. Before the control module determines whether the count value corresponding to the second time is greater than the count value corresponding to the previous timestamp, the control module determines that the second time is triggered in the specific flag interval and the count value is reset. The control module calculates a current angle parameter as the previous angle parameter of the second time plus an angle displacement parameter, and the angle displacement parameter is the angle displacement amount corresponding to a total time of the previous specific period.

6. The motor control device according to claim 5, characterized in that, When the control module determines that the second time is triggered in the specific flag interval and the count value has not been reset, the control module calculates the current angle parameter as the previous angle parameter of the second time plus an angle displacement parameter, and the angle displacement parameter is the angle displacement amount corresponding to a second time difference between the trigger time point of the first specific period in which the previous angle parameter is located and the timestamp of the same first specific period.

7. The motor control device according to claim 1, characterized in that, At the second time following the timestamp, the control module adjusts a pulse width modulation signal provided to the drive circuit based on a current angle parameter and a current parameter, so as to control the motor through the pulse width modulation signal.

8. The motor control device according to claim 1, characterized in that, When the control module determines that the desired time point for providing the first time or the second time is within a specific interruption period, the control module will provide the first time or the second time after the specific interruption period ends.

9. The motor control device according to claim 1, characterized in that, The plurality of first specific periods are not entirely the same as the plurality of second specific periods.

10. The motor control device according to claim 1, characterized in that, The angle sensing device is a deflector, and the deflector shaft is connected to a rotating shaft of the motor to sample the angle parameter and provide an angle signal.

11. A timestamp compensation method for a motor control device, characterized in that, The motor control device is used to control a drive circuit to drive a motor to operate, and the motor control device includes an angle sensing device and a current sensing device. The timestamp compensation method includes the following steps: Count multiple first specific periods and multiple second specific periods, and provide a count value that increases over time in each first specific period, and set a specific flag interval; At a first moment in each first specific cycle, the angle sensing device is controlled to sample an angle parameter of the motor according to an angle interruption procedure; At a second time in each second specific cycle, the current sensing device samples a current parameter provided by the drive circuit according to a current interruption procedure, and sets a timestamp at the trigger point of each second specific cycle to start the specific flag interval. and The angle parameter is compensated based on the specific flag interval in which the current interruption procedure is located, the timestamp, and the timing of the angle interruption procedure, the current interruption procedure, and a specific interruption procedure.

12. The timestamp compensation method according to claim 11, characterized in that, It also includes the following steps: (a) Determine whether the count value corresponding to the second time is greater than the count value corresponding to a timestamp of the trigger time of the previous second specific period; (b1) Determine if step (a) is incorrect; and (c1) Calculate a current angle parameter of the motor as the previous angle parameter of the second time minus an angle displacement parameter, and the angle displacement parameter is the angle displacement amount corresponding to a total time of the previous first specific cycle and a first time difference between the trigger point of the previous first specific cycle and the previous timestamp.

13. The timestamp compensation method according to claim 11, characterized in that, It also includes the following steps: (b2) Determine if step (a) is true; and (c2) Calculate a current angle parameter of the motor as the previous angle parameter of the second time plus an angle displacement parameter, and the angle displacement parameter is the angle displacement amount corresponding to a second time difference between the trigger time of the first specific cycle in which the previous angle parameter is located and the timestamp of the same first specific cycle.

14. The timestamp compensation method according to claim 13, characterized in that, The following steps are included after step (b1): (c3) Determine whether the count value was reset during an operation period of the second time; (d1) Determine if step (c3) is true; and (e1) Execute step (c2).

15. The timestamp compensation method according to claim 14, characterized in that, The following steps are included after step (c3): (d2) Determine if step (c3) is incorrect; and (e2) Execute step (c1).

16. The timestamp compensation method according to claim 13, characterized in that, The following steps are included before step (a): (a01) The period from the end of the second time period to the end of the first time period is set as the specific flag interval; (a02) Determine whether the second time interval is triggered within the specific flag interval; and (a03) Determine if step (a02) is true, and execute step (a).

17. The timestamp compensation method according to claim 13, characterized in that, The following steps are included after step (a02): (f1) Determine whether the count value was reset during an operation period of the second time; (g1) Determine if step (f1) is true; and (h1) The current angle parameter is calculated as the previous angle parameter of the second time plus the angle displacement parameter, and the angle displacement parameter is the angle displacement amount corresponding to a total time of the previous specific period.

18. The timestamp compensation method according to claim 17, characterized in that, The following steps are included after step (f1): (g2) Determine if step (f1) is incorrect; and (h2) Perform step (b2).

19. The timestamp compensation method according to claim 11, characterized in that, It also includes the following steps: At the second time after the timestamp is provided, a pulse width modulation signal provided to the drive circuit is adjusted according to a current angle parameter and a current parameter of the motor, so as to control the operation of the motor through the pulse width modulation signal.

20. The timestamp compensation method according to claim 11, characterized in that, It also includes the following steps: (i1) Determine the time point during which the first time or the second time is to be provided is within a specific interruption period; and (i2) Provide the first time or the second time after the specific interruption period ends.