A method and system for dynamically adjusting flame using multi-color LEDs

CN122513899APending Publication Date: 2026-08-04NINGBO HANKS HEATING APPLIANCE TECH CO LTD
View PDF 0 Cites 0 Cited by

Patent Information

Application Number
CN202610849170.X
Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
Filing Date
2026-06-12
Publication Date
2026-08-04

AI Technical Summary

Technical Problem

[0004]然而,传统火焰模拟方案多依赖于存储在存储器中的固定亮度序列进行循环调用,导致光效在长时间观察下呈现出明显的周期性重复,严重影响视觉体验的自然度

Benefits of technology

[0047]1. This invention introduces a chaotic operator module and utilizes the logistic mapping equation to generate control signals. Due to the inherent randomness and infinite non-repetition of chaotic systems, the generated flame light effect completely eliminates the periodic repetition defects of traditional fixed sequence schemes in the time domain. Over a long operating period, the flame's trajectory and brightness combination do not repeat, effectively solving the problem of decreased realism caused by visual fatigue. Simultaneously, the seed value generated based on physical noise ensures that the initial state is different each time the system starts, further enhancing the unpredictability of the simulation effect.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN122513899A_ABST
    Figure CN122513899A_ABST
Patent Text Reader

Abstract

This invention discloses a method and system for simulating flames using dynamic adjustment of multi-color LEDs, belonging to the field of intelligent electronic lighting adjustment technology. The method includes: generating chaotic initial values ​​by collecting physical noise from the floating pins of a microcontroller; generating an infinite, non-repeating chaotic numerical sequence using the logistic mapping equation based on the chaotic initial values; allocating the PWM duty cycles of the red and yellow channels using a nonlinear coupling algorithm based on the current chaotic values, and generating the PWM duty cycle of the orange channel based on these duty cycles; smoothing and filtering the three PWM duty cycles to generate smoothed drive signals; and driving the multi-color LED array to emit light according to the smoothed drive signals to simulate a dynamic flame effect. This invention can generate highly realistic and dynamic flame effects using a low-cost, low-power embedded solution.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] This application belongs to the field of intelligent electronic lighting adjustment technology, specifically relating to a flame simulation method and system for dynamic adjustment of multi-color LEDs. Background Technology

[0002] With the continuous advancement of semiconductor lighting technology, its application in decorative lighting and landscape simulation is becoming increasingly widespread, serving as an important means of creating immersive environments. LED devices, with their high response speed, low power consumption, and rich color gamut, demonstrate significant advantages in simulating natural light effects, especially the dynamic visual effects of flames. In applications such as smart homes, stage design, and urban lighting, the electronic control methods used to reproduce the flickering characteristics and light and shadow changes of flames are of great importance in enhancing the realism of the environment and the visual artistic effect.

[0003] Among them, the multi-color LED dynamic adjustment technology aims to simulate the color temperature fluctuations and light intensity jumps of natural flames during combustion by coordinating the brightness of multiple color light sources such as red, orange, and yellow. This technology typically uses pulse width modulation (PWM) signals generated by a microcontroller to perform high-frequency switching control on the LED array, and combines the principle of physical light mixing to visually reproduce the dynamic layering of flames, thereby achieving an electronic fit to the real combustion process.

[0004] However, traditional flame simulation schemes often rely on cyclically calling fixed brightness sequences stored in memory, resulting in noticeable periodic repetition of the light effect under long-term observation, severely impacting the naturalness of the visual experience. Furthermore, while some schemes introduce pseudo-random functions to generate control signals, the lack of physical logic continuity constraints leads to abrupt and unnatural brightness transitions, failing to capture the dynamic characteristics of flame movement. In addition, the combustion process of real flames exhibits complex nonlinear chaotic properties, and existing control logic struggles to effectively reproduce such nonlinear dissipative systems in low-cost embedded systems, resulting in poor correlation between color temperature and brightness, and failing to reflect the dynamic coupling relationship of the flame under different energy states. Therefore, a flame simulation scheme with dynamic adjustment of multi-color LEDs is desired. Summary of the Invention

[0005] The purpose of this invention is to provide a method and system for simulating flames by dynamically adjusting multi-color LEDs, which can effectively solve the problems in the background art.

[0006] To achieve the above objectives, the technical solution adopted by the present invention is as follows:

[0007] A method for simulating flames with dynamic adjustment of multi-color LEDs includes the following specific steps:

[0008] Obtain the initial chaotic value, which is generated by collecting the physical noise of the floating pin of the microcontroller;

[0009] Based on the initial chaotic value, the logistic mapping equation is used for recursive iteration to generate an infinite sequence of non-repeating chaotic values.

[0010] Based on the current chaotic value in the chaotic numerical sequence, the PWM duty cycle of the red channel and the yellow channel is allocated through a nonlinear coupling algorithm, and the PWM duty cycle of the orange channel is generated based on the duty cycle of the red channel and the yellow channel.

[0011] The PWM duty cycle of the red, yellow, and orange channels is smoothed and filtered to generate a smoothed drive signal;

[0012] The multi-color LED array is driven to emit light based on the smoothed drive signal to simulate a dynamic flame effect.

[0013] Furthermore, the process of generating an infinite, non-repeating chaotic numerical sequence also includes a dynamic perturbation step:

[0014] In each iteration cycle, the control parameter μ of the logistic mapping equation is not a fixed value, but is dynamically fine-tuned based on the chaotic values ​​generated in the previous cycle. The fine-tuning formula is as follows:

[0015]

[0016] in, The reference control parameter has a value range of [3.8, 4.0]. This is the disturbance amplitude coefficient, with a value range of [0.01, 0.1]. This represents the current chaos value;

[0017] This dynamic perturbation enhances the unpredictability and non-periodicity of chaotic sequences, further improving the naturalness of flame simulation.

[0018] Furthermore, the step of generating an infinite, non-repeating sequence of chaotic numerical values ​​further includes:

[0019] Set the control parameters of the logistic mapping equation to preset values ​​within the completely chaotic interval;

[0020] Configure a timer to generate periodic interrupts. Within each interrupt cycle, based on the current status value... Calculate the state value at the next moment. The calculation formula is: ,in For control parameters;

[0021] The calculated The new current state value is stored for the next iteration, thus forming a continuously evolving chaotic numerical sequence.

