资源描述:
《超声波测距仪硬件电路的设计》由会员上传分享,免费在线阅读,更多相关内容在行业资料-天天文库。
1、超声波测距仪电路设计实验报告轮机系楼宇071周钰泉2007212117实验目的:了解超声波测距仪的原理,掌握焊接方法,掌握电路串接方法,熟悉电路元件。实验设备及器材:电烙铁,锡线,电路元件以下为元件清单:参数名称代号数量参数名称代号数量470UC111KR1,R2,R3,R4,R16,R176100uC214.7R131104C3,C42220KR141224C5,C10222KR151223C614.7KR181330PC71按键RST,S1,S2,S3,S453.3UFC81蜂鸣器SP111UFC91超声波接收管R147UFC111
2、超声波发射管T110uFC121LM7805U1130pCY1,CY2274HC245U214007D1,D2,D3,D4489S52U310.36数码管DS11CD4069/74LS04U41360ΩR5,R6,R7,R8,R9,R10,R11,R12,8CX20106AU5110K排阻PR1111.0592MY118550Q1,Q2,Q3,Q4,Q55DC电源插座P11下载头JTAG1PCB电路板1实验步骤:1,学习keil软件编写程序2、焊接电路板3、运行调试超声波测距程序:11#includeunsigne
3、dcharcodedispbitcode[]={0x31,0x32,0x34,0x38,0x30,0x30,0x30,0x30};unsignedcharcodedispcode[]={0x3f,0x06,0x5b,0x4f,0x66,0x6d,0x7d,0x07,0x7f,0x6f,0x00,0x77,0x7c,0x39};unsignedchardispbuf[8]={10,10,10,10,10,10,0,0};unsignedchardispcount;unsignedchargetdata;unsignedinttemp;un
4、signedinttemp1;11unsignedchari;sbitST=P3^0;sbitOE=P3^1;sbitEOC=P3^4;sbitCLK=P3^5;sbitM1=P3^6;sbitM2=P3^7;sbitSPK=P2^6;sbitLA=P3^3;sbitLB=P3^2;sbitLC=P2^7;sbitK1=P2^4;sbitK2=P2^5;bitwd;bityw;bitshuid;bitshuig;unsignedintcnta;unsignedintcntb;bitalarmflag;voiddelay10ms(void
5、){unsignedchari,j;for(i=20;i>0;i--)for(j=248;j>0;j--);}voidmain(void){M1=0;M2=0;yw=1;wd=0;SPK=0;ST=0;OE=0;TMOD=0x12;TH0=0x216;TL0=0x216;TH1=(65536-500)/256;TL1=(65536-500)%256;TR1=1;TR0=1;ET0=1;ET1=1;EA=1;ST=1;ST=0;while(1){if(K1==0){delay10ms();if(K1==0){yw=1;wd=0;}}els
6、eif(K2==0){delay10ms();if(K2==0){wd=1;yw=0;}}elseif(LC==1){delay10ms();if(LC==1){M1=0;M2=1;temp1=13;shuid=0;shuig=1;LB=0;}}elseif((LC==0)&&(LB==1)){delay10ms();if((LC==0)&&(LB==1)){M1=0;M2=0;temp1=12;shuig=0;shuid=0;LB=0;}11}elseif((LB==0)&&(LA==1)){delay10ms();if((LB==0
7、)&&(LA==1)){M1=1;M2=0;temp1=11;shuig=0;shuid=0;LB=0;}}elseif(LA==0){delay10ms();if(LA==0){M1=1;M2=0;temp1=0;shuid=1;shuig=0;LB=0;}}}}voidt0(void)interrupt1using0{CLK=~CLK;}voidt1(void)interrupt3using0{TH1=(65536-500)/256;TL1=(65536-500)%256;if(EOC==1){OE=1;getdata=P1;OE=
8、0;temp=getdata*25;temp=temp/64;i=2;dispbuf[0]=10;dispbuf[1]=10;dispbuf[2]=0;dispbuf[3]=0;if((yw==1)&&(w