Netduino home hardware projects downloads community

Jump to content


The Netduino forums have been replaced by new forums at community.wildernesslabs.co. This site has been preserved for archival purposes only and the ability to make new accounts or posts has been turned off.
Photo

Library for HC_SR04 Ultrasonic Rangefinder


  • Please log in to reply
27 replies to this topic

#21 rjstoner

rjstoner

    New Member

  • Members
  • Pip
  • 1 posts

Posted 30 May 2013 - 11:44 PM

The code works perfectly.  Thank you very much!



#22 Chuckles

Chuckles

    Advanced Member

  • Members
  • PipPipPip
  • 40 posts

Posted 14 June 2013 - 02:21 AM

This looks really cool.

Could 4 sensors be connected to a single Netduino Plus 2? I am thinking of using a set to collect simultaneous data at the same time; 4 are lined up within 1" of each other, pointing at the sky, and when something rolls over each one, the Datetime could be saved/displayed for each acquisition.



#23 stimphy

stimphy

    New Member

  • Members
  • Pip
  • 1 posts
  • LocationOmaha

Posted 31 July 2013 - 04:04 AM

This is awesome, thanks so much for sharing!



#24 yasasri

yasasri

    New Member

  • Members
  • Pip
  • 1 posts

Posted 27 September 2013 - 05:09 PM

Someone might find this code useful. I found these HC SR04 ultrasonic rangefinders on amazon for $15 but they had no code. I found some Arduino code, but was pretty useless for Netduino because it used blocking for the timing. So I wrote my own that uses interrupts for the timing. We used this successfully on a mobile robot for detecting obstacles. Accurate to sub-inch against hard surfaces. It is calibrated for my altitude and climate, you may need to adjust the InchConversionFactor and LatencyTicks for your environment. If you want it to read centimeters, just add your own TicksToCentimeters function. Enjoy and feel free to improve it. 2012/04/03 - Corrected pin documentation on constructor

 

 

Thank you sir for sharing this,

 

But your code seem to be not working when 4 sonar sensors are connected together, When I try it using 3 sonars it works fine, But for 4 sonar sensors I gives false value in a one sonar.  Does anyone have any idea why?



#25 Dmitry Mikhaylov

Dmitry Mikhaylov

    New Member

  • Members
  • Pip
  • 2 posts

Posted 24 December 2013 - 10:26 PM

Thanks

 

Someone might find this code useful. I found these HC SR04 ultrasonic rangefinders on amazon for $15 but they had no code. I found some Arduino code, but was pretty useless for Netduino because it used blocking for the timing. So I wrote my own that uses interrupts for the timing. We used this successfully on a mobile robot for detecting obstacles. Accurate to sub-inch against hard surfaces. It is calibrated for my altitude and climate, you may need to adjust the InchConversionFactor and LatencyTicks for your environment. If you want it to read centimeters, just add your own TicksToCentimeters function. Enjoy and feel free to improve it. 2012/04/03 - Corrected pin documentation on constructor

 

Thanks! Works just fine.



#26 Mark Anderson

Mark Anderson

    Member

  • Members
  • PipPip
  • 25 posts
  • LocationChciago

Posted 31 December 2013 - 09:28 PM

Anyone got any other calibration numbers? If so, how did you do it?

 

I've no idea where the exact zero point is (presumably the center of the cones behind the mesh. I presume I put a ruler there and placed an object at x-inches, I could determine the error



#27 chevi99

chevi99

    Member

  • Members
  • PipPip
  • 19 posts

Posted 22 June 2014 - 09:19 PM

thnx your code works perfectly well. but i have another sensor this time not HC - SR04 but mb 1260 from maxbotix can i have its class library to work with it. thx 



#28 hareega

hareega

    New Member

  • Members
  • Pip
  • 4 posts

Posted 08 October 2014 - 10:17 AM

maybe this is usefully too someone if u want Centimeters add:

        public double TicksToCentimeters(long ticks)
        {
            return ((double)ticks / inchConversion) * 2.54;
        }

to the class.






0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users

home    hardware    projects    downloads    community    where to buy    contact Copyright © 2016 Wilderness Labs Inc.  |  Legal   |   CC BY-SA
This webpage is licensed under a Creative Commons Attribution-ShareAlike License.