[0022] Furthermore, the step of allocating the PWM duty cycle further includes:

[0023] The current chaotic value is linearly mapped to the basic reference value of the PWM duty cycle;

[0024] The aforementioned basic reference value is directly used as the PWM duty cycle of the red channel;

[0025] The square of the current chaotic value is multiplied by the maximum duty cycle parameter of the yellow channel to obtain the PWM duty cycle of the yellow channel, in order to simulate the nonlinear enhancement effect of the high-temperature zone of the flame.

[0026] The weighted average of the duty cycle of the red channel and the duty cycle of the yellow channel is used as the PWM duty cycle of the orange channel.

[0027] Furthermore, the smoothing filtering process employs an adaptive smoothing coefficient:

[0028] Based on the current chaos value Dynamic adjustment of the smoothing coefficient of the rate of change rate of change , The calculation formula is:

[0029]

[0030] in, and These are the preset minimum and maximum smoothing coefficients. This is the sensitivity coefficient;

[0031] When the brightness of the flame changes drastically Automatically increases for a quick response; when changes are gradual... Automatically reduce size to enhance smoothness.

[0032] Furthermore, the step of driving the multi-color light-emitting diode array to emit light also includes dynamic duty cycle compensation:

[0033] Real-time monitoring of the junction temperature or ambient temperature of each LED channel; when the temperature exceeds a preset threshold, a temperature compensation coefficient is applied. The PWM duty cycle of the corresponding channel is linearly reduced, and the compensation formula is as follows:

[0034]

[0035] in, For actual measured temperature, For reference temperature, This is the temperature compensation coefficient;

[0036] This compensation is used to prevent light decay or color shift caused by LED overheating, ensuring the long-term stability of the flame simulation effect.

[0037] Furthermore, it also includes a preset mode switching step: by reading external instructions, the control parameters of the logistic mapping equation or the smoothing coefficient in the smoothing filter process are changed to simulate the dynamic characteristics of flames under different combustion states.

[0038] Furthermore, it also includes a voltage compensation step: real-time monitoring of the power supply voltage, and when the voltage fluctuation exceeds a preset threshold, adjusting the reference value of the PWM duty cycle through an automatic gain compensation algorithm to maintain the stability of the simulated flame brightness under different voltages;

[0039] The automatic gain compensation algorithm includes: pre-establishing a voltage-compensation coefficient mapping table, obtaining the current compensation coefficient by looking up the table and linear interpolation based on the measured power supply voltage, and multiplying the compensation coefficient by the base duty cycle reference value obtained by linear mapping of chaotic values ​​to obtain the compensated duty cycle reference value.

[0040] A multi-color LED dynamically adjustable flame simulation system, comprising:

[0041] The chaos initialization module is used to generate initial chaotic values ​​by collecting physical noise from the floating pins of the microcontroller;

[0042] The chaotic sequence generation module is used to generate an infinite, non-repeating chaotic numerical sequence by recursively iterating the logistic mapping equation based on the initial chaotic value.

[0043] The mapping and weight allocation module is used to allocate the PWM duty cycle of the red channel and the yellow channel according to the current chaotic value in the chaotic numerical sequence through a nonlinear coupling algorithm, and generate the PWM duty cycle of the orange channel based on the duty cycle of the red channel and the yellow channel.

[0044] The smoothing filter module is used to perform first-order hysteresis filtering on the PWM duty cycle of the red, yellow and orange channels to generate smoothed drive signals.

[0045] The driving and light-emitting module is used to drive the multi-color LED array to emit light according to the smoothed driving signal to simulate a dynamic flame effect.

[0046] In summary, this application includes at least one of the following beneficial technical effects:

[0047] 1. This invention introduces a chaotic operator module and utilizes the logistic mapping equation to generate control signals. Due to the inherent randomness and infinite non-repetition of chaotic systems, the generated flame light effect completely eliminates the periodic repetition defects of traditional fixed sequence schemes in the time domain. Over a long operating period, the flame's trajectory and brightness combination do not repeat, effectively solving the problem of decreased realism caused by visual fatigue. Simultaneously, the seed value generated based on physical noise ensures that the initial state is different each time the system starts, further enhancing the unpredictability of the simulation effect.

[0048] 2. Compared to traditional pseudo-random functions, the nonlinear mapping equation used in this invention possesses deterministic mathematical logic and a continuous state evolution process. Through the synergistic operation of smoothing filtering algorithms and chaotic logic, this invention can simulate the nonlinear dissipation process of a flame under the influence of aerodynamics. Brightness changes include both rapid flickering transitions and maintain physical continuity in numerical evolution, resulting in natural light and shadow transitions and avoiding the abrupt transitions common in existing technologies. The dynamic adjustability of the smoothing coefficient allows the system to simulate various dynamic characteristics, ranging from a tranquil candle flame to a blazing campfire.

[0049] 3. This invention establishes a nonlinear coupling relationship between the duty cycles of the red and yellow channels through a weighted allocation algorithm. This mapping method based on chaotic numerical power laws successfully simulates the physical correlation between the temperature and radiation intensity at the center of a flame. At high brightness, the yellow component increases rapidly, simulating the incandescence characteristics of the flame center; at low brightness, the red component dominates, simulating the red-hot characteristics of the embers. This synchronous coupling of color temperature and brightness enhances the three-dimensionality and dynamic realism of the simulated flame, making the electronic light source visually closely resemble the real chemical combustion process.

[0050] 4. This invention utilizes the hardware computing power of an embedded microcontroller to achieve complex chaotic calculations, eliminating the need for external large-capacity storage chips to store brightness sequences, thus significantly reducing system hardware costs and circuit complexity. Complex nonlinear signals can be generated through simple recursive formulas, enabling the scheme to operate stably in low-power, compact embedded systems. Furthermore, because the algorithm has extremely low memory resource requirements, it leaves ample computational margin for integrating other intelligent control functions into the system, demonstrating significant industrial application value and market competitiveness. Attached Figure Description

[0051] Figure 1 This is an overall schematic diagram of a flame simulation method that uses multi-color LEDs for dynamic adjustment;

[0052] Figure 2 This is a schematic diagram illustrating the principle of chaotic sequence generation based on logistic mapping;

