这里是主程序部分:
void main ( )
{
currentup_flag = 0;
currentdown_flag = 0;
currentup=1;
currentdown=1;
LCD_Ini
tial();
value_save=100.0;
while (1)
{
static unsigned char i=0;
if (i==20)
{
i=0;
ADValue= ADC0808_init();
ADC=ADValue*5.0/256; //转换5V为参考电压
Volt=ADC*45.0;//计算输出电压
ADValue1= ADC0808_1init();
ADC1=ADValue1*5.0/256; //转换5V为参考电压
Current=ADC1*24.0;//计算输出电流
}
else i++;
current_save();
if(Current>=value_save)
{
lamp = 0;
Al
ARM(100);
}
//if(Current<value_save)
else
{
lamp = 1;
}
//液晶显示
GotoXY(0,0) ;
Print("Voltage:");
sprintf(buffer,"%.2f",Volt);
Print(buffer);
GotoXY(0,1) ;
Print("Current:");
sprintf(buffer,"%.2f",Current);
Print(buffer);
}
}
是不稳定吗?
ADC=ADValue*5.0/256; //转换5V为参考电压
Volt=ADC*45.0;//计算输出电压
ADValue1= ADC0808_1init();
ADC1=ADValue1*5.0/256; //转换5V为参考电压
Current=ADC1*24.0;//计算输出电流
那就是这里计算的问题,第一:必须是float,这个应该知道吧。第二:计算小数点比如5.00
一周热门 更多>