作业帮 > 综合 > 作业

为什么用超声波测距离的时候,测得很不准?尤其在近距离时

来源:学生作业帮 编辑:作业帮 分类:综合作业 时间:2024/10/06 18:51:14
为什么用超声波测距离的时候,测得很不准?尤其在近距离时
#include
#include
#define uint unsigned int
#define uchar unsigned char
uchar code table[]="0123456789.m";
uchar code table1[]="too far";
uchar code table2[]="the distance is:";
uchar code table3[]="please wait";
sbit lcden=P2^0;
sbit lcdrs=P2^1;
sbit trig=P2^2;
sbit echo=P3^2;
uint succeed;
float t,d,timeh,timel;
uint distance;
void delay(uint z)
{
uint x,y;
\x05for(x=z;x>0;x--)
\x05 for(y=110;y>0;y--);
}
void delay20us()
{
_nop_();_nop_();_nop_();_nop_();_nop_();_nop_();_nop_();_nop_();_nop_();_nop_();
\x05_nop_();_nop_();_nop_();_nop_();_nop_();_nop_();_nop_();_nop_();_nop_();_nop_();
}
\x05\x05\x05\x05
\x05\x05\x05\x05 void display( )
\x05\x05\x05\x05 {
\x05\x05\x05\x05 uchar i;
\x05\x05\x05\x05 init();\x05 //1602初始化
\x05\x05\x05\x05 \x05 write_com(0x80);
\x05\x05\x05\x05\x05\x05\x05\x05 for(i=0;i
误差源于声速的不准确和声波传播时间的记录误差,声速跟空气的温度有关,传播时间记录跟仪器的精度有关.声波接受设备的水平线性也对结果有一定影响.
再问: 与同学一起测试时,他的准确(程序不一样)
再答: 多测几次。修改程序