RGB LED lamp brightness rapid automatic calibration circuit and method
Through the MCU automatically calculates and compensates for the relationship between the brightness and PWM duty cycle of the RGB LED lamp, the problem of inconsistent brightness of the RGB LED lamp is solved, and the brightness consistency calibration between different products is achieved.
Patent Information
- Application Number
- CN202510986951.9
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2025-07-17
- Publication Date
- 2025-08-26
AI Technical Summary
In the prior art, when the MCU adjusts the RGB LED lamp through PWM, the display effect is poor due to inconsistent brightness of the three colors: red, green and blue.
The MCU automatically calculates the functional relationship between brightness and PWM duty cycle, uses the ADC module to collect voltage values, calculate the actual maximum current, determine the deviation coefficient, and build a mapping function between brightness and PWM duty cycle to compensate to ensure the consistency of brightness between different products.
It realizes rapid automatic calibration of RGB LED light brightness, ensuring consistency of brightness between different products, simplifying the calibration process without relying on external intervention.
Smart Images

Figure CN120547718A_ABST
Abstract
Description
Technical Field
[0001] The present invention belongs to the field of electronic technology, and more specifically, relates to a circuit and method suitable for an MCU to quickly calibrate the brightness of an RGB LED lamp. Background Art
[0002] In consumer electronics, RGB LEDs (red, green, and blue light-emitting diodes) are widely used for display and lighting effects. An MCU controls the brightness of the RGB LEDs by adjusting the brightness of the three colors (red, green, and blue).
[0003] In existing technology, the MCU can adjust and control the brightness of the light through PWM. However, because different colored LEDs have different brightness performance under the same current conditions, this can lead to poor display effects of RGB lights. Specifically, when the same PWM duty cycle is used to illuminate the RGB lights, the inconsistent brightness of the red, green, and blue colors leads to poor display effects. Summary of the Invention
[0004] To address the problem of poor display effects caused by inconsistent brightness of the red, green, and blue colors when using the same PWM duty cycle to illuminate RGB lights, the present invention provides a method for rapid automatic brightness calibration of RGB LED lights. The method uses an MCU to automatically calculate and compensate for the functional relationship between brightness and the PWM duty cycle used to control the LED lights. When adjusting to any brightness, the PWM duty cycle of the red, green, and blue lights can be accurately calculated and controlled, thereby maintaining consistent brightness for the three colors. Furthermore, the method can detect differences between different circuits and compensate for them during calculation, ensuring brightness consistency between different products.
[0005] According to one aspect of the present invention, a circuit for fast automatic brightness calibration of an RGB LED lamp is provided. The anode of the RGB LED lamp is connected to a power supply, and the cathode is connected to three output channels of a PWM module in an MCU via current-limiting resistors. The input channel of the ADC module in the MCU is connected to the anode of the RGB LED lamp.
[0006] As a further technical solution, a resistor is connected in series between the anode of the RGB LED lamp and the power supply, and the end of the resistor close to the anode of the light-emitting diode is connected to the input channel of the ADC module in the MCU.
[0007] According to one aspect of the present invention, a method for quickly and automatically calibrating the brightness of an RGB LED lamp is provided, comprising: The MCU is powered on, the PWM module is turned on, and the red, green, and blue lights are all controlled to output high levels. Control the red, green and blue lights to output low levels in turn, and collect the corresponding voltage values of the red, green and blue lights through the ADC module; Calculate the actual maximum current of the red, green and blue street lights based on the collected voltage values, determine the deviation coefficient based on the actual maximum current and the theoretical maximum current, and update the mapping function of each light based on the deviation coefficient; Based on the required brightness of the red, green and blue lights, combined with the updated mapping function of each light, the corresponding PWM duty cycle of each light is output.
[0008] As a further technical solution, the method further includes: The mapping function between brightness and PWM duty cycle is: L = (kX - a) b , where X represents the PWM duty cycle, L represents the brightness, a and b are constants, and k is the deviation coefficient.
[0009] As a further technical solution, for any color of red, green, or blue, the corresponding constants a and b are determined using the following method: Determine the critical values A and B of the PWM duty cycle, where: when the PWM duty cycle is A, the brightness is 0 (A is usually a value slightly greater than 0, and the light will not turn on when the duty cycle is less than or equal to A, and the light will start to turn on when the duty cycle is greater than A); when the PWM duty cycle is B, the brightness is 100 (B is usually a value less than 100, and the brightness will not change even if the duty cycle is greater than B). Taking the RGB light during debugging as the benchmark, the deviation coefficient k=1, and according to the mapping relationship between brightness and PWM duty cycle, calculate a=A, b=ln(100) / ln(BA).
[0010] As a further technical solution, the method further includes: Obtain the actual maximum current of the circuit where each lamp is located, and calculate the deviation coefficient based on the actual maximum current and the theoretical maximum current; The deviation coefficient is used to compensate the constants a and b of the mapping function corresponding to each lamp. The constants after compensation are: a = A / k b = ln(100) / (ln(BA)–ln(k)).
[0011] As a further technical solution, the method further includes: The compensated constants are stored in the memory device of the MCU.
[0012] As a further technical solution, determining the brightness thresholds A and B of the lamp includes: The light sensor is used to scan the PWM duty cycle when the brightness is 0 and 100 respectively, and calibrate it into the storage device of the MCU.
[0013] As a further technical solution, the method further includes: If it is calculated that the PWM duty cycle of one of the red, green, and blue lights needs to exceed 100%, then the duty cycles of the other two lights will be lowered based on the brightness of that light when the PWM duty cycle is 100%.
[0014] Compared with the prior art, the present invention has the following beneficial effects: The present invention effectively utilizes the voltage acquisition and calculation capabilities of the MCU to automatically and quickly calculate and calibrate the brightness differences of the red, green, and blue colors of RGB LED lights, as well as the brightness differences between different products of the same model. This method is simple and effective, does not rely on external intervention, and is universal for RGB light brightness calibration. BRIEF DESCRIPTION OF THE DRAWINGS
[0015] In order to more clearly illustrate the embodiments of the present invention or the technical solutions in the prior art, a brief introduction will be given below to the drawings used in the embodiments or the description of the prior art. Obviously, the drawings described below are some embodiments of the present invention. For ordinary technicians in this field, other drawings can be obtained based on these drawings without paying any creative work.
[0016] Figure 1 This is a schematic diagram of the structure of a circuit for rapid automatic brightness calibration of an RGB LED lamp provided by an embodiment of the present invention.
[0017] Figure 2 A schematic diagram of the structure of another RGB LED lamp brightness fast automatic calibration circuit provided by an embodiment of the present invention.
[0018] Figure 3 Schematic diagram of the relationship between the brightness and current of the three colors red, green, and blue for an RGB LED light provided by an embodiment of the present invention.
[0019] Figure 4 This is a flow chart of a method for rapid and automatic brightness calibration of an RGB LED lamp provided by an embodiment of the present invention. DETAILED DESCRIPTION
[0020] In order to make the purpose, technical solutions and advantages of the embodiments of the present invention clearer, the technical solutions in the embodiments of the present invention will be clearly and completely described below in conjunction with the drawings in the embodiments of the present invention. Obviously, the described embodiments are part of the embodiments of the present invention, not all of the embodiments. Based on the embodiments of the present invention, all other embodiments obtained by ordinary technicians in this field without making creative work are within the scope of protection of the present invention. In addition, the technical features in the various embodiments or single embodiments provided by the present invention are arbitrarily combined with each other to form a new technical solution. This combination is not restricted by the sequence of steps and / or structural composition mode, but must be based on the ability of ordinary technicians in this field to implement it. When the combination of technical solutions is contradictory or cannot be implemented, it should be deemed that this combination of technical solutions does not exist and is not within the scope of protection required by the present invention.
[0021] The present invention provides a circuit for rapid automatic brightness calibration of an RGB LED lamp. The anode of the light-emitting diode of the RGB LED lamp is connected to a power supply, and the cathode is connected to three output channels of a PWM module in an MCU via current-limiting resistors. The input channel of the ADC module in the MCU is connected to the anode of the light-emitting diode of the RGB LED lamp.
[0022] The present invention also provides a method for rapid automatic calibration of RGB LED lamp brightness. The MCU automatically calculates the mapping relationship between brightness and the PWM duty cycle of the LED lamp and performs automatic compensation. When adjusting to any brightness, the PWM duty cycle of the red, green, and blue lights can be accurately calculated and controlled, thereby controlling the brightness of the three colors of lights to remain consistent. At the same time, the method can detect differences between different circuits and compensate for them during calculation, ensuring brightness consistency between different products.
[0023] See also Figure 1 The anode of the RGB light is connected in series with a small resistor R3, which is then connected to the power supply VCC. The cathodes of the red, green, and blue LEDs are connected to current-limiting resistors (R0, R1, and R2), respectively. The other ends of these resistors are connected to the three output channels of the MCU's PWM (Pulse Width Modulation) module (PWM_LED_R, PWM_LED_G, and PWM_LED_B). R3 is a fixed resistor with a relatively small resistance. (R0 + R3) represents the actual current-limiting resistor value for the red light, (R1 + R3) represents the actual current-limiting resistor value for the green light, and (R2 + R3) represents the actual current-limiting resistor value for the blue light.
[0024] Connect the end of R3 close to the anode of the red, green, and blue LEDs to an input channel (ADC_CH0) of the MCU ADC (Analog-to-Digital Converter).
[0025] After the MCU is powered on, it controls PWM_LED_R, PWM_LED_G, and PWM_LED_B to output high levels (corresponding to a duty cycle of 100%), which means that the red, green, and blue light-emitting diodes are not lit; then the red, green, and blue lights are turned on in sequence (control PWM_LED_R, PWM_LED_G, and PWM_LED_B to output low levels in sequence, corresponding to a duty cycle of 0%). The MCU collects the voltages V0, V1, and V2 at the LED end of R3 through the ADC channel ADC_CH0, and calculates the current corresponding to the maximum brightness of the red, green, and blue light-emitting diodes (I R0 , I G0 , I B0 , where: I R0 = (VCC - V0) / R3, I G0 = (VCC - V1) / R3 - I R0 , I B0 = (VCC - V2) / R3 - I R0 -I G0 ).
[0026] It should be noted that theoretically, R3 can be omitted and the voltage of the three current limiting resistors of the red, green and yellow lights can be directly collected using the ADC channel to calculate the current. The effect is the same, but it requires two more ADC channels, such as Figure 2 In this circuit, the red, green, and blue lights are turned on simultaneously (PWM_LED_R, PWM_LED_G, and PWM_LED_B are controlled to output a low level, corresponding to a duty cycle of 0%). The MCU collects the voltages V0, V1, and V2 of the R0, R1, and R2 close to the LED lamp ends through the ADC channels ADC_CH0, ADC_CH1, and ADC_CH2, respectively, and calculates the current (I R0 , I G0 , I B0 , where: I R0 =V0 / R0,I G0 =V1 / R1, I B0 =V2 / R2).
[0027] After collecting the above voltages, turn off the ADC module.
[0028] There's a mapping relationship (function) between the brightness (L) and the current (I), and red, green, and blue lights typically have different mapping relationships to current (this is why brightness varies when the current is the same). The current flowing through an LED light is linearly related to the duty cycle of the corresponding PWM channel. In actual circuits, a 0% PWM duty cycle results in maximum current; a 100% duty cycle results in zero current. (For ease of calculation, this embodiment of the present invention assumes a positive correlation between brightness and PWM duty cycle values. In actual settings, simply subtract the corresponding value from 100%. Subsequent calculations assume that the current is minimum when the PWM duty cycle is 0% and maximum when the duty cycle is 100%.) Therefore, PWM can be used instead of current during debugging.
[0029] From the datasheet of a typical LED, the brightness and current have a nonlinear monotonically increasing relationship, such as Figure 3 As shown, the brightness and PWM duty cycle also have the above relationship. When debugging the sample, the brightness L can be determined by the sensory effect of the eyes. When the light is not on, L=0, and when the light is brightest, L=100 (for the sake of simplicity in calculation, the brightness range is determined to be 0~100. The actual value range can be flexibly defined, and can be other values such as 0~1, 0~1000, as long as it can represent the brightness). The value range of the PWM duty cycle is also 0~100, where 0 means that the LED is completely off and 100 means it is fully on (the duty cycle value range here can also be flexibly defined according to the actual calculation convenience, as long as it can represent the current situation). During actual debugging, it is usually the case that when the PWM duty cycle is small, the light does not light up, and the light only starts to light up when it reaches a certain value (assuming it is A); after the PWM duty cycle exceeds a certain value (assuming it is B), the light will not become brighter if it continues to increase. Based on the above information, the fitting function of the agreed brightness and PWM duty cycle (replaced by the variable X) is: L = (X - a) b , where a and b are constants.
[0030] According to the mapping relationship between the two points: X=A, L=0; X=B, L=100, the constants in the above function can be calculated: a = A b = ln(100) / ln(BA) So the fitting function is: L = (X - A) ln(100) / ln(B-A) As mentioned above, the red, green, and blue lights each have their own mapping functions (i.e., the corresponding constants a and b are different), which are calculated based on actual conditions.
[0031] The mapping functions obtained during the debugging phase include: Red light brightness and PWM duty cycle relationship function: L R = (X -a R ) bR Green light brightness and PWM duty cycle relationship function: L G = (X - a G ) bG Blue light brightness and PWM duty cycle relationship function: L B = (X - a B ) bB .
[0032] During debugging, record the current value I corresponding to the PWM duty cycle of the red, green and blue lights of the current circuit when it is 100. RMAX , I GMAX , I BMAX .
[0033] Given a target brightness value for each color light (any value between 0 and 100), calculate the PWM duty cycle of the corresponding color light according to the mapping function of the three lights and output it. At this time, the brightness of the three color lights is consistent.
[0034] Considering the variations between circuits during mass production, the mapping relationship between actual current and PWM may vary between different circuits. This can lead to differences in the mapping relationship between the brightness and PWM of different circuit lights. That is, outputting the same PWM duty cycle will result in different brightness values. For example, with a 50% PWM duty cycle, the current I in Circuit 1 may be 10.1mA, while the current I in Circuit 2 may be 10.3mA. Although the PWM and current values are still linearly proportional, there are some differences in the coefficients. This difference may be due to individual differences in VCC, LED lights, and current-limiting resistors. Therefore, further consideration was given to compensating the above function using current as a reference to reduce the deviation caused by these differences.
[0035] It's important to note that deviation refers to the deviation from a reference. For example, if the RGB light used during the debugging phase is A, then A is the reference, and the deviation coefficient is naturally 1. During the production phase, there are a large number of RGB lights. Due to differences in materials, circuits, and other factors, their mapping relationships cannot all be exactly the same as light A during the debugging phase. Furthermore, it's impossible to debug each one individually on the production line. Therefore, a deviation coefficient can be used to compensate for this. The deviation coefficient is based on the maximum current of the circuit. For example, if the maximum current of RGB light A (the reference) is IA, and the maximum current of any RGB light X on the production line is IX, then the deviation coefficient k for light X is IX / IA, where IX is measured by the sampling circuit during production, and IA is a known value measured during the debugging phase.
[0036] Compensation method: Compare the difference between the actual and theoretical maximum currents. Taking the red light as an example, the actual maximum current I R0 , the theoretical maximum current I RMAX , coefficient k = I R0 / I RMAX In the calculation of the aforementioned mapping relationship, the A value corresponding to the PWM duty cycle of the current circuit should be corrected to A / k, and the corresponding B value should be corrected to B / k. That is, if the current of this circuit is larger than that of the reference circuit (corresponding to k>1), the PWM duty cycle should be reduced according to the proportional relationship to reduce the current to the same value as the reference circuit; if the current of this circuit is smaller than that of the reference circuit (corresponding to k<1), the PWM duty cycle should be increased according to the proportional relationship to increase the current to the same value as the reference circuit. Therefore, the constants in the above formula are: a = A / k b = ln(100) / (ln(BA) – ln(k)) Of course, the maximum PWM duty cycle is 100%. If it is calculated that the PWM value of one of the red, green, and blue lights needs to exceed 100%, the brightness when the maximum PWM duty cycle is 100% should be used as the benchmark to lower the duty cycles of the other two lights.
[0037] According to the above formula, adjust the brightness of the LED light to any value between 0 and 100, and calculate the PWM duty cycle of the corresponding red, green, and blue lights. At this time, the brightness of the red, green, and blue lights is consistent.
[0038] In the actual circuit, according to Figure 4 The logic of the process performs sampling, calculation and calibration to set the PWM duty cycle value corresponding to the target brightness.
[0039] Furthermore, the corrected constants a and b can be saved in the MCU's non-volatile storage device (such as Flash), and only need to be calibrated once on the production line. Subsequently, they can be directly calculated using the formula or the calibration process can be restarted according to user needs.
[0040] Because the relationship between the brightness and current of RGB LED lights can shift with factors such as temperature, the calibration process can be restarted when necessary to obtain the relationship function under the current environmental conditions.
[0041] Furthermore, by adding a light sensor to the production line, the A and B values of the PWM can be scanned and calibrated to the MCU's storage device (such as Flash). This can produce a more accurate relationship function than the correction coefficient. This method is more expensive.
[0042] The terms "including" and "having" and any variations thereof in the description and claims of the present invention and the above-mentioned drawings are intended to cover non-exclusive inclusions, for example, a process, method, system, product or apparatus that includes a series of steps or units is not necessarily limited to the steps or units explicitly listed, but may include other steps or units not explicitly listed or inherent to these processes, methods, products or apparatuses.
[0043] Finally, it should be noted that the above embodiments are only used to illustrate the technical solutions of the present invention, rather than to limit it. Although the present invention has been described in detail with reference to the aforementioned embodiments, those skilled in the art should understand that they can still modify the technical solutions described in the aforementioned embodiments, or replace some or all of the technical features therein with equivalents. However, these modifications or replacements do not deviate the essence of the corresponding technical solutions from the technical solutions of the embodiments of the present invention.
Claims
1. A RGB LED lamp brightness fast automatic calibration circuit, characterized in that: The anode of the RGB LED light-emitting diode is connected to the power supply, and the cathode is connected to the three output channels of the PWM module in the MCU via current-limiting resistors. The input channel of the ADC module in the MCU is connected to the anode of the RGB LED light-emitting diode.
2. The RGB LED lamp brightness fast automatic calibration circuit according to claim 1, characterized in that: A resistor is connected in series between the anode of the light-emitting diode of the RGB LED lamp and the power supply, and one end of the resistor close to the anode of the light-emitting diode is connected to the input channel of the ADC module in the MCU.
3. A method for rapid automatic calibration of RGB LED light brightness, implemented using the circuit of claim 1 or 2, characterized in that: include: The MCU is powered on, the PWM module is turned on, and the red, green, and blue lights are all controlled to output high levels. Control the red, green and blue lights to output low levels in turn, and collect the corresponding voltage values of the red, green and blue lights through the ADC module; Calculate the actual maximum current of the red, green and blue street lights based on the collected voltage values, determine the deviation coefficient based on the actual maximum current and the theoretical maximum current, and update the mapping function of each light based on the deviation coefficient; Based on the required brightness of the red, green and blue lights, combined with the updated mapping function of each light, the corresponding PWM duty cycle of each light is output.
4. The method for rapid automatic calibration of RGB LED light brightness according to claim 3, characterized in that: The method further comprises: The mapping function between brightness and PWM duty cycle is: L = (kX - a) b , where: X represents the PWM duty cycle, L represents the brightness, a and b are constants, and k is the deviation coefficient.
5. The method for rapid automatic calibration of RGB LED lamp brightness according to claim 4, characterized in that: For any color light among red, green and blue, use the following method to determine its corresponding constants a and b: Determine PWM duty cycle critical values A and B, where when the PWM duty cycle is A, the brightness is 0; when the PWM duty cycle is B, the brightness is 100; According to the mapping relationship between brightness and PWM duty cycle, we can calculate: a=A, b=ln(100) / ln(BA).
6. The method for rapid automatic calibration of RGB LED lamp brightness according to claim 5, characterized in that: The method further comprises: Obtain the actual maximum current of the circuit where each lamp is located, and calculate the deviation coefficient based on the actual maximum current and the theoretical maximum current; The deviation coefficient is used to compensate the constants a and b of the mapping function corresponding to each lamp. The constants after compensation are: a = A / k b = ln(100) / (ln(BA)–ln(k)).
7. The method for rapid automatic calibration of RGB LED lamp brightness according to claim 6, characterized in that: The method further comprises: The compensated constants are stored in the memory device of the MCU.
8. The method for rapid automatic calibration of RGB LED lamp brightness according to claim 5, characterized in that: Determine the PWM duty cycle critical values A and B, including: The light sensor is used to scan the PWM duty cycle when the brightness is 0 and 100 respectively, and calibrate it into the storage device of the MCU.
9. The method for rapid automatic calibration of RGB LED lamp brightness according to claim 3, characterized in that: The method further comprises: If it is calculated that the PWM duty cycle of one of the red, green, and blue lights needs to exceed 100%, then the duty cycles of the other two lights will be lowered based on the brightness of that light when the PWM duty cycle is 100%.
Citation Information
Patent Citations
Multi-color LED lamp and control method and device thereof
CN109963377A
RGB LED lamp brightness control method and device, equipment and storage medium
CN119922782A
Red light compensation method and device for RGB lamp and RGB lamp
WO2019120230A1