[0053] Figure 3It is a logic diagram based on nonlinear mapping of chaotic numerical sequences and weight allocation of multiple PWM signals;

[0054] Figure 4 This is a schematic diagram of the multi-level interaction and data flow between the first-order hysteresis filtering of the duty cycle signal and the driving of the multi-color LED array. Detailed Implementation

[0055] To make the objectives, technical solutions, and advantages of this invention clearer, the following description is provided in conjunction with the appendix. Figure 1-4 The present invention will be further described in detail with reference to specific embodiments.

[0056] Firstly, the flame simulation method for dynamic adjustment of multi-color LEDs in this application is implemented according to the following steps:

[0057] First, step S1 initializes the chaotic operator. Its specific execution logic includes the following sub-steps:

[0058] Step S101: After the microcontroller is powered on, it first performs system clock configuration and hardware module initialization. One input pin of the microcontroller's internal analog-to-digital converter is set to high-impedance analog input mode. This pin is kept floating in the PCB layout and is not connected to any external circuits, making it a coupling point for environmental thermal noise, spatial electromagnetic radiation, and noise from the chip's internal substrate.

[0059] At the same time, the reference voltage of the analog-to-digital converter is configured to be the internal precise voltage source or power supply voltage, and the sampling and holding time is set to a period sufficient to capture weak noise signals, usually set to several ADC clock cycles.

[0060] In step S102, the microcontroller's general-purpose timer is configured to generate periodic trigger events, for example, the timer overflow period is set to 10 microseconds, which serves as the start trigger source for the analog-to-digital converter.

[0061] The analog-to-digital converter uses a successive approximation register structure to quantize the instantaneous voltage on the floating pin after each trigger, with the sampling bit set to 12 bits.

[0062] The system continuously collects a preset number of sample values, such as 32 conversion results. Each result is 12 bits of valid data and is stored in the microcontroller's data register or direct memory access buffer.

[0063] In step S103, the microcontroller reads the 32 12-bit raw sampled values ​​sequentially from the buffer. For each 12-bit data, only the least significant bit, i.e., the lowest 1 or 2 bits, is taken, because these low bits are most affected by noise and have the strongest randomness.

[0064] The least significant bits extracted are concatenated sequentially into a 32-bit temporary variable, with the concatenation order based on the sampling time.

[0065] Then, a cyclic XOR operation is performed on this 32-bit temporary variable, that is, the high 16 bits are XORed with the low 16 bits, and then the high 8 bits of the result are XORed with the low 8 bits, and so on, until a fully mixed 32-bit unsigned integer is obtained.

[0066] Divide the integer by 2^32 and subtract 1 to convert it into a double-precision floating-point number in the open interval (0,1) that is not equal to 0.25, 0.5, or 0.75. This number will be used as the initial state variable for the logistic mapping equation. If the transformation result is exactly equal to 0.25, 0.5 or 0.75, then a very small random perturbation ε (e.g. 10^(-9)) is added or subtracted to deviate it from that value to ensure the non-degenerative properties of the chaotic sequence.

[0067] In step S104, to ensure the real-time performance of subsequent chaotic iterative operations, the microcontroller uses a processing core with a built-in hardware multiplier and floating-point arithmetic unit, and its operating frequency is set to no less than 72MHz.

[0068] The central processing unit is directly connected to the hardware multiplier and floating-point unit via an internal bus, enabling it to complete 32-bit floating-point multiplication and addition operations within a single clock cycle. This satisfies the computational throughput required for simulating flames to update at a frequency of no less than 50Hz, avoiding output signal delay or blockage caused by the accumulation of mathematical operations.

[0069] In summary, step S1 constitutes the initialization process of the chaotic operator. This process utilizes the inherent physical randomness of the hardware to generate an unpredictable initial seed, laying the data foundation for the subsequent generation of aperiodic and highly random chaotic numerical sequences. Simultaneously, the hardware acceleration unit ensures real-time computing capabilities, guaranteeing the natural smoothness and dynamic realism of the flame simulation effect. After initialization, the system will enter the chaotic sequence generation stage, i.e., step S2.

[0070] For step S2, a chaotic sequence is generated, and its specific execution logic includes the following sub-steps:

[0071] Step S201: After completing the chaos operator initialization in step S1 and obtaining the initial state variable x0, the system sets the control parameter μ of the logistic mapping equation. μ is configured to 3.99, a value within the fully chaotic range, which enables the mapping system to exhibit extremely nonlinear characteristics, ensuring that the generated sequence has inherent randomness and high sensitivity to initial values.

[0072] In step S202, the already initialized timer resource is reused, and its overflow period is reconfigured to 20 milliseconds to generate a periodic interrupt with a frequency of 50Hz. This interrupt serves as the trigger source for chaotic iteration, ensuring that the chaotic state value is updated once in each interrupt service routine. This refresh rate matches the persistence of vision characteristic of the human eye, ensuring smooth perception of flame dynamics without placing an unnecessary burden on the processor due to excessively high computational frequency.

[0073] Step S203: At the entry point of each timer interrupt service routine, the processor first reads the current chaotic state value from the specified memory variable. This value is x0 generated in step S1 when the first interruption occurs.

[0074] In step S204, the processor calls the hardware multiplier and floating-point unit to calculate the state value at the next moment according to the logistic mapping equation. The mathematical expression for this equation is:

[0075]

[0076] in The current state value is between 0 and 1; μ is a control parameter with a current value of 3.99. The newly generated chaotic value also remains within the range of 0 to 1.

[0077] Step S205, calculate the... Write back to the original memory variable, overwriting the original one. This serves as the current state value for the next interrupted iteration. This update operation allows the chaotic sequence to evolve continuously, forming an infinitely long and never-repeating numerical chain.

[0078] Step S206, the interrupt service routine will generate the new chaotic values. The data is passed to the subsequent processing module, namely the mapping and weight allocation unit in step S3, for calculating the PWM duty cycle. After the transmission is complete, the interrupt service routine exits, and the microcontroller can return to the main loop or enter a low-power mode to wait for the next timer trigger.

[0079] In another preferred embodiment, to further enhance the unpredictability and aperiodicity of the chaotic sequence, a dynamic perturbation step is introduced during the generation of the chaotic numerical sequence. Unlike fixed control parameters, in this embodiment, each iteration period... The value is dynamically fine-tuned based on the chaotic value generated in the previous cycle. The fine-tuning formula is:

