首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >arduino双超声波流量计

arduino双超声波流量计
EN

Stack Overflow用户
提问于 2016-03-06 13:17:13
回答 1查看 2.4K关注 0票数 3

我正在从事一个项目,其中包括两个超声波,液晶显示器和Arduino。

超声波也可用于流速测量。这背后的概念是通过第一个超声波向第二个超声波发送波,计算time1。接下来,从第二个发送将被第一个接收的波,并计算time2。

如果没有流,则time1必须等于time2。但我不确定我的arduino代码是否正确,因为它没有向我显示真实的结果。

这是concept http://www.universalmetering.co.uk/images/mobile/ultrasonic-diagram.gif

你能检查一下吗?如果你有代码,请给我..

谢谢..

代码语言:javascript
复制
LiquidCrystal LCD(11,10,9,2,3,4,5); 
//Create Liquid Crystal Object called LCD 
#define trigPin1 12 #define echoPin1 13 
#define trigPin2 8 
#define echoPin2 7
//Simple program just for testing the HC-SR04 Ultrasonic Sensor with LCD dispaly //URL: 

void setup()
{ 
  pinMode(trigPin1, OUTPUT);
  pinMode(echoPin1, INPUT);
  pinMode(trigPin2, OUTPUT);
  pinMode(echoPin2, INPUT);
  LCD.begin(16,2); 
  //Tell Arduino to start your 16 column 2 row LCD 
  LCD.setCursor(0,0); //Set LCD cursor to upper left corner, column 0, row 0
  LCD.print("Difference in time:"); //Print Message on First Row 

 }


  void loop() 
  { 
    long duration1, duration2, diff;
    digitalWrite(trigPin1, LOW);
     delayMicroseconds(2); 
    digitalWrite(trigPin1, HIGH);
    delayMicroseconds(10);
    digitalWrite(trigPin1, LOW); 
    duration1 = pulseIn(echoPin2, HIGH);

    digitalWrite(trigPin2, LOW);
     delayMicroseconds(2); 
    digitalWrite(trigPin2, HIGH);
    delayMicroseconds(10);
    digitalWrite(trigPin2, LOW);
    duration2 = pulseIn(echoPin1, HIGH);
    diff = (duration2) - (duration1);
    LCD.setCursor(0,1); //Set cursor to first column of second row 
    LCD.print(" "); //Print blanks to clear the row
    LCD.setCursor(0,1); //Set Cursor again to first column of second row
    LCD.print(diff); //Print measured distance 
    LCD.print(" sec"); //Print your units.
    delay(250); //pause to let things settle

    } 
EN

回答 1

Stack Overflow用户

发布于 2020-02-29 17:28:50

SR-04在触发时提供回声响应。这发生在同一个模块中。也就是说,用trigPin1触发一个模块,用echoPin2读取另一个模块,结果几乎是随机的,也是无关的。

触发trigPin1后读取echoPin1

SR-04可以记录在空气中返回20厘米或更远距离的声音。它需要最短的时间,大约是。0.6ms (588)。对于SR-04来说,低于这个值就是“没有”。

声音在水中的传播速度比在空气中快5倍左右。此外,在SR-04中,接收器和发送器之间的距离很小。此外,管道宽度很窄,不是为SR-04设计的。

因此,如果你把发射器和接收器放在10厘米远的地方,使用1英寸宽的管道,在水中的预期返回时间大约是0.1ms (100 is )。这是SR-04注册功能的背后。

但是,您可能想要建立自己的飞行时间计,使用TDC-GP22模块,加上分离的超声波接收器和发射器,以及适当的电源管理。这是一个相当复杂的项目(而且不像SR-04那样便宜),它得益于非侵入性的液体流量测量。

票数 1
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/35823423

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档