资源描述:
《远程数字电压表.docx》由会员上传分享,免费在线阅读,更多相关内容在教育资源-天天文库。
1、实训2远程数字电压表班级:xxxxxxxxx组员:XXX表1:单片机远程数字电压表元件名类子类数量参数备注7SEG-MPX4-CCOptonelectronics1七段数码管(共阴)LM331274046AT89C51Miscellaneous8051Family1单片机BUTTONSwitches&relaysSwitches1按钮CAPCapacitorsGeneric230pF电容CAP-ELECCapacitorsGeneric122uF极性电容CRYSTALMicroprocessor112MHz晶体振荡器RESResistorsGeneric10K电阻
2、SWITCHSwitches&relaysSwitches2开关RESPACK-8八位电阻排POT-HG比例电位器74HC14非门数字电压表原理图:数字电压表原理程序:#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