Pulse modulation LED dimming system and method based on STM32 single-chip microcomputer

Through the pulse modulation LED dimming system based on the STM32 microcontroller, combined with hybrid modulation and dynamic compensation technology, the shortcomings of existing LED dimming technology in dimming accuracy, stability and control methods are solved, and stepless dimming, multi-mode dimming and remote control are realized, which improves user experience and system stability.

CN120640465APending Publication Date: 2025-09-12JINLING INST OF TECH
View PDF 0 Cites 1 Cited by

Patent Information

Application Number
CN202511000480.6
Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
Filing Date
2025-07-21
Publication Date
2025-09-12

AI Technical Summary

Technical Problem

Existing LED dimming technology has shortcomings in dimming accuracy, stability, dimming mode switching, current compensation, nonlinear characteristic compensation and control methods, making it difficult to meet high-quality lighting needs. In particular, there are problems such as flickering, unstable dimming performance and harmonic distortion in the low brightness and medium and high brightness ranges. In addition, the control method is single and cannot meet remote control needs.

Method used

It adopts a pulse modulation LED dimming system based on the STM32 microcontroller, combining a hybrid modulation strategy of pulse width modulation and pulse density modulation. Through dynamic carrier frequency allocation, real-time current sampling and harmonic distortion rate adjustment, and nonlinear volt-ampere characteristic compensation, it supports 0% to 100% stepless dimming, and realizes local remote control through matrix buttons and Bluetooth modules.

Benefits of technology

It achieves smooth and flicker-free brightness adjustment, supports multiple dimming modes, improves dimming accuracy and stability, has the flexibility of local and remote control, meets the diverse needs of users, and the overall system is stable and reliable.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN120640465A_ABST
    Figure CN120640465A_ABST
Patent Text Reader

Abstract

The invention provides a pulse modulation LED dimming system and method based on an STM32 single-chip microcomputer. The system is mainly composed of an STM32F103C8T6-single-chip microcomputer module, an OLED display module, a signal acquisition module, a matrix key module, a Bluetooth module, an LED lamp module and the like. The system method comprises the following steps: step 1, optimizing a hybrid modulation strategy and carrier allocation, and establishing a dynamic carrier frequency allocation model through a multi-mode hybrid scheme fusing pulse width modulation and pulse density modulation; step 2, collecting an LED load current waveform in real time through a current sampling module, dynamically adjusting a gain coefficient based on a harmonic distortion rate, and counteracting a main harmonic component of a current signal in real time; and step 3, implementing nonlinear compensation of volt-ampere characteristics. The system supports 0%-100% stepless dimming, brightness adjustment is smooth and flicker-free, the system has four dimming modes of normally-on, single-point, circulating and sliding, matrix key local control and Bluetooth remote control are supported, and a flexible and stable LED dimming scheme is provided for a user.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present invention relates to the technical field of LED dimming, and in particular to a pulse modulation LED dimming system and method based on an STM32 single-chip microcomputer. Background Art

[0002] With the continuous development of LED lighting technology, it has been widely used in various fields. As a key technology in LED lighting applications, LED dimming plays a vital role in meeting the lighting needs of different scenarios. In traditional LED dimming technologies, common methods mainly include analog dimming and digital dimming. Analog dimming usually achieves brightness adjustment by changing the magnitude of the LED drive current. Although this method is simple and direct, it has some obvious disadvantages. For example, analog dimming is easily affected by environmental factors such as temperature, ambient brightness, and power supply fluctuations, resulting in reduced dimming accuracy. In addition, in low brightness conditions, analog dimming may cause LED lights to flicker, which not only affects the visual effect but also may cause damage to the human eye with long-term use.

[0003] Relatively speaking, digital dimming technology has seen significant performance improvements, with pulse-width modulation (PWM) being a commonly used digital dimming method. PWM adjusts the average LED current by controlling the duty cycle of the pulse signal, thereby adjusting the brightness of the light source. It offers advantages such as high dimming accuracy, low current heat dissipation, and convenient control. However, PWM dimming still has certain drawbacks. For example, at low brightness levels, PWM dimming generates low-frequency ripple, which can cause LED lights to flicker. Furthermore, the frequency modulation efficiency of PWM dimming is relatively low in the medium and high brightness ranges, which can also hinder the full utilization of LED performance advantages.

[0004] Pulse density modulation (PDM), another digital dimming method, can control brightness in the low-brightness range by adjusting the number of pulses per unit time, which to a certain extent suppresses low-frequency ripple. However, PDM's dimming effect in the medium and high-brightness range is not ideal, and when switching between different dimming modes, critical point oscillation is prone to occur, resulting in unstable dimming performance. At the same time, existing LED dimming technology also has shortcomings in current compensation and nonlinear characteristic compensation. This is because the LED's volt-ampere characteristic is nonlinear. During the dimming process, its impedance characteristics will cause deviations in the dimming curve, thereby affecting the accuracy and consistency of dimming. In addition, in actual applications, the LED load current will produce harmonic distortion due to interference from various factors, but existing technologies are often unable to effectively offset these harmonic components in real time, which will also affect the luminous quality and life of the LED.

[0005] In addition, the current traditional LED dimming system has a relatively simple control method. Most of them can only be controlled by local buttons and cannot meet the user's remote control needs. Even if some systems support remote control, their operational flexibility and stability need to be improved.

[0006] In summary, the existing LED dimming technology has many shortcomings in dimming accuracy, stability, dimming mode switching, current compensation, nonlinear characteristic compensation and control methods, making it difficult to meet the growing demand for high-quality lighting. To this end, the applicant proposed a pulse modulation LED dimming system and method based on the STM32 microcontroller based on the LED dimming needs, which can provide users with a flexible and stable LED dimming solution. Summary of the Invention

[0007] To solve the above technical problems, the present invention proposes a pulse modulation LED dimming system and method based on an STM32 single-chip microcomputer. The system includes an STM32F103C8T6 single-chip microcomputer module, an OLED display module, a matrix button module, a Bluetooth module, etc., and an LED lamp module. The single-chip microcomputer module can receive signals through a serial port connection and change the duty cycle of the PWM signal according to code calculation to control the high and low levels of the I / O port, thereby controlling the state of the LED lamp by changing its brightness to achieve four functions: constant output, cyclic output, single-point output, and sliding output. The system supports 0%-100% stepless dimming, and the brightness adjustment is smooth and flicker-free. It has four dimming modes: constant light, single-point, cyclic, and sliding. It also supports local control of the matrix button and remote control of Bluetooth, which can achieve flexible and stable adjustment of the LED lamp.

