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

Flow meter rate and total


  • Please log in to reply
2 replies to this topic

#1 Automate

Automate

    New Member

  • Members
  • Pip
  • 6 posts

Posted 22 December 2014 - 08:41 PM

I'm looking to get pluses from a flow meter tied to an input and calculate the flow rate and flow total. Anybody already developed code to do this?  Flow sensor puts out roughly a square wave at 450 pulses per liter, 30 L/Min max flow rate.

http://www.adafruit.com/products/828

 

Thanks for any help

 



#2 KiwiDev

KiwiDev

    Advanced Member

  • Members
  • PipPipPip
  • 100 posts
  • LocationNew Zealand

Posted 24 December 2014 - 12:35 AM

Hi,

 

I have a couple of similar sensors (http://www.seeedstud...id-Flow-c-25_32), we used an InterruptPort to count the pulses and a Timer to regularly calculate then display the instantaneous flow in L/Min.

 

I chopped out some of the code to show my approach, you'll need to adjust the calculation to suit your sensor.

 

Bryn

blog.devmobile.co.nz

   public class Program
   {
      private static int waterFlowCounter = 0;

      public static void Main()
      {
         InterruptPort flowCounterSensor = new InterruptPort(Pins.GPIO_PIN_D5, false, Port.ResistorMode.Disabled, Port.InterruptMode.InterruptEdgeHigh);
         flowCounterSensor.OnInterrupt += new NativeEventHandler(flowCounter_OnInterrupt);

         Timer waterFlowUpdate = new Timer(waterFlowUpdateProc, null, 0, 1000);

         Thread.Sleep(Timeout.Infinite);
      }

      static void flowCounter_OnInterrupt(uint data1, uint data2, DateTime time)
      {
         Interlocked.Increment(ref waterFlowCounter);
      }

      static void waterFlowUpdateProc(object status)
      {
         int flowCount = Interlocked.Exchange(ref waterFlowCounter, 0);

         double flowLitresMinute = flowCount / 5.5 ; // 5.5 is the Q of the 3/4" sensor

         Debug.Print(flowLitresMinute.ToString("F1") + "L/m  ");
      }


#3 Automate

Automate

    New Member

  • Members
  • Pip
  • 6 posts

Posted 24 December 2014 - 04:20 AM

Looks great.  Thanks






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.