您的位置:首页 > 游戏 > 手游 > 电子烟开发【恒压、恒有效算法】

电子烟开发【恒压、恒有效算法】

2024/11/17 15:44:14 来源:https://blog.csdn.net/weixin_47321452/article/details/139347726  浏览:    关键词:电子烟开发【恒压、恒有效算法】

恒压算法

pwm是通过软件模拟的 pwm满值运行是250全占空比

#define D_TARGET_AVERAGE_VOLTAGE  3500
//R_ADC1_Vout 	:发热丝两端AD值
//R_ADC_FVR 	:电池电压AD值
//FVR_VOLTAGE 	:电池AD参考电压 满电值AD
//R_Smk1Duty  	:最后得出的占空比
void CAL1_ConstantVoltage(void)
{R_Temp32 = (vu32)D_TARGET_AVERAGE_VOLTAGE * 250 * R_ADC_FVR;	//电压* duty =3.5V;		R_Temp32 = R_Temp32 / R_ADC1_Vout;R_Temp32 = R_Temp32/FVR_VOLTAGE;if(R_Temp32 > 250) R_Smk1Duty = 250;else	R_Smk1Duty = R_Temp32 & 0xff;
}

恒有效值表对应AD值

AD值 = (功率 * 负载阻值 * (电池参考电压)^2 ) 开方
=SQRT(A9988988B9)
=SQRT(A9
10001000B9)
在这里插入图片描述

恒有效算法

//VoltageTab 	:恒有效对应输出功率AD值
//R_Power_Num	:输出的功率 1-30W
//R_ADC1_Vout 	:发热丝两端AD值
//R_ADC_FVR 	:电池电压AD值
//FVR_VOLTAGE 	:电池AD参考电压 满电值AD
//R_Smk1Duty  	:最后得出的占空比
const vu16 VoltageTab[31] = {0,// 699 ,988 ,1210,1397,1562,1711,1848,1976,2096,2209,		//1-10w -0.5R// 2317,2420,2519,2614,2706,2794,2880,2964,3045,3124,		//11-20w -0.5R// 3201,3277,3350,3423,3493,3562,3630,3697,3762,3827		//21-30w -0.5R699 ,988 ,1210,1397,1562,1711,1848,1976,2096,2079,		//1-10w -0.5R2190,2300,2400,2500,2585,2664,2730,2814,2900,2985,		//11-20w -0.5R3061,3137,3210,3285,3353,3562,3630,3697,3762,3827		//21-30w -0.5R};void ConstantValidVoltage(void)
{R_Temp32 = (vu32)R_ADC_FVR * VoltageTab[R_Power_Num];R_Temp32 = R_Temp32 / R_ADC1_Vout;R_Temp32 = R_Temp32 << 8;R_Temp32 = R_Temp32 / FVR_VOLTAGE;R_Temp32 = R_Temp32 * R_Temp32;R_Temp32 = R_Temp32 >> 8;if (R_Temp32 > 250)R_Smk1Duty = 250;elseR_Smk1Duty = R_Temp32 & 0xff;
}

定时器处理

此函数8ms打开一次mos管 一个占空比周期为8ms 通过控制Timer2定时器去关mos实现调整mos管输出占空比实现调整发热丝输出

	SMOKE1_MOS_ON; 
//定时器2 通道1R_Smk1Duty_Valid = ((vu16)R_Smk1Duty + R_Smk1Duty_Valid) >> 1;	// re-initial TIMER2// re-initial TIMER2PR2H = R_Smk1Duty_Valid >> 7;PR2L = (R_Smk1Duty_Valid & 0x7F) << 1;TMR2H = 0;TMR2L = 0;TMR2IF = 0;TMR2IE = 1;

中断函数处理

//低优先级中断服务函数
void interrupt low_priority ISR_l (void)
{if(TMR2IE == 1 && TMR2IF == 1)     //一个PWM周期关MOS时间到;{                    TMR2IF = 0;CMP1IE = 0;//关比较器中断TMR2IE = 0;//禁止中断SMOKE1_MOS_OFF;}
}

版权声明:

本网仅为发布的内容提供存储空间,不对发表、转载的内容提供任何形式的保证。凡本网注明“来源:XXX网络”的作品,均转载自其它媒体,著作权归作者所有,商业转载请联系作者获得授权,非商业转载请注明出处。

我们尊重并感谢每一位作者,均已注明文章来源和作者。如因作品内容、版权或其它问题,请及时与我们联系,联系邮箱:809451989@qq.com,投稿邮箱:809451989@qq.com