[0008] To achieve the above object, the technical solution adopted by the present invention is:

[0009] The invention relates to an LED dimming system and method based on pulse width modulation technology of an STM32 single-chip microcomputer, characterized in that: the pulse modulation LED dimming system based on the STM32 single-chip microcomputer includes an STM32F103C8T6 single-chip microcomputer module, an OLED display module, a matrix button module, a Bluetooth module and an LED lamp module; the STM32F103C8T6 single-chip microcomputer module is connected to the OLED display module, the matrix button module, the Bluetooth module and the LED lamp module, and the STM32F103C8T6 single-chip microcomputer module is used to control the normal operation and function realization of the dimming system; after receiving the signal sent by the STM32F103C8T6 single-chip microcomputer, the OLED display module converts the data into pixel points through an internal display algorithm and a drive circuit, and displays them on a screen. The matrix button module is connected to the STM32F103C8T6 single-chip microcomputer module, and is used to provide more operation options and functions by sending a button pressing signal to the STM32F103C8T6 single-chip microcomputer module; the Bluetooth module is connected to the STM32F103C8T6 single-chip microcomputer module and the mobile phone APP module, and the Bluetooth module can send the mobile phone APP module data received by Bluetooth from the serial port to the STM32F103C8T6 single-chip microcomputer module, thereby achieving the purpose of remote control; the LED light module is connected to the STM32F103C8T6 single-chip microcomputer module, and the LED light is controlled by the STM32F103C8T6 single-chip microcomputer module by controlling the high and low levels of the I / O port.

[0010] Furthermore, the pulse modulation LED dimming system based on the STM32 single-chip microcomputer is provided with an OLED display module, which adopts a 0.96-inch OLED display screen. The GND of the hardware circuit of the OLED display module is grounded, VCC is connected to a 3.3V power supply, and the SCL / I2C clock pin and the SDA / I2C data pin are respectively connected to the PA0 and PA1 pins of the single-chip microcomputer.

[0011] Furthermore, the pulse modulation LED dimming system based on the STM32 microcontroller is provided with a matrix key module. The matrix key module adopts a 4×4 size HW-834 matrix key, each pin of which uses GPIO mode, and uses 4 GPIO inputs to detect high and low levels. The 4 GPIOs output high and low levels in sequence for detecting the key status.

[0012] Furthermore, the pulse modulation LED dimming system based on the STM32 single-chip microcomputer is provided with a Bluetooth module. The Bluetooth module adopts the HC-06 Bluetooth module. The HC-06 Bluetooth module contains a serial port Bluetooth chip and a series of circuits including a radio frequency circuit, a baseband processor and a protocol stack layer. It is connected to the STM32 controller through a UART interface, allowing the user to configure the module through the serial port interface to achieve wireless communication.

[0013] The specific steps of the pulse modulation LED dimming method based on the STM32 microcontroller are as follows:

[0014] Step 1: Optimize hybrid modulation strategy and carrier allocation, and establish a dynamic carrier frequency allocation model by integrating a multi-modal hybrid scheme of pulse width modulation and pulse density modulation;

[0015] Step 2: The current sampling module collects the LED load current waveform in real time, and dynamically adjusts the gain coefficient based on the harmonic distortion rate to offset the main harmonic components of the current signal in real time;

[0016] Step 3: Implement nonlinear compensation of volt-ampere characteristics.

[0017] Furthermore, the implementation method of the pulse modulation LED dimming system based on the STM32 single chip microcomputer, the specific process of step one is:

[0018] 1) Hybrid modulation mode division and switching logic;

[0019] The mathematical boundary conditions of the multimodal modulation strategy are defined based on the brightness control signal L∈[0%,100%]. When the low brightness range L < 10%, the pulse density modulation dominant mode is adopted. Pulse density modulation is abbreviated as PDM in the following text. The brightness is controlled by adjusting the number of pulses per unit time to suppress low-frequency ripples. When the medium and high brightness range L>10%, the pulse width modulation dominant mode is enabled. Pulse width modulation is abbreviated as PWM in the following text. The frequency modulation efficiency is improved by adjusting the pulse duty cycle. The brightness switching threshold is set. When the pulse width modulation switches to the pulse density modulation, L up =11%, when switching from pulse density modulation to pulse width modulation, L down =9%, avoiding critical point oscillation;

[0020] 2) Modulation parameter mathematical model;

[0021] The modulation parameter mathematical model includes the PDM mode mathematical model and the PWM mode mathematical model;

[0022] PDM mode mathematical model:

[0023] In the low brightness range, the pulse density D pdm The relationship with brightness L is:

[0024]

[0025] in: The base frequency is 500Hz;

[0026] The maximum modulation frequency of PDM is 2kHz;

[0027] PWM mode mathematical model:

[0028] In the medium and high brightness range, the relationship between the duty cycle Dpwm and the brightness L is:

[0029]

[0030] Where: Dmin = 0.5% is the minimum duty cycle threshold to avoid MOSFET switching losses, and Dmax = 98% is the maximum duty cycle threshold to prevent dead time conflicts;

[0031] γ=1.05 is the gamma correction factor to compensate for the nonlinear brightness perception of the human eye.

[0032] Furthermore, the specific process of step 2 of the implementation method of the pulse modulation LED dimming system based on the STM32 single chip microcomputer is as follows:

[0033] 1) Dynamic adjustment of active filter parameter algorithm architecture;

[0034] The algorithms for dynamically adjusting active filter parameters include: current sampling, real-time harmonic detection algorithm, adaptive repetitive control algorithm, and digital filter dynamic tuning algorithm. Current sampling uses a current sensor to collect the LED load current waveform in real time. The real-time harmonic detection algorithm uses the LED current signal as input to calculate the current harmonic component set and real-time THD value. The adaptive repetitive control algorithm uses the current harmonic component set and real-time THD value as input to calculate the current compensation signal. The digital filter dynamic tuning algorithm uses the current signal and current compensation signal as input to calculate the compensated current signal.