[0080]

[0081] in, The reference control parameter has a range of values. ; This is the disturbance amplitude coefficient, with a value range of [value range missing]. ; This represents the current chaos value. When... hour, The system enters a more intense chaotic region; when hour, The chaotic evolution is relatively gradual. This dynamic perturbation causes the chaotic sequence to exhibit different random statistical characteristics at different time periods, which is closer to the real process of natural flames being affected by airflow and fuel inhomogeneity.

[0082] In summary, step S2 describes the generation mechanism of the chaotic sequence. This mechanism drives the logistic mapping iteration at fixed time intervals, utilizing the sensitivity of the chaotic system to initial conditions and the chaotic characteristics of the parameters to continuously generate a non-periodic, highly random numerical sequence, providing a basic data source for subsequent simulation of the dynamic changes of the flame. Through this process, the system can achieve a visually infinitely changing and physically consistent flame jumping effect without storing a large amount of preset data.

[0083] Step S3 performs mapping and weight allocation, and its specific execution logic includes the following sub-steps:

[0084] Step S301: Obtain the chaotic value at the current moment from the chaotic sequence generation module in step S2. This value is a double-precision floating-point number between 0 and 1, representing the current energy state of the simulated flame.

[0085] Step S302, convert the chaotic value Linearly mapped to the baseline reference value of the PWM duty cycle. Specifically, Multiply by 255 to get a floating-point number between 0 and 255, then convert it to an 8-bit unsigned integer using a floor function. ,Right now ,in This indicates rounding down. This is the base reference value. This serves as the benchmark for subsequent calculations of the duty cycle of each color channel.

[0086] Step S303: Set the maximum duty cycle parameters for the red and yellow channels. In this embodiment, the maximum duty cycle of the red channel is... The value is 255, representing the maximum duty cycle of the yellow channel. The value is also 255, corresponding to a 100% duty cycle of the PWM signal. The maximum duty cycle of the orange channel is obtained through subsequent weighted calculations and does not need to be set separately.

[0087] Step S304: Calculate the PWM duty cycle of the red channel. Chaos values Maximum duty cycle of the red channel After multiplying, the floating-point result is converted to an integer. .because The expression is 255, and is equivalent to... That is, the duty cycle of the red channel is directly adopted from the basic reference value.

[0088] Step S305: Calculate the PWM duty cycle of the yellow channel. Using chaotic values The squared term is used to characterize the nonlinear enhancement effect in the high-temperature region of the flame, and the calculation formula is: .when When the value is small, the squared term decays rapidly, and the yellow component is weak; when... When the value approaches 1, the square term approaches 1, and the yellow component approaches the maximum duty cycle, thus simulating the incandescence characteristics of the flame center.

[0089] Step S306: Calculate the PWM duty cycle of the orange channel. This embodiment introduces a color shift factor that varies gradually over time. This factor is used to simulate the movement and drift of the orange hue in a real flame at different stages of combustion. It is generated by a low-frequency chaotic sequence or a low-frequency sine wave, and its value ranges from [value range missing]. The change period is approximately 2 to 10 seconds. The PWM duty cycle of the orange channel is calculated using the following formula:

[0090]

[0091] in, This refers to the PWM duty cycle of the red channel. This represents the PWM duty cycle for the yellow channel. Indicates rounding down. When When it approaches 0.3, the orange color becomes reddish, simulating the state of the flame root or embers; when... When the value approaches 0.7, the orange color becomes yellowish, simulating the high-temperature zone of a flame. This offset factor drifts slowly over time, causing the overall color tone of the flame to exhibit a periodic but not strictly repetitive change, significantly enhancing visual realism.

[0092] Step S307: Calculate the duty cycle values ​​for the three channels. , , The raw duty cycle signal is passed to the smoothing and filtering module in step S4. These values ​​will undergo first-order hysteresis filtering in subsequent steps to eliminate the visual abruptness caused by numerical abrupt changes, and are ultimately used to drive the multi-color LED array.

[0093] In summary, step S3 describes the mapping and weight allocation process from chaotic values ​​to multi-channel PWM duty cycles. This process converts chaotic energy into a brightness reference through linear mapping, then uses a power function to establish a nonlinear coupling relationship between the red and yellow channels, and generates an orange channel through weighted averaging, thus achieving a dynamic correlation between flame color temperature and brightness. This processing method makes the simulated flame appear as a reddish ember at low energy and as a yellowish-white high-temperature effect at high energy, thereby visually closely approximating the physical characteristics of a real flame. After completing the weight allocation, the system will proceed to step S4 for smoothing filtering.

[0094] Step S4 performs smoothing filtering, and its specific execution logic includes the following sub-steps:

[0095] Step S401: Obtain the original duty cycle values ​​of the three channels at the current time from the mapping and weight allocation in step S3, and record them as the original duty cycle of the red channel. Original duty cycle of the yellow channel and the original duty cycle of the orange channel These values ​​are all 8-bit unsigned integers between 0 and 255, representing the instantaneous brightness signal without smoothing.

[0096] Step S402: Configure a first-order hysteresis filter independently for each color channel. This embodiment no longer uses a fixed smoothing coefficient, but instead employs an adaptive smoothing coefficient, dynamically adjusted according to the rate of change of the current chaotic value. The rate of change is defined as:

[0097]

[0098] in, This represents the current chaos value. This represents the chaos value from the previous moment. Smoothing coefficient. Dynamically adjust according to the following formula:

[0099]

[0100] in, and The preset minimum and maximum smoothing coefficients are set to 0.1 and 0.6 respectively in this embodiment; This is the sensitivity coefficient, with a value of 10. When the flame brightness changes drastically, Larger Automatically increases the filter output to quickly follow the original input, preserving details of rapidly fluctuating inputs; when changes are gradual... Smaller Automatically reduces and enhances smoothness, eliminating unnecessary jitter.

[0101] Step S403: Initialize the previous time-lapse filter output value for each channel. When the system performs the filtering operation for the first time, since there is no previous time-lapse filter output value, the previous time-lapse filter output value is initialized. Initialize to the original input value at the current time. ,Right now This initialization operation avoids output jumps caused by missing historical values ​​at startup. Each channel's... The value is stored in a static or global variable assigned to the channel within the microcontroller, and these variables are persisted during system operation.

