Pages: [1]   Go Down
Author Topic: Distance Sensor  (Read 1472 times)
0 Members and 1 Guest are viewing this topic.
Offline Offline
Newbie
*
Karma: 0
Posts: 7
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

I'm looking for a distance sensor that can reliably measure if someone is within about 10 ft of it.  A digital proximity sensor might work too, if I can pretty reliably change its max distance by playing with the input voltage.  Cheap is the name of the game here, but it does need to work.  I've been looking at the HC-SR04, but a couple of commenters said it only worked for them up to ~60 cm, while others said it worked up and beyond 10ft.  Any suggestions?  -- I'm looking at ultrasound because I will be using it at school where there are several Wi-Fi hotspots and a ham radio club, I don't know how much noise this'll cause an IR sensor.

I will be using this in a lab where the space directly in front of the sensor will be clear for at least 20 ft, but there will be some tables to the side.  I was thinking maybe I could put some kind of tube around the sensor to narrow it's detection width.  Something like a toilet paper roll or a disassembled flashlight tube.  Do you think this'll work or will it be likely to always go off because it's reading the tube?
Logged

Global Moderator
Netherlands
Offline Offline
Shannon Member
*****
Karma: 216
Posts: 13664
In theory there is no difference between theory and practice, however in practice there are many...
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset


check - http://www.acroname.com/robotics/info/articles/sharp/sharp.html -

to handle the mapping of the (non linear) curve I wrote - http://arduino.cc/playground/Main/MultiMap -

Logged

Rob Tillaart

Nederlandse sectie - http://arduino.cc/forum/index.php/board,77.0.html -
(Please do not PM for private consultancy)

Global Moderator
Netherlands
Offline Offline
Shannon Member
*****
Karma: 216
Posts: 13664
In theory there is no difference between theory and practice, however in practice there are many...
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset


or these - http://www.pololu.com/catalog/category/78 - (given your distance of 10 feet)
Logged

Rob Tillaart

Nederlandse sectie - http://arduino.cc/forum/index.php/board,77.0.html -
(Please do not PM for private consultancy)

Offline Offline
Newbie
*
Karma: 0
Posts: 7
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Does anyone have any experience they'd like to share before I buy the MB1040 LV-MaxSonar-EZ4, then?  From what I can tell it supposedly detects large objects (hopefully a person is large enough) up to 6.45m away over a width of about 0.6m from the center of the beam.  Does this seem about right?
Logged

Ontario, Ohio
Offline Offline
Full Member
***
Karma: 1
Posts: 208
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

for people detection, you probably want the ez-0 or ez-1. But they aren't reliable for people detection. You would be better off buying a cheap ultrasonic sensor and try teckel's newping library.

http://code.google.com/p/arduino-new-ping/
Logged

Toledo, OH
Offline Offline
God Member
*****
Karma: 36
Posts: 510
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

I'm looking for a distance sensor that can reliably measure if someone is within about 10 ft of it.  A digital proximity sensor might work too, if I can pretty reliably change its max distance by playing with the input voltage.  Cheap is the name of the game here, but it does need to work.  I've been looking at the HC-SR04, but a couple of commenters said it only worked for them up to ~60 cm, while others said it worked up and beyond 10ft.  Any suggestions?  -- I'm looking at ultrasound because I will be using it at school where there are several Wi-Fi hotspots and a ham radio club, I don't know how much noise this'll cause an IR sensor.

I will be using this in a lab where the space directly in front of the sensor will be clear for at least 20 ft, but there will be some tables to the side.  I was thinking maybe I could put some kind of tube around the sensor to narrow it's detection width.  Something like a toilet paper roll or a disassembled flashlight tube.  Do you think this'll work or will it be likely to always go off because it's reading the tube?

The HC-SR04 works up to about 450-500cm.  Those that only work to 60cm are broken.  Don't make your decision based on a couple people with poorly sourced or broken sensors.  Using my NewPing library you should get good results even with a $2 eBay ultrasonic sensor from China.  But, I would suggest paying a little more and get one from Amazon as you'll get it much faster and if there's a problem you can send it back.

Tim
Logged

Arduino - Teensy - Raspberry Pi
My libraries: NewPing - LCDBitmap - toneAC - NewTone - TimerFreeTone

Offline Offline
Newbie
*
Karma: 0
Posts: 7
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Thanks.
Logged

Offline Offline
Newbie
*
Karma: 0
Posts: 7
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Alright, I just got in the HC-SR04.  And, as I feared, I'm not getting enough range.  I used the example you package with your NewPing library ("NewPingExample") with MAX_DISTANCE changed to 5000 and an if statement so that it'd only display the range if it was greater than the range that was displayed before (so I didn't just have tons of data constantly shooting across the serial monitor).  The max range I got (and only if I stood still in front of the sensor so that it could measure the range several times) was about 150cm.  I need the sensor to go off with a person walking toward it at normal (or slightly slower than normal) walking speed at about twice that range.
So should I try a different sensor?  Do I need an amplifier?
Logged

Toledo, OH
Offline Offline
God Member
*****
Karma: 36
Posts: 510
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

Alright, I just got in the HC-SR04.  And, as I feared, I'm not getting enough range.  I used the example you package with your NewPing library ("NewPingExample") with MAX_DISTANCE changed to 5000 and an if statement so that it'd only display the range if it was greater than the range that was displayed before (so I didn't just have tons of data constantly shooting across the serial monitor).  The max range I got (and only if I stood still in front of the sensor so that it could measure the range several times) was about 150cm.  I need the sensor to go off with a person walking toward it at normal (or slightly slower than normal) walking speed at about twice that range.
So should I try a different sensor?  Do I need an amplifier?

First, you can't set MAX_DISTANCE to 5000cm.  The max you ever need to set that to is 500cm as that's the maximum distance the sensor is able to read.  Setting it to 5000 will give you a much longer delay and possible problems if you're trying to ping frequently.  You should set MAX_DISTANCE to either 500 or the maximum distance you care about, but never more than 500.

I also believe you're making things too complicated for testing.  Use this sketch:

Code:
#include <NewPing.h>

#define TRIGGER_PIN  12  // Arduino pin tied to trigger pin on the ultrasonic sensor.
#define ECHO_PIN     11  // Arduino pin tied to echo pin on the ultrasonic sensor.

NewPing sonar(TRIGGER_PIN, ECHO_PIN); // NewPing setup of pins and maximum distance.

void setup() {
  Serial.begin(115200); // Open serial monitor at 115200 baud to see ping results.
}

void loop() {
  delay(35);                      // Wait 35ms between pings.
  unsigned int uS = sonar.ping(); // Send ping, get ping time in microseconds (uS).
  if (uS != NO_ECHO) {
    Serial.print("Ping: ");
    Serial.print(uS / US_ROUNDTRIP_CM); // Convert ping time to distance and print result (0 = outside set distance range, no ping echo)
    Serial.println("cm");
  }
}

Don't use pin 13 or a pin with an LED on the main board (pins 11 and 12 are safe if you're using an Arduino Uno).  Point it in a direction where there's nothing within around 17 feet and start the serial monitor.  Then, starting in front of the sensor, walk away till you're 17 feet away.  Flank the beam and review the results.

Tim
Logged

Arduino - Teensy - Raspberry Pi
My libraries: NewPing - LCDBitmap - toneAC - NewTone - TimerFreeTone

Pages: [1]   Go Up
Jump to: