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

Inconsistent reads on ultrasonic range sensor?


  • Please log in to reply
2 replies to this topic

#1 Daniel Minnaar

Daniel Minnaar

    Advanced Member

  • Members
  • PipPipPip
  • 46 posts
  • LocationJohannesburg, South Africa

Posted 11 November 2011 - 10:40 AM

Hi there, I've recently started playing around with Netduino and some sensors - specifically the ultrasonic range sensor (seed studio). I've connected it to my digital pin. If I aim it at the same place, I get fluctuations of about 20cm sometimes... usually from 85cm -> 120cm at the same place? Any ideas? Here are some environmental situations: The 5V range sensor is on the breadboard with a LED and a resistor (330ohm) Code: while (true) { outPort.Active = true; // Put port in write mode outPort.Write(true); // Pulse pin outPort.Write(false); outPort.Active = false;// Put port in read mode; bool lineState = false; // Wait for the line to go high, for start of pulse. while (lineState == false) lineState = outPort.Read(); long startOfPulseAt = System.DateTime.Now.Ticks; // Save start ticks. // Wait for line to go low. while (lineState) lineState = outPort.Read(); long endOfPulse = System.DateTime.Now.Ticks; // Save end ticks. int ticks = (int)(endOfPulse - startOfPulseAt); lastReading = ticks / 580; Debug.Print(lastReading.ToString() + " cm");

#2 Mario Vernari

Mario Vernari

    Advanced Member

  • Members
  • PipPipPip
  • 1768 posts
  • LocationVenezia, Italia

Posted 11 November 2011 - 12:44 PM

Hello Reactive, and welcome to the forum. Could you specify a link with the sensor specs? Cheers
Biggest fault of Netduino? It runs by electricity.

#3 Stefan W.

Stefan W.

    Advanced Member

  • Members
  • PipPipPip
  • 153 posts

Posted 11 November 2011 - 01:58 PM

The busy-loop method is not very accurate as a single read can take pretty long - i've used an InterruptPort to detect the edges (you'll need another port or some piece of circuitry with e.g. a 555 to trigger the sensor reading, since there's no tristate for interrupt ports ...). Mario, it's at http://www.seeedstud...surement_module - it's basically the same as the Parallax Ping))) which already has some threads here.
I believe that no discovery of fact, however trivial, can be wholly useless to the race, and that no trumpeting of falsehood, however virtuous in intent, can be anything but vicious.
-- H.L. Mencken, "What I Believe"




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.