超声波测距仪硬件电路的设计
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();
dispbuf[0]=10;
dispbuf[1]=10;
dispbuf[2]=0;
dispbuf[3]=0;
if((yw==1)&&(wd==0))
{
dispbuf[++i]=temp1;
}
else if((yw==0)&&(wd==1))
{while(temp/10)
{
dispbuf[i]=temp/10;
unsigned char code dispcode[]={0x3f,0x06,0x5b,0x4f,0x66, 0x6d,0x7d,0x07,0x7f,0x6f,0x00,0x77,0x7c,0x39};
unsigned char dispbuf[8]={10,10,10,10,10,10,0,0};
CY1, CY2
2
74HC245
U2
1
4007
D1, D2, D3, D4
4
89S52
U3
1
0.36数码管
DS1
1
CD4069/74LS04
U4
1
360Ω
R5, R6, R7, R8, R9, R10, R11, R12,
8
CX20106A
U5
1
10K排阻
PR1
1
11.0592M
Y1
1
8550
Q1, Q2, Q3, Q4, Q5
{
cnta++;
if(cnta==800)
{
cnta=0;
alarmflag=~alarmflag;
}
if(alarmflag==1)
{
SPK=~SPK;
}
}
else if((shuig==0) && (shuid==1))
{
cntb++;
if(cntb==400)
{
cntb=0;
alarmflag=~alarmflag;
sbit M1=P3^6;
sbit M2=P3^7;
sbit SPK=P2^6;
sbit LA=P3^3;
sbit LB=P3^2;
sbit LC=P2^7;
sbit K1=P2^4;
sbitK2=P2^5;
bit wd;
bit yw;
bit shuid;
bit shuig;
unsigned int cnta;
else if((LC==0) && (LB==1))
{
delay10ms();
if((LC==0) && (LB==1))
{
M1=0;
M2=0;
temp1=12;
shuig=0;
shuid=0;
LB=0;
}
}
else if((LB==0) && (LA==1))
{
delay10ms();
if((LB==0) && (LA==1))
1
4.7
R13
1
104
C3, C4
2
220K
R14
1
224
C5, C10
2
22K
R151223C6 Nhomakorabea1
4.7K
R18
1
330P
C7
1
按键
RST, S1, S2, S3, S4
5
3.3UF
C8
1
蜂鸣器
SP1
1
1UF
C9
1
超声波接收管
R
1
47UF
C11
1
超声波发射管
T
1
10uF
C12
1
LM7805
U1
1
30p
unsigned int cntb;
bit alarmflag;
void delay10ms(void)
{
unsigned char i,j;
for(i=20;i>0;i--)
for(j=248;j>0;j--);
}
void main(void)
{
M1=0;
M2=0;
yw=1;
wd=0;
SPK=0;
if(K1==0)
{
yw=1;
wd=0;
}
}
else if(K2==0)
{
delay10ms();
if(K2==0)
{
wd=1;
yw=0;
}
}
else if(LC==1)
{
delay10ms();
if(LC==1)
{
M1=0;
M2=1;
temp1=13;
shuid=0;
shuig=1;
LB=0;
}
}
unsigned char dispcount;
unsigned char getdata;
unsigned int temp;
unsigned int temp1;
unsigned char i;
sbit ST=P3^0;
sbit OE=P3^1;
sbit EOC=P3^4;
sbit CLK=P3^5;
超声波测距仪
轮机系楼宇071周钰泉2007212117
实验目的:了解超声波测距仪的原理,掌握焊接方法,掌握电路串接方法,熟悉电路元件。
实验设备及器材:电烙铁,锡线,电路元件
以下为元件清单:
参数
名称代号
数量
参数
名称代号
数量
470U
C1
1
1K
R1, R2, R3, R4, R16, R17
6
100u
C2
temp=temp%10;
}
dispbuf[++i]=temp;
}
ST=1;
ST=0;
}
P0=dispcode[dispbuf[dispcount]];
P2=dispbitcode[dispcount];
dispcount++;
if(dispcount==8)
{
dispcount=0;
}
if((shuig==1) && (shuid==0))
{
CLK=~CLK;
}
void t1(void) interrupt 3 using 0
{
TH1=(65536-500)/256;
TL1=(65536-500)%256;
if(EOC==1)
{
OE=1;
getdata=P1;
OE=0;
temp=getdata*25;
temp=temp/64;
i=2;
5
DC电源插座
P1
1
下载头
JTAG1
PCB电路板
1
实验步骤:1,学习keil软件编写程序2、焊接电路板3、运行调试
超声波测距程序:
#include <AT89X52.H>
unsigned char code dispbitcode[]={0x31,0x32,0x34,0x38,0x30,0x30,0x30,0x30};
{
M1=1;
M2=0;
temp1=11;
shuig=0;
shuid=0;
LB=0;
}
}
else if (LA==0)
{
delay10ms();
if(LA==0)
{
M1=1;
M2=0;
temp1=0;
shuid=1;
shuig=0;
LB=0;
}
}
}
}
void t0(void) interrupt 1 using 0