Random PWM control method, vehicle controller and vehicle
By reading and synchronizing the duty cycle and carrier period values at the start of the PWM cycle, the problems of synchronous updates and bridge arm shoot-through in random PWM control are solved, thereby improving the stability and reliability of motor control.
Patent Information
- Application Number
- CN202611484804.2
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2026-09-22
- Publication Date
- 2026-11-17
AI Technical Summary
Existing random PWM control methods have difficulty ensuring the synchronous update of duty cycle and carrier period when the carrier period changes dynamically, and are prone to bridge arm shoot-through risk due to interrupt execution time overflow.
By reading the current duty cycle and carrier cycle value from the pre-stored module at the beginning of the PWM cycle and synchronizing them at the beginning of the next cycle, and combining the double buffering characteristics of the shadow register and the active register, the duty cycle and carrier cycle are strictly synchronized and updated, avoiding interrupt execution time overflow.
It effectively overcomes the output errors and bridge arm shoot-through risks caused by duty cycle and carrier period mismatch, improves the stability and reliability of motor control, and does not require additional hardware costs.
Smart Images

Figure CN123104419A_ABST
Abstract
Description
Technical Field
[0001] This application relates to the field of vehicle control technology, and in particular to a random PWM control method, a vehicle controller, and a vehicle. Background Technology
[0002] Currently, permanent magnet synchronous motors in electric vehicles generally use PWM control with a fixed carrier frequency for driving. Fixed carrier frequency PWM control can achieve stable regulation of motor torque and speed, and its control performance directly affects the vehicle's power output and ride comfort.
[0003] However, fixed carrier frequency PWM control concentrates switching harmonic energy at the switching frequency and its harmonics, generating significant electromagnetic noise at specific frequency points and affecting the overall NVH performance of the vehicle. To improve this issue, random PWM technology has been proposed. By randomly or periodically changing the PWM carrier frequency, it disperses the originally concentrated harmonic energy across a wider frequency band, thereby reducing peak noise.
[0004] However, existing random PWM control methods are difficult to ensure strict synchronization between the duty cycle and the carrier cycle when the carrier cycle changes dynamically. Furthermore, they are prone to duty cycle update errors or even direct connection between upper and lower bridge arms due to interrupt execution time overflow, posing a risk of false alarms or missed alarms. Summary of the Invention
[0005] The main objective of this application is to provide a random PWM control method, a vehicle controller, and a vehicle, aiming to solve the technical problems of asynchronous updates of duty cycle and carrier period in existing random PWM control, as well as the risk of bridge arm shoot-through caused by interrupt execution time overflow.
[0006] To achieve the above objectives, this application provides a random PWM control method, the method comprising: In response to the counter reaching the start point of the current PWM cycle, the first random carrier cycle value and the first duty cycle instruction are read from the pre-stored module, and the output of the current PWM cycle is controlled with the first random carrier cycle value and the first duty cycle instruction. The first random carrier cycle value and the first duty cycle instruction were written to the pre-stored module at the start point of the previous PWM cycle. The second duty cycle instruction and the second random carrier cycle value corresponding to the next PWM cycle are determined and stored in the pre-storage module so that they take effect synchronously at the start of the next PWM cycle.
[0007] In addition, to achieve the above objectives, this application also provides a vehicle controller, which includes: a counter module for counting the current PWM cycle; The control module is configured to, in response to the counter module reaching the start point of the current PWM cycle, read a first random carrier cycle value and a first duty cycle instruction from the pre-storage module, and control the output of the current PWM cycle with the first random carrier cycle value and the first duty cycle instruction, wherein the first random carrier cycle value and the first duty cycle instruction were written to the pre-storage module at the start point of the previous PWM cycle. The determination module is used to determine the second duty cycle instruction and the second random carrier cycle value corresponding to the next PWM cycle. A pre-storage write module is used to store the second duty cycle instruction and the second random carrier period value into the pre-storage module so that they take effect synchronously at the start of the next PWM cycle.
[0008] In addition, to achieve the above objectives, this application also provides a vehicle controller, including: a memory, a processor, and a computer program stored in the memory and executable on the processor, the computer program being configured to implement the steps of the random PWM control method as described above.
[0009] In addition, to achieve the above objectives, this application also provides a vehicle that includes the vehicle controller as described above.
[0010] This application provides a random PWM control method. This method, in response to a counter reaching the start point of the current PWM cycle, reads the first random carrier cycle value and the first duty cycle instruction of the current PWM cycle from a pre-stored module, and uses these two to control the output of the current PWM cycle. Simultaneously, at the same start point, it determines the second duty cycle instruction and the second random carrier cycle value corresponding to the next PWM cycle, and stores both in the pre-stored module so that they take effect synchronously at the start point of the next PWM cycle. This transforms the control of random PWM from the traditional method of separately updating the cycle value and duty cycle at inconsistent update times, to reading the current value and writing the next value at the same start point. The quantitative control, which synchronizes the execution of the cycle and the duty cycle at the start of the next cycle, effectively overcomes the technical defects caused by the mismatch between the duty cycle and the carrier cycle due to dynamic changes in the carrier cycle, fluctuations in interrupt execution time, or inconsistencies in register update timing, which in turn lead to erroneous or disordered updates in random PWM control. At the same time, since the output of the current cycle uses the value prepared in the previous cycle, the execution of the control interrupt is decoupled from the output of the current cycle. It avoids the risk of bridge arm shoot-through caused by interrupt overflow without relying on instantaneous judgment in a single cycle. Without increasing hardware costs, it maximizes the range of random carrier frequencies, thereby improving the stability and reliability of motor control. Attached Figure Description
[0011] The accompanying drawings, which are incorporated in and form part of this specification, illustrate embodiments consistent with this application and, together with the description, serve to explain the principles of this application.
[0012] To more clearly illustrate the technical solutions in the embodiments of this application or the prior art, the drawings used in the description of the embodiments or the prior art will be briefly introduced below. Obviously, for those skilled in the art, other drawings can be obtained based on these drawings without creative effort.
[0013] Figure 1 A schematic diagram of an existing random PWM control method provided for embodiments of this application; Figure 2 A schematic diagram of a random PWM control method provided in an embodiment of this application; Figure 3 This is a flowchart illustrating an embodiment of the random PWM control method of this application. Figure 4 This is a flowchart illustrating Embodiment 2 of the random PWM control method of this application; Figure 5 This is a flowchart illustrating Embodiment 3 of the random PWM control method of this application; Figure 6 Schematic diagram of the vehicle controller provided in this application Figure 1 ; Figure 7 Schematic diagram of the vehicle controller provided in this application Figure 2 ; Figure 8 Schematic diagram of the vehicle controller provided in this application Figure 3 .
[0014] The purpose, features, and advantages of this application will be further explained in conjunction with the embodiments and with reference to the accompanying drawings. Detailed Implementation
[0015] It should be understood that the specific embodiments described herein are merely illustrative of the technical solutions of this application and are not intended to limit this application.
[0016] To better understand the technical solution of this application, a detailed description will be provided below in conjunction with the accompanying drawings and specific implementation methods.
[0017] The main solution of this application is as follows: In response to the counter reaching the start point of the current PWM cycle, the first random carrier cycle value and the first duty cycle instruction are read from the pre-stored module, and the output of the current PWM cycle is controlled by the first random carrier cycle value and the first duty cycle instruction. The first random carrier cycle value and the first duty cycle instruction were written into the pre-stored module at the start point of the previous PWM cycle. The second duty cycle instruction and the second random carrier cycle value corresponding to the next PWM cycle are determined, and the second duty cycle instruction and the second random carrier cycle value are stored in the pre-stored module so that they take effect synchronously at the start point of the next PWM cycle.
[0018] The following is through Figure 1 The shortcomings of existing technologies are introduced, such as... Figure 1 As shown, the horizontal axis represents time, and the vertical axis represents the counter count; the interval between two adjacent zero-crossing points is one PWM carrier cycle T_. Carrier The interrupt service routine begins execution after the zero-crossing, and its execution time is T_. int In practical applications, the dynamic and random changes in the carrier period, fluctuations in the execution time of interrupt service routines, and inconsistencies between the period value and the duty cycle update time can all lead to a mismatch between the duty cycle and the carrier period, thereby causing risks such as output voltage errors, current harmonics, and even shoot-through short circuits in the upper and lower bridge arms. For example, when T_ int Approaching or exceeding T_ Carrier If interrupts are nested or lost, it can lead to erratic duty cycle updates. However, existing solutions typically only focus on the generation method of the random carrier frequency, lacking coordinated management of the synchronous update capability of the duty cycle under changes in the random carrier period and the risk of interrupt overflow. When the random range of the carrier frequency expands, the interrupt execution time may exceed the shortest PWM period, leading to erratic duty cycle updates or even bridge arm shoot-through. Furthermore, the margin relationship between the interrupt execution time and the PWM period naturally differs between different individual motors and between the same motor at different speeds and load conditions, making fixed update timing unsuitable for all scenarios. Therefore, how to utilize the unique moment of the PWM period start point to achieve synchronous updates of the duty cycle and the carrier period, while dynamically constraining the interrupt execution time, thereby maximizing the random carrier frequency range while ensuring system safety, is a problem that urgently needs to be solved in the current field of random PWM control.
[0019] Combination Figure 2The technical solution of this application can be summarized as follows: After the zero-crossing point triggers the control interrupt in each PWM cycle, the interrupt is first triggered at the zero-crossing point. Then, the complete FOC motor control algorithm is executed in the interrupt to generate the three-phase duty cycle instruction required for the next PWM cycle. The second duty cycle instruction and the second random carrier cycle value of the next PWM cycle are written into the pre-storage module. When the next zero-crossing point interrupt is triggered, they take effect synchronously to control the output of the next PWM cycle. The output of the current PWM cycle uses the first random carrier cycle value and the first duty cycle instruction that were written into the pre-storage module in the previous zero-crossing point interrupt. Thus, under the premise of decoupling the interrupt execution from the current output, the strict synchronous update of the duty cycle and the carrier cycle is achieved, and the duty cycle update disorder and bridge arm shoot-through risk caused by the interrupt execution time overflow are effectively prevented.
[0020] Based on this, this application proposes a random PWM control method according to the first embodiment, please refer to... Figure 3 The method is executed on the vehicle's vehicle controller, and the random PWM control method includes the following steps: Step S10: Determine whether the counter has reached the start point of the current PWM cycle; and execute steps S20 and S30 when it has reached the start point. It should be noted that steps S20 and S30 can be executed simultaneously or in a specific order. This application does not impose a specific restriction on the execution order, as long as they are completed within the same control interrupt. The counter can be a counter in a PWM timer, which is used to count for each PWM cycle. When the counter value reaches the count value corresponding to the start point of the current PWM cycle, it is determined that the counter has reached the start point of the current PWM cycle and a control interrupt is triggered.
[0021] For example, this application may pre-generate a set of random carrier cycle value sequences and store them in an interrupt buffer, and a counter obtains the cycle value of each PWM cycle from the interrupt buffer and counts them.
[0022] In one feasible embodiment, if the counter adopts an edge-aligned and upward counting mode, that is, the counter starts counting from zero until the cycle reload value, for example: if the cycle value of a PWM cycle is 1000, the upward counting mode means that the counter counts from 0 to 1000, and one cycle ends. Then it returns to 0. Therefore, this application can determine the start point of the current PWM cycle when the counter underflows to zero.
[0023] In another feasible embodiment, if the counter adopts an edge-aligned and down-counting operating mode, that is, the counter starts counting from the cycle reload value until zero, for example: if the cycle value of one PWM cycle is 1000, and the cycle value of the next PWM cycle is 800; in the down-counting mode, the counter counts from 1000 to 0, at which point one cycle ends. Then the counter is reloaded to the cycle reload value of the next PWM cycle, 800. The moment the counter's count value equals 800 is the starting point of the next PWM cycle, and the counter continues counting down from 800. Therefore, this application can determine the start point of the current PWM cycle when the counter reaches the cycle reload value.
[0024] Regardless of whether the method of underflow to zero or reaching the cycle reload value is used, as long as the counter reaches the start point of the current PWM cycle, a control interrupt is triggered to execute subsequent steps.
[0025] Step S20: Read the first random carrier cycle value and the first duty cycle instruction from the pre-storage module, and control the output of the current PWM cycle with the first random carrier cycle value and the first duty cycle instruction. The first random carrier cycle value and the first duty cycle instruction were written into the pre-storage module at the beginning of the previous PWM cycle. Step S30: Determine the second duty cycle instruction and the second random carrier cycle value corresponding to the next PWM cycle, and store the second duty cycle instruction and the second random carrier cycle value in the pre-storage module so that they can take effect synchronously at the beginning of the next PWM cycle.
[0026] The subsequent steps, based on the above description, include two different operations: one is reading from the pre-store module, and the other is writing to the pre-store module. The read and write operations occur at the beginning of the same PWM cycle, but for different PWM cycles. Specifically, the read operation is for the current PWM cycle, while the write operation is for the next PWM cycle.
[0027] It should be explained here that since the first random carrier period value and the first duty cycle instruction used in the output of the current PWM cycle are both written into the pre-storage module at the beginning of the previous PWM cycle, they are read and take effect at the beginning of the current PWM cycle. This avoids output voltage errors, current harmonics and torque ripple caused by the inconsistency between the update time of the period value and the duty cycle, and improves the torque control accuracy.
[0028] The second duty cycle command is obtained by executing a motor control algorithm, which includes at least one of current sampling, coordinate transformation, speed loop adjustment, current loop adjustment, and space vector pulse width modulation. The second random carrier period value is obtained from the pre-generated random carrier period buffer. After storing the second duty cycle command and the second random carrier period value together in the pre-storage module, they are not effective immediately, but will take effect synchronously when the start point of the next PWM cycle arrives, in order to control the output of the next PWM cycle.
[0029] Understandably, the pre-store module has double-buffering characteristics, including an active register for loading the current PWM cycle parameters and a shadow register for temporarily storing the next PWM cycle parameters. At the start of the same PWM cycle, the active register loads the first random carrier cycle value and the first duty cycle instruction written at the start of the previous PWM cycle for control output in the current PWM cycle. The shadow register receives the second duty cycle instruction and the second random carrier cycle value written at the start of the current PWM cycle, and synchronously loads the stored second duty cycle instruction and the second random carrier cycle value into the active register at the start of the next PWM cycle to control the output of the next PWM cycle. Since the first random carrier cycle value and the first duty cycle instruction are written to the pre-store module together at the start of the same PWM cycle, and the second duty cycle instruction and the second random carrier cycle value are also written to the pre-store module together at the start of the same PWM cycle, the two parameters written to the pre-store module are simultaneously loaded and take effect at the start of the next PWM cycle, thus ensuring strict synchronous updates of the random carrier cycle value and the duty cycle instruction.
[0030] Since the output of the current PWM cycle uses the value prepared in the previous PWM cycle, the execution process of the control interrupt is decoupled from the output of the current PWM cycle. The control interrupt only needs to complete the write operation before the start of the next PWM cycle. Therefore, even in scenarios with high carrier frequencies or complex control algorithms, the duty cycle update will not be disordered due to excessive interrupt execution time, and there will be no situation where the duty cycle updates of the upper and lower bridge arms are not in the same PWM cycle, fundamentally eliminating the risk of bridge arm shoot-through short circuit.
[0031] In one possible implementation, before starting the PWM timer, the random carrier period value and duty cycle instruction of the first PWM cycle may be pre-loaded into the pre-store module; after enabling the PWM timer, at the beginning of the first PWM cycle, the value in the pre-store module is synchronously loaded into the active register to ensure that the first PWM cycle can be output normally.
[0032] Based on the above description, the pre-storage module includes a shadow register and an active register. Therefore, this application controls the output of the current PWM cycle through the first random carrier period value and the first duty cycle instruction. Specifically, the first random carrier period value and the first duty cycle instruction corresponding to the current PWM cycle generated at the beginning of the previous PWM cycle are read from the shadow register and synchronously loaded in the active register.
[0033] Optionally, the activity register may include a periodic activity register and a comparison activity register. During loading, a first random carrier period value may be loaded into the periodic activity register, and a first duty cycle may be loaded into the comparison activity register. After loading, the first random carrier period value in the periodic activity register determines the carrier period length of the current PWM cycle, and the first duty cycle instruction in the comparison activity register determines the toggling time of each phase PWM output within the current PWM cycle, thereby controlling the output of the current PWM cycle with the first random carrier period value and the first duty cycle instruction.
[0034] Since the first random carrier period value and the first duty cycle instruction are written to the shadow register together at the start of the previous PWM cycle and simultaneously loaded into the corresponding active register at the start of the current PWM cycle, both take effect at the start of the current PWM cycle, eliminating the transitional state where one is effective while the other is not. Therefore, the carrier period length of the current PWM cycle is strictly matched with the three-phase duty cycle, avoiding output voltage errors, current harmonics, and torque ripple caused by inconsistencies in the effective times of the period value and duty cycle, thus improving torque control accuracy.
[0035] In one possible implementation, the loading is performed automatically by hardware. Specifically, the shadow register is configured to automatically load its stored first random carrier cycle value and first duty cycle instruction into the corresponding active register in parallel when the counter reaches the start of the current PWM cycle, without CPU intervention. Thus, the loading action is strictly aligned with the moment the counter reaches its start, further ensuring synchronization accuracy.
[0036] In one possible implementation, simultaneous loading can also be actively triggered by the vehicle controller during a control interrupt. Specifically, in response to a control interrupt, the vehicle controller reads the first random carrier period value and the first duty cycle instruction from the shadow register and writes them respectively into the corresponding active registers. Thus, the loading action is bound to the execution of the control interrupt, ensuring that both take effect synchronously.
[0037] Accordingly, this application may pre-generate a random carrier cycle buffer, in which multiple random carrier cycle values can be pre-generated using a pseudo-random number function. For example, during the initialization phase of the control system or the idle period of a main interrupt, a set of random carrier cycle values between the minimum safe cycle threshold and the maximum cycle threshold is generated using a pseudo-random number function, and the generated multiple random carrier cycle values are sequentially stored in the random carrier cycle buffer. The random carrier cycle buffer can be a circular buffer; after the random carrier cycle values in the buffer are read sequentially, new random carrier cycle values can continue to be written into the buffer, thereby achieving a cyclical supply of random carrier cycle values.
[0038] It is understood that this application requires reading a random carrier cycle value from the aforementioned random carrier cycle buffer at the beginning of each current PWM cycle, as the second random carrier cycle value for the next PWM cycle. The multiple stacked carrier cycle values in the random carrier cycle buffer can be arranged according to a predetermined random sequence. The vehicle controller reads the random carrier cycle values from the buffer sequentially, ensuring that the second random carrier cycle value obtained each time is randomly varying within a preset frequency range and possesses randomness, thus achieving the effect of dispersing harmonic energy and reducing peak noise.
[0039] It should be noted that the preset frequency range can be dynamically adjusted according to the motor's operating conditions. For example, the upper and / or lower limits of the preset frequency range can be dynamically adjusted based on at least one of the motor speed, load current, and DC bus voltage, so that the random range of the random carrier period value can be adaptively adjusted according to changes in operating conditions.
[0040] In one possible implementation, the multiple random carrier period values in the random carrier period buffer can also be updated in real time after each read. For example, after each random carrier period value is read from the random carrier period buffer, a new random carrier period value is generated using a pseudo-random number function and written into the random carrier period buffer to replace the read random carrier period value, thereby ensuring that the random carrier period buffer always stores a sufficient number of random carrier period values.
[0041] In one alternative method embodiment, such as Figure 4 As shown, this application also provides a method for adjusting a preset frequency range, the method comprising the following steps: Step S401: Monitor the execution time of the control interrupt in real time; It should be noted that the control interrupt is triggered when the counter reaches the start point of the current PWM cycle. At the start point of each PWM cycle, the vehicle controller, in response to the control interrupt, executes step S20 while simultaneously monitoring the execution time of the control interrupt in real time.
[0042] Specifically, the vehicle controller may include a high-precision timer that operates independently of the PWM timer to time the execution time of control interrupts. Therefore, by monitoring the operation of the high-precision timer, the execution time of the control interrupt, i.e., the total duration from the start to the end of the control interrupt, can be obtained. Since the counting frequency of the high-precision timer is much higher than the PWM carrier frequency, it can accurately reflect the actual execution time of the control interrupt.
[0043] Step S402: Adjust the preset frequency range of each random carrier period value in the random carrier period buffer according to the execution time.
[0044] The preset frequency range is used to define the range of values for each random carrier period in the random carrier period buffer, including, for example, a lower limit and an upper limit. The random carrier period values in the random carrier period buffer originally vary randomly within the preset frequency range. When the execution time of the control interrupt changes, the vehicle controller adjusts the preset frequency range to adapt to the current control interrupt execution time.
[0045] The vehicle controller determines the adjustment amount or adjusted boundary value of the preset frequency range based on the execution time, and updates the preset frequency range of each random carrier period value in the random carrier period buffer according to the determined adjustment amount or adjusted boundary value. The adjustment can be to the lower limit of the preset frequency range, the upper limit of the preset frequency range, or both the upper and lower limits of the preset frequency range simultaneously. The adjusted preset frequency range is used to constrain subsequent random carrier period values read from the random carrier period buffer, ensuring that subsequent read random carrier period values fall within the adjusted preset frequency range.
[0046] In one possible implementation, when the execution time of the control interrupt increases, the vehicle controller raises the lower limit of the preset frequency range to narrow the random range of the random carrier period value, thereby reserving more execution time for the control interrupt; when the execution time of the control interrupt decreases, the vehicle controller lowers the lower limit of the preset frequency range to expand the random range of the random carrier period value, thereby enhancing the harmonic dispersion effect of the random PWM while ensuring safety.
[0047] In one possible implementation, when the execution time of the control interrupt exceeds the safety boundary allowed by the current preset frequency range, the vehicle controller raises the lower limit of the preset frequency range to a value that matches the current execution time, and applies the adjusted lower limit to random carrier period values that have not yet been read in the random carrier period buffer, or to random carrier period values subsequently written into the random carrier period buffer, thereby constraining the random carrier period values of subsequent PWM cycles.
[0048] In one possible implementation, the vehicle controller can perform this step once at the beginning of each PWM cycle, that is, adjust the preset frequency range once every time the execution time of a control interrupt is detected, so that the preset frequency range always follows the change of the execution time of the control interrupt. The vehicle controller can also perform this step according to a preset adjustment cycle, for example, adjust the preset frequency range every N PWM cycles to reduce the adjustment frequency and reduce computational overhead.
[0049] In one possible implementation, the vehicle controller may also filter or average the execution time before using it to adjust the preset frequency range, so as to avoid frequent adjustments to the preset frequency range due to occasional fluctuations in the execution time of a single execution.
[0050] The following example illustrates how to adjust the preset frequency range. Figure 5 As shown, it includes the following steps: Step S501: Obtain the first count value when the control interrupt starts execution and the second count value when the control interrupt ends execution; As mentioned above, the vehicle controller may be equipped with a high-precision timer. In this application, when the control interrupt begins execution, the count value of the high-precision timer is read and recorded as the first count value Cnt1; when the control interrupt ends execution, the count value of the high-precision timer is read again and recorded as the second count value Cnt2. The first count value Cnt1 corresponds to the time when the control interrupt begins execution, and the second count value Cnt2 corresponds to the time when the control interrupt ends execution.
[0051] Step S502: Determine the count difference between the second count value and the first count value, and use the product of the count difference and a single count cycle as the execution time reference value for the control interrupt; The count difference represents the number of counts elapsed by the high-precision timer during the control interrupt execution. Multiplying the count difference by a single count cycle (tick) of the high-precision timer yields the reference value T_ for the control interrupt execution time. int That is, T_ int = (Cnt2 - Cnt1) × tick. Execution time reference value T_ intThis is the actual execution time of this control interruption.
[0052] Step S503: Compare the execution time reference value with the safety margin coefficient to obtain the safety period threshold; The safety margin factor is used to reserve a safety margin for the execution time of control interruptions, and is generally taken as 70%. The execution time reference value T_ int Dividing by the safety margin coefficient PercentofMargin yields the safety period threshold T_ min That is, T_ min = T_ int / PercentofMargin. Safe period threshold T_ min This indicates the minimum value of the PWM cycle that can be allowed in order for the control interrupt to complete within the PWM cycle.
[0053] Step S504: Set the safety cycle threshold to the lower limit of each preset frequency range.
[0054] Specifically, the lower limit of the preset frequency range of each random carrier period value in the random carrier period buffer is set as the safe period threshold T_. min Due to the safety period threshold T_ min It is based on the actual execution time T_ of the control interrupt. int The safety cycle threshold T_ is dynamically determined; therefore, as the execution time of the control interrupt increases, the safety cycle threshold T_ min The lower limit of the preset frequency range is increased accordingly, thereby ensuring that the period value of each random carrier in the random carrier period buffer is not less than the safe period threshold T_. min This ensures that the execution time of the control interrupt is always less than the current PWM cycle.
[0055] For example, if the single counting cycle of the high-precision timer is tick = 0.1μs; Cnt1 = 1000 when the control interrupt starts; Cnt2 = 5000 when the control interrupt ends; and the safety margin coefficient PercentofMargin = 70%, then: the counting difference = 5000 - 1000 = 4000; the execution time reference value T_ int = 4000 × 0.1μs = 400μs; Safety period threshold T_ min = 400μs / 70% ≈ 571μs.
[0056] Therefore, the lower limit of the preset frequency range of each random carrier period value in the random carrier period buffer is set to 571μs, that is, the random carrier period value read from the buffer afterward is not less than 571μs, thereby ensuring that the execution time of the control interrupt of 400μs is always less than the current PWM period.
[0057] Additionally, it should be noted that the upper limit of the preset frequency range can be set to a fixed value during system initialization and not changed subsequently. Only the lower limit of the preset frequency range needs to be adjusted, for example, to 1000μs.
[0058] Alternatively, the upper limit of the preset frequency range can be dynamically adjusted according to the motor's operating status, such as adjusting based on at least one of the motor speed, load current, and DC bus voltage. When the motor speed increases, the upper limit can be appropriately lowered to avoid the PWM cycle being too long at high speeds and affecting the control response; when the motor speed decreases, the upper limit can be appropriately raised to expand the random range of the random carrier period value and enhance the harmonic dispersion effect of the random PWM.
[0059] Alternatively, the upper limit of the preset frequency range can be dynamically adjusted along with the lower limit. For example, the upper limit can be set as a preset multiple of the lower limit, so that the upper limit increases accordingly as the lower limit increases. This ensures that a sufficient random range is maintained even when the control interrupt execution time increases and the lower limit increases. This application does not impose specific limitations on this.
[0060] In another embodiment, such as Figure 6 As shown, this application also provides a vehicle controller 600, including: a counter module 601, a control module 602, a pre-storage module 603, a determination module 604, and a pre-storage write module 605.
[0061] Counter module 601 is used to count the current PWM cycle; The control module 602 is used to read the first random carrier cycle value and the first duty cycle instruction from the pre-storage module 603 in response to the counter module reaching the start point of the current PWM cycle, and control the output of the current PWM cycle with the first random carrier cycle value and the first duty cycle instruction. The first random carrier cycle value and the first duty cycle instruction were written into the pre-storage module 603 at the start point of the previous PWM cycle. The determination module 604 is used to determine the second duty cycle instruction and the second random carrier cycle value corresponding to the next PWM cycle. The pre-storage write module 605 is used to store the second duty cycle instruction and the second random carrier period value into the pre-storage module 603 so that they can take effect synchronously at the beginning of the next PWM cycle.
[0062] In one feasible implementation, such as Figure 7 As shown, the pre-storage module 603 includes: Shadow register 6031 is used to store the second duty cycle instruction and the second random carrier cycle value corresponding to the next PWM cycle. The active register 6023 is used to read the first random carrier cycle value and the first duty cycle instruction of the current PWM cycle from the shadow register and load them.
[0063] This application provides a vehicle controller, which includes: at least one processor; and a memory communicatively connected to the at least one processor; wherein the memory stores instructions executable by the at least one processor, which are executed by the at least one processor to enable the at least one processor to perform the random PWM control method in the above embodiment 1.
[0064] like Figure 8 As shown, the vehicle controller may include a processing unit 801 (e.g., a central processing unit, a graphics processing unit, etc.), which can perform various appropriate actions and processes according to a program stored in a read-only memory (ROM) 802 or a program loaded from a storage device 803 into a random access memory (RAM) 804. The RAM 804 also stores various programs and data required for the operation of the vehicle controller. The processing unit 801, ROM 802, and RAM 804 are interconnected via a bus 805. An input / output (I / O) interface 806 is also connected to the bus. Typically, the following systems can be connected to the I / O interface 806: input devices 807 including, for example, a touchscreen, touchpad, keyboard, mouse, image sensor, microphone, accelerometer, gyroscope, etc.; output devices 808 including, for example, a liquid crystal display (LCD), speaker, vibrator, etc.; storage devices 803 including, for example, magnetic tape, hard disk, etc.; and communication devices 809. The communication device 809 allows the vehicle controller to communicate wirelessly or wiredly with other devices to exchange data. Although the diagram shows a vehicle controller with various systems, it should be understood that it is not required to implement or have all of the systems shown. More or fewer systems may be implemented alternatively.
[0065] Specifically, according to the embodiments disclosed in this application, the processes described above with reference to the flowcharts can be implemented as computer software programs. For example, embodiments disclosed in this application include a computer program product comprising a computer program carried on a computer-readable medium, the computer program containing program code for performing the methods shown in the flowcharts. In such embodiments, the computer program can be downloaded and installed from a network via a communication device, or installed from storage device 803, or installed from ROM 802. When the computer program is executed by processing device 801, it performs the functions defined in the methods of the embodiments disclosed in this application.
[0066] The vehicle controller provided in this application employs the random PWM control method described in the above embodiments, which solves the technical problems of asynchronous updates between duty cycle and carrier period, and the risk of bridge arm shoot-through caused by interrupt execution time overflow in existing random PWM control. Compared with the prior art, the beneficial effects of the vehicle controller provided in this application are the same as those of the random PWM control method provided in the above embodiments, and other technical features of this vehicle controller are the same as those disclosed in the previous embodiment method, and will not be repeated here.
[0067] It should be understood that the various parts disclosed in this application can be implemented using hardware, software, firmware, or a combination thereof. In the description of the above embodiments, specific features, structures, materials, or characteristics can be combined in any suitable manner in one or more embodiments or examples.
[0068] The above description is merely a specific embodiment of this application, but the scope of protection of this application is not limited thereto. Any variations or substitutions that can be easily conceived by those skilled in the art within the scope of the technology disclosed in this application should be included within the scope of protection of this application. Therefore, the scope of protection of this application should be determined by the scope of the claims.
[0069] This application also provides a vehicle that includes the vehicle controller described above.
[0070] The above are merely preferred embodiments of this application and do not limit the patent scope of this application. Any equivalent structural or procedural transformations made using the content of this application's specification and drawings, or direct or indirect applications in other related technical fields, are similarly included within the patent scope of this application.
Claims
1. A random PWM control method, characterized in that, The method includes: In response to the counter reaching the start point of the current PWM cycle, the first random carrier cycle value and the first duty cycle instruction are read from the pre-stored module, and the output of the current PWM cycle is controlled with the first random carrier cycle value and the first duty cycle instruction. The first random carrier cycle value and the first duty cycle instruction were written to the pre-stored module at the start point of the previous PWM cycle. The second duty cycle instruction and the second random carrier cycle value corresponding to the next PWM cycle are determined and stored in the pre-storage module so that they take effect synchronously at the start of the next PWM cycle.
2. The method as described in claim 1, characterized in that, The step of controlling the output of the current PWM cycle with the first random carrier period value and the first duty cycle instruction includes: The first random carrier period value and the first duty cycle instruction are loaded simultaneously into the corresponding active register.
3. The method as described in claim 1, characterized in that, Determining the second random carrier period value corresponding to the next PWM period includes: A random carrier period value is obtained from the random carrier period buffer and used as the second random carrier period value corresponding to the next PWM period. The random carrier period buffer stores multiple pre-generated random carrier period values that change randomly within a preset frequency range.
4. The method as described in claim 3, characterized in that, The method further includes: Real-time monitoring and control of interrupt execution time; The preset frequency range of each random carrier period value in the random carrier period buffer is adjusted according to the execution time.
5. The method as described in claim 1, characterized in that, The response before the counter reaches the start point of the current PWM cycle also includes: When the counter is detected to underflow to zero, or the counter reaches the cycle reload value, it is determined that the counter has reached the start point of the current PWM cycle.
6. The method as described in claim 4, characterized in that, The preset frequency range for adjusting the random carrier period values in the random carrier period buffer according to the execution time includes: Obtain the first count value when the control interrupt starts execution, and the second count value when the control interrupt ends execution; The count difference between the second count value and the first count value is determined, and the product of the count difference and a single count cycle is used as the execution time reference value of the control interrupt; The execution time reference value is compared with the safety margin coefficient to obtain the safety period threshold; The safety cycle threshold is set as the lower limit of each of the preset frequency ranges.
7. A vehicle controller, characterized in that, include: The counter module is used to count the current PWM cycle; The control module is configured to, in response to the counter module reaching the start point of the current PWM cycle, read a first random carrier cycle value and a first duty cycle instruction from the pre-storage module, and control the output of the current PWM cycle with the first random carrier cycle value and the first duty cycle instruction, wherein the first random carrier cycle value and the first duty cycle instruction were written to the pre-storage module at the start point of the previous PWM cycle. The determination module is used to determine the second duty cycle instruction and the second random carrier cycle value corresponding to the next PWM cycle. A pre-storage write module is used to store the second duty cycle instruction and the second random carrier period value into the pre-storage module so that they take effect synchronously at the start of the next PWM cycle.
8. The vehicle controller according to claim 7, characterized in that, The pre-storage module includes: The shadow register is used to store the second duty cycle instruction and the second random carrier cycle value corresponding to the next PWM cycle. The activity register is used to read the first random carrier cycle value and the first duty cycle instruction of the current PWM cycle from the shadow register and load them.
9. A vehicle controller, characterized in that, include: The memory, the processor, and the computer program stored in the memory and executable on the processor, the computer program being configured to implement the random PWM control method as described in any one of claims 1 to 6.
10. A vehicle, characterized in that, The vehicle includes the vehicle controller described in any one of claims 7-9.
