使用两个超声与流量计的流量计

问题描述 投票:2回答:1

我正在研究一个由两个超声波,LCD和Arduino组成的项目。

超声波也用于流量测量。其背后的概念是通过第一个超声波向第二个超声波发送波,计算时间1。接下来,从第二个发送波形,第一个将接收该波形并计算时间2。

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

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

请您检查一下,如果您有代码,请给它。.

谢谢..

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

    } 
c arduino arduino-uno arduino-ultra-sonic
1个回答
0
投票

SR-04在触发时提供回波响应。这在同一模块中发生。即用trigPin1触发一个模块并用echoPin2读取另一个模块几乎带来随机且无关的结果。

触发echoPin1后读取trigPin1

SR-04可以记录在空中20厘米或更远处返回的声音。大约需要最短时间。 0.6毫秒(588ns)。对于SR-04来说,这比“没什么”。

声音在水中的传播速度比空气中的传播速度快5倍。另外,SR-04中的接收器和发射器之间的距离很小。同样,管道宽度很窄,并非为SR-04设计。

因此,如果使用1英寸宽的管子甚至将发射器和接收器放置在10厘米以外的水中,预期的返回时间约为0.1毫秒(100 ns)。这是SR-04注册功能的背后。

但是,您可能要使用TDC-GP22模块加上分开的超声波接收器和发射器以及适当的电源管理来构建自己的TOF仪表。该项目非常复杂(并且与SR-04相比并不便宜),它受益于无创液体流量测量。

© www.soinside.com 2019 - 2024. All rights reserved.