A method based on dual-cycle three-channel PWM signal pulse width modulation
By using a dual-cycle, three-channel PWM signal pulse width modulation method, the superposition time of multiple PWM signals is precisely controlled, solving the problem of superimposed current of multiple PWM signals, achieving current stability and circuit stability, reducing electromagnetic interference and pulse noise, and improving circuit performance.
Patent Information
- Application Number
- CN202310795386.9
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2023-06-30
- Publication Date
- 2026-11-17
- Estimated Expiration
- 2043-06-30
AI Technical Summary
Existing technologies cannot effectively prevent superimposed current when multiple PWM signals are working simultaneously, resulting in unstable current and circuit instability, and cannot effectively suppress peak power supply and pulse noise.
By programming to control the superposition time of multiple PWM signals, the operating current of the three PWM signals is precisely controlled. The dual-cycle three-channel PWM signal pulse width modulation method is adopted to adjust the duty cycle of each signal to avoid uneven distribution of simultaneous low or high levels, thus ensuring current stability and circuit stability.
It achieves current smoothness and circuit stability, reduces electromagnetic interference and pulse noise, reduces circuit power consumption, improves circuit performance, and has low cost and high compatibility.
Smart Images

Figure CN116886083B_ABST
Abstract
Description
Technical Field
[0001] This invention relates to the field of PWM control technology, and more particularly to a method based on dual-cycle three-channel PWM signal pulse width modulation. Background Technology
[0002] LED lights are common lighting devices, and their brightness and color can be controlled by adjusting the current. A common method for controlling the current is Pulse Width Modulation (PWM), which changes the average operating current of the LED by altering the duty cycle of a square wave signal. PWM control technology is simple, efficient, and programmable, and is widely used for brightness control of LED lights. Besides brightness control, PWM technology can also be used for color control of LED lights. In PWM control, each color has its own duty cycle value. By simultaneously controlling LEDs of different colors using multiple PWM signals, precise color control of the LED light can be achieved. Common color-adjustable LEDs synthesize the desired color by setting different duty cycle values for red, green, and blue using three PWM signals respectively.
[0003] A dual-cycle PWM waveform is a special type of PWM waveform in which the duty cycle changes twice within adjacent cycles, thereby achieving higher regulation precision and lower output ripple. Dual-cycle PWM waveforms can be used to improve the performance and efficiency of lighting control circuits.
[0004] Current LED control methods mostly use fixed-period PWM signals to control the lights. Most related patent designs focus on optimizing hardware design, while software design patents include variable duty cycles that automatically adjust the duty cycle based on ambient brightness, current, and voltage, and eliminate narrow PWM pulses. For PWM control signals of multiple colors, the superimposed current generated when multiple PWM pulses operate simultaneously is generally not considered. In lower-end chips, the built-in PWM output only outputs a low or high level when the value exceeds the comparison threshold. For the three PWM control signals required for multi-color LEDs, it is difficult to effectively avoid superimposed current.
[0005] In view of this, the present invention provides a method based on pulse width modulation of a dual-cycle three-channel PWM signal. Summary of the Invention
[0006] To address the technical problem of superimposed current generated when multiple PWM pulses operate simultaneously, this invention provides a method based on pulse width modulation of three PWM signals with a dual-cycle period. This invention primarily uses programming to precisely control the superposition timing of the currents from multiple PWM pulses, thereby averaging the operating current generated by the three PWM signals. This effectively ensures current stability, improves circuit stability, suppresses peak power supply, and reduces pulse noise. Furthermore, it features low cost and high compatibility.
[0007] The technical means employed in this invention are as follows:
[0008] This invention provides a method for pulse width modulation based on a dual-cycle three-channel PWM signal, comprising:
[0009] Set the period length of the pulse width modulation circuit, take the adjacent first period and second period as a modulation period, and set the preset duty cycle of the first modulation signal, the second modulation signal and the third modulation signal respectively;
[0010] Determine whether the preset duty cycle of the first modulation signal and the third modulation signal satisfies the first switching condition;
[0011] If the first switching condition is not met, determine whether the preset duty cycle of the second modulation signal and the third modulation signal meets the second switching condition;
[0012] If the second exchange condition is not met, the preset duty cycle of the first modulation signal, the second modulation signal, and the third modulation signal is converted into the actual duty cycle of the first modulation signal, the second modulation signal, and the third modulation signal;
[0013] The working intervals of the first and second modulation signals are obtained based on the actual duty cycles of the first and second modulation signals; the working length of the third modulation signal within the modulation period is obtained based on the actual duty cycle of the third modulation signal; the preset period includes a first interval and a second interval, the first interval being the intersection of the working intervals of the first and second modulation signals, and the working length of the third modulation signal is filled into the second interval in a preset order.
[0014] Furthermore, the step of determining whether the preset duty cycle of the first modulation signal and the third modulation signal satisfies the first switching condition further includes:
[0015] If the first exchange condition is met, the preset duty cycle of the first modulation signal is converted into the actual duty cycle of the third modulation signal, the preset duty cycle of the second modulation signal is converted into the actual duty cycle of the second modulation signal, and the preset duty cycle of the third modulation signal is converted into the actual duty cycle of the first modulation signal.
[0016] Furthermore, the step of determining whether the preset duty cycle of the second modulation signal and the third modulation signal satisfies the second switching condition further includes:
[0017] If the second exchange condition is met, the preset duty cycle of the first modulation signal is converted into the actual duty cycle of the first modulation signal, the preset duty cycle of the second modulation signal is converted into the actual duty cycle of the third modulation signal, and the preset duty cycle of the third modulation signal is converted into the actual duty cycle of the second modulation signal.
[0018] Further, the step of obtaining the operating ranges of the first modulation signal and the second modulation signal based on the actual duty cycle of the first modulation signal and the actual duty cycle of the second modulation signal includes:
[0019] The operating lengths of the first modulation signal and the second modulation signal within the modulation period are calculated respectively, as follows:
[0020]
[0021] Where T is the period length, p a P represents the true duty cycle of the first modulation signal. a p is the operating length of the first modulation signal within the modulation period. b P represents the true duty cycle of the second modulation signal. b The operating length of the second modulation signal within the modulation period;
[0022] Taking the start point of the first cycle as zero, the working length of the first modulation signal is spread out from the start point of the first cycle, and the working length of the second modulation signal is spread out from the start point of the second cycle to obtain the endpoint values of the working intervals of the first modulation signal and the second modulation signal, calculated in the following manner:
[0023]
[0024] Among them, y a1 y is the endpoint value of the first modulation signal in the first period. a2 y is the endpoint value of the first modulation signal in the second period. b1y is the endpoint value of the second modulation signal in the first period. b2 f is the endpoint value of the second modulation signal in the second period. m To simplify the function, f s For selection functions;
[0025] Based on the endpoints of the working intervals of the first modulation signal and the second modulation signal, the working interval of the first modulation signal is obtained as [0, y]. a1 ] and [T,y a2 The operating range of the second modulation signal is [0, y]. b1 ] and [T,y b2 ].
[0026] Further, filling the second interval with the working length of the third modulation signal in a preset order includes:
[0027] A first endpoint value is determined between the end of the first cycle and the endpoint value of the first modulation signal in the first cycle; a second endpoint value is determined between the end of the second cycle and the endpoint value of the second modulation signal in the second cycle; a third endpoint value is determined between the endpoint value of the first modulation signal in the first cycle and the endpoint value of the second modulation signal in the first cycle; and a fourth endpoint value is determined between the endpoint value of the first modulation signal in the second cycle and the endpoint value of the second modulation signal in the second cycle.
[0028] The working length of the third modulation signal is filled from the end of the first period to the first endpoint value to obtain the first remaining working length, and it is determined whether the first remaining working length is greater than 0.
[0029] If the first remaining working length is greater than 0, the first remaining working length is filled from the end of the second cycle to the second endpoint value to obtain the second remaining working length, and it is determined whether the second remaining working length is greater than 0.
[0030] If the second remaining working length is greater than 0, the second remaining working length is filled from the first endpoint value to the third endpoint value to obtain the third remaining working length, and it is determined whether the third remaining working length is greater than 0.
[0031] If the third remaining working length is greater than 0, the third remaining working length is filled from the second endpoint value to the fourth endpoint value to obtain the fourth remaining working length, and it is determined whether the fourth remaining working length is greater than 0.
[0032] If the fourth remaining working length is greater than 0, the fourth remaining working length is filled from the third endpoint value to the starting point of the first cycle to obtain the fifth remaining working length, and it is determined whether the fifth remaining working length is greater than 0.
[0033] If the fifth remaining working length is greater than 0, the fifth remaining working length is filled from the fourth endpoint value to the starting point of the second cycle.
[0034] Further, the first endpoint value, the second endpoint value, the third endpoint value, the fourth endpoint value, the fifth endpoint value, and the sixth endpoint value are calculated in the following manner:
[0035]
[0036] Where, x n Let y1 be the value of the nth endpoint. a1 y2=y b2 y3=y b1 y4=y a2 f1 is f m The normalization function, P c The operating length of the third modulation signal within the modulation period.
[0037] Further, the determination of whether the preset duty cycle of the first modulation signal and the third modulation signal satisfies the first switching condition is calculated in the following manner:
[0038] n1=f1(p a -0.5)×f1(1-p a -p c )×f1(0.5-p b -p c )+f1(0.5-p a )×
[0039] f1(p a +p c -1.5)×f1(p a +p c -1);
[0040] Where n1 is the first coefficient, p a p is the preset duty cycle of the first modulation signal. c f1 is the preset duty cycle of the third modulation signal, and f1 is the normalization function of the simplified function;
[0041] When the first coefficient is equal to 0, the preset duty cycle of the first modulation signal and the third modulation signal does not satisfy the first exchange condition; when the first coefficient is not equal to 0, the preset duty cycle of the first modulation signal and the third modulation signal satisfies the first exchange condition.
[0042] Further, the determination of whether the preset duty cycle of the second modulation signal and the third modulation signal satisfies the second switching condition is calculated in the following manner:
[0043] n2=f1(p b -0.5)×f1(1-p b -p c )×f1(0.5-p a -p c )+f1(0.5-p b )×
[0044] f1(p b +p c -1.5)×f1(p b +p c -1);
[0045] Where n2 is the second coefficient, p b p is the preset duty cycle of the second modulation signal. c f1 is the preset duty cycle of the third modulation signal, and f1 is the normalization function of the simplified function;
[0046] When the second coefficient is equal to 0, the preset duty cycle of the second modulation signal and the third modulation signal does not satisfy the second exchange condition; when the second coefficient is not equal to 0, the preset duty cycle of the second modulation signal and the third modulation signal satisfies the second exchange condition.
[0047] Compared with the prior art, the present invention has the following advantages:
[0048] The present invention provides a method for pulse width modulation based on dual-cycle three-channel PWM signals. This method obtains the working intervals of the first and second modulation signals based on their actual duty cycles. It then obtains the working length of the third modulation signal within the modulation period based on its actual duty cycle. The preset period includes a first interval and a second interval. The first interval is the intersection of the working intervals of the first and second modulation signals. The working length of the third modulation signal is filled into the second interval in a preset order. This avoids situations where three modulation signals are simultaneously low in one working interval and at least two modulation signals are simultaneously high in another working interval, or where only one modulation signal is high in one working interval and all three modulation signals are high in another working interval. This results in a more uniform distribution of high-level modulation signals, reducing electromagnetic interference or current fluctuations during modulation signal changes, making the circuit more stable, suppressing peak power supply, reducing pulse noise, lowering circuit power consumption, and improving circuit performance. Furthermore, this method is easy to program and debug, automatically setting the waveform according to the required duty cycle of each PWM signal, and has the advantages of low cost and high compatibility. Attached Figure Description
[0049] To more clearly illustrate the technical solutions in the embodiments of the present invention or the prior art, the drawings used in the description of the embodiments or the prior art will be briefly introduced below. Obviously, the drawings described below are some embodiments of the present invention. For those skilled in the art, other drawings can be obtained based on these drawings without creative effort.
[0050] Figure 1 This is a schematic diagram of the operating current for a three-channel PWM signal pulse width modulation in the prior art.
[0051] Figure 2 This invention provides a schematic diagram of an operating current based on dual-cycle three-channel PWM signal pulse width modulation.
[0052] Figure 3 This is a schematic diagram of an interval division method based on dual-cycle three-channel PWM signal pulse width modulation provided by the present invention.
[0053] Figure 4 This is a schematic diagram illustrating another interval division method based on dual-cycle three-channel PWM signal pulse width modulation provided by the present invention.
[0054] Figure 5 This is a schematic diagram illustrating a special interval division method based on dual-cycle three-channel PWM signal pulse width modulation provided by the present invention.
[0055] Figure 6This is a flowchart of a method based on dual-cycle three-channel PWM signal pulse width modulation provided by the present invention.
[0056] Figure 7 A power comparison chart processed by MATLAB software simulation.
[0057] Figure 8 This is a comparison chart of peak-to-average power ratio processed by MATLAB software simulation.
[0058] Figure 9 Another comparison chart of peak-to-average power ratio processed by MATLAB software simulation.
[0059] Figure 10 This is another comparison chart of peak-to-average power ratio processed by MATLAB software simulation.
[0060] Figure 11 This is another comparison chart of peak-to-average power ratio processed by MATLAB software simulation.
[0061] Figure 12 It is a type of circuit module. Detailed Implementation
[0062] To enable those skilled in the art to better understand the present invention, the technical solutions of the present invention will be clearly and completely described below with reference to the accompanying drawings of the embodiments of the present invention. Obviously, the described embodiments are only some embodiments of the present invention, and not all embodiments. Based on the embodiments of the present invention, all other embodiments obtained by those skilled in the art without creative effort should fall within the scope of protection of the present invention.
[0063] It should be noted that the terms "first," "second," etc., in the specification, claims, and accompanying drawings of this invention are used to distinguish similar objects and are not necessarily used to describe a specific order or sequence. It should be understood that such data can be interchanged where appropriate so that the embodiments of the invention described herein can be implemented in orders other than those illustrated or described herein. Furthermore, the terms "comprising" and "having," and any variations thereof, are intended to cover a non-exclusive inclusion; for example, a process, method, system, product, or apparatus that comprises a series of steps or units is not necessarily limited to those steps or units explicitly listed, but may include other steps or units not explicitly listed or inherent to such processes, methods, products, or apparatus.
[0064] Combination Figures 1 to 11 , Figure 1 This is a schematic diagram of the operating current for a three-channel PWM signal pulse width modulation method in existing technology. Figure 2This is a schematic diagram of an operating current based on dual-cycle three-channel PWM signal pulse width modulation provided by the present invention. Figure 3 This is a schematic diagram illustrating an interval division method based on dual-cycle three-channel PWM signal pulse width modulation provided by the present invention. Figure 4 This is a schematic diagram illustrating another interval division method based on dual-cycle three-channel PWM signal pulse width modulation provided by the present invention. Figure 5 This is a schematic diagram illustrating a specific interval division method based on dual-cycle three-channel PWM signal pulse width modulation provided by the present invention. Figure 6 The flowchart illustrates a specific embodiment of the method based on dual-cycle three-channel PWM signal pulse width modulation provided by the present invention, including:
[0065] S1: Set the period length of the pulse width modulation circuit, taking the adjacent first period and second period as a modulation period, and set the preset duty cycle of the first modulation signal, the second modulation signal and the third modulation signal respectively;
[0066] S2: Determine whether the preset duty cycle of the first modulation signal and the third modulation signal satisfies the first switching condition;
[0067] In step S2, it is determined whether the preset duty cycle of the first modulation signal and the third modulation signal satisfies the first switching condition, calculated as follows:
[0068] n1=f1(p a -0.5)×f1(1-p a -p c )×f1(0.5-p b -p c )+f1(0.5-p a )×f1(p a +p c -1.5)×f1(p a +p c -1);
[0069] Where n1 is the first coefficient, p a p is the preset duty cycle of the first modulation signal. c f1 is the preset duty cycle of the third modulation signal, and f1 is the normalization function of the simplified function;
[0070] When the first coefficient is equal to 0, the preset duty cycle of the first modulation signal and the third modulation signal does not satisfy the first exchange condition; when the first coefficient is not equal to 0, the preset duty cycle of the first modulation signal and the third modulation signal satisfies the first exchange condition.
[0071] Understandably, to simplify calculations, this invention defines the simplification function as f. m (z) = (|z| + z) ÷ 2. Furthermore, the normalized function f1(z) of the simplified function is calculated according to the following formula:
[0072]
[0073] The selection function f is also defined. S Calculate according to the following formula:
[0074]
[0075] It is understandable that if z3 = 0, the selection function outputs z2; if z3 > 0, the selection function outputs z1; and if z3 is less than 0, the selection function outputs z2.
[0076] S21: If the first switching condition is not met, determine whether the preset duty cycle of the second modulation signal and the third modulation signal meets the second switching condition;
[0077] In step S21, it is determined whether the preset duty cycle of the second modulation signal and the third modulation signal satisfies the second switching condition, calculated as follows:
[0078] n2=f1(p b -0.5)×f1(1-p b -p c )×f1(0.5-p a -p c )+f1(0.5-p b )×f1(p b +p c -1.5)×f1(p b +p c -1);
[0079] Where n2 is the second coefficient, p b p is the preset duty cycle of the second modulation signal. c f1 is the preset duty cycle of the third modulation signal, and f1 is the normalization function of the simplified function;
[0080] When the second coefficient is equal to 0, the preset duty cycle of the second modulation signal and the third modulation signal does not satisfy the second exchange condition; when the second coefficient is not equal to 0, the preset duty cycle of the second modulation signal and the third modulation signal satisfies the second exchange condition.
[0081] S22: If the first exchange condition is met, convert the preset duty cycle of the first modulation signal into the actual duty cycle of the third modulation signal, convert the preset duty cycle of the second modulation signal into the actual duty cycle of the second modulation signal, and convert the preset duty cycle of the third modulation signal into the actual duty cycle of the first modulation signal, and calculate according to the following formula:
[0082] p a ′=f s (p c ,p a ,n1);
[0083] S211: If the second exchange condition is not met, convert the preset duty cycle of the first modulation signal, the second modulation signal and the third modulation signal into the actual duty cycle of the first modulation signal, the second modulation signal and the third modulation signal;
[0084] S212: If the second exchange condition is met, convert the preset duty cycle of the first modulation signal into the actual duty cycle of the first modulation signal, convert the preset duty cycle of the second modulation signal into the actual duty cycle of the third modulation signal, and convert the preset duty cycle of the third modulation signal into the actual duty cycle of the second modulation signal, and calculate according to the following formula:
[0085] p b ′=f s (p c ,p b ,n2);
[0086] It is understandable that, such as Figure 3 As shown, there is a situation where, after the working length of the third modulation signal is filled in the second interval according to the preset order, there is still a portion that is not filled. This results in the working length of the third modulation signal being filled at position 5, causing the high potentials of the three modulation signals to overlap. Figure 5 As shown, there are also cases where the intersection of the non-working intervals of the first, second, and third modulation signals is not empty. To avoid these two situations, the duty cycles of the three signals need to be adjusted. However, these two situations will not occur simultaneously, and the duty cycles of the first and second modulation signals do not need to be adjusted simultaneously. The final true value of the third modulation signal satisfies the following formula:
[0087] p c ′=f s (p a ,p c ,n1)+f s (p b ,p c ,n2)-p c .
[0088] It should be noted that it is also possible to first determine whether the second exchange condition is met, and then determine whether the first exchange condition is met. Of course, the first and second exchange conditions can also be determined simultaneously, because in actual application, the first and second exchange conditions cannot be met at the same time. The order of determination of the first and second exchange conditions can be set according to actual needs. This embodiment does not impose specific restrictions on this.
[0089] S3: Obtain the working intervals of the first and second modulated signals based on the actual duty cycles of the first and second modulated signals; obtain the working length of the third modulated signal within the modulation period based on the actual duty cycle of the third modulated signal; the preset period includes a first interval and a second interval, the first interval being the intersection of the working intervals of the first and second modulated signals, and the working length of the third modulated signal is filled into the second interval in a preset order.
[0090] In step S3, the operating ranges of the first and second modulated signals are obtained based on the actual duty cycle of the first and second modulated signals, including:
[0091] The operating lengths of the first and second modulating signals within the modulation period are calculated separately as follows:
[0092]
[0093] Where T is the period length, p a P represents the true duty cycle of the first modulated signal. a p is the working length of the first modulated signal within the modulation period. b P represents the true duty cycle of the second modulated signal. b The operating length of the second modulated signal within the modulation period;
[0094] Taking the start point of the first cycle as zero, the working length of the first modulation signal is spread from the start point of the first cycle, and the working length of the second modulation signal is spread from the start point of the second cycle, to obtain the endpoint values of the working intervals of the first and second modulation signals, which are calculated as follows:
[0095]
[0096] Among them, y a1 Let y be the endpoint value of the first modulated signal in the first period. a2 y is the endpoint value of the first modulation signal in the second period. b1 y is the endpoint value of the second modulation signal in the first period. b2 f is the endpoint value of the second modulation signal in the second period. mTo simplify the function, f s For selection functions;
[0097] Based on the endpoints of the working intervals of the first modulation signal and the second modulation signal, the working interval of the first modulation signal is [0, y]. a1 ] and [T,y a2 The operating range of the second modulation signal is [0, y]. b1 ] and [T,y b2 ].
[0098] Where, [0, y a1 ] and [T,y b2 [T, y] is the priority interval to fill. a2 ] and [0, y b1 [0, y] represents the second filling interval. Spreading the working length of the second modulation signal from the beginning of the second period will spread it to the end of the first period of the next modulation period. The first period of the next modulation period is equal to the first period of this modulation period, so we directly obtain [0, y]. b1 ].
[0099] In step S3, the working length of the third modulation signal is filled into the second interval in a preset order, including:
[0100] A first endpoint value is determined between the end of the first cycle and the endpoint value of the first modulation signal in the first cycle; a second endpoint value is determined between the end of the second cycle and the endpoint value of the second modulation signal in the second cycle; a third endpoint value is determined between the endpoint value of the first modulation signal in the first cycle and the endpoint value of the second modulation signal in the first cycle; and a fourth endpoint value is determined between the endpoint value of the first modulation signal in the second cycle and the endpoint value of the second modulation signal in the second cycle.
[0101] The working length of the third modulation signal is filled from the end of the first cycle to the first endpoint value to obtain the first remaining working length, and it is determined whether the first remaining working length is greater than 0.
[0102] If the first remaining working length is greater than 0, fill the first remaining working length from the end of the second cycle to the second endpoint to obtain the second remaining working length, and determine whether the second remaining working length is greater than 0.
[0103] If the second remaining working length is greater than 0, fill the second remaining working length from the first endpoint value to the third endpoint value to obtain the third remaining working length, and determine whether the third remaining working length is greater than 0.
[0104] If the third remaining work length is greater than 0, fill the third remaining work length from the second endpoint value to the fourth endpoint value to obtain the fourth remaining work length, and determine whether the fourth remaining work length is greater than 0.
[0105] If the fourth remaining working length is greater than 0, fill the fourth remaining working length from the third endpoint value to the starting point of the first cycle to obtain the fifth remaining working length, and determine whether the fifth remaining working length is greater than 0.
[0106] If the fifth remaining working length is greater than 0, fill the fifth remaining working length from the fourth endpoint value to the starting point of the second cycle.
[0107] The first, second, third, fourth, fifth, and sixth endpoint values are calculated as follows:
[0108]
[0109] Where, x n Let y1 be the value of the nth endpoint. a1 y2=y b2 y3=y b1 y4=y a2 f1 is f m The normalization function, P c The operating length of the third modulation signal within the modulation period.
[0110] It is understandable that if y b1 >y a1 Then x3 = x1, and similarly, if y a2 >y b2 Then x4 = x2. To calculate the values of the fifth and sixth endpoints, we only need to determine P. c We can determine whether there is any remaining signal and whether the boundary exceeds 0 or T. Finally, we obtain the working range of the third modulation signal as [x5, T] and [x6, 2T].
[0111] The method based on dual-cycle three-channel PWM signal pulse width modulation provided in this embodiment can reduce the operating current fluctuation of LEDs at various color temperatures and brightness levels, thereby suppressing peak power supply, reducing pulse noise, lowering circuit power consumption, and improving circuit performance. It can be applied to any MCU that supports outputting bipolar PWM signals via a timer, facilitating programming and debugging. It can automatically set the waveform according to the duty cycle required by each PWM channel, offering advantages such as low cost and high compatibility.
[0112] In some alternative embodiments, refer to Figures 7 to 12 , Figure 7 A power comparison chart processed by MATLAB software simulation. Figure 8 This is a comparison chart of peak-to-average power ratio processed by MATLAB software simulation. Figure 9 This is another comparison chart of peak-to-average power ratio processed by MATLAB software simulation. Figure 10This is another comparison chart of peak-to-average power ratio processed by MATLAB software simulation. Figure 11 This is another comparison chart of peak-to-average power ratio processed by MATLAB software simulation. Figure 12 This circuit module applies the dual-cycle three-channel PWM signal pulse width modulation method provided by this invention to an MCU. It utilizes the PWM mode of its timer to output a PWM signal to control the PWM drive circuit, outputting a 12V voltage to drive a common-anode 8×8 LED matrix. A schematic diagram of the circuit module is attached. Figure 12 .
[0113] Understandably, the program sets the duty cycle of the PWM signal corresponding to each color based on different color temperatures and brightness levels, and obtains the required working range according to the formula. In the timer's counter refresh or interrupt, the output polarity of each PWM channel and the comparator value are set. If the working range is [x5, T] and [x6, 2T], then the output polarity is set to low. It's important to note that the working range is two cycles, but the dual-cycle implementation within the chip is achieved by setting the duty cycle of adjacent cycles separately. Therefore, y2, y4, and x6 all need to be subtracted from T to obtain their corresponding values. Additionally, if the LED is a common cathode, the output polarity needs to be flipped; see [link to implementation details]. Figure 7 and Figure 11 .
[0114] The sequence numbers of the above embodiments of the present invention are for descriptive purposes only and do not represent the superiority or inferiority of the embodiments.
[0115] In the above embodiments of the present invention, the descriptions of each embodiment have different focuses. For parts not described in detail in a certain embodiment, please refer to the relevant descriptions of other embodiments.
[0116] Finally, it should be noted that the above embodiments are only used to illustrate the technical solutions of the present invention, and not to limit them; although the present invention has been described in detail with reference to the foregoing embodiments, those skilled in the art should understand that modifications can still be made to the technical solutions described in the foregoing embodiments, or equivalent substitutions can be made to some or all of the technical features; and these modifications or substitutions do not cause the essence of the corresponding technical solutions to deviate from the scope of the technical solutions of the embodiments of the present invention.
Claims
1. A method based on dual-cycle three-channel PWM signal pulse width modulation, characterized in that, include: Set the period length of the pulse width modulation circuit, take the adjacent first period and second period as a modulation period, and set the preset duty cycle of the first modulation signal, the second modulation signal and the third modulation signal respectively; Determine whether the preset duty cycle of the first modulation signal and the third modulation signal satisfies the first switching condition; If the first switching condition is not met, determine whether the preset duty cycle of the second modulation signal and the third modulation signal meets the second switching condition; If the second exchange condition is not met, the preset duty cycle of the first modulation signal, the second modulation signal, and the third modulation signal is converted into the actual duty cycle of the first modulation signal, the second modulation signal, and the third modulation signal; The operating intervals of the first and second modulated signals are obtained based on the actual duty cycles of the first and second modulated signals; the operating length of the third modulated signal within the modulation period is obtained based on the actual duty cycle of the third modulated signal; the modulation period includes a first interval and a second interval, the first interval being the intersection of the operating intervals of the first and second modulated signals, and the operating length of the third modulated signal is filled into the second interval in a preset order; The step of obtaining the operating range of the first modulation signal and the second modulation signal based on the actual duty cycle of the first modulation signal and the actual duty cycle of the second modulation signal includes: The operating lengths of the first modulation signal and the second modulation signal within the modulation period are calculated respectively, as follows: ; in, The period length is... The actual duty cycle of the first modulation signal. The operating length of the first modulation signal within the modulation period. The actual duty cycle of the second modulation signal. The operating length of the second modulation signal within the modulation period; Taking the start point of the first cycle as zero, the working length of the first modulation signal is spread out from the start point of the first cycle, and the working length of the second modulation signal is spread out from the start point of the second cycle to obtain the endpoint values of the working intervals of the first modulation signal and the second modulation signal, calculated in the following manner: ; ; ; ; in, The value of the first modulation signal at the endpoint of the first period. The value of the first modulation signal at the endpoint of the second period. The value of the second modulation signal at the endpoint of the first period. The value of the second modulation signal at the endpoint of the second period. To simplify the function, for The normalization function, For selection functions; Based on the endpoints of the working intervals of the first modulation signal and the second modulation signal, the working interval of the first modulation signal is [0, ...]. y a1 ]and[ T , y a2 The operating range of the second modulation signal is [0, ...]. y b1 ]and[ T , y b2 ]; The step of filling the second interval with the working length of the third modulation signal in a preset order includes: A first endpoint value is determined between the end of the first cycle and the endpoint value of the first modulation signal in the first cycle; a second endpoint value is determined between the end of the second cycle and the endpoint value of the second modulation signal in the second cycle; a third endpoint value is determined between the endpoint value of the first modulation signal in the first cycle and the endpoint value of the second modulation signal in the first cycle; and a fourth endpoint value is determined between the endpoint value of the first modulation signal in the second cycle and the endpoint value of the second modulation signal in the second cycle. The working length of the third modulation signal is filled from the end of the first period to the first endpoint value to obtain the first remaining working length, and it is determined whether the first remaining working length is greater than 0. If the first remaining working length is greater than 0, the first remaining working length is filled from the end of the second cycle to the second endpoint value to obtain the second remaining working length, and it is determined whether the second remaining working length is greater than 0. If the second remaining working length is greater than 0, the second remaining working length is filled from the first endpoint value to the third endpoint value to obtain the third remaining working length, and it is determined whether the third remaining working length is greater than 0. If the third remaining working length is greater than 0, the third remaining working length is filled from the second endpoint value to the fourth endpoint value to obtain the fourth remaining working length, and it is determined whether the fourth remaining working length is greater than 0. If the fourth remaining working length is greater than 0, the fourth remaining working length is filled from the third endpoint value to the starting point of the first cycle to obtain the fifth remaining working length, and it is determined whether the fifth remaining working length is greater than 0. If the fifth remaining working length is greater than 0, the fifth remaining working length is filled from the fourth endpoint value to the starting point of the second cycle; The first endpoint value, the second endpoint value, the third endpoint value, the fourth endpoint value, the fifth endpoint value, and the sixth endpoint value are calculated in the following manner: ; Where, x n For the nth endpoint value, , , , , The operating length of the third modulation signal within the modulation period.
2. The method based on dual-cycle three-channel PWM signal pulse width modulation according to claim 1, characterized in that, The step of determining whether the preset duty cycle of the first modulation signal and the third modulation signal satisfies the first switching condition further includes: If the first exchange condition is met, the preset duty cycle of the first modulation signal is converted into the actual duty cycle of the third modulation signal, the preset duty cycle of the second modulation signal is converted into the actual duty cycle of the second modulation signal, and the preset duty cycle of the third modulation signal is converted into the actual duty cycle of the first modulation signal.
3. The method based on dual-cycle three-channel PWM signal pulse width modulation according to claim 1, characterized in that, The step of determining whether the preset duty cycle of the second modulation signal and the third modulation signal satisfies the second switching condition further includes: If the second exchange condition is met, the preset duty cycle of the first modulation signal is converted into the actual duty cycle of the first modulation signal, the preset duty cycle of the second modulation signal is converted into the actual duty cycle of the third modulation signal, and the preset duty cycle of the third modulation signal is converted into the actual duty cycle of the second modulation signal.
4. The method based on dual-cycle three-channel PWM signal pulse width modulation according to claim 1, characterized in that, The determination of whether the preset duty cycle of the first modulation signal and the third modulation signal satisfies the first switching condition is calculated in the following manner: ; in, As the first coefficient, The preset duty cycle of the first modulation signal. The preset duty cycle of the second modulation signal. The preset duty cycle of the third modulation signal. A normalization function to simplify the function; When the first coefficient is equal to 0, the preset duty cycle of the first modulation signal and the third modulation signal does not satisfy the first exchange condition; when the first coefficient is not equal to 0, the preset duty cycle of the first modulation signal and the third modulation signal satisfies the first exchange condition.
5. The method based on dual-cycle three-channel PWM signal pulse width modulation according to claim 1, characterized in that, The determination of whether the preset duty cycle of the second modulation signal and the third modulation signal satisfies the second switching condition is calculated in the following manner: ; in, As the second coefficient, The preset duty cycle of the first modulation signal. The preset duty cycle of the second modulation signal. The preset duty cycle of the third modulation signal. A normalization function to simplify the function; When the second coefficient is equal to 0, the preset duty cycle of the second modulation signal and the third modulation signal does not satisfy the second exchange condition; when the second coefficient is not equal to 0, the preset duty cycle of the second modulation signal and the third modulation signal satisfies the second exchange condition.