[0102] Step S404: Apply a first-order lag filtering algorithm to each channel to calculate the filtered output value at the current time. The mathematical expression of this algorithm is:

[0103]

[0104] in, This is the input value for the original duty cycle of the channel at the current moment, and the value is an integer ranging from 0 to 255; The filtered output value of this channel at the previous moment is stored as a floating-point number or a high-precision fixed-point number to maintain the recursive accuracy; The smoothing coefficient is obtained from the above adaptive calculation and is not a fixed value; The current filtered output value is calculated using floating-point numbers to ensure accuracy. After calculation, [the value will be...]. The integer is converted to an 8-bit unsigned integer in the range of 0 to 255 by rounding or truncating, so that it can be written to the PWM register later.

[0105] Step S405: Calculate the current time filtered output value. Update the stored data as historical values ​​for the next filtering operation. Specific operations are described below. The floating-point result overwrites the original. The variable ensures that the latest historical value can be used for recursion during the next interruption.

[0106] Step S406: The filtered and rounded duty cycle values ​​from the three channels are written into the corresponding PWM registers as the final drive signals. The writing operation is completed before the interrupt service routine exits, ensuring that the brightness value output in each 20-millisecond refresh cycle is smoothed. The PWM peripheral automatically generates the corresponding high-level time based on the written duty cycle values ​​to drive the subsequent LED driver circuit.

[0107] In summary, step S4 above describes the process of performing first-order hysteresis filtering on the original duty cycle signal. This process effectively suppresses drastic jumps that may occur in chaotic sequences by introducing a weighted average of historical states, making the brightness transition more natural and smooth, while preserving the non-periodic nature of the chaotic system. After filtering, the system will proceed to step S5 to drive the LED array, converting the smoothed digital signal into actual light output.

[0108] Finally, step S5 drives the LED array, and its specific execution logic includes the following sub-steps:

[0109] Step S501: Configure the PWM module inside the microcontroller, setting its carrier frequency within a preset range of 1kHz to 10kHz. This frequency selection avoids flickering perceptible to the human eye while ensuring the operating efficiency of the LED driver circuit and reducing switching losses.

[0110] Step S502: Obtain the filtered duty cycle values ​​of the three channels from the smoothing filter processing module in step S4, which correspond to the duty cycle of the red channel respectively. Yellow channel duty cycle and orange channel duty cycle These values ​​are all 8-bit unsigned integers between 0 and 255, representing the final brightness level to be output.

[0111] Step S503: Write the three duty cycle values ​​into the corresponding PWM comparator registers of the microcontroller. The PWM peripheral automatically adjusts the high-level duration of its output pins based on the values ​​in the comparator registers at the hardware level, thereby generating pulse width modulation signals corresponding to the duty cycles. The write operation is typically performed at the end of the timer interrupt service routine to ensure that the signal output in each 20-millisecond cycle is fully calculated.

[0112] Step S503a: To prevent light decay or color shift caused by increased junction temperature during long-term LED operation, this system also includes a duty cycle temperature compensation step. The microcontroller monitors the ambient temperature near the LED array in real time or estimates the junction temperature using an internal temperature sensor or an external thermistor. When the measured temperature exceeds the preset reference temperature, the system automatically performs linear attenuation compensation on the duty cycle of the three PWM channels. The compensation formula is as follows:

[0113]

[0114] in, The original duty cycle before compensation, with a value ranging from 0 to 255; The measured temperature is in °C. For reference temperature, 60℃ is used in this embodiment; This is the temperature compensation coefficient. To prevent frequent compensation switching due to temperature fluctuations near the reference value, a hysteresis interval is set: when the temperature exceeds [a certain value] three consecutive times... Compensation will be activated when the temperature is below a certain level for three consecutive consecutive samplings. Compensation is disabled at 58℃; within the 58℃ to 60℃ range, the compensation status from the previous moment remains unchanged. The sampling period is 500 milliseconds, and the time interval between three consecutive samples is no less than 1 second. When the temperature drops below 58℃, compensation is automatically canceled.

[0115] The calibration method for the temperature compensation coefficient is as follows:

[0116] 1. Place the LED array under test in a constant temperature chamber and set the ambient temperature to five points: 25℃, 40℃, 60℃, 70℃, and 85℃.

[0117] 2. At each temperature point, the relative luminous flux of the red LED, yellow LED, and orange LED under a fixed driving current was measured, with the luminous flux at 25℃ being 100%.

[0118] 3. Plot the attenuation curves of luminous flux for each channel as a function of temperature, and fit the curves to obtain the relative luminous flux ratio. ,in .

[0119] 4. Let the compensation coefficient be... satisfy Experimental calibration showed that when three channels share the same... Under the condition of value, This allows for brightness fluctuations after compensation within a temperature range of 25℃ to 85℃ to be controlled within ±5%, which is below the threshold perceptible to the human eye. If the attenuation characteristics of the three channels differ significantly, they can be set separately. , , The recommended values ​​given in this embodiment are based on actual measurements: , , The calibration experimental data are as follows: At 25℃, the relative luminous flux of each channel is 1.000; at 40℃, red is 0.940, yellow is 0.955, and orange is 0.948; at 60℃, red is 0.820, yellow is 0.850, and orange is 0.835; at 70℃, red is 0.740, yellow is 0.780, and orange is 0.760; at 85℃, red is 0.680, yellow is 0.730, and orange is 0.705. Correspondingly, when the original compensated duty cycle value is 200, it remains at 200 at 25℃; at 40℃, red is 213, yellow is 209, and orange is 211; at 60℃, red is 244, yellow is 235, and orange is 240; at 70℃, red is 270, yellow is 256, and orange is 263; and at 85℃, red is 294, yellow is 274, and orange is 284.

[0120] The junction temperature estimation method is as follows: If an internal temperature sensor is used, the junction temperature... Estimate using the following formula:

[0121]

[0122] in, The ambient temperature is measured by an internal temperature sensor. The real-time power consumption of the LED is calculated as follows: , Forward conduction voltage, For driving current; The thermal resistance from the LED package junction to the environment is obtained by consulting the device datasheet. Taking a 3528 packaged red LED as an example, the typical value is... If measurements are taken using an external thermistor, the thermistor should be mounted flush against the LED heat sink, and the measured values ​​should be filtered with a first-order hysteresis time constant. Seconds, the filtered temperature value is used as Substitute into the compensation formula.

