資源描述:
《遠(yuǎn)程數(shù)字電壓表.docx》由會(huì)員上傳分享,免費(fèi)在線(xiàn)閱讀,更多相關(guān)內(nèi)容在教育資源-天天文庫(kù)。
1、實(shí)訓(xùn)2遠(yuǎn)程數(shù)字電壓表班級(jí):xxxxxxxxx組員:XXX表1:?jiǎn)纹瑱C(jī)遠(yuǎn)程數(shù)字電壓表元件名類(lèi)子類(lèi)數(shù)量參數(shù)備注7SEG-MPX4-CCOptonelectronics1七段數(shù)碼管(共陰)LM331274046AT89C51Miscellaneous8051Family1單片機(jī)BUTTONSwitches&relaysSwitches1按鈕CAPCapacitorsGeneric230pF電容CAP-ELECCapacitorsGeneric122uF極性電容CRYSTALMicroprocessor112MHz晶體振蕩器RESResistorsGeneric10K電阻
2、SWITCHSwitches&relaysSwitches2開(kāi)關(guān)RESPACK-8八位電阻排POT-HG比例電位器74HC14非門(mén)數(shù)字電壓表原理圖:數(shù)字電壓表原理程序:#include#include#defineucharunsignedchar#defineuintunsignedintsfr16DPTR=0x82;bitstatus_F=1;uint,aa,qian,bai,shi,ge,bb,wan.shiwan;ucharcout;unsignedlongtemp;ucharcodetable[]={0x3f,0x
3、06,0x5b,0x4f,0x66,0x6d,0x7d,0x07,0x7f,0x6f,0x77,0x7c.0x39,0x5e,0x79,0x71};voiddelay(uintz);voidinit();voiddisplay(uintqian,uintbai,uintshi,uintge);voidxtimer0();voidxtime1();voidxint();voidmain(){P0=0xFF;init();while(1){if(aa==19){aa=0;status_F=1;TR1=0;delay(46);TR0=0;DPL=TL0;DPH=TH0;
4、temp=DPTR+cout*65535;qian=temp%10000/1000;bai=temp%1000/100;shi=temp%100/10;ge=temp%10;}display(qian,bai,shi,ge);}}voidinit(){temp=0;aa=0;cout=0;IE=0X8A;TMOD=0x15;TH1=0x3c;TL1=0xb0;TR1=1;TH0=0;TL0=0;TR0=1;}voiddisplay(uintqian,uintbai,uintshi,uintge){P0=0xf7;P2=table[qian];P2=P2
5、
6、
7、
8、80
9、delay(3);P0=0xfb;P2=table[bai];delay(3);P0=0xfd;P2=table[shi];delay(3);P0=0xfe;P2=table[ge];delay(3);}voidxtimer1()interrupt3{TH1=0x3c;TL1=0xb0;aa++;}voidxtimer0()interrupt1{cout++;}voiddelay(uintz){uinti,j;for(i=0;i