[0035] 2) Accurately extract the 3rd / 5th / 7th harmonic components of current and calculate THD; specifically, real-time harmonic detection algorithm and harmonic positioning and interpolation correction; specifically:

[0036] ① Real-time harmonic detection algorithm:

[0037] Every 5ms, the current window data is intercepted through the sliding window:

[0038]

[0039] Where: M=100, overlap rate 80%;

[0040] is the current data set in the kth sliding window;

[0041] k is the window index;

[0042] is the discretized current sampling sequence;

[0043] n is the sampling point index;

[0044] N is the window length;

[0045] Then use the Blackman-Harris window to suppress spectrum leakage:

[0046] in: is the Blackman-Harris window function coefficient;

[0047] n is the position index within the window;

[0048] is the current sequence after windowing;

[0049] k is the window index;

[0050] n is the sampling point index within the window;

[0051] Compute the spectral components:

[0052]

[0053] in: is the FFT spectrum component;

[0054] m is the frequency index;

[0055] ② Harmonic positioning and interpolation correction:

[0056] The double spectrum interpolation method is used to improve the accuracy of the 3rd / 5th / 7th harmonics:

[0057]

[0058] in: is the frequency deviation correction;

[0059] is the hth harmonic amplitude;

[0060] Then extract the amplitudes of the 3rd, 5th, and 7th harmonics and calculate the total harmonic distortion THD:

[0061]

[0062] 3) Calculate compensation signal;

[0063] Adopting gain adaptive mechanism to dynamically adjust controller gain :

[0064]

[0065] Among them: Constraints: ;

[0066] is the controller gain;

[0067] ΔTHD=THD-5%, which is the absolute error of THD;

[0068] Generate compensation signal:

[0069]

[0070] in: is the fundamental frequency;

[0071] is the sampling period;

[0072] is the compensation signal of the nth sampling point;

[0073] is the hth harmonic phase angle extracted by FFT phase spectrum;

[0074] 4) Compensate for the current signal in the actual circuit;

[0075] Compensated current signal It can be expressed as:

[0076] .

[0077] Furthermore, the specific process of step three of the implementation method of the pulse modulation LED dimming system based on the STM32 single-chip microcomputer is to embed the PI algorithm in the constant current control loop to establish a voltage-current dual-variable compensation model; by pre-storing the volt-ampere characteristic curve of the LED device, the operating point offset is identified in real time, and the proportional coefficient and integral time of the PI controller are dynamically adjusted to compensate for the dimming curve deviation caused by the nonlinear impedance characteristics of the LED; it is divided into volt-ampere characteristic parameter modeling, dynamic PI controller parameter adjustment and dual-variable compensation control algorithm implementation;

[0078] 1) Parametric modeling of volt-ampere characteristics. Parametric modeling of volt-ampere characteristics includes establishing a Vf-If parameter table and calculating the real-time operating point offset. Specifically:

[0079] Establish Vf-If parameter table;

[0080] During the system initialization phase, a discrete volt-ampere characteristic parameter table is constructed based on the volt-ampere characteristic curve of the LED lamp, and continuous mapping is achieved through cubic spline interpolation.

[0081] Real-time working point offset calculation;

[0082] During the constant current control period, the compensated load current is obtained through step 2. , check the volt-ampere characteristic parameter table to get the theoretical forward voltage drop , calculate the real-time pressure drop deviation:

[0083]

[0084] in: is the pressure drop deviation;

[0085] is the actual measured value of voltage;

[0086] 2) Dynamic PI controller parameter adjustment; Dynamic PI controller parameter adjustment includes proportional coefficient adaptive rules and integral time dynamic adjustment strategy; specifically:

[0087] Adaptive rule of proportional coefficient;

[0088] Dynamically adjust the proportional coefficient according to the voltage deviation amplitude to achieve a balance between fast response and stability:

[0089]

[0090] in: is the proportionality coefficient;

[0091] Dynamic adjustment strategy of integration time;

[0092] An exponential decay function is used to adjust the integration time to avoid overshoot and accelerate steady-state convergence:

[0093]

[0094] in: is the integration time;

[0095] 3) Implementation of dual-variable compensation control algorithm; the implementation of dual-variable compensation control algorithm includes PI controller discretization design and current closed-loop compensation injection; specifically:

[0096] Discrete design of PI controller;

[0097] In the STM32, the backward difference method is used for discretization and the compensation current output is:

[0098]

[0099] in: Output compensation current for PWM;

[0100] To control the cycle;

[0101] Current closed-loop compensation injection;

[0102] Add the compensation current to the PWM / PDM modulation signal to correct the drive current output:

[0103]

[0104] in: is the corrected current drive output;

[0105] is the current signal after compensation in step 2.

[0106] Furthermore, the pulse modulation LED dimming system and method based on the STM32 microcontroller supports 0%-100% stepless dimming, smooth brightness adjustment without flicker, and has four dimming modes: constant light, single point, sliding, and cycle, and supports matrix button local control and Bluetooth remote control.

[0107] The benefits of this application are:

[0108] 1. The pulse modulation LED dimming system and method based on the STM32 microcontroller adopts hybrid modulation and dynamic compensation technology. Through hybrid modulation and dynamic compensation, it supports stepless dimming from 0% to 100%, and the brightness adjustment is smooth and flicker-free, achieving stepless dimming and improving user experience.

[0109] 2. The pulse modulation LED dimming system and method based on the STM32 microcontroller adopts a digital dimming method of hybrid modulation and dynamic compensation, which is based on adjusting the pulse of the control signal to achieve precise control of the output device;

[0110] 3. The pulse modulation LED dimming system and method based on the STM32 microcontroller supports four dimming modes: constant output mode, cycle output mode, single-point output mode and sliding output mode, fully considering the various needs of users;

[0111] 4. The pulse modulation LED dimming system and method based on the STM32 microcontroller sets four dimming modes. At different brightness levels, there will be no obvious flickering phenomenon. After the dimming system is connected to the Bluetooth device, the overall system is stable and reliable.

[0112] 5. The pulse modulation LED dimming system and method based on the STM32 microcontroller supports local control through matrix buttons, and also supports remote control through the Bluetooth module. Users can perform remote dimming operations through the mobile phone APP, which makes the control method more flexible and convenient. BRIEF DESCRIPTION OF THE DRAWINGS

[0113] Figure 1 It is a schematic diagram of the process of the present invention;