[0123] In step S504, the microcontroller's PWM output pin is connected to the input of the constant current driver chip. The constant current driver chip receives these logic level signals and controls the average current flowing through the red, orange, and yellow LEDs via its internally integrated power MOSFET switch. The constant current driver chip ensures that the current flowing through the LEDs remains constant even when the power supply voltage fluctuates, thereby stabilizing the brightness.

[0124] Step S505: The multicolor light-emitting diode array consists of at least three groups of light-emitting units with different color temperatures. The dominant wavelength of the red light-emitting diode is in the range of 620 nm to 630 nm, the dominant wavelength of the orange light-emitting diode is in the range of 600 nm to 610 nm, and the dominant wavelength of the yellow light-emitting diode is in the range of 585 nm to 595 nm. These light-emitting units are arranged in an alternating pattern in physical space, such as a honeycomb arrangement or a concentric circle arrangement, to ensure that the light of different colors can be fully mixed within a very short distance, avoiding the appearance of color separation spots.

[0125] In step S506, through the above hardware driving and light mixing design, a flame effect with smooth transition, rich colors and dynamic changes is finally presented visually, completing the conversion from digital signal to actual light output.

[0126] In summary, step S5 discloses the specific implementation process from the filtered duty cycle signal to driving the LED array to emit light. This process ensures that the digitally calculated dynamic signal can be accurately converted into the expected flame light effect by configuring PWM parameters, writing to registers, connecting a constant current driver chip, selecting LEDs of specific wavelengths, and employing optimized physical arrangement. At this point, the core process of the entire flame simulation method is complete, and the system can run continuously and output realistic flame dynamic effects in real time.

[0127] In the above method, the multicolor light-emitting diode array is arranged in an alternating pattern in physical space, and a translucent diffuser is placed over the array. The transmittance of the diffuser is set within a preset range of 60% to 85%, and its material is selected from polycarbonate or polymethyl methacrylate, doped with a specific proportion of diffusion particles. By refracting and scattering light multiple times, the diffuser converts point light sources from different positions and wavelengths into a light field with a continuous distribution, thereby visually eliminating discrete light spots and forming a soft and layered flame texture.

[0128] In the above system architecture, the microcontroller also has a preset mode switching module. This module changes the control parameter μ in the logistic mapping equation or the smoothing coefficient α in the smoothing filter by reading the external button status or receiving remote communication commands, and can adjust the trigger period of chaotic iteration to simulate the dynamic characteristics of flames under different combustion states.

[0129] Specifically, in "Quiet Mode", the system adjusts the control parameter μ of the logistic mapping equation to a value between 3.7 and 3.8 (e.g., 3.75) to ensure that the system is still in the chaotic range but the output changes more smoothly; the smoothing coefficient α of the first-order hysteresis filter is reduced to between 0.1 and 0.2 (e.g., 0.15) to make the brightness changes more gentle; at the same time, the timer overflow period is adjusted to 40 milliseconds to 50 milliseconds (e.g., 45 milliseconds) to reduce the update frequency of the chaotic sequence, so that the flame presents a slow fluctuating state, similar to the burning state of candlelight or embers.

[0130] In "Carnival Mode", the system sets the control parameter μ to 3.99, placing it in the fully chaotic range to produce drastic changes; increases the smoothing coefficient α to between 0.5 and 0.6 (e.g., 0.55) to make the output respond faster to changes in the chaotic input and retain more high-frequency jitter; at the same time, adjusts the timer overflow period to between 10 and 20 milliseconds (e.g., 15 milliseconds) to increase the update frequency of chaotic iteration, thereby producing a more intense and varied visual impact, simulating the dynamic characteristics of a campfire or carnival flame.

[0131] The specific numerical ranges of the above parameters were obtained through experimental calibration to ensure that the system always operates in the chaotic range under different modes and that the output effect meets the expected visual characteristics.

[0132] In addition, the system includes a voltage monitoring module for real-time monitoring of the stability of the power supply voltage. In battery-powered applications, the actual driving current of the LED may deviate as the voltage drops. The voltage monitoring module obtains the power supply voltage in real time through an analog-to-digital converter. When the voltage fluctuation exceeds a preset voltage fluctuation threshold (e.g., ±5%), the microcontroller adjusts the reference value of the PWM duty cycle through an automatic gain compensation algorithm to ensure that the brightness of the simulated flame remains consistent under different remaining power levels.

[0133] The automatic gain compensation algorithm is implemented as follows: a voltage-compensation coefficient mapping table is pre-established in the microcontroller's non-volatile memory. This mapping table is obtained through experimental calibration, and the brightness compensation coefficient k(V) corresponding to different supply voltages V is recorded. During system operation, the voltage monitoring module collects the current supply voltage every 100 milliseconds. And look up the corresponding compensation coefficient in the mapping table. .like If the voltage is between two calibration voltage points, then the compensation coefficient is calculated using linear interpolation.

[0134]

[0135] in, and To and Two adjacent calibration voltage values, and This refers to the corresponding calibration compensation coefficient. Obtain the compensation coefficient. Then, it is compared with the base reference value generated in step S3. Multiply by this to obtain the voltage-compensated duty cycle reference value. The final duty cycle of each color channel is calculated based on this to offset brightness changes caused by voltage fluctuations.

[0136] To illustrate the specific application of the above method, let's take an electronic candlestick system as an example:

[0137] After the system powers on, the microcontroller enters the initialization phase, configures the system clock to 72MHz, and starts the ADC peripheral. The ADC samples a GPIO pin that is not connected to any circuit 100 times consecutively, with a sampling interval of 10 microseconds.

[0138] The microcontroller extracts the lowest two bits of these 100 sampled values ​​and uses a shift operation to form a 32-bit unsigned integer. This integer is then divided by its maximum possible value to obtain a decimal in the (0,1) interval, which is stored in RAM as the initial variable for chaotic evolution.

[0139] Start a hardware timer with a period of 20 milliseconds. In the timer interrupt service routine, the processor performs a floating-point multiplication operation to calculate the new chaos value.

