void delayms(unsigned int ms)
{
unsigned char i;
while (ms--)
{
for (i = 0; i < 114; i++)
;
}
}
void show_value(unsigned int ad_data)
{
aa = ad_data * 1.2207;
bb=aa/1000;
cc=aa%1000/100;
dd=aa%1000%100/10;
ee=aa%1000%100%10;
P2=0xfe;
P0=table[ee];
delayms(3) ;
P2=0xfd;
P0=table1[dd];
delayms(3);
P2=0xfb;
P0=table[cc];
delayms(3);
P2=0xf7;
P0=table[bb];
delayms(3);
}
void main()
{
unsigned int test,i;
double rin; // PID 输入
Proportion = 1; // 设定PID值
Integral = 1;
Derivative = 0;
SetPoint = 200;
// PID输出值 // 设定控制目标值
init();
while(1)
{
receivebuf[0] =0;
receivebuf[0] = ADConverOneChannel(0);//AD转换的值付给receibebuf[0]
show_value(receivebuf[0]);
}
}
void T0_time() interrupt 1
{
TH0=(65536-45872)/256;
TL0=(65536-45872)%256;
num++;
if(num==20)
{
num=0;
}
}
void T1_time() interrupt 3
{
// double T;
// rout=T;
TH1=(65536-45872)/256;
TL1=(65536-45872)%256;
temp++;
if (temp==20)
{
KW=1; //电炉加热,P1^3给高电平
}
else if(temp==300)
{
KW=0;
delayms(5000);
temp=0 ;
}
}
|