Shop OBEX P1 Docs P2 Docs Learn Events
One-Buck Ultrasonic Sensor - Page 5 — Parallax Forums

One-Buck Ultrasonic Sensor

1235»

Comments

  • ercoerco Posts: 20,244
    edited 2014-03-25 16:22
    Martin_H wrote: »
    Let's not forget that the cheapo sensors are missing the Ping)))'s most important feature. The LED that blinks when it is actively sensing! Besides being fun the LED has spared me time debugging when I simply had the Ping))) connected to the wrong pin.

    LED, shmell -ED. Tracy Allen recently pointed out that the PING's hardware timeout is 20 ms, whereas this cheap sensor's is much longer. That's critical for refreshing servos every 20 ms when there is nothing for the sensor to detect: http://forums.parallax.com/showthread.php/153735-Pulsin-Timeout-and-HC-SR04-problems?p=1244702&viewfull=1#post1244702

    Further, Tracy shares a clever RC workaround to force a shorter timeout when using these cheap sensors.
  • ercoerco Posts: 20,244
    edited 2014-08-13 16:25
    Down to $1.15 now: http://www.ebay.com/itm/New-Arduino-Ultrasonic-Module-HC-SR04-Distance-Sensor-Measuring-Transducer-HE-/400756229697

    I should have waited! Now renaming the thread to "One Buck" .
  • Ken GraceyKen Gracey Posts: 7,386
    edited 2014-08-13 16:37
    http://en.wikipedia.org/wiki/Caveat_emptor

    Buy the Ping))) and it'll work with all of our tutorials and examples without any consideration to wiring or code. And you'll have a warranty on replacement even if you blow it up.

    Remember, your hobby time is limited and it's valuable too. After you carve out your job, time for family, cleaning the house and paying bills you have your hobby so make that time effective by using the best hardware you can buy.

    Ken Gracey
  • ercoerco Posts: 20,244
    edited 2014-08-13 17:04
    No argument there, Ken!

    Another PING plus (which Parallax should promote more IMO) is that Tracy Allen tested and noted that the PING's timeout (i.e., nothing detected) is a tad under 20 seconds, which makes it perfect for supporting the 20 ms refresh rate for CR servos. The dollar sensors' timeout is longer than 20 ms and will cause servo stutter.
  • Ken GraceyKen Gracey Posts: 7,386
    edited 2014-08-13 17:54
    erco wrote: »
    No argument there, Ken!

    Another PING plus (which Parallax should promote more IMO) is that Tracy Allen tested and noted that the PING's timeout (i.e., nothing detected) is a tad under 20 seconds, which makes it perfect for supporting the 20 ms refresh rate for CR servos. The dollar sensors' timeout is longer than 20 ms and will cause servo stutter.

    I didn't know this, but now I shall bring this detail to the surface!

    Can you point me to Tracy's link? Maybe I'll be so lucky to find an oscilloscope screen shot or some proof I can use for an Insider post.

    Ken Gracey
  • ercoerco Posts: 20,244
    edited 2014-08-13 17:58
  • Hal AlbachHal Albach Posts: 747
    edited 2014-11-09 15:47
    I finally succumbed to ordering a 10 pack of these HC-SR04 ultrasonic modules. Ordered them on Oct 30 and they arrived Nov 6th, free shipping and a total cost of $12.58. I did not expect to see them before Thanksgiving. Using a BS2 program I tested each of them and found 2 that would not return a distance even though I could hear both pinging. Looked closely at the SMD parts and found one resistor skewed so that only one end was actually soldered down. Using a toothpick I gently nudged all the parts and one of the transistors, a 1F, popped off completely. I carefully soldered the parts back on and that module is now working fine. The other one had no visible problems and all the SMD's were tight. Chalking that up as a DOA. BTW, has anyone else noticed that two of the three IC's have their ID info sanded off?
    I then set about setting them up to only require one I/O pin. With the BS2 it was easy using the setup on one of Erco's earlier posts. I/O pin direct to the Trigger and a 1.8K resister between Trigger and Echo. Worked like a charm. I found that I could use a resistor as high as 3.3K without any problems. When I went for 4.7K all I got were zeros.
    Then I turned to making these units use 1 pin from the Propeller, since the bot I'm building will have 5 of these for obstacle avoidance. Using the circuit provided by Alex Stanfield in post # 108 I was successful in mating the propeller to the SR04 with one pin. When I looked at the pin with my scope I saw that the Echo part of the signal was barely making it to 2 Volts, so I reduced the 10K resistor to 3.3K and now the Echo shows 3 Volts. I tried various objects at various distances and always received a good, steady reading. The program I'm using is C with simpleide. I just included ping.h and used the function call;
    cmDist = ping_cm(10);
    and display the data on an LCD. I'm including a pic of the scope trace, vertical is 1 Volt/div and horizontal is 0.5 ms/div. The trigger pulse is barely visible at the left and the positive pulse is the Echo from an object 50 cm away.
    I also quickly fabricated a prototype mount for the pingers out of wood. Used a small sheet of 1/4" poplar board, cut two 5/8" slots about half an inch down and rounded out the bottom with a Dremel drum sander. Then glued a base to it so I can screw it down on the bot.
    EDIT: Taking a closer look at the scope measurements it appears that after the 10us trigger pulse there is about a 450us delay before the Echo pin goes high to start the measurement, seems like plenty of time to get the I/O pin into input mode.



    2014-11-09 17.26.36.jpg
    2014-11-09 17.37.27.jpg
    2014-11-09 17.40.19.jpg
    1024 x 1024 - 129K
    1024 x 1024 - 99K
    1024 x 1024 - 114K
  • ercoerco Posts: 20,244
    edited 2014-11-09 17:32
    Great work, Hal, thanks for the very helpful info and documentation. :)
  • Duane DegnDuane Degn Posts: 10,588
    edited 2014-11-09 19:01
    Ditto to erco's thanks. Very useful information.
  • ercoerco Posts: 20,244
    edited 2015-01-05 17:40
    Hal Albach wrote: »
    I/O pin direct to the Trigger and a 1.8K resister between Trigger and Echo. Worked like a charm. I found that I could use a resistor as high as 3.3K without any problems.

    I was beating my head against the wall earlier today hooking up two of these sensors to a PicAxe (yeah, I know, serves me right). I assumed Hal's resistor range was OK for all processors. I didn't have any 1.8K resistors, so I used 2.2K. My rapid-fire sonar readings were mostly good, but at least once per second, there was a hiccup and the sensor returned a maximum timeout reading, which glitched my servos badly. Wasted an hour trying different code routines, then I swapped resistors to 1.7K (1.5K + 220R) and all was right with my data stream again.

    Note to self: buy some 1.8K resistors for that drawerful of ultrasonic sensors!

    Note to self #2: "Drawerful" blows spell check's mind. Use it daily to confound the computer network and possibly stave off Judgment day for another year or two.
  • RDL2004RDL2004 Posts: 2,554
    edited 2015-01-06 05:29
    erco wrote: »
    Note to self #2: "Drawerful" blows spell check's mind. Use it daily to confound the computer network and possibly stave off Judgment day for another year or two.

    Wow, I would have bet money that "drawerful" was incorrectly spelled (my spell checker doesn't like it either), but I checked and that is indeed the right way to spell it.
  • mindrobotsmindrobots Posts: 6,506
    edited 2015-01-06 08:18
    Interesting response to the varied resistor values by a different processor.
    erco wrote: »

    Note to self #2: "Drawerful" blows spell check's mind. Use it daily to confound the computer network and possibly stave off Judgment day for another year or two.

    More interesting response to "drawerful" - Firefox doesn't like it, Word doesn't like it but my iPhone has no problem with it and Pages has no problem with it.

    Firefox does accept "dwarfer" while both Apple products support the political correctness of discussing vertically challenged people with proper terms by rejecting that word.

    Just more junk food for thought!
  • mkeydiluffymkeydiluffy Posts: 4
    edited 2015-02-09 11:00
    Thanks for your help. I bought the HY-SRF05 sensor, below I put the code I've tried and it work quite well .

    ' {$STAMP BS2}
    ' {$PBASIC 2.5}
    ' HY-SR05 ultrasonic sensor mode 1 usage
    ' P11 to trigger
    ' P10 echo


    DO
    Range VAR Word ' define the 16 bit range variable
    LOW 11 ' start with pin low
    PULSOUT 11, 10 ' issue 10uS trigger pulse (5 x 2uS)
    PULSIN 10, 1, Range ' measure echo time
    Range = Range/29 ' convert to cm (divide by 29)

    DEBUG HOME, "distancia = ", DEC5 Range ,"cm"
    PAUSE 100
    LOOP


    I hope someone will be helpful
  • ercoerco Posts: 20,244
    edited 2015-02-09 16:52
    Welcome, mkeydiluffy. Glad to hear you got it working in standard 2-pin mode. Now try the one-pin mode, put a 1.8K resistor between trigger and echo, and use one I/O pin to trigger. Save a pin every chance you get!
  • macrobeakmacrobeak Posts: 353
    edited 2015-02-09 17:31
    Erco,
    While you are sourcing and investigating ultrasonic sensors, don't forget to look for cheap underwater sensor devices!
    There seem to be many expensive closed source ultrasonic underwater sensors but I have not come across any cheap open source devices like the air based PING/SR02 etc
  • ercoerco Posts: 20,244
    edited 2015-02-09 20:18
  • mkeydiluffymkeydiluffy Posts: 4
    edited 2015-02-10 06:15
    erco wrote: »
    Welcome, mkeydiluffy. Glad to hear you got it working in standard 2-pin mode. Now try the one-pin mode, put a 1.8K resistor between trigger and echo, and use one I/O pin to trigger. Save a pin every chance you get!

    Thx for you message, i will do it this afternoon, is a good advice for to use only one pin I/O. Sorry for my english writing im spanish and try to write myself without the help translator.

    One question, how i connect a resistor between trigger and echo? if in the connection of the mode 1, i see that the pin echo has to be free.
    Maybe the infomation of conexion about the mode 1 it not be good. I connect Vcc +5v, trigger pin I/O, echo whitout connection, OUT Vss(0v) and GND too.
  • ErnestErnest Posts: 1
    edited 2015-04-12 10:10
    Hello,
    there are a lot of different versions of extremely cheap „rebuilds“ of the HC-SR04 from china.
    They all have the same arrangement of piezo-transmitter, piezo-receiver and connectors.
    They differ in R's, C's and their placements on the board. Some even don't have a quartz.
    But the most important difference is the firmware, the program in the microcontroller.
    Most of these versions are working. In our project with schools we got three lots.
    a) 15 pieces with an error in the firmware using a "never-ending polling for a never coming echo"
    b) 20 pieces (no quartz ) with absolutely unsufficent sensivity and
    c) 20 pieces for 0.98 EUR = 1.05 $ per piece (without separate transistors on board) working properly.

    Lot a) After sending the ultrasonic bursts to an object outside the detection range they wait in an endless loop for a response and ignore further triggers. A first way out is a short metallic tap to the receiver. Then short distances could be measured until you have a too far object . . . .
    A curious strategy may cure this erroneous behavior: When there is no answer before timeout, then switch off the power for the HC-SR04 and repower it after a short delay.
    My modifications: Connect the Vcc-pin of the sensor with the collector of an additional pnp-Transistor. Connect the emitter of this transistor with the 5V of the arduino board and the base of this transistor via an 1k resistor to an additional controlPin. LOW at the controlPin switches the power on, HIGH switches off. A short HIGH pulse by a digitalWrite( controlPin, HIGH ) directly followed by a digitalWrite( controlPin, LOW ) is enough to reset the ultrasonic sensor. This reset must be done whenever the output of the functions ping() or pulseIn() is 0.
    So this software initiated hardware reset ends the infinite polling of the firmware in the controller.
    This strategy was successful for 14 sensors. The 15th needed a delay(1).

    Lot b) These sensors were not able to detect a reflected signal from a hand in 35 cm distance.
    The maximum distance of a hard reflecting medium was about 120 cm. I suppose unsufficient correlation between transmitted frequence and bandpass frequence due to tolerances of the used chip capacitors. The result of my analysis will be presented later.
    Of course the low price will limit my amount of time for modifications.
  • mkeydiluffymkeydiluffy Posts: 4
    edited 2015-05-01 03:16
    Ernest wrote: »
    Hello,
    there are a lot of different versions of extremely cheap „rebuilds“ of the HC-SR04 from china.
    They all have the same arrangement of piezo-transmitter, piezo-receiver and connectors.
    They differ in R's, C's and their placements on the board. Some even don't have a quartz.
    But the most important difference is the firmware, the program in the microcontroller.
    Most of these versions are working. In our project with schools we got three lots.
    a) 15 pieces with an error in the firmware using a "never-ending polling for a never coming echo"
    b) 20 pieces (no quartz ) with absolutely unsufficent sensivity and
    c) 20 pieces for 0.98 EUR = 1.05 $ per piece (without separate transistors on board) working properly.

    Lot a) After sending the ultrasonic bursts to an object outside the detection range they wait in an endless loop for a response and ignore further triggers. A first way out is a short metallic tap to the receiver. Then short distances could be measured until you have a too far object . . . .
    A curious strategy may cure this erroneous behavior: When there is no answer before timeout, then switch off the power for the HC-SR04 and repower it after a short delay.
    My modifications: Connect the Vcc-pin of the sensor with the collector of an additional pnp-Transistor. Connect the emitter of this transistor with the 5V of the arduino board and the base of this transistor via an 1k resistor to an additional controlPin. LOW at the controlPin switches the power on, HIGH switches off. A short HIGH pulse by a digitalWrite( controlPin, HIGH ) directly followed by a digitalWrite( controlPin, LOW ) is enough to reset the ultrasonic sensor. This reset must be done whenever the output of the functions ping() or pulseIn() is 0.
    So this software initiated hardware reset ends the infinite polling of the firmware in the controller.
    This strategy was successful for 14 sensors. The 15th needed a delay(1).

    Lot b) These sensors were not able to detect a reflected signal from a hand in 35 cm distance.
    The maximum distance of a hard reflecting medium was about 120 cm. I suppose unsufficient correlation between transmitted frequence and bandpass frequence due to tolerances of the used chip capacitors. The result of my analysis will be presented later.
    Of course the low price will limit my amount of time for modifications.

    Hello Ernest, thanks for you comment. Can you answer me some question?, How you connect the sensors? in mode 1 or 2?, and which programming language do you use?.

    I wait your answer. Thanks again
  • My Local inporter has them in stock in Chicago. $2.10 each

    I don't know how they can make this stuff so cheap.

    http://www.valuehobby.com/arduino-and-cnc/ultrasonic-ranging-module-hc-sr04.html

  • ercoerco Posts: 20,244
    edited 2015-10-28 04:09
    jdolecki wrote: »
    I don't know how they can make this stuff so cheap.

    I'm pretty sure they are factory seconds, maybe failed QC tests. Quality and range vary widely. I have modified many for 1-pin use. Some are OK, some (maybe 20%) just don't work at all. I just toss them, it's not worth troubleshooting. Hmmm... diet coke or two ultrasonic sensors? Tough call some days!

  • ercoerco Posts: 20,244
    A 5-pack of sensors for $4.19, less than a 6-pack of PBR. Each providing a different and necessary kind of fun.

    http://www.ebay.com/itm/5pcs-Ultrasonic-Module-HC-SR04-Distance-Measuring-Transducer-Sensor-for-Arduino/301877065006



  • xanaduxanadu Posts: 3,347
    edited 2017-08-12 02:24
    I have a couple of the waterproof version - http://www.ebay.com/itm/Ultrasonic-Module-Distance-Measuring-Transducer-Sensor-Waterproof-JSN-SR04T/262136734027

    Has anyone tried the 2.0?

    I have some of the non-waterproof and they work great. The operating parameters are similar. The waterproof won't return an echo pulse.

  • According to this page the 2.0 requires a pullup on TX/echo.

    http://artofcircuits.com/product/jsn-sr04t-2-0-water-proof-ultrasonic-module-distance-measuring-sensor

    All is well :)
  • xanaduxanadu Posts: 3,347
    edited 2017-08-12 03:07
    FYI the trimpot on the board is to calibrate the distance measured. Maybe not, it seemed to work for a couple of mm. I wonder if it adjusts the modulation to eliminate crosstalk between modules.
  • ercoerco Posts: 20,244
    edited 2017-09-02 17:17
    New self-contained $14 module with LED display (0-400cm) and adjustable min/max trigger output signals.

    http://www.ebay.com/itm/New-Ultrasonic-Motion-Detector-Sensor-Module-Security-Non-contact-Display-Board-/261432834516

    s-l500.jpg
  • xanadu wrote: »
    I have a couple of the waterproof version - http://www.ebay.com/itm/Ultrasonic-Module-Distance-Measuring-Transducer-Sensor-Waterproof-JSN-SR04T/262136734027

    Has anyone tried the 2.0?

    I have some of the non-waterproof and they work great. The operating parameters are similar. The waterproof won't return an echo pulse.

    I had a similar requirement for waterproof ultrasonic sensor but JSN SR04T 2.0 has a blind distance of around 20cm due to single transducer.

    I instead opted for this https://ebay.com/itm/253978673298 which has 2 transducers instead of 1 therefore smaller blind distance and looks completely sealed from all sides.
Sign In or Register to comment.