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 ");
}