LED light bar brightness and color temperature adjustment

Generally, the LED light bar is powered by 12V or 24V and is driven by a constant voltage. Since the current limiting resistor is embedded in the LED light bar, there is no need to use complex constant current measures. To adjust the color temperature and brightness of the LED light bar, the MOS tube can be switched on and off by PWM.

 Positive white 4000~4500K or warm white 3000~3500K

1. Constant current hardware circuit

2. MOS control circuit

 

 3 Software implementation: In the general way, PWM is output as shown in the figure below. However, if the MOS tube is used for control, there will be a problem. If the power adapter is 12V 1A, the output of the A and B channels is the largest at the same time, and the current is 2A.

There will be two situations. The maximum current of the power adapter is limited and cannot be supplied, so the voltage drop makes the device unable to work. The power adapter has no current limit, and 2A current is drawn by the device, so the adapter is overloaded and heats up, and there is a risk of burning.

4. Improvement: 2 PWM for complementary output.

Software code

A与B二组灯带,无极切换,循环变色

#define ConPwmPeriod	 594  //PWM周期
//
//参数为色温的PWM的duty值以及亮度的百分比值
void TiaoGuang(u16 ColdData,u8 LumData)
{

	u16 tmp0,tmp1,tmp2;
    u16  duty1,duty2;

		tmp2 = ColdData;             //色温冷光比例  
		tmp1 =ConPwmPeriod -tmp2;    //计算暖光值
		//
        tmp0 = LumData;              //亮度比例
		//
		//暖光duty1
		duty1= tmp1*tmp0/100;        //SW_DUTY * LD_DUTY / GRADE 
		
		//冷光duty2
		duty2= ConPwmPeriod-tmp2*tmp0/100;
		//
		PWM_IndependentModeConfig(PWM1,duty1);//暖光
		PWM_IndependentModeConfig(PWM4,duty2);//冷光
		PWMAllON();
}

 

 

 

 

Guess you like

Origin blog.csdn.net/u013830926/article/details/115369073