[0114] Figure 2 This is a schematic diagram of the main program flow of the STM32F103C8T6 single-chip microcomputer module of the present invention;

[0115] Figure 3 This is a flow chart of the LED dimming hybrid modulation and dynamic compensation algorithm of the present invention;

[0116] Figure 4 A schematic diagram of setting codes for the matrix key module of the present invention;

[0117] Figure 5 Graphs showing dimming performance of the four dimming modes of the present invention. DETAILED DESCRIPTION

[0118] The present invention is further described in detail below with reference to the accompanying drawings and specific embodiments:

[0119] like Figure 1As shown, a pulse modulation LED dimming system and method based on STM32 single-chip microcomputer is shown. The pulse modulation LED dimming system based on STM32 single-chip microcomputer includes STM32F103C8T6 single-chip microcomputer module, OLED display module, matrix button module, Bluetooth module, and LED lamp module; the STM32F103C8T6 single-chip microcomputer module is connected to the OLED display module, matrix button module, Bluetooth module and LED lamp module, and the STM32F103C8T6 single-chip microcomputer module is used to control the normal operation and function realization of the dimming system; the OLED display module converts the signal sent by the STM32F103C8T6 single-chip microcomputer into pixel points through the internal display algorithm and drive circuit, and displays the pixel points on the screen. Displayed above; the matrix button module shown is connected to the STM32F103C8T6 single-chip microcomputer module shown, and is used to provide more operation options and functions by sending a button press signal to the STM32F103C8T6 single-chip microcomputer module shown; the Bluetooth module shown is connected to the STM32F103C8T6 single-chip microcomputer module shown and the mobile phone APP module shown, and the Bluetooth module shown can send the mobile phone APP module data received by Bluetooth from the serial port to the STM32F103C8T6 single-chip microcomputer module, thereby achieving the purpose of remote control; the LED light module shown is connected to the STM32F103C8T6 single-chip microcomputer module shown, and the LED light module shown is controlled by the STM32F103C8T6 single-chip microcomputer module shown by controlling the high and low levels of the I / O port.

[0120] The STM32 microcontroller module in the pulse modulation LED dimming system and method based on the STM32 microcontroller shown usually uses a DC power supply with an operating voltage range of 2.0V to 3.6V. In this system, a power supply circuit is built that uses a TP2019-3.3LDO step-down chip to reduce the voltage to a 3.3V lithium battery for self-powering. Pins 1 and 3 of the TP2019-3.3 LDO step-down chip are connected to the input power supply. A 22μF capacitor is connected in series with the input power supply and then grounded to pin 2. These capacitors can absorb voltage fluctuations that may occur during the operation of the microcontroller and maintain power supply stability. Pin 5 outputs a 3.3V voltage. The power supply is located in the corner between the inside and the outside, which is conducive to reducing power loss, extending the overall working life while reducing the required space and facilitating portability.

[0121] The filter circuit set in the pulse modulation LED dimming system and method based on the STM32 single-chip microcomputer shown in the figure works with appropriate resistors to eliminate external noise and electromagnetic interference when the signal acquisition module, the matrix key module keys and the serial port of the Bluetooth module send signals, filter out noise, interference and unnecessary frequency components, ensure the normal operation and stable performance of the system, and ensure that a clean DC signal can be transmitted to the circuit board; the filter circuit in this system is composed of four 100nF capacitors in parallel, one end of which is connected to the power output and the other end is grounded.

[0122] The clock circuit set in the pulse modulation LED dimming system and method based on the STM32 single-chip microcomputer drives the processor, peripherals, and other functional modules in the system, so that they work according to the predetermined frequency and time sequence. In this system, an 8MHz external crystal oscillator is selected as the clock source. Pins 2 and 4 of the clock source are grounded, and pins 1 and 3 are respectively connected in series with a 20pF capacitor and then grounded. The main clock signal required by the system is generated after PLL frequency multiplication, ensuring the efficient and stable operation of the entire system.

[0123] The power-on reset circuit of the pulse modulation LED dimming system and method based on the STM32 microcontroller shown in the figure consists of components such as capacitors, resistors, and a reset chip. The capacitors are responsible for delay and voltage regulation, while the resistors play a current limiting role. The reset chip monitors the power status of the system and generates a reset signal after the power supply voltage stabilizes to ensure that the system starts normally from the reset state. In this system, a 4.7k resistor and a 100nF resistor are used to form the power-on reset circuit, and its NRST pin is connected to the NRST pin of the microcontroller.

[0124] The download circuit of the pulse modulation LED dimming system and method based on the STM32 single-chip microcomputer is used to write the compiled program into the single-chip microcomputer module to achieve the target function. It consists of a USB-to-serial port module and a serial port download cable. Program download is performed in JTAG or SWD mode. The system reads the program code from the preset startup address 0x08000000 and executes it directly after the system is restarted. The USB-to-serial port module is used to convert the USB interface on the computer into a serial port signal. The serial port download cable connects the USB-to-serial port module and the download pin of the STM32 development board.

[0125] The pulse modulation LED dimming system and method based on the STM32 microcontroller is provided with an OLED display module. The OLED display module uses a 0.96-inch OLED display screen. The GND of the hardware circuit of the OLED display module is grounded, the VCC is connected to a 3.3V power supply, and the SCL / I2C clock pin and the SDA / I2C data pin are respectively connected to the PA0 and PA1 pins of the microcontroller.

[0126] The pulse modulation LED dimming system and method based on the STM32 microcontroller shown is provided with a matrix key module. The matrix key module shown adopts a 4×4 size HW-834 matrix key. Each pin thereof uses GPIO mode, and four GPIO inputs are used to detect high and low levels. The four GPIOs output high and low levels in sequence for detecting the key status.

[0127] The pulse modulation LED dimming system and method based on the STM32 microcontroller is equipped with a Bluetooth module. The Bluetooth module is an HC-06 Bluetooth module. The HC-06 Bluetooth module has four pins: power supply VCC, ground GND, transmitter TXD, and receiver RXD. TXD is connected to the STM32's PA2 pin, and RXD to the PA3 pin. By connecting to the STM32 controller, the user can configure the module through the serial port to achieve wireless communication.

