資源描述:
《測(cè)頻率膜厚儀程序.doc》由會(huì)員上傳分享,免費(fèi)在線閱讀,更多相關(guān)內(nèi)容在教育資源-天天文庫(kù)。
1、此文檔收集于網(wǎng)絡(luò),如有侵權(quán),請(qǐng)聯(lián)系網(wǎng)站刪除#include#include#defineuintunsignedint#defineucharunsignedcharsignedlongcount=0;signedlonghoud,fq;signedlongk1,k2,k3;inti=0,x=0;sbitP2_4=P2^4;sbitRS=P2^5;sbitRW=P2^6;sbitE=P2^7;//數(shù)字ASCII碼放在數(shù)組中//unsignedintshu[]={0x30,0x31,0x32,
2、0x33,0x34,0X35,0x36,0x37,0x38,0x39};unsignedintshu1[]={0x30,0x31,0x32,0x33,0x34,0X35,0x36,0x37,0x38,0x39};voiddelay(intcount)//延時(shí){intp;while(count--)for(p=0;p<110;p++);}voidwrite_com(unsignedintn)//寫(xiě)指令{RS=0;P1=n;delay(5);E=1;delay(5);E=0;}voidwrite_data(unsignedcha
3、rt)//寫(xiě)數(shù)據(jù){此文檔僅供學(xué)習(xí)與交流此文檔收集于網(wǎng)絡(luò),如有侵權(quán),請(qǐng)聯(lián)系網(wǎng)站刪除RS=1;P1=t;delay(5);E=1;delay(5);E=0;}voidtime1_int(void)interrupt3{TH1=TL1=0;TR1=1;x++;}voidtime0_int(void)interrupt1{TH0=(65535-50000)/256;//裝初值,定時(shí)50msTL0=(65535-50000)%256;i++;if(i==20)//1s時(shí)間已到{i=0;TR1=0;//關(guān)閉計(jì)數(shù)器1count=(6553
4、6*x+256*TH1+TL1)*1000;x=0;此文檔僅供學(xué)習(xí)與交流此文檔收集于網(wǎng)絡(luò),如有侵權(quán),請(qǐng)聯(lián)系網(wǎng)站刪除if(k1==1){fq=2.65;}elseif(k2==1){fq=2.7;}elseif(k3==1){fq=3.97;}houd=0.123*(6000000-count)/fq;TH1=TL1=0;//重新裝初值TR1=1;//重新啟動(dòng)計(jì)數(shù)器器}}voidshow(){write_com(0x85);write_data(shu[count/100000]);delay(5);//顯示十萬(wàn)位write_
5、com(0x86);write_data(shu[(count/10000)%10]);delay(5);//顯示萬(wàn)位write_com(0x87);write_data(shu[(count/1000)%10]);delay(5);//顯示千位write_com(0x88);write_data(shu[(count/100)%10]);delay(5);//顯示百位write_com(0x89);write_data(shu[(count/10)%10]);delay(5);//顯示十位write_com(0x8a);w
6、rite_data(shu[count%10]);delay(5);//顯示個(gè)位write_com(0x83);write_data(0x66);delay(5);//顯示頻率表示的字符f此文檔僅供學(xué)習(xí)與交流此文檔收集于網(wǎng)絡(luò),如有侵權(quán),請(qǐng)聯(lián)系網(wǎng)站刪除write_com(0x84);write_data(0x3d);delay(5);//顯示字符=write_com(0x8b);write_data(0x48);delay(5);//顯示字母Hwrite_com(0x8c);write_data(0x7a);delay(5);
7、//顯示字母zwrite_com(0xc5);write_data(shu1[houd/100000]);delay(5);//顯示十萬(wàn)位write_com(0xc6);write_data(shu1[(houd/10000)%10]);delay(5);//顯示萬(wàn)位write_com(0xc7);write_data(shu1[(houd/1000)%10]);delay(5);//顯示千位write_com(0xc8);write_data(shu1[(houd/100)%10]);delay(5);//顯示百位writ
8、e_com(0xc9);write_data(shu1[(houd/10)%10]);delay(5);//顯示十位write_com(0xca);write_data(shu1[houd%10]);delay(5);//顯示個(gè)位write_com(0xc3);write_data(0x6