Vehicle lamp temperature control method and system based on PID (Proportion Integration Differentiation) algorithm
By applying a temperature control method based on PID algorithm in the car lights, the fan output power is adjusted in real time, and the problems of low temperature control accuracy and high energy consumption in the prior art are solved, and more stable LED lamp lighting effects and more efficient temperature control are achieved.
Patent Information
- Application Number
- CN202510332681.X
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2025-03-20
- Publication Date
- 2025-05-16
AI Technical Summary
The prior art cannot dynamically adjust the heat dissipation intensity according to the real-time temperature of the car lights, resulting in low temperature control accuracy, unstable LED brightness, high energy consumption and unsatisfactory noise control, making it difficult to achieve accurate constant temperature control.
The headlight temperature control method based on the PID algorithm is adopted. By setting the target temperature value and adjusting the PID parameters, the headlight temperature is monitored in real time, the temperature deviation and error change rate are calculated, and the PWM signal is output to adjust the fan output power, realizing closed-loop temperature control.
It effectively reduces the fluctuations in LED junction temperature, improves the overall lighting effect of LED lamps, simplifies the control system structure, reduces production costs, and improves the accuracy and stability of temperature control.
Smart Images

Figure CN120018345A_ABST
Abstract
Description
Technical Field
[0001] The present invention relates to the technical field of vehicle lamp temperature control, and in particular to a vehicle lamp temperature control method and system based on a PID algorithm. Background Art
[0002] LED is the mainstream light source of current car lights. With the increasing application of LED in car lights in recent years, the number of LEDs has been increasing, the power has been increasing, and the heat dissipation efficiency of car lights has become more and more important. However, due to the variety of climate zones in different regions in China and the large temperature difference between the north and the south, the brightness of LEDs is greatly affected by the ambient temperature. The complex and changeable ambient temperature makes it difficult to ensure the stability of the brightness of LEDs when they are working.
[0003] In the prior art, the mainstream heat dissipation method of LED headlights is to use a fan rotating at a constant power, but it is traditionally open-loop control. From the control point of view, this heat dissipation method cannot monitor the temperature control and cannot finely control the temperature. The fluctuation of the LED junction temperature affected by the ambient temperature will make the LED brightness unstable (reference Figure 1 As shown in the figure, the lighting effect of the car lights is affected. In addition, due to the large temperature difference between the north and the south, the continuous full power output of the fan of the lamp without considering the influence of the ambient temperature will not only increase unnecessary energy consumption, but also increase noise. That is, the prior art has the following technical defects:
[0004] (1) It is impossible to dynamically adjust the heat dissipation intensity according to the real-time temperature of the car lamp.
[0005] (2) The temperature control accuracy is low, which easily causes temperature fluctuations and makes the LED brightness unstable.
[0006] (3) High energy consumption and poor noise control.
[0007] (4) It is difficult to achieve precise constant temperature control.
[0008] The above problems need to be solved urgently. Summary of the invention
[0009] The purpose of the present invention is to overcome at least one technical problem existing in the prior art, and to provide a vehicle lamp temperature control method and system based on a PID algorithm.
[0010] On the one hand, an embodiment of the present invention provides a lamp temperature control method based on a PID algorithm, the method comprising: step S1, setting a lamp target temperature value S t , and the proportional coefficient K in the PID algorithm p , integral coefficient K i and the differential coefficient K dStep S2, by collecting the current voltage value V of the temperature sensor placed in the headlight NTC , use the preset voltage-resistance formula to calculate the current resistance value R of the headlight NTC ; Step S3, according to the calculated resistance value R of the current headlight NTC , obtain the current temperature value X through the NTC resistance value and temperature value correspondence table; step S4, according to the target temperature value S t , proportionality coefficient K p , integration coefficient K i , differential coefficient K d And the output value OUT is obtained by the preset PID calculation formula, and the preset PID calculation formula is:
[0011] OUT=((K p ×E k )+(K i ×S k )+(K d ×D k ))+OUT 0 ;
[0012] E k =S t –X k ;
[0013] S k =E 1 +E 2 +E 3 +...+E k-2 +E k-1 +E k ;
[0014] D k =E k -E k-1 ;
[0015] In the formula, E k is the temperature deviation, X k is the temperature value sampled at the kth time, OUT 0 is the reference output, E k is the current error, S k is the cumulative error, D k is the error change rate;
[0016] Step S5, using the output value OUT as the high level width of PWM, periodically outputting the PWM value to drive the MOS tube switch, thereby adjusting the output power of the lamp fan; Step S6, controlling the fan speed according to the fan output power, and adjusting the lamp temperature to the target temperature value S tStep S7, loop steps S1-S6, monitor and adjust the lamp temperature in real time to stabilize it at the target temperature value S t .
[0017] Furthermore, the step S4 further includes:
[0018] The preset PID calculation formula is:
[0019] OUT=P OUT +I OUT +D OUT ;
[0020] P OUT =(K p ×E k )+OUT 0 ;
[0021] I OUT =(K p ×((1 / T i )×S k ×T))+OUT 0 ;
[0022] D OUT =K p ×(T d ×D k / T)+OUT 0 ;
[0023] make:
[0024] K i =K p ×((1 / T i )×T);
[0025] K d =K p ×(T d / T);
[0026] Where, T i is the integration time constant, T is the sampling period, T d is the differential time constant.
[0027] Furthermore, the voltage-resistance formula is:
[0028] V NTC =3.3*R NTC / (R 1 +R NTC );
[0029] In the formula, R 1 is the voltage divider resistance in ohms.
[0030] Furthermore, the step S2 collects the voltage value V of the temperature sensor placed in the headlight at the current moment. NTC , use the preset voltage-resistance formula to calculate the current resistance value R of the headlight NTC Including: Get the current resistance value R of the lamp through the NTC thermistor temperature detection circuit NTC The NTC thermistor temperature detection circuit includes: a power supply is connected to one end of the NTC thermistor through a third resistor R3, and the other end of the NTC thermistor is grounded to form a voltage divider circuit, which outputs the voltage value V of the temperature sensor at the current moment. NTC The inverting input terminal -IN of the operational amplifier is grounded, and the non-inverting input terminal +IN is grounded through the second capacitor C2, and is also connected to the voltage dividing node between the NTC thermistor and the third resistor R3, for obtaining the voltage signal V after the NTC thermistor voltage division. NTC ; Operational amplifier output voltage V ADC1_NTC Equal to the voltage V at the operational amplifier's non-inverting input +IN NTC , V NTC After the voltage is divided by the fourth resistor R4 and the sixth resistor R6, it enters the controller ADC1 pin, and the controller ADC1 pin reads the voltage value V ADC1_NTC , calculate the resistance value R of the NTC thermistor at this time according to the preset voltage-resistance formula NTC .
[0031] Furthermore, the method also includes: supplying power to the voltage divider of the third resistor R3 and the temperature sensor NTC through a voltage stabilizing circuit and providing a power supply voltage for the operational amplifier; the voltage stabilizing circuit integrates a voltage stabilizing chip U1, and the reference electrode of the voltage stabilizing chip U1 is connected to the voltage divider circuit node composed of the ninth resistor R9, the tenth resistor R10, the eleventh resistor R11 and the twelfth resistor R12, and the output voltage of the voltage stabilizing chip U1 is set by resistor voltage division, the anode of the voltage stabilizing chip U1 is grounded, and the cathode is connected to the power supply line through the eighth resistor R8, and a 3.3V voltage is output at the same time.
[0032] Further, the step S5, using the output value OUT as the high level width of PWM, periodically outputting the PWM value to drive the MOS tube switch, and then adjusting the output power of the lamp fan includes: using the output value OUT as the high level width of PWM, adjusting the output power of the lamp fan through the heat dissipation fan driving circuit; the heat dissipation fan driving circuit includes a MOS tube Q1 and a diode D1, the PWM signal is connected to the gate of the MOS tube Q1 through a first resistor R1, and is used to control the conduction and cutoff of the MOS tube Q1, the pull-down resistor R2 is connected between the gate of the MOS tube Q1 and the ground, and the diode D1 is reversely connected in parallel between the drain and the source of the MOS tube Q1, and is used to protect the MOS tube Q1.
[0033] Furthermore, the method further includes: limiting the output value OUT in step S4 to be less than or equal to 0.9t by setting a configurable PWM signal period parameter t.
[0034] Furthermore, the method also includes: when the temperature change rate calculated for N consecutive sampling periods exceeds a preset change rate threshold, the PID control working mode is switched to the abnormal protection working mode; the abnormal protection working mode is to force the output of a 100% duty cycle PWM signal.
[0035] Furthermore, the step S5, using the output value OUT as the high level width of PWM, periodically outputting the PWM value to drive the MOS tube switch, and then adjusting the output power of the lamp fan includes: converting the output value OUT into a duty cycle, D=(OUT / t)×100%, t is the PWM signal period, the unit is ms, D is the duty cycle, the unit is percentage; generating a PWM signal based on the duty cycle to drive the MOS tube; and controlling the fan speed by the gate voltage of the MOS tube.
[0036] In a second aspect, an embodiment of the present invention further provides a lamp temperature control system based on a PID algorithm, wherein the system is implemented by the lamp temperature control method based on the PID algorithm, and the system comprises: a controller, adapted to set a lamp target temperature value S t , and the proportional coefficient K in the PID algorithm p , integral coefficient K i and the differential coefficient K d ; By collecting the current voltage value V of the temperature sensor placed in the car light NTC , use the preset voltage-resistance formula to calculate the current resistance value R of the headlight NTC ; According to the calculated resistance value R of the current headlight NTC , obtain the current temperature value X through the NTC resistance value and temperature value correspondence table; according to the target temperature value S t , proportionality coefficient K p , integration coefficient K i , differential coefficient K d And the output value OUT is obtained by the preset PID calculation formula, and the preset PID calculation formula is:
[0037] OUT=((K p ×E k )+(K i ×S k )+(K d ×D k ))+OUT 0 ;
[0038] Ek =S t –X k ;
[0039] S k =E 1 +E 2 +E 3 +...+E k-2 +E k-1 +E k ;
[0040] D k =E k -E k-1 ;
[0041] In the formula, E k is the temperature deviation, X k is the temperature value sampled at the kth time, OUT 0 is the reference output, E k is the current error, S k is the cumulative error, D k The output value OUT is used as the high level width of PWM, and the PWM value is periodically output to drive the MOS tube switch, thereby adjusting the output power of the lamp fan; the NTC thermistor temperature detection circuit is suitable for real-time monitoring of the lamp temperature, and converting the temperature signal into a voltage signal and outputting it to the controller; the cooling fan drive circuit is suitable for controlling the on / off and speed of the fan according to the PWM signal output by the controller, so that the lamp temperature reaches the target temperature value S t ; Fan, suitable for rotating and cooling according to the control of MOS tube; Storage module, used to store NTC resistance value and temperature correspondence table, target temperature value S t , PID parameters, PWM signal period parameter t, preset change rate threshold, integral time constant T i , sampling period T and differential time constant T d One or a combination of the following.
[0042] In a third aspect, an embodiment of the present invention further provides an electronic device, comprising: a memory, a processor, and a computer program stored in the memory and executable on the processor, wherein the computer program implements the above-mentioned vehicle light temperature control method based on the PID algorithm when executed by the processor.
[0043] In a fourth aspect, an embodiment of the present invention further provides a readable storage medium, which, when the instructions in the storage medium are executed by a processor of an electronic device, enables the electronic device to execute the above-mentioned vehicle lamp temperature control method based on the PID algorithm.
[0044] The beneficial effects of the present invention are:
[0045] (1) The temperature value of the lamp at the moment is obtained in real time by detecting the resistance value at both ends of the lamp temperature sensor. The output PWM value is calculated by comparing the deviation between the target temperature and the current temperature value and the input PID parameters. The fan output power is periodically adjusted by the PWM value to perform closed-loop control of the temperature. When the lamp temperature reaches the target temperature and continues to stabilize, the lamp is stable and its fluctuation amplitude is reduced, which effectively reduces the fluctuation of the relative brightness of the LED caused by the fluctuation of the LED junction temperature, thereby improving and stabilizing the overall lighting effect of the LED lamp.
[0046] (2) The control system provided by the present invention has a simple structure, is easy to implement, has a low production cost, and is suitable for various types of lamp heat dissipation applications. BRIEF DESCRIPTION OF THE DRAWINGS
[0047] The present invention will be further described below in conjunction with the accompanying drawings and embodiments.
[0048] Figure 1 It is a schematic diagram of the relationship between the junction temperature and relative brightness of an LED lamp mentioned in the background technology of the present invention.
[0049] Figure 2 This is a flow chart of a vehicle lamp temperature control method based on a PID algorithm provided in Example 1 of the present invention.
[0050] Figure 3 This is a topological diagram of an NTC thermistor temperature detection circuit provided in Example 1 of the present invention.
[0051] Figure 4 This is a topology diagram of a front-end voltage stabilization circuit provided in Example 1 of the present invention.
[0052] Figure 5 This is a topology diagram of a cooling fan driving circuit provided in Example 1 of the present invention.
[0053] Figure 6 It is a schematic diagram comparing temperature curves of a lamp when a fan is not working, a fan is not configured with PID regulation, and a fan is configured with PID regulation, provided in Embodiment 1 of the present invention.
[0054] Figure 7 It is a schematic diagram of the structure of a vehicle lamp temperature control system based on a PID algorithm provided in Example 2 of the present invention.
[0055] Figure 8 This is a partial block diagram of an electronic device provided in Embodiment 3 of the present invention. DETAILED DESCRIPTION
[0056] It should be mentioned before discussing the exemplary embodiments in more detail that some exemplary embodiments are described as processes or methods depicted as flow charts. Although the flow charts describe the operations as sequential processes, many of the operations therein can be implemented in parallel, concurrently or simultaneously. In addition, the order of the operations can be rearranged. The process can be terminated when its operation is completed, but can also have additional steps not included in the accompanying drawings. The process can correspond to a method, function, procedure, subroutine, subprogram, etc.
[0057] It should be understood that, although the terms "first", "second", etc. may be used herein to describe various units, these units should not be limited by these terms. These terms are used only to distinguish one unit from another unit. For example, without departing from the scope of the exemplary embodiments, the first unit may be referred to as the second unit, and similarly the second unit may be referred to as the first unit. The term "and / or" used herein includes any and all combinations of one or more of the listed associated items.
[0058] The present invention will now be described in detail with reference to the accompanying drawings. This figure is a simplified schematic diagram, which only illustrates the basic structure of the present invention in a schematic manner, and therefore only shows the components related to the present invention.
[0059] Example 1
[0060] For ease of understanding, the inventive concept is generally described below before describing the embodiments of the present invention in detail:
[0061] The present application provides a method and system for controlling the temperature of a headlight based on a PID algorithm. By setting a target temperature value, the deviation between the current temperature and the target temperature is calculated. By recording the historical data of the temperature value of the lamp, the temperature change trend is obtained, and the output power of the fan is adjusted regularly to adjust the temperature of the lamp to the set target temperature, reduce the fluctuation of the LED junction temperature affected by the ambient temperature, and stabilize the lighting effect of the headlight. The cooling fan of the lamp will automatically adjust its power output under the influence of different ambient temperatures, saving energy while reducing the noise when the fan rotates, and improving the comfort of the driver and passengers. This method is simple and convenient to adjust. In the environment where the industry is increasingly paying attention to energy conservation and cost reduction, it can not only meet the needs of customers, but also improve the performance of lamps.
[0062] The specific implementation is as follows:
[0063] like Figure 2 As shown, it is a flow chart of a vehicle lamp temperature control method based on PID algorithm provided by the present invention.
[0064] As an example, the method includes:
[0065] Step S1, setting the target temperature value S of the lamp t , and the proportional coefficient K in the PID algorithm p , integral coefficient K i and the differential coefficient K d .
[0066] In some feasible implementations, the target temperature value S t The range that can be set is [25℃, 85℃]. Preferably, the target temperature value S t is 70℃; proportionality coefficient K p Can be set to 100, integral coefficient K i Can be set to 10, differential coefficient K d It can be set to 10. It should be noted that the target temperature value S t , and the proportional coefficient K in the PID algorithm p , integral coefficient K i and the differential coefficient K d The specific values in are limited, and relevant technicians can change the preset values based on actual needs.
[0067] Step S2: collecting the current voltage value V of the temperature sensor placed in the car lamp NTC , use the preset voltage-resistance formula to calculate the current resistance value R of the headlight NTC .
[0068] Step S3: Based on the calculated resistance value R of the current headlight NTC , the current temperature value X is obtained through the NTC resistance value and temperature value correspondence table.
[0069] In some feasible implementations, step S2 collects the voltage value V of the temperature sensor placed in the vehicle lamp at the current moment. NTC , use the preset voltage-resistance formula to calculate the current resistance value R of the headlight NTC Including: Get the current resistance value R of the lamp through the NTC thermistor temperature detection circuit NTC ; Combine Figure 3 As shown, the NTC thermistor temperature detection circuit includes: a power supply is connected to one end of the NTC thermistor through a third resistor R3, and the other end of the NTC thermistor is grounded to form a voltage divider circuit, which outputs the voltage value V of the temperature sensor at the current moment. NTC The inverting input terminal -IN of the operational amplifier is grounded, and the non-inverting input terminal +IN is grounded through the second capacitor C2, and is also connected to the voltage dividing node between the NTC thermistor and the third resistor R3, for obtaining the voltage signal V after the NTC thermistor voltage division. NTC ; Operational amplifier output voltage VADC1_NTC Equal to the voltage V at the operational amplifier's non-inverting input +IN NTC , V NTC After the voltage is divided by the fourth resistor R4 and the sixth resistor R6, it enters the controller ADC1 pin, and the controller ADC1 pin reads the voltage value V ADC1_NTC , calculate the resistance value R of the NTC thermistor at this time according to the preset voltage-resistance formula NTC . Specifically, the 3.3V power supply is connected to one end of the NTC thermistor (model KNTC0603 / 10KF3950, resistance 10K) through the third resistor R3 (10K, 1% accuracy), and the other end of the NTC is grounded to form a voltage divider circuit. At the same time, the 3.3V power supply is directly connected to the power pin of the operational amplifier to power the operational amplifier, and a 1uF / 10V first capacitor C1 is connected between the power pin and the ground for power supply filtering. The inverting input terminal -IN of the operational amplifier is directly grounded, and the non-inverting input terminal +IN is grounded through the second capacitor C2 (100nF / 10V), and is also connected to the voltage dividing node of the NTC thermistor and the third resistor R3, for obtaining the voltage signal after the NTC voltage division. The output terminal OUT of the operational amplifier is connected to a low-pass filter circuit composed of a fourth resistor R4 (1K, 1% accuracy), a sixth resistor R6 (2K, 1% accuracy) and a third capacitor C3 (100nF / 10V). After passing through the low-pass filter circuit, the final output voltage signal V ADC1_NTC , used for subsequent ADC processing to obtain temperature-related digital signals.
[0070] More specifically, 3.3V is divided by the temperature sensor NTC and the third resistor R3 to obtain a voltage value V NTC Input op amp pin IN+. V NTC The calculation formula is as follows:
[0071] V NTC =3.3*R NTC / (R 1 +R NTC );
[0072] In the formula, R 1 is the voltage divider resistor (corresponding to Figure 3 The unit of resistance is ohm.
[0073] The op amp is a voltage follower, and the op amp output voltage V ADC1_NTC Equal to the voltage V at the op amp +IN input NTC . V NTC Through R 4 and R 6 The divided voltage enters the controller ADC1 pin.
[0074] VADC1_NTC =V NTC *R 6 / (R 4 +R 6 );
[0075] The controller ADC1 pin reads this voltage value V ADC1_NTC Calculate the NTC resistance R at this time NTC .
[0076] R NTC =((R 4 +R 6 )*V ADC1_NTC ) / (3.3*R 6 -(R 4 +R 6 )*V ADC1_NTC ).
[0077] The step S3 comprises: according to the calculated R NTC The temperature value X at this moment is obtained through the NTC resistance value and temperature value correspondence table.
[0078] In some feasible implementations, the method further includes: supplying power to the third resistor R3 and the voltage division of the temperature sensor NTC through a voltage stabilizing circuit and providing a power supply voltage to the operational amplifier; Figure 4 As shown, the voltage stabilizing circuit integrates a voltage stabilizing chip U1, and the reference electrode of the voltage stabilizing chip U1 is connected to the voltage dividing circuit node composed of the ninth resistor R9, the tenth resistor R10, the eleventh resistor R11 and the twelfth resistor R12. The output voltage of the voltage stabilizing chip U1 is set by the resistor voltage division. The anode of the voltage stabilizing chip U1 is grounded, and the cathode is connected to the power supply line through the eighth resistor R8, and a 3.3V voltage is output at the same time. Specifically, the 5V power supply is used as the input, and after passing through the eighth resistor R8 (100R, 1% accuracy), it is respectively connected to two 100nF, 16V withstand voltage fourth capacitors C4 and fifth capacitors C5, and the other ends of the two capacitors are grounded, which plays a filtering role and reduces the high-frequency noise in the power supply. The reference electrode of the voltage stabilizing chip U1 (model LR431ATLT1G) is connected to the node of the voltage divider circuit composed of the ninth resistor R9 (2.4K, 1% accuracy), the tenth resistor R10 (5.6K, 1% accuracy), the eleventh resistor R11 (10K, 1% accuracy) and the twelfth resistor R12 (15K, 1% accuracy). The output voltage of the voltage stabilizing chip is set by the voltage divider of these resistors. The anode of the voltage stabilizing chip U1 is grounded, and the cathode is connected to the power supply line after the eighth resistor R8, and a 3.3V voltage is output at the same time. Through such a connection, the conversion from 5V input to a stable 3.3V output is realized, providing a stable power supply for the subsequent circuit.
[0079] Step S4: according to the target temperature value St , proportionality coefficient K p , integration coefficient K i , differential coefficient K d And the output value OUT is obtained by the preset PID calculation formula, and the preset PID calculation formula is:
[0080] OUT=((K p ×E k )+(K i ×S k )+(K d ×D k ))+OUT 0 ;
[0081] E k =S t –X k ;
[0082] S k =E 1 +E 2 +E 3 +...+E k-2 +E k-1 +E k ;
[0083] D k =E k -E k-1 ;
[0084] In the formula, E k is the temperature deviation, X k is the temperature value sampled at the kth time, OUT 0 is the reference output, E k is the current error, S k is the cumulative error, D k is the error change rate;
[0085] In some feasible implementations, the derivation process of the PID calculation formula in step S4 is as follows: the preset PID calculation formula is:
[0086] OUT=P OUT +I OUT +D OUT ;
[0087] Where P OUT The derivation process is as follows:
[0088] By calculating the target temperature S t And the k-th sampled temperature value X k The temperature deviation E is obtained by k :E k =St –X k ;
[0089] From the time the lamp is powered on, the lamp temperature value is sampled at regular intervals. Thus, a data sequence formed by the lamp temperature values at each sampling time point since the lamp is powered on can be obtained: X 1 ,X 2 ,....X k-2 ,X k-1 ,X k Among them, X 1 is the first temperature sampling value since the power-on, X k is the kth temperature sampling value. k Real-time calculation of proportional control output result P OUT The mathematical model of proportional control can be expressed as:
[0090] P OUT =(K p ×E k )+OUT 0 ;
[0091] Where E k Reflects the Kth sampling temperature X k With the setting value S t The degree of deviation can be calculated based on E k The output signal OUT is adjusted according to the size of the deviation: OUT Increase, the deviation is small P OUT That is, the strength of the output signal is proportional to the current deviation. 0 is a constant, which can be set to 10. The purpose of setting it is to k When the Kth sampling temperature is equal to the set value, ensure that the output signal is not 0, so that the controller output signal OUT is not 0 when the Kth sampling temperature is equal to the set value, and the system is in an out-of-control state without a control signal. p is the proportional coefficient used to amplify or attenuate E.
[0092] I OUT The derivation process is as follows:
[0093] Since the power-on, the sampling period is T, and the temperature deviation sequence data at each sampling moment is accumulated to obtain the cumulative temperature deviation value S k :S k =E 1 +E 2 +E 3 +...+E k-2 +E k-1 +E k ;Right now:
[0094] Sk =∑ k k=1 E k ;
[0095] According to S k Calculate the integral control output result I OUT The mathematical model of integral control can be expressed as:
[0096] I OUT =(K p ×((1 / T i )×S k ×T))+OUT 0 ;
[0097] Each deviation value E k Possibly: E k >0,E k <0,E k = 0, because from the start to now, the control algorithm continuously outputs the control signal I OUT The temperature of the lamps is controlled, which sometimes exceeds the standard in the past period of time (E k <0), sometimes not up to standard (E k >0), sometimes it just meets the requirement (E k =0); if these deviation values are accumulated and algebraically summed, S k , when S k >0 means that the target was not met most of the time in the past. k =0 means that the target was met most of the time in the past. k <0 means that the limit was exceeded most of the time in the past. k The analysis can comprehensively evaluate the past control effect of the PID control algorithm. k In fact, it is the sum of the errors at each time point in the past, which is similar to the definite integral operation in mathematics. Therefore, according to S k The method of adjusting the output signal is called the integration algorithm. p For S k Amplify or attenuate. i It is the integral time constant. The larger the value, the smaller the output OUT will be. It can be understood that the error value for a long time has affected the current output signal. The smaller the value, the stronger the output OUT will be. It can be understood that the integration only considers the error in the most recent period of time. T is the sampling period, also called the control period. PID calculation is performed every T time period.
[0098] D OUT The derivation process is as follows:
[0099] According to the current deviation E kand the deviation value E based on the previous sampling moment k-1 Calculate the difference D between the two most recent deviations k :
[0100] D k =E k -E k-1 ;
[0101] D k It can explain the state change trend of the controlled object from the last sampling to the current sampling. This change trend is likely to continue to the next sampling time point to a certain extent, so it can be based on this change trend (D k The output signal OUT is adjusted according to the value of the control signal to achieve the purpose of advance control.
[0102] D k It reflects the changing trend and amount of the controlled object over a period of time, and is expressed in a mathematical model as follows:
[0103] D OUT =K p ×(T d ×D k / T)+OUT 0 ;
[0104] Proportional coefficient K p It can be understood as a hardware amplifier or attenuator, which is used to adjust the gain of the output signal OUT; T d is the differential time constant, T d The larger the D OUT Increase, affecting the output signal.
[0105] According to the above three algorithms, a current control quantity OUT is generated to control the temperature of the lamp. Their advantages and disadvantages complement each other. The mathematical model of PID algorithm is OUT = P OUT +I OUT +D OUT ;Right now
[0106] OUT=(K p ×E k )+OUT 0 +(K p ×((1 / T i )×S k ×T))+OUT 0 +K p ×(T d ×
[0107] D k / T)+OUT 0 ;
[0108] Let K i =K p ×((1 / T i )×T), K d =K p ×(T d / T);
[0109] Rearranging this formula yields:
[0110] OUT=((K p ×E k )+(K i ×S k )+(K d ×D k ))+OUT 0 ;
[0111] Where K p is the proportionality coefficient, K i is the integration coefficient, K d is the differential coefficient. Choose a reasonable K according to the actual situation p , K i and K d The value of can get good control effect.
[0112] Step S5: using the output value OUT as the high level width of PWM, periodically outputting the PWM value to drive the MOS tube switch, thereby adjusting the output power of the lamp fan.
[0113] Step S6: Control the fan speed according to the fan output power and adjust the lamp temperature to the target temperature value S t ;
[0114] Step S7: loop through steps S1-S6 to monitor and adjust the lamp temperature in real time to stabilize it at the target temperature S. t .
[0115] In some feasible implementations, the step S5, using the output value OUT as the high level width of PWM, periodically outputting the PWM value to drive the MOS tube switch, and then adjusting the output power of the lamp fan includes: using the output value OUT as the high level width of PWM, adjusting the output power of the lamp fan through the heat dissipation fan driving circuit; combining Figure 5As shown, the cooling fan driving circuit includes a MOS tube Q1 and a diode D1, a PWM signal is connected to the gate of the MOS tube Q1 through a first resistor R1, and is used to control the conduction and cutoff of the MOS tube Q1, a pull-down resistor R2 is connected between the gate of the MOS tube Q1 and the ground, and a diode D1 is reversely connected in parallel between the drain and source of the MOS tube Q1, and is used to protect the MOS tube Q1. Specifically, a 12V power supply is used as the power supply of the entire circuit, directly connected to the drain of the MOS tube Q1 (model NCE3050K), and is also connected to one end of the cooling fan FAN, and the other end of the fan is connected to the source of the MOS tube Q1, forming a power supply circuit for the fan. The PWM (pulse width modulation) signal is connected to the gate of the MOS tube Q1 through a first resistor R1 (100R), and is used to control the conduction and cutoff of the MOS tube Q1. The second resistor R2 (4.7K) is connected between the gate of the MOS tube Q1 and the ground, and acts as a pull-down resistor to ensure that when there is no PWM signal input, the gate of the MOS tube Q1 is at a low level and the MOS tube Q1 is cut off. Diode D1 (model B340AG) is connected in reverse parallel between the drain and source of MOS tube Q1 to protect MOS tube Q1. When reverse electromotive force is generated due to power failure of the fan, diode D1 can provide a path for reverse current to prevent the reverse electromotive force from damaging MOS tube Q1.
[0116] In some feasible implementations, the step S5, using the output value OUT as the high level width of PWM, periodically outputting the PWM value to drive the MOS tube switch, and then adjusting the output power of the lamp fan includes: the controller uses the OUT value as the high level time of PWM, in ms. When OUT is less than 0, the high level time of PWM is the minimum value 0ms, and when OUT is greater than 5000, the high level time of PWM is the maximum value 5000ms. The controller outputs a PWM signal every 5000ms to obtain a PWM duty cycle, and the PWM duty cycle is (OUT / 5000)×100%. The PWM signal enters the gate of the MOS tube, the MOS tube is turned on, the fan is powered, and the fan outputs power according to the current PWM signal.
[0117] In some feasible implementations, the method further includes: by setting a configurable PWM signal cycle parameter t, limiting the output value OUT in step S4 to be less than or equal to 0.9t. Specifically, according to the above embodiment, when OUT is greater than 5000, the high level time of PWM is a maximum value of 5000ms. The controller outputs a PWM signal every 5000ms to obtain a PWM duty cycle, and the PWM duty cycle is 100%. When the PWM duty cycle reaches 100% (ie, OUT=t), the MOS tube will continue to conduct, causing the power device to withstand a large current for a long time, causing overheating damage. Moreover, in PID control, if the output is at a limit value for a long time (such as a 100% duty cycle), the integral term will continue to accumulate errors, resulting in a system response lag. In addition, some cooling fans may have excessive starting current or accelerated mechanical wear at full duty cycle, and limiting the duty cycle can extend the life of the motor. Therefore, it is very necessary to limit the output of OUT. For example, by limiting the output of OUT to less than or equal to 0.9t, that is, limiting the output to within 90% duty cycle, forcing at least 10% of the off time to ensure that the MOS tube is reset and dissipated periodically; by limiting the upper limit of OUT, the controller is forced to stop the growth of the integral term after reaching the threshold to avoid the control amount being "stuck"; by reserving a 10% time window (10% of T) as a dynamic adjustment space, it is ensured that the system can still respond quickly through the PID algorithm when the temperature suddenly changes, rather than directly entering the saturation state. For a specific example, assuming that the PWM period is set to t = 1000ms, the maximum allowable OUT value is 900ms (duty cycle 90%). When the temperature of the lamp rises sharply, the OUT value calculated by the PID algorithm may reach 900ms. At this time: MOS tube: There is a 100ms off time per cycle to avoid continuous conduction and cause the junction temperature to rise. Control system: Even if the temperature error still exists, the controller needs to adjust the PID parameters (such as increasing K p ) rather than simply extending the on-time to optimize regulation and prevent loss of control. The dual design of hardware protection and control optimization significantly improves the robustness and practicality of the system.
[0118] In some feasible implementations, the method further includes: when the temperature change rate calculated for N consecutive sampling periods exceeds the preset change rate threshold, the PID control working mode is switched to the abnormal protection working mode; the abnormal protection working mode is to force the output of a 100% duty cycle PWM signal. Wherein, N can be 3, and the preset change rate threshold can be set to 5°C / s. Specifically, when the temperature of the lamp soars at a rate of 5°C / s due to heat dissipation failure (such as fan jamming) or sudden high heat load (such as circuit short circuit), it may cause key components such as LED light source and drive circuit to burn out due to overheating; and the conventional PID algorithm may be unable to cope with extreme situations due to response lag or output limiting (such as the above-mentioned 90% duty cycle limit). Therefore, it is necessary to provide an abnormal protection method. When the temperature of the lamp soars at a rate of 5°C / s due to heat dissipation failure (such as fan jamming) or sudden high heat load (such as circuit short circuit), forcibly outputting 100% duty cycle PWM can make the fan run at full speed, suppress the temperature rise in the shortest time, and avoid the key components such as LED light source and drive circuit from burning out due to overheating. Breaking through the limits of conventional PID control: Conventional PID algorithms may not be able to cope with extreme situations due to response lag or output limiting. This abnormal protection method serves as an independent safety redundancy to ensure that the system can still trigger the maximum heat dissipation capacity in an out-of-control state. For a specific example, suppose the temperature rise rate of the lamp reaches 8°C / s due to a foreign object blocking the fan: Cycle 1: The temperature rise rate is detected to be excessive and the count is started; Cycle 2: The temperature rise rate continues to exceed the standard and the count is accumulated; Cycle 3: The temperature rise rate is still excessive, triggering protection and the fan runs at full speed; Cycle 4: The temperature increase rate drops to 2°C / s and the protection state is maintained; Cycle 5: The increase rate is <1°C / s, exiting the abnormal protection working mode and resuming the PID control working mode. This abnormal protection method builds a key safety line of defense while maintaining intelligent control of the system through the dual design of precise diagnosis + extreme response.
[0119] In some feasible implementations, the step S5, using the output value OUT as the high level width of PWM, periodically outputting the PWM value to drive the MOS tube switch, and then adjusting the output power of the lamp fan includes: converting the output value OUT into a duty cycle, D = (OUT / t) × 100%, t is the PWM signal period, the unit is ms, D is the duty cycle, the unit is percentage; generating a PWM signal based on the duty cycle to drive the MOS tube; controlling the fan speed by the gate voltage of the MOS tube.
[0120] In some feasible implementations, the target temperature is set to 70 degrees, the PWM output time interval is 5s, and the proportional coefficient K is p is 100, the integral coefficient K i is 10, the differential coefficient K d =10, OUT 0is 10, and the ambient temperature when the lamp is working is 55 degrees Celsius. Take the same set of sample lamps to test the lamp temperature values when the fan has PID adjustment function, the fan does not have PID adjustment function, and the fan is not working. Figure 6 As shown in the figure, it can be seen that the cooling effect of the same set of lamps when the fan is working is more obvious than when the fan is not working. The temperature of the same set of lamps with PID function is more stable than when it is not working with PID function. Based on the following table 1, the temperature reaches the set temperature of 70 degrees after PID adjustment for 30 minutes, and the temperature adjustment effect basically meets expectations.
[0121] Table 1:
[0122] Test content Fan Not Working Fan without PID regulation Fan with PID regulation Time T(min) Temperature T(℃) Temperature T(℃) Temperature T(℃) 1 55 55 55 2 59 58 59 3 63 61 63 4 66 64 66 5 69 68 69 6 72 69 72 7 75 70 74 8 77 68 76 9 79 66 76 10 81 67 75 11 83 68 76 12 84 66 74 13 84 64 74 14 85 66 74 15 86 63 73 16 85 64 73 17 84 66 72 18 86 67 73 19 87 64 72 20 85 66 71 21 84 67 71 22 87 65 70 23 85 64 71 24 86 66 71 25 86 67 70 26 84 65 70 27 85 64 71 28 87 66 70 29 85 64 70 30 86 67 70
[0123] In the above implementation, the temperature value of the lamp at this moment is obtained in real time by detecting the resistance value at both ends of the lamp temperature sensor, and the output PWM value is calculated by comparing the deviation between the target temperature and the current temperature value and the input PID parameters. The fan output power is periodically adjusted by the PWM value to perform closed-loop control of the temperature. When the lamp temperature reaches the target temperature and continues to stabilize, the lamp is stable and its fluctuation amplitude is reduced, which effectively reduces the fluctuation of the relative brightness of the LED caused by the fluctuation of the LED junction temperature, thereby improving and stabilizing the overall lighting effect of the LED lamp.
[0124] Example 2
[0125] See also Figure 7 , this embodiment provides a structural schematic diagram of a vehicle lamp temperature control system based on a PID algorithm.
[0126] As an example, the system is implemented by the vehicle lamp temperature control method based on the PID algorithm described in Example 1, and the system includes:
[0127] Controller 1, suitable for setting the target temperature value S of the lamp t , and the proportional coefficient K in the PID algorithm p , integral coefficient K i and the differential coefficient K d ; By collecting the current voltage value V of the temperature sensor placed in the car light NTC , use the preset voltage-resistance formula to calculate the current resistance value R of the headlight NTC ; According to the calculated resistance value R of the current headlight NTC , obtain the current temperature value X through the NTC resistance value and temperature value correspondence table; according to the target temperature value S t , proportionality coefficient K p , integration coefficient K i , differential coefficient K dAnd the output value OUT is obtained by the preset PID calculation formula, and the preset PID calculation formula is:
[0128] OUT=((K p ×E k )+(K i ×S k )+(K d ×D k ))+OUT 0 ;
[0129] E k =S t –X k ;
[0130] S k =E 1 +E 2 +E 3 +...+E k-2 +E k-1 +E k ;
[0131] D k =E k -E k-1 ;
[0132] In the formula, E k is the temperature deviation, X k is the temperature value sampled at the kth time, OUT 0 is the reference output, E k is the current error, S k is the cumulative error, D k is the error change rate;
[0133] The output value OUT is used as the high level width of PWM, and the PWM value is periodically output to drive the MOS tube switch, thereby adjusting the output power of the lamp fan.
[0134] The NTC thermistor temperature detection circuit 2 is suitable for real-time monitoring of the lamp temperature and converting the temperature signal into a voltage signal and outputting it to the controller.
[0135] The cooling fan driving circuit 3 is suitable for controlling the on / off and speed of the fan according to the PWM signal output by the controller, so that the temperature of the headlight reaches the target temperature value S t .
[0136] The fan 4 is adapted to rotate and dissipate heat according to the control of the heat dissipation fan driving circuit 3 .
[0137] Storage module 5, used to store the NTC resistance value and temperature correspondence table, target temperature value S t, PID parameters, PWM signal period parameter t, preset change rate threshold, integral time constant T i , sampling period T and differential time constant T d One or a combination of the following.
[0138] In some feasible implementations, the following preparations need to be done before the system starts working:
[0139] Install the NTC thermistor temperature detection circuit 2 on the lamp housing near the heat source to ensure accurate monitoring of the lamp temperature. Connect the cooling fan drive circuit 3 to the fan 4, connect the drain of the MOS tube to the positive pole of the fan power supply, the source to the ground, and the gate to the PWM output pin of the controller 1. The controller 1 uses a microcontroller with data processing and PWM signal output functions, such as the STM32 series microcontroller. The storage module 5 can use EEPROM to store the NTC resistance value and temperature correspondence table, the target temperature value S t , PID parameters, PWM signal period parameter t, preset change rate threshold, integral time constant T i , sampling period T and differential time constant T d One or a combination of the following.
[0140] It is not difficult to find that this embodiment is a system embodiment corresponding to the first embodiment, and this embodiment can be implemented in conjunction with the first embodiment. The relevant technical details mentioned in the first embodiment are still valid in this embodiment, and in order to reduce repetition, they are not repeated here. Accordingly, the relevant technical details mentioned in this embodiment can also be applied in the first embodiment.
[0141] It is worth mentioning that all modules involved in this embodiment are logical units. In practical applications, a logical unit can be a physical unit, a part of a physical unit, or a combination of multiple physical units. In addition, in order to highlight the innovative part of the present invention, this embodiment does not introduce units that are not closely related to solving the technical problem proposed by the present invention, but this does not mean that there are no other units in this embodiment.
[0142] Example 3
[0143] See also Figure 8 An embodiment of the present invention further provides an electronic device, comprising: a memory and a processor; the memory stores at least one program instruction; the processor implements the vehicle light temperature control method based on the PID algorithm provided in Example 1 by loading and executing the at least one program instruction.
[0144] The memory 702 and the processor 701 are connected in a bus manner, and the bus may include any number of interconnected buses and bridges, and the bus connects various circuits of one or more processors 701 and the memory 702 together. The bus can also connect various other circuits such as peripheral devices, voltage regulators, and power management circuits, which are well known in the art and are therefore not further described herein. The bus interface provides an interface between the bus and the transceiver. The transceiver can be one element or multiple elements, such as multiple receivers and transmitters, providing a unit for communicating with various other devices on a transmission medium. The data processed by the processor 701 is transmitted on a wireless medium via an antenna, and further, the antenna also receives data and transmits the data to the processor 701.
[0145] The processor 701 is responsible for managing the bus and general processing, and can also provide various functions, including timing, peripheral interfaces, voltage regulation, power management and other control functions. The memory 702 can be used to store data used by the processor 701 when performing operations.
[0146] Example 4
[0147] The embodiment of the present invention further provides a storage medium, on which a method for controlling the temperature of a vehicle lamp based on a PID algorithm is stored, and when the temperature control program for controlling the temperature of a vehicle lamp based on a PID algorithm is executed by a processor, the steps of the method for controlling the temperature of a vehicle lamp based on a PID algorithm as described above are implemented. Since the storage medium adopts all the technical solutions of all the above embodiments, it has at least all the beneficial effects brought by the technical solutions of the above embodiments, which will not be described one by one here.
[0148] The above is only an embodiment of the present invention. The common sense such as the known specific structure and characteristics in the scheme is not described in detail here. The ordinary technicians in the relevant field know all the common technical knowledge in the technical field of the invention before the application date or priority date, can know all the existing technologies in the field, and have the ability to apply the conventional experimental means before that date. The ordinary technicians in the relevant field can improve and implement this scheme in combination with their own abilities under the enlightenment given by this application. Some typical known structures or known methods should not become obstacles for ordinary technicians in the relevant field to implement this application. It should be pointed out that for those skilled in the art, without departing from the structure of the present invention, several deformations and improvements can be made, which should also be regarded as the scope of protection of the present invention, which will not affect the effect of the implementation of the present invention and the practicality of the patent. The scope of protection required by this application shall be based on the content of its claims, and the specific implementation methods and other records in the specification can be used to interpret the content of the claims.
Claims
1. A vehicle lamp temperature control method based on PID algorithm, characterized in that: The method comprises: Step S1, setting the target temperature value S of the lamp t , and the proportional coefficient K in the PID algorithm p , integral coefficient K i and the differential coefficient K d ; Step S2: collecting the current voltage value V of the temperature sensor placed in the car lamp NTC , use the preset voltage-resistance formula to calculate the current resistance value R of the headlight NTC ; Step S3: Based on the calculated resistance value R of the current headlight NTC , obtain the current temperature value X through the NTC resistance value and temperature value correspondence table; Step S4: according to the target temperature value S t , proportionality coefficient K p , integration coefficient K i , differential coefficient K d And the output value OUT is obtained by the preset PID calculation formula, and the preset PID calculation formula is: OUT=((K p ×E k )+(K i ×S k )+(K d ×D k ))+OUT0; E k =S t –X k ; S k =E1+E2+E3+...+E k-2 +E k-1 +E k ; D k =And k -AND k-1 ; In the formula, E k is the temperature deviation, X k is the temperature value sampled at the kth time, OUT0 is the reference output, E k is the current error, S k is the cumulative error, D k is the error change rate; Step S5, using the output value OUT as the high level width of PWM, periodically outputting the PWM value to drive the MOS tube switch, thereby adjusting the output power of the lamp fan; Step S6: Control the fan speed according to the fan output power and adjust the lamp temperature to the target temperature value S t ; Step S7: loop through steps S1-S6 to monitor and adjust the lamp temperature in real time to stabilize it at the target temperature S. t .
2. The vehicle lamp temperature control method based on PID algorithm according to claim 1, characterized in that: The step S4 further comprises: The preset PID calculation formula is: OUT=P OUT +I OUT +D OUT ; P OUT =(K p ×E k )+OUT0; I OUT =(K p ×((1 / T i )×S k ×T))+OUT0; D OUT =K p ×(T d ×D k / T)+OUT0; make: K i =K p ×((1 / T i )×T); K d =K p ×(T d / T); Where, T i is the integration time constant, T is the sampling period, T d is the differential time constant.
3. The vehicle lamp temperature control method based on PID algorithm according to claim 1, characterized in that: The voltage-resistance formula is: In NTC =3.3*R NTC / (R1+R NTC ); Where R1 is the voltage divider resistor in ohms.
4. The vehicle lamp temperature control method based on PID algorithm according to claim 3 is characterized in that: The step S2 collects the voltage value V of the temperature sensor placed in the car lamp at the current moment. NTC , use the preset voltage-resistance formula to calculate the current resistance value R of the headlight NTC include: The current resistance value R of the headlight is obtained through the NTC thermistor temperature detection circuit NTC ; The NTC thermistor temperature detection circuit includes: a power supply is connected to one end of the NTC thermistor through a third resistor R3, and the other end of the NTC thermistor is grounded to form a voltage divider circuit, which outputs the voltage value V of the temperature sensor at the current moment. NTC The inverting input terminal -IN of the operational amplifier is grounded, and the non-inverting input terminal +IN is grounded through the second capacitor C2, and is also connected to the voltage dividing node between the NTC thermistor and the third resistor R3, for obtaining the voltage signal V after the NTC thermistor voltage division. NTC ; Operational amplifier output voltage V ADC1_NTC Equal to the voltage V at the operational amplifier's non-inverting input +IN NTC , V NTC After the voltage is divided by the fourth resistor R4 and the sixth resistor R6, it enters the controller ADC1 pin, and the controller ADC1 pin reads the voltage value V ADC1_NTC , calculate the resistance value R of the NTC thermistor at this time according to the preset voltage-resistance formula NTC .
5. The vehicle lamp temperature control method based on PID algorithm according to claim 4, characterized in that: The method further includes: supplying power to the third resistor R3 and the divided voltage of the temperature sensor NTC through a voltage stabilizing circuit and providing a power supply voltage to the operational amplifier; A voltage stabilizing chip U1 is integrated in the voltage stabilizing circuit. The reference electrode of the voltage stabilizing chip U1 is connected to a voltage divider circuit node composed of a ninth resistor R9, a tenth resistor R10, an eleventh resistor R11 and a twelfth resistor R12. The output voltage of the voltage stabilizing chip U1 is set by resistor voltage division. The anode of the voltage stabilizing chip U1 is grounded, and the cathode is connected to the power supply line through the eighth resistor R8, and a 3.3V voltage is output at the same time.
6. The vehicle lamp temperature control method based on PID algorithm according to claim 1, characterized in that: The step S5, using the output value OUT as the high level width of PWM, periodically outputting the PWM value to drive the MOS tube switch, and then adjusting the output power of the lamp fan includes: The output value OUT is used as the high level width of PWM, and the output power of the lamp fan is adjusted through the cooling fan driving circuit; The cooling fan driving circuit includes a MOS tube Q1 and a diode D1. The PWM signal is connected to the gate of the MOS tube Q1 through a first resistor R1 to control the on and off of the MOS tube Q1. The pull-down resistor R2 is connected between the gate of the MOS tube Q1 and the ground. The diode D1 is reversely connected in parallel between the drain and source of the MOS tube Q1 to protect the MOS tube Q1.
7. The vehicle lamp temperature control method based on PID algorithm according to claim 1, characterized in that: The method further comprises: By setting the configurable PWM signal period parameter t, the output value OUT in step S4 is limited to be less than or equal to 0.9t.
8. The vehicle lamp temperature control method based on PID algorithm according to claim 1, characterized in that: The method further comprises: When the temperature change rate calculated for N consecutive sampling periods exceeds the preset change rate threshold, the PID control working mode is switched to the abnormal protection working mode; The abnormal protection working mode is to forcibly output a 100% duty cycle PWM signal.
9. The vehicle lamp temperature control method based on PID algorithm according to claim 1, characterized in that: The step S5, using the output value OUT as the high level width of PWM, periodically outputting the PWM value to drive the MOS tube switch, and then adjusting the output power of the lamp fan includes: The output value OUT is converted into a duty cycle, D=(OUT / t)×100%, t is the PWM signal period, in ms, and D is the duty cycle, in percentage; Generate a PWM signal based on the duty cycle to drive the MOS tube; The fan speed is controlled by the gate voltage of the MOS tube.
10. A vehicle lamp temperature control system based on PID algorithm, the system is implemented by the vehicle lamp temperature control method based on PID algorithm as claimed in any one of claims 1 to 9, characterized in that: The system comprises: Controller, suitable for setting the target temperature value S of the lamp t , and the proportional coefficient K in the PID algorithm p , integral coefficient K i and the differential coefficient K d ; By collecting the current voltage value V of the temperature sensor placed in the car light NTC , use the preset voltage-resistance formula to calculate the current resistance value R of the headlight NTC ; According to the calculated resistance value R of the current headlight NTC , obtain the current temperature value X through the NTC resistance value and temperature value correspondence table; according to the target temperature value S t , proportionality coefficient K p , integration coefficient K i , differential coefficient K d And the output value OUT is obtained by the preset PID calculation formula, and the preset PID calculation formula is: OUT=((K p ×E k )+(K i ×S k )+(K d ×D k ))+OUT0; E k =S t –X k ; S k =E1+E2+E3+...+E k-2 +E k-1 +E k ; D k =And k -AND k-1 ; In the formula, E k is the temperature deviation, X k is the temperature value sampled at the kth time, OUT0 is the reference output, E k is the current error, S k is the cumulative error, D k is the error change rate; The output value OUT is used as the high level width of PWM, and the PWM value is periodically output to drive the MOS tube switch, thereby adjusting the output power of the lamp fan; NTC thermistor temperature detection circuit is suitable for real-time monitoring of lamp temperature and converting temperature signals into voltage signals and outputting them to the controller. The cooling fan drive circuit is suitable for controlling the on / off and speed of the fan according to the PWM signal output by the controller, so that the temperature of the headlight reaches the target temperature value S t . The fan is adapted to rotate and dissipate heat according to the control of a drive circuit. Storage module, used to store the NTC resistance value and temperature correspondence table, target temperature value S t , PID parameters, PWM signal cycle parameter t, preset change rate threshold, integral time constant T i , sampling period T and differential time constant T d One or a combination of the following.