[0128] The STM32F103C8T6 microcontroller module shown can receive signals through the serial port connection and calculate the high and low levels of the control I / O port according to the code to adjust the average current during the power-on time of the LED to change the output current, thereby changing its brightness, to achieve four functions: constant light output, single-point output, cycle output and sliding output, to meet the needs of controlling the status of the LED light.

[0129] like Figure 2 As shown, the main program flow chart of the STM32F103C8T6 single-chip microcomputer module is shown. After power is turned on, the dimming system shown is initialized first, and then the STM32 single-chip microcomputer detects the GPIO signal. If there is no key signal, it continues to detect. If there is a key signal, the LED light is lit according to the key setting; after the Bluetooth module is powered on, it is connected to the mobile phone APP. At this time, the STM32 single-chip microcomputer detects the serial port signal. If there is no serial port signal, it continues to detect. If there is a serial port signal, the LED light is lit according to the mobile phone APP setting.

[0130] like Figure 3 As shown, the specific steps of the implementation method of the pulse modulation LED dimming system based on the STM32 microcontroller are as follows:

[0131] Step 1: Optimize hybrid modulation strategy and carrier allocation. By integrating a multi-modal hybrid scheme of pulse width modulation and pulse density modulation, a dynamic carrier frequency allocation model is established. Specifically:

[0132] 1) Hybrid modulation mode division and switching logic;

[0133] The mathematical boundary conditions of the multimodal modulation strategy are defined based on the brightness control signal L∈[0%,100%]. When the low brightness range L<10%, the pulse density modulation dominant mode is adopted to control the brightness by adjusting the number of pulses per unit time and suppress low-frequency ripples. When the medium and high brightness range L>10%, the pulse width modulation dominant mode is enabled to improve the frequency modulation efficiency by adjusting the pulse duty cycle. The brightness switching threshold is set. When the pulse width modulation switches to the pulse density modulation, L up =11%, when switching from pulse density modulation to pulse width modulation, L down =9%, avoiding critical point oscillation;

[0134] 2) Modulation parameter mathematical model;

[0135] The modulation parameter mathematical model includes the PDM mode mathematical model and the PWM mode mathematical model;

[0136] PDM mode mathematical model:

[0137] In the low brightness range, the pulse density D pdm The relationship with brightness L is:

[0138]

[0139] in: The base frequency is 500Hz;

[0140] The maximum modulation frequency of PDM is 2kHz;

[0141] PWM mode mathematical model:

[0142] In the medium and high brightness range, the relationship between the duty cycle Dpwm and the brightness L is:

[0143]

[0144] Where: Dmin = 0.5% is the minimum duty cycle threshold to avoid MOSFET switching losses, and Dmax = 98% is the maximum duty cycle threshold to prevent dead time conflicts;

[0145] γ=1.05 is the gamma correction factor to compensate for the nonlinear brightness perception of the human eye;

[0146] Step 2: Use the current sampling module to collect the LED load current waveform in real time, dynamically adjust the gain coefficient based on the harmonic distortion rate, and offset the main harmonic components of the current signal in real time; specifically:

[0147] 1) Dynamic adjustment of active filter parameter algorithm architecture;

[0148] The algorithms for dynamically adjusting active filter parameters include: current sampling, real-time harmonic detection algorithm, adaptive repetitive control algorithm, and digital filter dynamic tuning algorithm. Current sampling uses a current sensor to collect the LED load current waveform in real time. The real-time harmonic detection algorithm uses the LED current signal as input to calculate the current harmonic component set and real-time THD value. The adaptive repetitive control algorithm uses the current harmonic component set and real-time THD value as input to calculate the current compensation signal. The digital filter dynamic tuning algorithm uses the current signal and current compensation signal as input to calculate the compensated current signal.

[0149] 2) Accurately extract the 3rd / 5th / 7th harmonic components of current and calculate THD; specifically, real-time harmonic detection algorithm and harmonic positioning and interpolation correction; specifically:

[0150] ① Real-time harmonic detection algorithm:

[0151] Every 5ms, the current window data is intercepted through the sliding window:

[0152]

[0153] Where: M=100, overlap rate 80%;

[0154] is the current data set in the kth sliding window;

[0155] k is the window index;

[0156] is the discretized current sampling sequence;

[0157] n is the sampling point index;

[0158] N is the window length;

[0159] Then use the Blackman-Harris window to suppress spectrum leakage:

[0160] in: is the Blackman-Harris window function coefficient;

[0161] n is the position index within the window;

[0162] is the current sequence after windowing;

[0163] k is the window index;

[0164] n is the sampling point index within the window;

[0165] Compute the spectral components:

[0166]

[0167] in: is the FFT spectrum component;

[0168] m is the frequency index;

[0169] ② Harmonic positioning and interpolation correction:

[0170] The double spectrum interpolation method is used to improve the accuracy of the 3rd / 5th / 7th harmonics:

[0171]

[0172] in: is the frequency deviation correction;

[0173] is the hth harmonic amplitude;

[0174] Then extract the amplitudes of the 3rd, 5th, and 7th harmonics and calculate the total harmonic distortion THD:

[0175]

[0176] 3) Calculate compensation signal;

[0177] Adopting gain adaptive mechanism to dynamically adjust controller gain :

[0178]

[0179] Among them: Constraints: ;

[0180] is the controller gain;

[0181] ΔTHD=THD-5%, which is the absolute error of THD;

[0182] Generate compensation signal:

[0183]

[0184] in: is the fundamental frequency;

[0185] is the sampling period;

[0186] is the compensation signal of the nth sampling point;

[0187] is the hth harmonic phase angle extracted by FFT phase spectrum;

[0188] 3) Compensate for the current signal in the actual circuit;

[0189] Compensated current signal It can be expressed as:

[0190] ;

[0191] Step 3: Implement nonlinear compensation of volt-ampere characteristics, specifically:

[0192] The PI algorithm is embedded in the constant current control loop to establish a voltage-current dual-variable compensation model. By pre-storing the volt-ampere characteristic curve of the LED device, the operating point offset is identified in real time, and the proportional coefficient and integral time of the PI controller are dynamically adjusted to compensate for the dimming curve deviation caused by the nonlinear impedance characteristics of the LED. This is achieved through parameterized modeling of the volt-ampere characteristic, dynamic PI controller parameter adjustment, and a dual-variable compensation control algorithm.

