Ultrasonic Range Sensor

From LinkSprite Playgound
Jump to: navigation, search

Introduction

SRF04 ultrasonic distance sensor provides non-contact distance sensing function in the range of 3cm ~ 400cm with accuracy up to 0.3mm. This module has a stable performance, high distance measurement accuracy, and compact-size, and it’s simple and easy to use.

URS1.jpg

URS2.jpg

Specfication

Product Model SRF-04
Operational Voltage DC 5V
Static Current 2mA
Working Frequency 40Hz
Distance Measurement Range 3cm – 400cm
Measurement Angle 15°
Measurement Accuracy 0.3mm
Output Voltage H – 5V L – 0V

Interface Definitions

Ursinter.jpg

PIN Function
1 VCC Power Source
2 ECHO Signal Output
3 TRIG Trigger Signal Input
4 NC No Connection
5 GND Ground

Schematic

Dimensions

Ursdimensions1.jpg

Ursdimensions2.jpg

Notes

(1) This module should not be connected with power on, and if it’s necessary to do this, the module GND pin should be connected to ground first. Otherwise the module may not be able to work properly.

(2) When measuring distance, the area of the object should not be less than 0.5 square meters, and its surface need to be smooth enough. Otherwise it will affect the measurement results.

Application

Operational Principle of Module

  • (1) Use the IO (TRIG) to trigger the distance measurement, and the trigger need provide at least 10us of high level signal.
  • (2) The module automatically sends eight 40kHz square waves, and automatically detects whether a signal is returned.
  • (3) If a signal is returned, a high level signal will be output through the IO (ECHO) pin, and the high level time is equal to the interval between emitting ultrasonic wave and receiving the returned signal. The distance calculation formula is as below. (The suggested measurement cycle is greater than 60ms, in order to avoid the transmission signal's impact on the returned signal.)

Distance (unit: m) = high-level voltage time (unit: s) * speed of sound (340 m/s) / 2

or

Distance (unit: mm) = high-level voltage time (unit: us) / 58

or

Distance (unit: inch) = high-level voltage time (unit: us) / 148

Ultra Sonic Timing Diagram

Sonictiming.jpg

Arduino Duemilanove Example Codes

<syntaxhighlight lang="c"> const int pingPin = 7; const int start_signal = 8; void setup() {

 Serial.begin(9600);

} void loop() {

 long duration, inches, cm;
 pinMode(pingPin, OUTPUT);
 pinMode(start_signal, OUTPUT);
 digitalWrite(start_signal, HIGH);
 delayMicroseconds(20);
 digitalWrite(start_signal, LOW);
 digitalWrite(pingPin, LOW);
 delayMicroseconds(2);
 digitalWrite(pingPin, HIGH);
 delayMicroseconds(5);
 digitalWrite(pingPin, LOW);
 pinMode(pingPin, INPUT);
 duration = pulseIn(pingPin, HIGH);
 inches = microsecondsToInches(duration);
 cm = microsecondsToCentimeters(duration);  
 Serial.print(inches);
 Serial.print("in, ");
 Serial.print(cm);
 Serial.print("cm");
 Serial.println(); 
 delay(80);

} long microsecondsToInches(long microseconds) {

 return microseconds / 74 / 2;

} long microsecondsToCentimeters(long microseconds) {

 return microseconds / 29 / 2;

} </syntaxhighlight>

FAQ

Please list your question here:


Support

Resources

How to buy

See Also

Other related products and resources.


Licensing

This documentation is licensed under the Creative Commons Attribution-ShareAlike License 3.0 Source code and libraries are licensed under GPL/LGPL, see source code files for details.