[0140] The calculated chaotic value is converted into the red channel PWM duty cycle through a mapping function. Simultaneously, the squared term of the chaos value is calculated and multiplied by a preset coefficient to obtain the PWM duty cycle of the yellow channel. The duty cycle of the orange channel is the weighted average of that of the red and yellow channels.

[0141] The three duty cycle data points are fed into a first-order hysteresis filter with a smoothing coefficient of 0.3. The filtered data is then written into the PWM control register.

[0142] The PWM signal controls the tri-color LED beads located at the top of the candlestick via optocoupler isolation or direct drive of the power MOSFET. The light emitted by the LED beads passes through the frosted glass lampshade, presenting a natural flame effect with irregular jumping and constantly fluctuating color temperature.

[0143] On the other hand, the multi-color LED dynamic adjustment flame simulation system disclosed in this application includes:

[0144] The chaos initialization module generates initial chaotic values ​​by sampling the physical noise from a floating pin of the microcontroller. This module, centered around the microcontroller, includes: an analog-to-digital converter (ADC) input pin configured for high-impedance analog input mode, which is left floating on the circuit board to couple ambient noise; a timer for periodically triggering the ADC to continuously sample the floating pin; and an arithmetic unit for extracting the least significant bit of the sampled values, generating random integers through concatenation and cyclic XOR operations, and converting these random integers into double-precision floating-point numbers within a preset range as the initial state variables for the logistic mapping equation. The output of this module is the initial chaotic state value, which is then passed to the chaotic sequence generation module.

[0145] A chaotic sequence generation module, connected to the chaotic initialization module, is used to generate an infinite, non-repeating chaotic numerical sequence based on the initial chaotic value and recursively iteratively using the logistic mapping equation. This module is built into the microcontroller and includes: a register storing the control parameter μ, which is preset to a value within the completely chaotic range (e.g., 3.99); a timer interrupt service routine that triggers iterative calculations at a fixed period (e.g., 20 milliseconds); and a floating-point unit that executes the logistic mapping equation. And the new state value obtained in each iteration The current state is stored for use in the next cycle. This module outputs the current chaos value in each interrupt cycle. To the mapping and weight allocation module.

[0146] The mapping and weight allocation module, connected to the chaotic sequence generation module, is used to allocate the PWM duty cycles of the red and yellow channels based on the current chaotic value using a nonlinear coupling algorithm, and to generate the PWM duty cycle of the orange channel based on the red and yellow channel duty cycles. This module performs the following operations via the microcontroller's arithmetic logic unit: [The text abruptly ends here, likely due to an incomplete sentence or missing information.] Linear mapping to 8-bit base duty cycle Red channel duty cycle Yellow channel duty cycle Orange channel duty cycle The calculated raw duty cycles of the three channels are output to the smoothing filter module.

[0147] The smoothing filter module, connected to the mapping and weighting module, performs first-order hysteresis filtering on the duty cycles of the three PWM signals to generate smoothed drive signals. This module independently configures a first-order hysteresis filter for each color channel, includes a register storing the filtered output value from the previous moment, and a computational unit to execute the filtering algorithm. The filtering algorithm is as follows: ,in Set a preset smoothing coefficient (e.g., 0.2 to 0.4). This is the current original duty cycle. This is the filtered output value from the previous moment. The filtered duty cycle is rounded and written into the PWM comparator register as the final drive signal.

[0148] The driving and light-emitting module, connected to the smoothing and filtering module, is used to drive the multi-color LED array to emit light according to the smoothed driving signal. This module includes: a microcontroller's PWM peripheral, whose carrier frequency is set within a range where flicker is imperceptible to the human eye (e.g., 1kHz to 10kHz); three PWM output pins, which output pulse width modulation signals corresponding to the red, yellow, and orange channels, respectively; a constant current driving chip, which receives the pulse width modulation signal and controls the current flowing through the LEDs; and a multi-color LED array composed of red (620-630nm), orange (600-610nm), and yellow (585-595nm) LEDs, arranged in an alternating pattern (e.g., honeycomb or concentric circles), covered with a semi-transparent diffuser (60%–85% transmittance, made of polycarbonate or polymethyl methacrylate and doped with diffusion particles) to eliminate discrete light spots and form a continuously distributed light field.

[0149] Furthermore, the system may also include a preset mode switching module, which is connected to the chaotic sequence generation module and / or the smoothing filter module. By reading external instructions (such as key status, remote communication commands) to change the control parameter μ of the logistic mapping equation or the smoothing coefficient α of the smoothing filter, the system can simulate the dynamic characteristics of flames under different combustion states (such as quiet mode and carnival mode).

[0150] Furthermore, the system may also include a voltage monitoring and compensation module, which is connected to the power supply circuit and the mapping and weighting allocation module. This module monitors the power supply voltage in real time via an analog-to-digital converter. When voltage fluctuations exceed a preset threshold, it adjusts the reference value of the PWM duty cycle (e.g., linear scaling) using an automatic gain compensation algorithm. This is to maintain the stability of the simulated flame brightness under different voltages.

[0151] The aforementioned modules can be physically integrated into the same microcontroller chip and peripheral circuitry, working collaboratively with hardware resources via the microcontroller's internal bus. The microcontroller preferably has a built-in hardware multiplier and floating-point unit, with a clock speed of at least 72MHz to meet real-time computing requirements. During system operation, the chaos initialization module only operates during system startup or reset, generating an initial seed. Subsequently, the chaos sequence generation module, mapping and weight allocation module, and smoothing filtering module execute periodically under timer drive, while the driving and emission modules continuously output light effects, thus achieving a non-periodic, natural, and smooth flame simulation effect.

[0152] In summary, this system achieves highly realistic flame simulation through a low-cost, low-power embedded solution by tightly integrating hardware and algorithms, and has good market application prospects.

[0153] It will be apparent to those skilled in the art that the present invention is not limited to the details of the exemplary embodiments described above, and that the present invention can be implemented in other specific forms without departing from the spirit or essential characteristics of the present invention. Therefore, the embodiments should be regarded as exemplary and non-limiting in all respects.

[0154] Furthermore, it should be understood that although this specification describes embodiments, not every embodiment contains only one independent technical solution. This narrative style is merely for clarity. Those skilled in the art should consider the specification as a whole, and the technical solutions in each embodiment can also be appropriately combined to form other embodiments that can be understood by those skilled in the art.