[0193] 1) Parametric modeling of volt-ampere characteristics. Parametric modeling of volt-ampere characteristics includes establishing a Vf-If parameter table and calculating the real-time operating point offset. Specifically:

[0194] Establish Vf-If parameter table;

[0195] During the system initialization phase, a discrete volt-ampere characteristic parameter table is constructed based on the volt-ampere characteristic curve of the LED lamp, and continuous mapping is achieved through cubic spline interpolation.

[0196] Real-time working point offset calculation;

[0197] During the constant current control period, the compensated load current is obtained through step 2. , check the volt-ampere characteristic parameter table to get the theoretical forward voltage drop , calculate the real-time pressure drop deviation:

[0198]

[0199] in: is the pressure drop deviation;

[0200] is the actual measured value of voltage;

[0201] 2) Dynamic PI controller parameter adjustment; Dynamic PI controller parameter adjustment includes proportional coefficient adaptive rules and integral time dynamic adjustment strategy; specifically:

[0202] Adaptive rule of proportional coefficient;

[0203] Dynamically adjust the proportional coefficient according to the voltage deviation amplitude to achieve a balance between fast response and stability:

[0204]

[0205] in: is the proportionality coefficient;

[0206] Dynamic adjustment strategy of integration time;

[0207] An exponential decay function is used to adjust the integration time to avoid overshoot and accelerate steady-state convergence:

[0208]

[0209] in: is the integration time;

[0210] 3) Implementation of dual-variable compensation control algorithm; the implementation of dual-variable compensation control algorithm includes PI controller discretization design and current closed-loop compensation injection; specifically:

[0211] Discrete design of PI controller;

[0212] In the STM32, the backward difference method is used for discretization and the compensation current output is:

[0213]

[0214] in: Output compensation current for PWM;

[0215] To control the cycle;

[0216] Current closed-loop compensation injection;

[0217] Add the compensation current to the PWM / PDM modulation signal to correct the drive current output:

[0218]

[0219] in: is the corrected current drive output;

[0220] is the current signal after compensation in step 2.

[0221] The matrix key module in the pulse modulation LED dimming system and method based on the STM32 single chip microcomputer is arranged in a matrix manner. Each key forms a closed circuit at the intersection of rows and columns. When the key is pressed, the relevant row and column signals will change, and the system identifies the key status by detecting the change in the signal. Figure 4 As shown, the system declares a variable GPIO_InitStruct of type GPIO_InitTypeDef for the matrix button module code shown; for each GPIO pin X1, X2, X3, and X4, perform the following steps:

[0222] First, assign the corresponding GPIO pin number to GPIO_InitStruct.Pin; the X1_GPIO_PIN, X2_GPIO_PIN, X3_GPIO_PIN, and X4_GPIO_PIN mentioned here represent different GPIO pin numbers. These macro definitions need to be defined in advance to indicate the specific pin numbers;

[0223] Secondly, set the GPIO pin mode to output push-pull mode GPIO_MODE_OUTPUT_PP; this means that the pin is configured in output mode, directly connected to ground when outputting a low level, and connected to VCC through a pull-up resistor when outputting a high level;

[0224] Finally, set the GPIO speed to high GPIO_SPEED_FREQ_HIGH; this means that the GPIO switching frequency is set to high, and call the HAL_GPIO_Init() function, passing in the corresponding GPIO ports X1_GPIO_PORT, X2_GPIO_PORT, X3_GPIO_PORT, X4_GPIO_PORT and the configuration structure pointer &GPIO_InitStruct as parameters; this function is responsible for initializing the corresponding GPIO pins according to the provided configuration.

[0225] The pulse modulation LED dimming system and method based on the STM32 microcontroller is controlled by a matrix key module or a Bluetooth module to achieve four dimming modes: constant light mode, single-point output mode, sliding mode, and cyclic mode. In constant light mode, the LED maintains a constant brightness; in single-point output mode, the LED brightness can be precisely adjusted in multiple levels; in sliding mode, the LED brightness can be adjusted arbitrarily with smooth transitions; and in cyclic mode, the LED brightness changes periodically, simulating a breathing light effect. The specific function debugging method and performance test results are as follows: In the key control mode, when the S1 button is pressed on the matrix button, the system will drive the LED with a duty cycle of 100%. At this time, the brightness value of the light is a rated value. At the same time, the word "ON" will be displayed on the OLED display; when the S2 button is pressed, the system drives the LED light at 0% brightness, the LED is off, and the system enters the normally closed mode. At this time, the word "OFF" will be displayed on the OLED display; in the Bluetooth control mode, after the dimming system completes the Bluetooth connection with the mobile phone, click the "Always on Output" option on the main interface of the mobile phone APP to enter the always on mode interface; at this time, click the "ON" option on the mobile phone screen, the LED light will turn on at 100% brightness, and click the "OFF" option, the LED light will go out immediately. At this time, the output signal collected by the oscilloscope is as follows Figure 5 As shown in a.

[0226] In the pulse modulation LED dimming system and method based on the STM32 microcontroller, the single-point output mode allows for six levels of LED brightness adjustment. The first level has a 0% duty cycle, and the duty cycle increases by 20% with each level until the sixth level, at which point the duty cycle reaches 100%. In matrix key control mode, pressing any of the S9-S14 buttons changes the duty cycle to adjust the LED light output to different brightness levels. In Bluetooth control mode, tapping the "Single-Point Output" option on the mobile app enters single-point output mode. In this output mode, the app interface displays six levels: 0%, 20%, 40%, 60%, 80%, and 100%. Tap a different level to adjust the LED light output to the corresponding brightness.

[0227] In the pulse modulation LED dimming system and method based on the STM32 single-chip microcomputer shown in the figure, the sliding mode can continuously adjust the brightness of the LED lamp in the brightness range of 0 to 255. In the matrix button control mode, the user only needs to press and hold S15, and the brightness value of the LED lamp will continue to increase; relatively, continuously pressing the S16 key will gradually reduce the brightness value of the LED lamp; in the Bluetooth control mode, click the "sliding mode" option on the main interface of the mobile phone APP to enter the sliding output mode interface. By dragging the slider on the interface, the brightness value of the LED lamp can be adjusted at will. For example, when the sliding value is 100, the corresponding duty cycle is 39.22%. At this time, the output signal measured by the oscilloscope is as follows Figure 5 As shown in Figure b, the actual test results are basically consistent with the set values, proving that this operation mode can successfully achieve continuous dimming of the LED light source.

