已知水塔深度的话 做减法 水塔深度未知的话 这种方式水塔有水的情况下测量不到水塔深度的 |
做一个相减就行 |
其实可以用共阴极的数码管来显示,而且电路图几乎跟你一样,不用到锁存器。 求黑币,求黑币,求黑币!!!! #include<reg51.h> #include<intrins.h> #define uint unsigned int #define uchar unsigned char sbit c=P2^0; // sbit b=P2^1; sbit a=P2^2; sbit d=P2^3; sbit trig=P2^4; sbit echo=P2^5; uint time=0; uint timer=0; uchar posit=0; unsigned long s=0; bit flag =0; unsigned char code WE0[]={0x3f,0x06,0x5b,0x4f,0x66,0x6d,0x7d,0x07,0x7f,0x6f}; //uchar temp[3]; //测距接收缓冲区 void delay(uint z) { uchar x,y; for(x=z;x>0;x--) for(y=110;y>0;y--); } void display() //显示函数 { a=1,b=0,c=0,d=0; P0=WE0[s/100]; delay(25); P0=0x00; a=0,b=1,c=0,d=0; P0=WE0[s%100/10]; delay(25); P0=0x00; a=0;b=0;c=1;d=0; P0=WE0[s%100%10]; delay(25); P0=0x00; } void time0() interrupt 1 { flag=1; } void StartModule() //启动模块 { trig=1; //启动一次模块 _nop_(); _nop_(); _nop_(); _nop_(); _nop_(); _nop_(); _nop_(); _nop_(); _nop_(); _nop_(); _nop_(); _nop_(); _nop_(); _nop_(); _nop_(); _nop_(); _nop_(); _nop_(); _nop_(); _nop_(); _nop_(); _nop_(); //delay(20000); trig=0 ; } void count() { time=TH0*256+TL0; TH0=0; TL0=0; s=(time*1.7)/100; //算出来是CM display(); } void main() { TMOD=0x01; //设T0、T1为方式1,GATE=1; TH0=0; TL0=0; ET0=1; //允许T0中断 EA=1; // uint z; //开启总中断 while(1) { StartModule(); while(!echo); //当UL_RX为零时等待 TR0 = 1; //开启计数 while(echo); //当UL_RX为1计数并等待 TR0 = 0; count(); } } |
可以用一个连通器,测得就准了 |
超声波测水位严重不准,测水上漂浮物还可以。 |
先测一个空池深度,然后用池深减去你的测量值,最后显示剩下的数就是水深。 |
实地测试了吗,超声波遇到水面反射的多吗,能测准吗 |
解决的怎么样了,手绘原理图很漂亮. |