先贴程序,
uchar shuzi[10]={0123456789};
void dianliu(uint zen,uint fu)//输出电流
{uchar i;
uint zen1=(20000*zen)/4096;
uint fu1=(20000*fu)/4096;
for(i=0;i<2;i++)
{if(i==1)zen1=fu1;
xianshi((i*4),105,13,3,shuzi[(zen1/10000)]);
xianshi((i*4),119,13,3,shuzi[(zen1%10000)/1000]);
xianshi((i*4),136,13,3,shuzi[(zen1%1000)/100]);
xianshi((i*4),150,13,3,shuzi[(zen1%100)/10]);
xianshi((i*4),164,13,3,shuzi[(zen1%10)]);
}
}
void dianya(uint zen,uint fu)//输出电压
{ uchar i;
uint zen1=(50000*zen)/4096;
uint fu1=(50000*fu)/4096;
for(i=0;i<2;i++)
{if(i==1)zen1=fu1;
xianshi((i*4),18,13,3,shuzi[(zen1/10000)]);
xianshi((i*4),32,13,3,shuzi[(zen1%10000)/1000]);
xianshi((i*4),49,13,3,shuzi[(zen1%1000)/100]);
xianshi((i*4),63,13,3,shuzi[(zen1%100)/10]);
xianshi((i*4),77,13,3,shuzi[(zen1%10)]);
}
}
void ytdl(uint tlz,uint tlf) //预调电流
{uchar i;
tlz=(20000*tlz)/4096;
tlf=(20000*tlf)/4096;
for(i=0;i<2;i++)
{if(i==1)tlz=tlf;
xianshi((3+i*4),85,6,1,xiaoshu[(tlz/10000)]);
xianshi((3+i*4),92,6,1,xiaoshu[(tlz%10000)/1000]);
xianshi((3+i*4),101,6,1,xiaoshu[(tlz%1000)/100]);
xianshi((3+i*4),108,6,1,xiaoshu[(tlz%100)/10]);
xianshi((3+i*4),115,6,1,xiaoshu[(tlz%10)]);
}
}
void gonglv(uint v,uint I,uchar i)//功率显示,
{uint w;
w=(v*I*50000*20000)/(1000*4096*4096);
xianshi(3+i,133,6,1,xiaoshu[(w/100000)]);
xianshi(3+i,140,6,1,xiaoshu[(w%100000)/10000]);
xianshi(3+i,147,6,1,xiaoshu[(w%10000)/1000]);
xianshi(3+i,154,6,1,xiaoshu[(w%1000)/100]);
xianshi(3+i,163,6,1,xiaoshu[(w%100)/10]);
xianshi(3+i,170,6,1,xiaoshu[(w%10)]);
}
void main()
{uint h,m,zen2,fu2,yty,ytl,dl1,dl2;
zen2=0xe54;
fu2=0xe43;
yty=0xe54;
ytl=0x800;
dl1=0x802;
dl2=0x0b0;
CLI();
dytz(yty,fu2);//调整的电压输出显示
ytdl(ytl,ytl);//调整的电压输出显示
gonglv(zen2,dl1,0);//功率的输出显示
}
问题是这样的,电流和电压输出显示函数,程序只相差一个字,电压函数处理时,是uint zen1=(50000*zen)/4096; 电流处理是uint zen1=(20000*zen)/4096;但输出结果电压输出是对的,比如,处理0Xe54,得到结果44.775V,但是把这个数值放到电流函数里面,输出结果就是00.0013A,把uint zen1=(20000*zen)/4096;,换成uint zen1=(40000*zen)/4096;结果也是对的,为什么更换这个数值会对结果产生这么大的影响。
另外,功率处理函数结果也不对,不敢却定是电流结果影响了,所以还没找到原因。大侠们帮我看看,是什么原因。
|