Difference between revisions of "Ultrasonic Range Sensor"
Katherine.d (talk | contribs) |
Katherine.d (talk | contribs) |
||
(4 intermediate revisions by the same user not shown) | |||
Line 35: | Line 35: | ||
== Interface Definitions == | == Interface Definitions == | ||
− | [[File:ursinter.jpg]] | + | [[File:ursinter.jpg | 400px]] |
{|class="wikitable" border="1" | {|class="wikitable" border="1" | ||
Line 57: | Line 57: | ||
| Ground | | Ground | ||
|} | |} | ||
+ | |||
+ | == Schematic == | ||
+ | |||
+ | == Dimensions == | ||
+ | [[File:ursdimensions1.jpg | 400px]] | ||
+ | |||
+ | [[File:ursdimensions2.jpg | 400px]] | ||
+ | |||
+ | == 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''' | ||
+ | |||
+ | [[File:sonictiming.jpg | 400px]] | ||
+ | |||
+ | === 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 [http://creativecommons.org/licenses/by-sa/3.0/ Attribution-ShareAlike License 3.0] Source code and libraries are licensed under [http://www.gnu.org/licenses/gpl.html GPL/LGPL], see source code files for details. |
Latest revision as of 06:48, 30 December 2012
Contents
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.
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
PIN | Function |
---|---|
1 VCC | Power Source |
2 ECHO | Signal Output |
3 TRIG | Trigger Signal Input |
4 NC | No Connection |
5 GND | Ground |
Schematic
Dimensions
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
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.