Difference between revisions of "Ultrasonic Module"

From Wiki
Jump to: navigation, search
(Resource)
(Experimental Procedures For Arduino)
 
(10 intermediate revisions by the same user not shown)
Line 1: Line 1:
=='''Introduction'''==
+
 
<font color="blue">An upgraded ultrasonic module – improved properties and performance in various aspects</font>
+
<font color="blue">An upgraded ultrasonic module – improved properties and performance in various aspects</font><br>
 
[[File:Ultrasonic .jpg]] <br>
 
[[File:Ultrasonic .jpg]] <br>
Ultrasonic ranging module HC - SR04 provides 2cm - 700cm non-contact measurement function, the ranging accuracy can reach to 3mm. The modules includes ultrasonic transmitters, receiver and control circuit. The basic principle of work: <br>
+
Ultrasonic ranging module HC - SR04 provides 2cm - 700cm non-contact measurement function, the ranging accuracy can reach to 3mm.Ensured stable signal within 5m, gradually faded signal outside 5m till disappearing at 7m position.<br>
 +
The modules includes ultrasonic transmitters, receiver and control circuit. The basic principle of work: <br>
 
(1) Using IO trigger for at least 10us high level signal;<br>
 
(1) Using IO trigger for at least 10us high level signal;<br>
 
(2) The Module automatically sends eight 40 kHz and detect whether there is a pulse signal back. <br>
 
(2) The Module automatically sends eight 40 kHz and detect whether there is a pulse signal back. <br>
Line 39: Line 40:
  
 
=='''Pricinple'''==
 
=='''Pricinple'''==
The Timing diagram is shown below. You only need to supply a short 10uS pulse to the trigger input to start the ranging, and then the module will send out an 8 cycle burst of ultrasound at 40 kHz and raise its echo. The Echo is a distance object that is pulse width and the range in proportion .You can calculate the range through the time interval between sending trigger signal and receiving echo signal. Formula: uS / 58 = centimeters or uS / 148 =inch; or: the range = high level time * velocity (340M/S) / 2; we suggest to use over 60ms measurement cycle, in order to prevent trigger signal to the echo signal.
+
The Timing diagram is shown below. You only need to supply a short 10uS pulse to the trigger input to start the ranging, and then the module will send out an 8 cycle burst of ultrasound at 40 kHz and raise its echo. The Echo is a distance object that is pulse width and the range in proportion .You can calculate the range through the time interval between sending trigger signal and receiving echo signal. Formula: uS / 58 = centimeters or uS / 148 =inch; or: the range = high level time * velocity (340M/S) / 2; we suggest to use over 60ms measurement cycle, in order to prevent trigger signal to the echo signal.<br>
 
[[File:Cha.png]]
 
[[File:Cha.png]]
  
<font color="red">'''Note:'''
+
=='''Test Code'''==
If you want to test in a 500cm+ distance, you need to change the NewPing library, which defines the maximum distance (i.e. 500cm). You can set it as 700 or higher. it is as shown in follwing:<font>
+
 
<pre>
 
<pre>
#define MAX_SENSOR_DISTANCE 710
+
#include <Wire.h>
 +
#include <LiquidCrystal_I2C.h>
 +
 
 +
#define Echo 11 //Echo connnect to pin11
 +
#define Trig 12 //Trig connect to pin12
 +
unsigned long rxTime; //define a variable
 +
float distance;
 +
LiquidCrystal_I2C lcd(0x27,16,2);
 +
void setup()
 +
{
 +
  // put your setup code here, to run once:
 +
  Serial.begin(115200); //set the baud rate of serial monitor
 +
  pinMode(Echo,INPUT);
 +
  pinMode(Trig,OUTPUT);
 +
  lcd.init();                      // initialize the lcd
 +
 
 +
  // Print a message to the LCD.
 +
  lcd.backlight(); //turn o the backlight
 +
  lcd.setCursor(0, 0); //set the cursor on 0 row,0 col
 +
  lcd.print("Ping:"); //print the "Ping: "on the LCD
 +
}
 +
 
 +
void loop()
 +
{
 +
  // Generates a pulse
 +
  digitalWrite(Trig, HIGH);
 +
  delayMicroseconds(10);
 +
  digitalWrite(Trig, LOW);
 +
  rxTime = pulseIn(Echo, HIGH); //read the Receive time
 +
  //  Serial.print("rxTime:");
 +
  //  Serial.println(rxTime);
 +
  distance = (float)rxTime * 34 / 2000.0; //Converted into a distance ,cm
 +
  if(distance < 800 ) //filter interference signal
 +
  {
 +
    Serial.print("distance:");
 +
    Serial.print(distance); //print it the distance in serial monitor
 +
    Serial.println("CM");
 +
    lcd.setCursor(6, 0);
 +
    lcd.print(distance);//print it in LCD1602
 +
    lcd.print("CM");
 +
    delay(100);
 +
  }
 +
}
 
