I’m using the HY-SRF05 (the one from Upgrade Industries sold by robot-electronics,) which I bought because they stated it is supposed to time out and it doesn’t time out. I contacted their (the manufacturer, Upgrade Industries) support to find out what’s happening and here’s what i sent them:
I’ve been having a problems with a lot of the common SRF04 and SRF05 Ultrasonic rangers, and in this case I’m using the HY-SRF05. I thought this one might operate better than the others because the datasheet indicates that if nothing is detected, the sensor will time out after 30 ms
(This is the one I’m referring too, but there are many other similar ones out there)
“If nothing is detected then the SRF05 will lower its echo line anyway after about 30mS.”
So that means this sensor could range about 20 times in a second. The problem I’m seeing is that it’s take over 200ms for the sensor to time out when no object is detected. It’s a very easy to reproduce problem, just point the sensor at nothing, and attach a scope to the echo pin and the trigger pin, then trigger on the scope on the trigger pin and watch as the echo pin goes high and doesn’t come back down for 200ms.
Do you know if there could be any odd error in the code below? I’ve tried many of these sensors, they all behave the same way but the data sheet for this and even other brands indicates they should be able to return low around 30-40ms after no object is detected.
I’ve attached copies of the scope output, the echo pin is on Channel 4, and the measurements at the bottom show the “Width” of the pulse in the dark blue color.
The easy way around this problem is to read the echo pin after the pulse times out and make sure you don’t try to trigger if it’s still high, if you don’t set a timeout, I’ve found so far that all of them eventually do come back, but the amount of time it takes to return is variable within a range depending on the particular device.
For example, this Hy-SRF05 is around 220ms (it varies about 20ms either way) and other brands I’ve tested come in at 180ms and 200ms. I’ve tried dozens of these from many vendors, and I have yet to find one that properly times out. Hy-SRF05 was my biggest hope too, but even their sensor behaves the same way.
Of course I don’t want to only be able to Scan 4 times a second, and it seems when the sensor is past the 50ms mark, it won’t retrigger for any reason unless it receives a pulse from another sensor or it reaches the 200ms (or whatever the range for that model is) mark.