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

How to read values from an analog sensor ???


  • Please log in to reply
3 replies to this topic

#1 Beowolf

Beowolf

    Advanced Member

  • Members
  • PipPipPip
  • 39 posts

Posted 03 October 2011 - 08:19 AM

Hello,

I am using the following flow sensors for measuring the water flow through the pipe. But i don't know how to read the values from these sensors. I searched the google and found out that i have to use the PWM pins for taking the input from the sensor, which actually counts the number of pulses. But i don't know how to program it in c#. Can any one please help me with the code.

regards
Beowolf

#2 Nevyn

Nevyn

    Advanced Member

  • Members
  • PipPipPip
  • 1072 posts
  • LocationNorth Yorkshire, UK

Posted 03 October 2011 - 08:39 AM

I am using the following flow sensors for measuring the water flow through the pipe. But i don't know how to read the values from these sensors. I searched the google and found out that i have to use the PWM pins for taking the input from the sensor, which actually counts the number of pulses. But i don't know how to program it in c#. Can any one please help me with the code.

Sounds like you should be a ble to do this with an InterruptPort:
_counter = new InterruptPort(Pins.GPIO_PIN_19, false, Port.ResistorMode.Disabled, Port.InterruptMode.InterruptEdgeHigh);
_counter.OnInterrupt += new NativeEventHandler(_counter_OnInterrupt);
This sets up an InterruptPort on Pin 19 if a Mini.
void _counter_OnInterrupt(uint data1, uint data2, DateTime time)
{
}
Drop your counter code in the OnInterrupt method.

I'm assuming that you have the electronics sorted out so that the sensor is not generating more than 5V input to the Netduino.

Hope this helps,
Mark

To be or not to be = 0xFF

 

Blogging about Netduino, .NET, STM8S and STM32 and generally waffling on about life

Follow @nevynuk on Twitter


#3 Stefan W.

Stefan W.

    Advanced Member

  • Members
  • PipPipPip
  • 153 posts

Posted 03 October 2011 - 10:52 AM

Those are not what you'd usually call "analog sensors", by the way. Which kind of flow are we talking about, btw? How many liters per minute?
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"

#4 Bill E.

Bill E.

    Member

  • Members
  • PipPip
  • 26 posts
  • LocationSilicon Valley, California

Posted 07 October 2011 - 01:12 AM

Beowolf, how accurate do you need to be? I ask this because the interrupt method is the best way to go about precisely counting 3900 ppl (pulses-per-liter) but which begs the question: How fast is the flow? How many lpm? LPH (per hour), etc like Stefan did. I have a fish pond and I am interested in measuring flow from my pump(s) back to the pond. The "vane sensor" or hall effect sensor is a nice way to measure flow but you suffer from having to be responsive to the individual "ticks" of the sensor. If your CPU, in this case, a Netduino, is doing a lot of other things, you may not be able to deal with the latency, or delay, of handling many interrupts. I am an interrupt nut - I love them! But if you only need an average of the flow (which is what most people care about) why not convert the pulses to analog?? Integrate the pulses with an RC network and simply read the analog value from the RC. Over hours/days/weeks/..., this may be the best way to do this. Place a resistor in series with the sensor output and a capacitor to ground after that (your sensor must have a rail or "potential" level for this to work). Use the A/D to measure the capacitor level and, viola! You have an average of the flow! I believe in the "KISS" approach (KeepItSimpleStupid) whenever possible. Choose the R & C values emperically, that is trial and error - to what suits your needs. Good luck and let us know how it works out? Regards.




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.