</pre>
 
</pre>
 +
 
=='''Resource'''==
 
=='''Resource'''==
[http://www.sunfounder.com/wiki/index.php?title=File:NewPing.zip NewPing library][[File:ZIP.jpg]]<br>
+
[http://wiki.sunfounder.cc/images/9/95/Ultrasonic.zip Test Code][[File:ZIP.jpg]]<br>
[http://www.sunfounder.com/wiki/index.php?title=File:MAX232_DataSheet.pdf MAX232_DataSheet][[File:PDF.jpg]]<br>
+
[http://wiki.sunfounder.cc/images/f/f1/MAX232_DataSheet.pdf MAX232_DataSheet][[File:PDF.jpg]]<br>
[http://www.sunfounder.com/wiki/index.php?title=File:SGM324YS14.pdf SGM324YS14 datasheet][[File:PDF.jpg]]
+
[http://wiki.sunfounder.cc/images/b/ba/SGM324YS14.pdf SGM324YS14 datasheet][[File:PDF.jpg]]

Latest revision as of 08:38, 11 September 2019

An upgraded ultrasonic module – improved properties and performance in various aspects
Ultrasonic .jpg
Ultrasonic ranging module HC - SR04 provides 2cm - 700cm non-contact measurement function, the ranging accuracy can reach to 3mm.Ensured stable signal within 5m, gradually faded signal outside 5m till disappearing at 7m position.
The modules includes ultrasonic transmitters, receiver and control circuit. The basic principle of work:
(1) Using IO trigger for at least 10us high level signal;
(2) The Module automatically sends eight 40 kHz and detect whether there is a pulse signal back.
(3) IF the signal back, through high level , time of high output IO duration is the time from sending ultrasonic to returning. Test distance = (high level time×velocity of sound (340M/S) / 2.

Pin Function

TRIG: Trigger Pulse Input
ECHO: Echo Pulse Output
GND: Ground
VCC: 5V Supply

Features

Working Voltage DC5V
Working Current 16mA
Working Frequency 40Hz
Max Range 700cm, Ensured stable signal within 5m, gradually faded signal outside 5m till disappearing at 7m position.
Min Range 2cm
Trigger Input Signal 10uS TTL pulse
Echo Output Signal Input TTL lever signal and the range in proportion
Dimension 46x20.5x15 mm

Pricinple

The Timing diagram is shown below. You only need to supply a short 10uS pulse to the trigger input to start the ranging, and then the module will send out an 8 cycle burst of ultrasound at 40 kHz and raise its echo. The Echo is a distance object that is pulse width and the range in proportion .You can calculate the range through the time interval between sending trigger signal and receiving echo signal. Formula: uS / 58 = centimeters or uS / 148 =inch; or: the range = high level time * velocity (340M/S) / 2; we suggest to use over 60ms measurement cycle, in order to prevent trigger signal to the echo signal.
Cha.png

Test Code

#include <Wire.h>
#include <LiquidCrystal_I2C.h>

#define Echo 11 //Echo connnect to pin11
#define Trig 12 //Trig connect to pin12
unsigned long rxTime; //define a variable
float distance; 
LiquidCrystal_I2C lcd(0x27,16,2);
void setup() 
{
  // put your setup code here, to run once:
  Serial.begin(115200); //set the baud rate of serial monitor
  pinMode(Echo,INPUT);
  pinMode(Trig,OUTPUT);
  lcd.init();                      // initialize the lcd

  // Print a message to the LCD.
  lcd.backlight(); //turn o the backlight
  lcd.setCursor(0, 0); //set the cursor on 0 row,0 col
  lcd.print("Ping:"); //print the "Ping: "on the LCD
}

void loop()
{
  // Generates a pulse
  digitalWrite(Trig, HIGH);
  delayMicroseconds(10);
  digitalWrite(Trig, LOW);
  rxTime = pulseIn(Echo, HIGH); //read the Receive time
  //  Serial.print("rxTime:");
  //  Serial.println(rxTime);
  distance = (float)rxTime * 34 / 2000.0; //Converted into a distance ,cm
  if(distance < 800 ) //filter interference signal
  {
    Serial.print("distance:");
    Serial.print(distance); //print it the distance in serial monitor
    Serial.println("CM");
    lcd.setCursor(6, 0);
    lcd.print(distance);//print it in LCD1602
    lcd.print("CM");
    delay(100);
  }
}

Resource

Test CodeZIP.jpg
MAX232_DataSheetPDF.jpg
SGM324YS14 datasheetPDF.jpg