交流信號測量儀 作者: 時間:2016-11-29 來源:網(wǎng)絡(luò) 加入技術(shù)交流群 掃碼加入和技術(shù)大咖面對面交流海量資料庫查詢 收藏 void main(){uint i;ulong v=0;ulong av;uint hz;bit flag=0;ulong t1=0,t2=0;lcd_init();write_com(0x84);for(i=0;i<7;i++){write_data(xian[i]);DelayNS(2); }write_com(0x80+0x40);for(i=0;i<15;i++){write_data(xian1[i]);DelayNS(2); }DelayNS(1000); DelayNS(1000); timer_init();write_com(0x01);while(1){if(count==40){count=0;EX0=0;ET0=0;TR0=0;t1=100000000/mt;tab[0]=t1/1000+0x30;tab[1]=t1%1000/100+0x30;tab[2]=0x2e;tab[3]=t1%1000%100/10+0x30;tab[4]=t1%1000%100%10+0x30; //周期顯示十位tab[5]=0x48;tab[6]=0x7a;hz=t1/100;t=1000000/(50*hz)+100;TH1=65536-t/256;TL1=65535-t%256;t2=mt/10;tab2[0]=t2/1000+0x30;tab2[1]=t2%1000/100+0x30;tab2[2]=0x2e;tab2[3]=t2%1000%100/10+0x30;tab2[4]=t2%1000%100%10+0x30;tab2[5]=0x6d;tab2[6]=0x73; ET1=1;TR1=1;}if(count1==80) {ET1 = 0;TR1 = 0;count1=0;v=(vmax+1)*196/100;tab3[4]=0x56;tab3[3]=(v%100)%10+0x30;tab3[2]=(v%100)/10+0x30; tab3[1]=0x2e;tab3[0]=v/100+0x30;vs=vs*0.0195*0.0195;av=(sqrt(vs/50))*100;tab4[4]=0x56;tab4[3]=(av%100)%10+0x30;tab4[2]=(av%100)/10+0x30; tab4[1]=0x2e;tab4[0]=av/100+0x30;if((v/sqrt(2)-av)>25){tab4[7]=0x32;}else{tab4[7]=0x31;}av=0;flag=1;}if(flag==1){flag=0;write_com(0x80);for(i=0;i<7;i++){write_data(tab[i]);DelayNS(2); }write_com(0x80+0x09);for(i=0;i<7;i++){write_data(tab2[i]);DelayNS(2); }write_com(0x80+0x40);for(i=0;i<5;i++){write_data(tab3[i]);DelayNS(20);}write_com(0x80+0x47);for(i=0;i<8;i++){write_data(tab4[i]);DelayNS(20);}//write_com(0x80+0x54);//write_data(tab4[7]);//DelayNS(20);vmax=0;EX0=1;}}}void ex0() interrupt 0{ count++;if(count%2==0){ET0=1;TR0=1;TH0=0;TL0=0;}else{ET0=0;TR0=0;mt=TH0*256+TL0; }}void timer0() interrupt 1 //測頻率時計時{ TH0=0;TL0=0;}void timer1() interrupt 3 //控制AD轉(zhuǎn)換{uint data1;count1++;OE = 0;START = 0;_nop_();START = 1;_nop_(); START = 0; while(EOC==0); OE = 1; _nop_();data1 = P0;_nop_();OE = 0;if(data1>vmax){vmax=data1;}if(count1<=52){vs=vs+data1*data1;}TH1=65536-t/256;TL1=65535-t%256;} 上一頁 1 2 下一頁
評論