[0228] The pulse-modulated LED dimming system and method based on the STM32 microcontroller shown in this paper offers ten adjustment levels in cyclic output mode. Once a specific brightness level is determined, the signal's duty cycle can be adjusted to intermittently cycle the LED light source on and off according to a set pattern. Specifically, the first brightness level is 10%, and each subsequent level increases by 10% until the highest level, the tenth level, reaches 100%. Figure 5In c, A~J are the output signal waveforms corresponding to the system from gear 1 to gear 10, which are collected by the oscilloscope. As can be seen from the figure, the duty cycle corresponding to each gear is different, and as it changes from low gear to high gear, the duty cycle gradually increases until it reaches the maximum value, which fully demonstrates that the system has achieved 10-level dimming performance. In the matrix button control mode, press S6 to enter the cycle mode. At this time, the four parameters of LED lighting time ON_S, LED off time OFF_S, number of cycles num and LED luminous brightness value Duty can be set arbitrarily. Every time the LED light completes a switching cycle, it will be counted once. In Bluetooth control mode, click the "Loop Output" option on the main interface of the mobile phone APP to enter the cycle mode interface. In the cycle mode, you can arbitrarily set the LED light's lighting time, off time, number of cycles and brightness value; after the setting is completed, click the "Start Cycle" option. At this time, the LED light will perform intermittent switching cycles according to the set parameters; Figure 5 The inset in Figure c shows the output signal captured by an oscilloscope when the system is performing cyclic output at a fixed brightness. As can be seen, in cyclic mode, the signal changes periodically, and the duty cycle of each cycle remains essentially unchanged, resulting in a stable signal output.

[0229] The above description is merely a preferred embodiment of the present invention and does not constitute any other form of limitation to the present invention. Any modification or equivalent variation based on the technical essence of the present invention shall still fall within the scope of protection claimed by the present invention.

Claims

1. Pulse modulation LED dimming system based on STM32 microcontroller, characterized by: The pulse modulation LED dimming system based on the STM32 single-chip microcomputer includes an STM32F103C8T6 single-chip microcomputer module, an OLED display module, a matrix button module, a Bluetooth module and an LED lamp module; the STM32F103C8T6 single-chip microcomputer module is connected to the OLED display module, the matrix button module, the Bluetooth module and the LED lamp module, and the STM32F103C8T6 single-chip microcomputer module is used to control the normal operation and function realization of the dimming system; after receiving the signal sent by the STM32F103C8T6 single-chip microcomputer, the OLED display module converts the data into pixel points through an internal display algorithm and a driving circuit, and displays them on the screen. The matrix button module is connected to the STM32F103C8T6 single-chip microcomputer module, and is used to provide more operation options and functions by sending a button pressing signal to the STM32F103C8T6 single-chip microcomputer module; the Bluetooth module is connected to the STM32F103C8T6 single-chip microcomputer module and the mobile phone APP module, and the Bluetooth module can send the mobile phone APP module data received by Bluetooth from the serial port to the STM32F103C8T6 single-chip microcomputer module, thereby achieving the purpose of remote control; the LED light module is connected to the STM32F103C8T6 single-chip microcomputer module, and the LED light is controlled by the STM32F103C8T6 single-chip microcomputer module by controlling the high and low levels of the I / O port.

2. The pulse modulation LED dimming system based on the STM32 single chip microcomputer according to claim 1, characterized in that: The pulse modulation LED dimming system based on the STM32 single-chip microcomputer is provided with an OLED display module. The OLED display module adopts a 0.96-inch OLED display screen. The GND of the hardware circuit of the OLED display module is grounded, the VCC is connected to a 3.3V power supply, and the SCL / I2C clock pin and the SDA / I2C data pin are respectively connected to the PA0 and PA1 pins of the single-chip microcomputer.

3. The pulse modulation LED dimming system based on the STM32 single chip microcomputer according to claim 1, characterized in that: The pulse modulation LED dimming system based on the STM32 single-chip microcomputer is provided with a matrix key module. The matrix key module adopts a 4×4 size HW-834 matrix key. Each pin thereof uses the GPIO mode, and four GPIO inputs are used to detect high and low levels. The four GPIOs output high and low levels in sequence for detecting the key status.

4. The pulse modulation LED dimming system based on the STM32 single chip microcomputer according to claim 1, characterized in that: The pulse modulation LED dimming system based on the STM32 single-chip microcomputer is provided with a Bluetooth module. The Bluetooth module adopts the HC-06 Bluetooth module. The HC-06 Bluetooth module contains a serial port Bluetooth chip and a series of circuits including a radio frequency circuit, a baseband processor and a protocol stack layer. It is connected to the STM32 controller through a UART interface, allowing users to configure the module through the serial port interface to achieve wireless communication.

5. The method for implementing a pulse modulation LED dimming system based on an STM32 single chip microcomputer according to claims 1-4, characterized in that: The specific steps of the implementation method of the pulse modulation LED dimming system based on the STM32 single chip microcomputer are as follows: Step 1: Optimize hybrid modulation strategy and carrier allocation, and establish a dynamic carrier frequency allocation model by integrating a multi-modal hybrid scheme of pulse width modulation and pulse density modulation; Step 2: The current sampling module collects the LED load current waveform in real time, and dynamically adjusts the gain coefficient based on the harmonic distortion rate to offset the main harmonic components of the current signal in real time; Step 3: Implement nonlinear compensation of volt-ampere characteristics.