Claims

1. A method for simulating flames with dynamic adjustment of multi-color LEDs, characterized in that, Includes the following steps: Obtain the initial chaotic value, which is generated by collecting the physical noise of the floating pin of the microcontroller; Based on the initial chaotic value, the logistic mapping equation is used for recursive iteration to generate an infinite sequence of non-repeating chaotic values. Based on the current chaotic value in the chaotic numerical sequence, the PWM duty cycle of the red channel and the yellow channel is allocated through a nonlinear coupling algorithm, and the PWM duty cycle of the orange channel is generated based on the duty cycle of the red channel and the yellow channel. The PWM duty cycle of the red, yellow, and orange channels is smoothed and filtered to generate a smoothed drive signal; The smoothed drive signal drives a multi-color LED array consisting of red, orange, and yellow LEDs to emit light, simulating a dynamic flame effect.

2. The method of claim 1, wherein the plurality of colors are dynamically adjusted based on a plurality of color temperature values. The process of generating an infinite, non-repeating chaotic numerical sequence also includes a dynamic perturbation step: In each iteration cycle, the control parameter μ of the logistic mapping equation is not a fixed value, but is dynamically fine-tuned based on the chaotic values ​​generated in the previous cycle. The fine-tuning formula is as follows: in, The reference control parameter has a value range of [3.8, 4.0]. This is the disturbance amplitude coefficient, with a value range of [0.01, 0.1]. This represents the current chaos value; This dynamic perturbation enhances the unpredictability and non-periodicity of chaotic sequences, further improving the naturalness of flame simulation.

3. The flame simulation method with dynamic adjustment of multi-color LEDs according to claim 1, characterized in that, The steps for generating an infinite, non-repeating sequence of chaotic numerical values ​​further include: Set the control parameters of the logistic mapping equation to preset values ​​within the completely chaotic interval; Configure a timer to generate periodic interrupts. Within each interrupt cycle, based on the current status value... Calculate the state value at the next time step. The calculation formula is: ,in For control parameters; The calculated The new current state value is stored for the next iteration, thus forming a continuously evolving chaotic numerical sequence.

4. The flame simulation method with dynamic adjustment of multi-color LEDs according to claim 1, characterized in that, The steps of allocating the PWM duty cycle further include: The current chaotic value is linearly mapped to the basic reference value of the PWM duty cycle; The aforementioned basic reference value is directly used as the PWM duty cycle of the red channel; The square of the current chaotic value is multiplied by the maximum duty cycle parameter of the yellow channel to obtain the PWM duty cycle of the yellow channel, in order to simulate the nonlinear enhancement effect of the high-temperature zone of the flame. The weighted average of the duty cycle of the red channel and the duty cycle of the yellow channel is used as the PWM duty cycle of the orange channel.

5. The flame simulation method with dynamic adjustment of multi-color LEDs according to claim 1, characterized in that, The smoothing filtering process uses an adaptive smoothing coefficient: Based on the current chaos value Dynamic adjustment of the rate of change smoothing coefficient rate of change , The calculation formula is: in, and These are the preset minimum and maximum smoothing coefficients. This is the sensitivity coefficient; When the brightness of the flame changes drastically Automatically increases for a quick response; when changes are gradual, Automatically reduce size to enhance smoothness.

6. The flame simulation method with dynamic adjustment of multi-color LEDs according to claim 1, characterized in that, The process of driving a multi-color LED array to emit light also includes dynamic duty cycle compensation: Real-time monitoring of the junction temperature or ambient temperature of each LED channel; when the temperature exceeds a preset threshold, a temperature compensation coefficient is applied. The PWM duty cycle of the corresponding channel is linearly reduced, and the compensation formula is as follows: in, For actual measured temperature, For reference temperature, This is the temperature compensation coefficient; This compensation is used to prevent light decay or color shift caused by LED overheating, ensuring the long-term stability of the flame simulation effect.

7. The flame simulation method with dynamic adjustment of multi-color LEDs according to claim 1, characterized in that, It also includes a dynamic color shift simulation step: In the aforementioned nonlinear coupling algorithm, a color shift factor that varies slowly over time is introduced. It is generated by low-frequency chaotic sequences or low-frequency sine waves; The PWM duty cycle of the orange channel is no longer fixed as a red-yellow weighted average, but is dynamically adjusted as follows: in, The value ranges from [0.3, 0.7] and drifts slowly over time to simulate the movement and drift of the orange hue of a real flame at different stages of combustion.

8. The flame simulation method with dynamic adjustment of multi-color LEDs according to claim 1, characterized in that, It also includes a voltage compensation step: real-time monitoring of the power supply voltage, and when the voltage fluctuation exceeds a preset threshold, adjusting the reference value of the PWM duty cycle through an automatic gain compensation algorithm to maintain the stability of the simulated flame brightness under different voltages; The automatic gain compensation algorithm includes: pre-establishing a voltage-compensation coefficient mapping table, obtaining the current compensation coefficient by looking up the table and linear interpolation based on the measured power supply voltage, and multiplying the compensation coefficient by the base duty cycle reference value obtained by linear mapping of chaotic values ​​to obtain the compensated duty cycle reference value.

9. A flame simulation system with dynamic adjustment of multi-color LEDs, applied to the flame simulation method with dynamic adjustment of multi-color LEDs as described in any one of claims 1-8, characterized in that, include: The chaos initialization module is used to generate initial chaotic values ​​by collecting physical noise from the floating pins of the microcontroller; The chaotic sequence generation module is used to generate an infinite, non-repeating chaotic numerical sequence by recursively iterating the logistic mapping equation based on the initial chaotic value. The mapping and weight allocation module is used to allocate the PWM duty cycle of the red channel and the yellow channel according to the current chaotic value in the chaotic numerical sequence through a nonlinear coupling algorithm, and generate the PWM duty cycle of the orange channel based on the duty cycle of the red channel and the yellow channel. The smoothing filter module is used to perform first-order hysteresis filtering on the PWM duty cycle of the red, yellow and orange channels to generate smoothed drive signals. The driving and light-emitting module is used to drive the multi-color light-emitting diode array to emit light according to the smoothed driving signal to simulate a dynamic flame effect.