6. The method for implementing a pulse modulation LED dimming system based on an STM32 single chip microcomputer according to claim 5, wherein: The specific process of step 1 of the implementation method of the pulse modulation LED dimming system based on the STM32 single chip microcomputer is as follows: 1) Hybrid modulation mode division and switching logic; The mathematical boundary conditions of the multimodal modulation strategy are defined based on the brightness control signal L∈[0%,100%]. When the low brightness range L<10%, the pulse density modulation dominant mode is adopted. Pulse density modulation is abbreviated as PDM in the following text. The brightness is controlled by adjusting the number of pulses per unit time to suppress low-frequency ripples. When the medium and high brightness range L>10%, the pulse width modulation dominant mode is enabled. Pulse width modulation is abbreviated as PWM in the following text. The frequency modulation efficiency is improved by adjusting the pulse duty cycle. The brightness switching threshold is set. When the pulse width modulation switches to the pulse density modulation, L up =11%, when switching from pulse density modulation to pulse width modulation, L down =9%, avoiding critical point oscillation; 2) Modulation parameter mathematical model; The modulation parameter mathematical model includes the PDM mode mathematical model and the PWM mode mathematical model; PDM mode mathematical model: In the low brightness range, the pulse density D pdm The relationship with brightness L is: ; in: The base frequency is 500Hz; The maximum modulation frequency of PDM is 2kHz; PWM mode mathematical model: In the medium and high brightness range, the relationship between the duty cycle Dpwm and the brightness L is: ; Where: Dmin = 0.5% is the minimum duty cycle threshold to avoid MOSFET switching losses, and Dmax = 98% is the maximum duty cycle threshold to prevent dead time conflicts; γ=1.05 is the gamma correction factor to compensate for the nonlinear brightness perception of the human eye.

7. The method for implementing the pulse modulation technology LED dimming system based on the STM32 single chip microcomputer according to claim 5, characterized in that: The specific process of step 2 of the implementation method of the pulse modulation LED dimming system based on the STM32 single chip microcomputer is as follows: 1) Dynamic adjustment of active filter parameter algorithm architecture; The algorithms for dynamically adjusting active filter parameters include: current sampling, real-time harmonic detection algorithm, adaptive repetitive control algorithm, and digital filter dynamic tuning algorithm. Current sampling uses a current sensor to collect the LED load current waveform in real time. The real-time harmonic detection algorithm uses the LED current signal as input to calculate the current harmonic component set and real-time THD value. The adaptive repetitive control algorithm uses the current harmonic component set and real-time THD value as input to calculate the current compensation signal. The digital filter dynamic tuning algorithm uses the current signal and current compensation signal as input to calculate the compensated current signal. 2) Accurately extract the 3rd / 5th / 7th harmonic components of current and calculate THD; specifically, real-time harmonic detection algorithm and harmonic positioning and interpolation correction; specifically: ① Real-time harmonic detection algorithm: Every 5ms, the current window data is intercepted through the sliding window: ; Where: M=100, overlap rate 80%; is the current data set in the k-th sliding window; k is the window index; is the discretized current sampling sequence; n is the sampling point index; N is the window length; Then use the Blackman-Harris window to suppress spectrum leakage: in: is the Blackman-Harris window function coefficient; n is the position index within the window; is the current sequence after windowing; k is the window index; n is the sampling point index within the window; Compute the spectral components: ; in: is the FFT spectrum component; m is the frequency index; ② Harmonic positioning and interpolation correction: The double spectrum interpolation method is used to improve the accuracy of the 3rd / 5th / 7th harmonics: ; in: is the frequency offset correction; is the hth harmonic amplitude; Then extract the amplitudes of the 3rd, 5th, and 7th harmonics and calculate the total harmonic distortion THD: ; 3) Calculate compensation signal; Adopting gain adaptive mechanism to dynamically adjust controller gain : ; Among them: Constraints: ; is the controller gain; ΔTHD=THD-5%, which is the absolute error of THD; Generate compensation signal: ; in: is the fundamental frequency; is the sampling period; is the compensation signal of the nth sampling point; is the hth harmonic phase angle extracted by FFT phase spectrum; 4) Compensate for the current signal in the actual circuit; Compensated current signal It can be expressed as: 。 8. The method for implementing a pulse modulation LED dimming system based on an STM32 single chip microcomputer according to claim 5, wherein: The specific process of step three of the implementation method of the pulse modulation LED dimming system based on the STM32 single-chip microcomputer is to embed the PI algorithm in the constant current control loop to establish a voltage-current dual-variable compensation model; by pre-storing the volt-ampere characteristic curve of the LED device, the operating point offset is identified in real time, and the proportional coefficient and integral time of the PI controller are dynamically adjusted to compensate for the dimming curve deviation caused by the nonlinear impedance characteristics of the LED; the method is divided into parameterized modeling of the volt-ampere characteristic, dynamic PI controller parameter adjustment and dual-variable compensation control algorithm implementation; 1) Parametric modeling of volt-ampere characteristics. Parametric modeling of volt-ampere characteristics includes establishing a Vf-If parameter table and calculating the real-time operating point offset. Specifically: Establish Vf-If parameter table; During the system initialization phase, a discrete volt-ampere characteristic parameter table is constructed based on the volt-ampere characteristic curve of the LED lamp, and continuous mapping is achieved through cubic spline interpolation. Real-time working point offset calculation; During the constant current control period, the compensated load current is obtained through step 2. , check the volt-ampere characteristic parameter table to get the theoretical forward voltage drop , calculate the real-time pressure drop deviation: ; in: is the pressure drop deviation; is the actual measured value of voltage; 2) Dynamic PI controller parameter adjustment; Dynamic PI controller parameter adjustment includes proportional coefficient adaptive rules and integral time dynamic adjustment strategy; specifically: Adaptive rule of proportional coefficient; Dynamically adjust the proportional coefficient according to the voltage deviation amplitude to achieve a balance between fast response and stability: ; in: is the proportionality coefficient; Dynamic adjustment strategy of integration time; An exponential decay function is used to adjust the integration time to avoid overshoot and accelerate steady-state convergence: ; in: is the integration time; 3) Implementation of dual-variable compensation control algorithm: The implementation of dual-variable compensation control algorithm includes PI controller discretization design and current closed-loop compensation injection; specifically: Discrete design of PI controller; In the STM32, the backward difference method is used for discretization and the compensation current output is: ; in: Output compensation current for PWM; To control the cycle; Current closed-loop compensation injection; Add the compensation current to the PWM / PDM modulation signal to correct the drive current output: ; in: is the corrected current drive output; is the current signal after compensation in step 2.

9. The pulse modulation LED dimming system and method based on the STM32 single chip microcomputer according to claim 1, characterized in that: The pulse modulation LED dimming system based on the STM32 microcontroller supports 0%-100% stepless dimming, smooth brightness adjustment without flickering, and has four dimming modes: constant light, single point, sliding, and cycle. It also supports local control with matrix buttons and remote control with Bluetooth.

Citation Information

Cited By

  • Intelligent dimming system based on PSM technology

    CN121463292A