Water Flow Meter Sensors

Hello Everyone, thanks for your help firstly, I have a question, I want to get each flow meter output independently on DO Pin2 and DO Pin 3, I wrote a code which I posted below, but when I run the program when I give the start's and stop's input, only my start is running or when I give the start's and stop's input again only my stop is running, I want to get output of start and stop independently, I guess there is a problem on my interrupt codes but I couldn't get the right answer, could you please help me ?

This is my code which just runs the start;

volatile int Rising_Falling_Edge1; //measuring the rising edges of the signal
volatile int Rising_Falling_Edge2; //measuring the rising edges of the signal
int Calc; 
int Start;
int Stop;  


void ulu ()     //This is the function that the interupt calls 
{

 Rising_Falling_Edge1++;  //This function measures the rising and falling edge of the hall effect sensors signal
 Rising_Falling_Edge2++;  //This function measures the rising and falling edge of the hall effect sensors signal

} 

void setup() //The setup() method runs once, when the sketch starts
{ 
 pinMode(2, INPUT); //initializes digital pin 2 as an input
 pinMode(3, INPUT); //initializes digital pin 3 as an input
 
 Serial.begin(9600); //This is the setup function where the serial port is
} 


void loop () // the loop() method runs over and over again, as long as the Arduino has power
{
 cli();
 attachInterrupt(0, ulu, RISING); //and the interrupt is attached
 delay(1000);
 sei();
 Rising_Falling_Edge1 = 0;      //Set Rising_Falling_Edge to 0 ready for calculations
 delay (1000);      //Wait 1 second
 Calc = (Rising_Falling_Edge1 * 60 / 7.5); //(Pulse frequency x 60) / 7.5Q, = flow rate //in L/hour
 Serial.print ("Start:");
 Serial.print (Calc, DEC); //Prints the number calculated above
 Serial.print (" L/hour\r\n"); //Prints "L/hour" and returns a  new line  
 attachInterrupt(1, ulu, RISING); //and the interrupt is attached 
 delay(1000);
 Rising_Falling_Edge2 = 0;      //Set Rising_Falling_Edge to 0 ready for calculations
 Calc = (Rising_Falling_Edge2 * 60 / 7.5); //(Pulse frequency x 60) / 7.5Q, = flow rate //in L/hour 
 Serial.print ("Stop:");
 Serial.print (Calc, DEC); //Prints the number calculated above
 Serial.print (" L/hour\r\n"); //Prints "L/hour" and returns a  new line    
}
[code]



and this is my code just runs my stop;

[code]volatile int Rising_Falling_Edge1; //measuring the rising edges of the signal
volatile int Rising_Falling_Edge2; //measuring the rising edges of the signal
int Calc; 
int Start;
int Stop;  


void ulu ()     //This is the function that the interupt calls 
{

 Rising_Falling_Edge1++;  //This function measures the rising and falling edge of the hall effect sensors signal
 Rising_Falling_Edge2++;  //This function measures the rising and falling edge of the hall effect sensors signal

} 

void setup() //The setup() method runs once, when the sketch starts
{ 
 pinMode(2, INPUT); //initializes digital pin 2 as an input
 pinMode(3, INPUT); //initializes digital pin 3 as an input
 Serial.begin(9600); //This is the setup function where the serial port is
 
} 

void loop () // the loop() method runs over and over again, as long as the Arduino has power
{
 cli();
 attachInterrupt(0, ulu, RISING); //and the interrupt is attached
 Rising_Falling_Edge1 = 0;      //Set Rising_Falling_Edge to 0 ready for calculations
 delay (1000);      //Wait 1 second
 Calc = (Rising_Falling_Edge1 * 60 / 7.5); //(Pulse frequency x 60) / 7.5Q, = flow rate //in L/hour 
 sei();
 Serial.print ("Start:");
 Serial.print (Calc, DEC); //Prints the number calculated above
 Serial.print (" L/hour\r\n"); //Prints "L/hour" and returns a  new line
 attachInterrupt(1, ulu, RISING); //and the interrupt is attached
 Rising_Falling_Edge2 = 0;      //Set Rising_Falling_Edge to 0 ready for calculations
 delay(1000);
 Calc = (Rising_Falling_Edge2 * 60 / 7.5); //(Pulse frequency x 60) / 7.5Q, = flow rate //in L/hour 
 Serial.print ("Stop:");
 Serial.print (Calc, DEC); //Prints the number calculated above
 Serial.print (" L/hour\r\n"); //Prints "L/hour" and returns a  new line
}
[code]

Please use [ code ] tags next time. The forum software mangles the code without the tags.

It looks like you are missing an interrupt for the second pin. And you will need another variable to record for that pin.

You also have a major problem doing Serial.print() while interrupts are turned off. If you fill the outgoing serial buffer then it will freeze. Normally, for this Lind of thing, you should turn interrupts off for just a couple of lines while you grab a copy of the volatile variable, then you re enable interrupts as quickly as possible.

Thank you very much MorganS, as you observe I am new on this forum, actually can you write the missing part for me if it is ok for you ? I added also

attachInterrupt(1, rpm, RISING); //and the interrupt is attached

code line into my code. Now the program gives me outputs for Start and Stop but, when I wanted to observe Start I also see the stop output as well and vice versa, actually I dont know how to stop interrupt for observing just one output.. :S

Thank you very very much for your interest.

Here is your code using the code tags. It makes it easy for people to help you when the code is presented this way.

volatile int Rising_Falling_Edge; //measuring the rising edges of the signal
int Calc1;
int Calc2;
int hallsensor1 = 2;    //The pin location of the sensor
int hallsensor2 = 3;    //The pin location of the sensor
void rpm ()     //This is the function that the interupt calls
{
  Rising_Falling_Edge++;  //This function measures the rising and falling edge of the hall effect sensors signal
}

void setup() //The setup() method runs once, when the sketch starts
{
  pinMode(hallsensor1, INPUT); //initializes digital pin 2 as an input
  pinMode(hallsensor2, INPUT); //initializes digital pin 3 as an input

  Serial.begin(9600); //This is the setup function where the serial port is


  attachInterrupt(0, rpm, RISING); //and the interrupt is attached
}

void loop () // the loop() method runs over and over again, as long as the Arduino has power
{
  Rising_Falling_Edge = 0;      //Set Rising_Falling_Edge to 0 ready for calculations
  sei();            //Enables interrupts
  delay (1000);      //Wait 1 second
  cli();            //Disable interrupts
  Calc1 = (Rising_Falling_Edge * 60 / 7.5); //(Pulse frequency x 60) / 7.5Q, = flow rate
  Calc2 = (Rising_Falling_Edge * 60 / 7.5); //(Pulse frequency x 60) / 7.5Q, = flow rate

  //in L/hour
  Serial.print ("Start:");
  Serial.print (Calc1, DEC); //Prints the number calculated above
  Serial.print (" L/hour\r\n"); //Prints "L/hour" and returns a  new line

  Serial.print ("Stop:");
  Serial.print (Calc2, DEC); //Prints the number calculated above
  Serial.print (" L/hour\r\n"); //Prints "L/hour" and returns a  new line
}

Reading interrupt counts accumulated during a delay period is not ideal because it is blocking for the rest of your code. It is better to read the counts with a timer like in the "Blink without delay" example.

sei();            //Enables interrupts
  delay (1000);      //Wait 1 second
  cli();            //Disable interrupts

Here is some example code which reads two interrupts every second. You should be able to adapt it to your flow meters,

//pulse counts changed within count_ISR's
volatile unsigned int count1;
volatile unsigned int count2;

//variables for protected copies of counts
unsigned int copyCount1;
unsigned int copyCount2;

void count1_ISR()
{
  count1++;
}

void count2_ISR()
{
  count2++;
}
void setup() {

  Serial.begin(115200);

  attachInterrupt(0, count1_ISR, RISING); //pin2 (Atmega328)
  attachInterrupt(1, count2_ISR, RISING); //pin3 (Atmega328)
  
}

void loop() {
  static unsigned long lastSecond;
  if (micros() - lastSecond >= 1000000L)
  {
    lastSecond += 1000000;
    getCount();
    Serial.println(copyCount1);
    Serial.println(copyCount2);
    Serial.println();
  }

}
unsigned int getCount()
{
  noInterrupts();
  copyCount1 = count1;
  count1 = 0;
  copyCount2 = count2;
  count2 = 0;
  interrupts();
}

Thank I tried, but I can just get the output on stop, I tried many options but couldn't get the output from Start, only stop runs :S

Thank I tried, but I can just get the output on stop, I tried many options but couldn't get the output from Start, only stop runs :S

What does this mean?

Why do you have multiple threads on the same topic?

  Calc1 = (Rising_Falling_Edge * 60 / 7.5); //(Pulse frequency x 60) / 7.5Q, = flow rate
  Calc2 = (Rising_Falling_Edge * 60 / 7.5); //(Pulse frequency x 60) / 7.5Q, = flow rate

Why not just do

Calc2 = Calc1;

since the SAME data is used to calculate both values?

  Serial.print ("Start:");
  Serial.print (Calc1, DEC); //Prints the number calculated above
  Serial.print (" L/hour\r\n"); //Prints "L/hour" and returns a  new line

  Serial.print ("Stop:");
  Serial.print (Calc2, DEC); //Prints the number calculated above
  Serial.print (" L/hour\r\n"); //Prints "L/hour" and re

There is no way in hell that the Stop and following data prints on the Serial Monitor while the Start part does not.

+PaulS yes you are right, but I wrote like that, just in order to observe my each start and stop values independently, I can change it also and now my new code is just like that, I can just see the stop value that I gave, but I want to observe, start and stop values independently, such as Start : 345 Stop: 0 , and Start: 0, Stop: 456 like that.

[volatile int Rising_Falling_Edge1; //measuring the rising edges of the signal
volatile int Rising_Falling_Edge2; //measuring the rising edges of the signal
int Calc;
int Start;
int Stop;
int hallsensor1 = 2; //The pin location of the sensor
int hallsensor2 = 3; //The pin location of the sensor

void rpm () //This is the function that the interupt calls
{

Rising_Falling_Edge1++; //This function measures the rising and falling edge of the hall effect sensors signal
Rising_Falling_Edge2++; //This function measures the rising and falling edge of the hall effect sensors signal

}

void setup() //The setup() method runs once, when the sketch starts
{
pinMode(hallsensor1, INPUT); //initializes digital pin 2 as an input
pinMode(hallsensor2, INPUT); //initializes digital pin 3 as an input

Serial.begin(9600); //This is the setup function where the serial port is

attachInterrupt(0, rpm, RISING); //and the interrupt is attached
attachInterrupt(1, rpm, RISING); //and the interrupt is attached
}

void loop () // the loop() method runs over and over again, as long as the Arduino has power
{
noInterrupts(); //Disable interrupts
Rising_Falling_Edge1 = 0; //Set Rising_Falling_Edge to 0 ready for calculations
delay (1000); //Wait 1 second
Calc = (Rising_Falling_Edge1 * 60 / 7.5); //(Pulse frequency x 60) / 7.5Q, = flow rate
//in L/hour
Serial.print ("Start:");
Serial.print (Calc, DEC); //Prints the number calculated above
Serial.print (" L/hour\r\n"); //Prints "L/hour" and returns a new line

interrupts();
Rising_Falling_Edge2 = 0; //Set Rising_Falling_Edge to 0 ready for calculations
delay(1000);
Calc = (Rising_Falling_Edge2 * 60 / 7.5); //(Pulse frequency x 60) / 7.5Q, = flow rate
//in L/hour
Serial.print ("Stop:");
Serial.print (Calc, DEC); //Prints the number calculated above
Serial.print (" L/hour\r\n"); //Prints "L/hour" and returns a new line

}

]

I couldnt write as code text, sorry :confused:

volatile int Rising_Falling_Edge1; //measuring the rising edges of the signal
volatile int Rising_Falling_Edge2; //measuring the rising edges of the signal
int Calc; 
int Start;
int Stop;  
int hallsensor1 = 2;    //The pin location of the sensor
int hallsensor2 = 3;    //The pin location of the sensor

void rpm ()     //This is the function that the interupt calls 
{
 
 Rising_Falling_Edge1++;  //This function measures the rising and falling edge of the hall effect sensors signal
 Rising_Falling_Edge2++;  //This function measures the rising and falling edge of the hall effect sensors signal
 
} 

void setup() //The setup() method runs once, when the sketch starts
{ 
 pinMode(hallsensor1, INPUT); //initializes digital pin 2 as an input
 pinMode(hallsensor2, INPUT); //initializes digital pin 3 as an input
 
 Serial.begin(9600); //This is the setup function where the serial port is


 attachInterrupt(0, rpm, RISING); //and the interrupt is attached
 attachInterrupt(1, rpm, RISING); //and the interrupt is attached
} 

void loop () // the loop() method runs over and over again, as long as the Arduino has power
{
 noInterrupts();            //Disable interrupts 
 Rising_Falling_Edge1 = 0;      //Set Rising_Falling_Edge to 0 ready for calculations
 delay (1000);      //Wait 1 second
 Calc = (Rising_Falling_Edge1 * 60 / 7.5); //(Pulse frequency x 60) / 7.5Q, = flow rate
//in L/hour 
 Serial.print ("Start:");
 Serial.print (Calc, DEC); //Prints the number calculated above
 Serial.print (" L/hour\r\n"); //Prints "L/hour" and returns a  new line
 
 interrupts();
 Rising_Falling_Edge2 = 0;      //Set Rising_Falling_Edge to 0 ready for calculations
 delay(1000);
 Calc = (Rising_Falling_Edge2 * 60 / 7.5); //(Pulse frequency x 60) / 7.5Q, = flow rate
//in L/hour 
 Serial.print ("Stop:");
 Serial.print (Calc, DEC); //Prints the number calculated above
 Serial.print (" L/hour\r\n"); //Prints "L/hour" and returns a  new line
 
}

This is my last part of my code, actually I couldnt decide the exact place of interrupts, can you help me please ?

 volatile int Rising_Falling_Edge1; //measuring the rising edges of the signal
volatile int Rising_Falling_Edge2; //measuring the rising edges of the signal
int Calc; 
int Start;
int Stop;  
int hallsensor1 = 2;    //The pin location of the sensor
int hallsensor2 = 3;    //The pin location of the sensor

void rpm ()     //This is the function that the interupt calls 
{
 
 Rising_Falling_Edge1++;  //This function measures the rising and falling edge of the hall effect sensors signal
 Rising_Falling_Edge2++;  //This function measures the rising and falling edge of the hall effect sensors signal
 
} 

void setup() //The setup() method runs once, when the sketch starts
{ 
 pinMode(hallsensor1, INPUT); //initializes digital pin 2 as an input
 pinMode(hallsensor2, INPUT); //initializes digital pin 3 as an input
 
 Serial.begin(9600); //This is the setup function where the serial port is


 attachInterrupt(0, rpm, RISING); //and the interrupt is attached
 attachInterrupt(1, rpm, RISING); //and the interrupt is attached
} 

void loop () // the loop() method runs over and over again, as long as the Arduino has power
{
 noInterrupts();            //Disable interrupts 
 Rising_Falling_Edge1 = 0;      //Set Rising_Falling_Edge to 0 ready for calculations
 delay (1000);      //Wait 1 second
 Calc = (Rising_Falling_Edge1 * 60 / 7.5); //(Pulse frequency x 60) / 7.5Q, = flow rate
//in L/hour 
 Serial.print ("Start:");
 Serial.print (Calc, DEC); //Prints the number calculated above
 Serial.print (" L/hour\r\n"); //Prints "L/hour" and returns a  new line
 
 interrupts();
 Rising_Falling_Edge2 = 0;      //Set Rising_Falling_Edge to 0 ready for calculations
 delay(1000);
 Calc = (Rising_Falling_Edge2 * 60 / 7.5); //(Pulse frequency x 60) / 7.5Q, = flow rate
//in L/hour 
 Serial.print ("Stop:");
 Serial.print (Calc, DEC); //Prints the number calculated above
 Serial.print (" L/hour\r\n"); //Prints "L/hour" and returns a  new line
 
}
 [code]

No, you need separate ISRs for each pin, and each ISR manages the variable for that pin only.

Alternatively you could use one ISR, but it would have to read both pins and work out which one(s)
have changed. Its easier to use two ISRs.

Thank you MarkT I tried but it doesn't work :confused:

I think the mistake is that part of the code, I dont specifically know, to where should I pot interrupts,can you help me ?

void loop () // the loop() method runs over and over again, as long as the Arduino has power
{
  
 noInterrupts(); 
 Rising_Falling_Edge1 = 0;      //Set Rising_Falling_Edge to 0 ready for calculations
 delay (1000);      //Wait 1 second
 Calc = (Rising_Falling_Edge1 * 60 / 7.5); //(Pulse frequency x 60) / 7.5Q, = flow rate
//in L/hour 
 interrupts(); //Enable Interrupts

 Serial.print ("Start:");
 Serial.print (Calc, DEC); //Prints the number calculated above
 Serial.print (" L/hour\r\n"); //Prints "L/hour" and returns a  new line
 
 noInterrupts(); 
 Rising_Falling_Edge2 = 0;      //Set Rising_Falling_Edge to 0 ready for calculations
 delay(1000);
 Calc = (Rising_Falling_Edge2 * 60 / 7.5); //(Pulse frequency x 60) / 7.5Q, = flow rate
//in L/hour 
  interrupts(); //Enable Interrupts
  
 Serial.print ("Stop:");
 Serial.print (Calc, DEC); //Prints the number calculated above
 Serial.print (" L/hour\r\n"); //Prints "L/hour" and returns a  new line
            //Disable interrupts
}
[code]

For any advice I appreciate, It is an urgent project that I should overcome.. Thanks for your interests.

Guys please help..

I think the mistake is that part of the code, I dont specifically know, to where should I pot interrupts,can you help me ?

Please post your complete code.

Thank you MarkT I tried but it doesn't work :confused:

Mark suggested you set up two ISR's. The example code I posted has two ISR's. Please take the hint and write two ISR's.

noInterrupts(); 
 Rising_Falling_Edge1 = 0;      //Set Rising_Falling_Edge to 0 ready for calculations
 delay (1000);      //Wait 1 second
 Calc = (Rising_Falling_Edge1 * 60 / 7.5); //(Pulse frequency x 60) / 7.5Q, = flow rate
//in L/hour 
 interrupts(); //Enable Interrupts

Rising_Falling_Edge1 will always be zero with what you have done. If interrupts are disabled with noInterrupts() the ISR can not count any pulses. You do the same with Rising_Falling_Edge2.

Please post your complete code. Confirm that you have the two independent ISR's. Are the flow readings supposed to be sequential one second apart? What are you trying to do with the two flows?

This code just gives me an output of start ;

 volatile int Rising_Falling_Edge1; //measuring the rising edges of the signal
volatile int Rising_Falling_Edge2; //measuring the rising edges of the signal
int Calc; 
int Start;
int Stop;  


void ulu ()     //This is the function that the interupt calls 
{

 Rising_Falling_Edge1++;  //This function measures the rising and falling edge of the hall effect sensors signal
 Rising_Falling_Edge2++;  //This function measures the rising and falling edge of the hall effect sensors signal

} 

void setup() //The setup() method runs once, when the sketch starts
{ 
 pinMode(2, INPUT); //initializes digital pin 2 as an input
 pinMode(3, INPUT); //initializes digital pin 3 as an input
 
 Serial.begin(9600); //This is the setup function where the serial port is
} 


void loop () // the loop() method runs over and over again, as long as the Arduino has power
{
 cli();
 attachInterrupt(0, ulu, RISING); //and the interrupt is attached
 delay(1000);
 sei();
 Rising_Falling_Edge1 = 0;      //Set Rising_Falling_Edge to 0 ready for calculations
 delay (1000);      //Wait 1 second
 Calc = (Rising_Falling_Edge1 * 60 / 7.5); //(Pulse frequency x 60) / 7.5Q, = flow rate //in L/hour
 Serial.print ("Start:");
 Serial.print (Calc, DEC); //Prints the number calculated above
 Serial.print (" L/hour\r\n"); //Prints "L/hour" and returns a  new line  
 attachInterrupt(1, ulu, RISING); //and the interrupt is attached 
 delay(1000);
 Rising_Falling_Edge2 = 0;      //Set Rising_Falling_Edge to 0 ready for calculations
 Calc = (Rising_Falling_Edge2 * 60 / 7.5); //(Pulse frequency x 60) / 7.5Q, = flow rate //in L/hour 
 Serial.print ("Stop:");
 Serial.print (Calc, DEC); //Prints the number calculated above
 Serial.print (" L/hour\r\n"); //Prints "L/hour" and returns a  new line    
}
[code]




And this code just gives me an output of stop ;

[code] volatile int Rising_Falling_Edge1; //measuring the rising edges of the signal
volatile int Rising_Falling_Edge2; //measuring the rising edges of the signal
int Calc; 
int Start;
int Stop;  


void ulu ()     //This is the function that the interupt calls 
{

 Rising_Falling_Edge1++;  //This function measures the rising and falling edge of the hall effect sensors signal
 Rising_Falling_Edge2++;  //This function measures the rising and falling edge of the hall effect sensors signal

} 

void setup() //The setup() method runs once, when the sketch starts
{ 
 pinMode(2, INPUT); //initializes digital pin 2 as an input
 pinMode(3, INPUT); //initializes digital pin 3 as an input
 
 Serial.begin(9600); //This is the setup function where the serial port is
} 


void loop () // the loop() method runs over and over again, as long as the Arduino has power
{
 cli();
 attachInterrupt(0, ulu, RISING); //and the interrupt is attached
 delay(1000);
 sei();
 Rising_Falling_Edge1 = 0;      //Set Rising_Falling_Edge to 0 ready for calculations
 delay (1000);      //Wait 1 second
 Calc = (Rising_Falling_Edge1 * 60 / 7.5); //(Pulse frequency x 60) / 7.5Q, = flow rate //in L/hour
 Serial.print ("Start:");
 Serial.print (Calc, DEC); //Prints the number calculated above
 Serial.print (" L/hour\r\n"); //Prints "L/hour" and returns a  new line  
 attachInterrupt(1, ulu, RISING); //and the interrupt is attached 
 delay(1000);
 Rising_Falling_Edge2 = 0;      //Set Rising_Falling_Edge to 0 ready for calculations
 Calc = (Rising_Falling_Edge2 * 60 / 7.5); //(Pulse frequency x 60) / 7.5Q, = flow rate //in L/hour 
 Serial.print ("Stop:");
 Serial.print (Calc, DEC); //Prints the number calculated above
 Serial.print (" L/hour\r\n"); //Prints "L/hour" and returns a  new line    
}
[code]

I couldnt combine them, my aim is to observe the output of start and stop independently, meaningly, when I runs the start, stop will not change, and when I runs the stop start will not change. I need your advices guys, where I missed.. :S:S

Interrupts are a really advanced programming topic. Even though I have a degree in computer science, my first thought is "Can I do this without interrupts?"

Here is my all code

volatile int Rising_Falling_Edge1; //measuring the rising edges of the signal
volatile int Rising_Falling_Edge2; //measuring the rising edges of the signal
int Calc; 
int Start;
int Stop;  


void ulu ()     //This is the function that the interupt calls 
{

 Rising_Falling_Edge1++;  //This function measures the rising and falling edge of the hall effect sensors signal
 Rising_Falling_Edge2++;  //This function measures the rising and falling edge of the hall effect sensors signal

} 

void setup() //The setup() method runs once, when the sketch starts
{ 
 pinMode(2, INPUT); //initializes digital pin 2 as an input
 pinMode(3, INPUT); //initializes digital pin 3 as an input
 
 Serial.begin(9600); //This is the setup function where the serial port is
} 


void loop () // the loop() method runs over and over again, as long as the Arduino has power
{
 cli();
 attachInterrupt(0, ulu, RISING); //and the interrupt is attached
 delay(1000);
 sei();
 Rising_Falling_Edge1 = 0;      //Set Rising_Falling_Edge to 0 ready for calculations
 delay (1000);      //Wait 1 second
 Calc = (Rising_Falling_Edge1 * 60 / 7.5); //(Pulse frequency x 60) / 7.5Q, = flow rate //in L/hour
 Serial.print ("Start:");
 Serial.print (Calc, DEC); //Prints the number calculated above
 Serial.print (" L/hour\r\n"); //Prints "L/hour" and returns a  new line  
 attachInterrupt(1, ulu, RISING); //and the interrupt is attached 
 delay(1000);
 Rising_Falling_Edge2 = 0;      //Set Rising_Falling_Edge to 0 ready for calculations
 Calc = (Rising_Falling_Edge2 * 60 / 7.5); //(Pulse frequency x 60) / 7.5Q, = flow rate //in L/hour 
 Serial.print ("Stop:");
 Serial.print (Calc, DEC); //Prints the number calculated above
 Serial.print (" L/hour\r\n"); //Prints "L/hour" and returns a  new line    
}
[code]

[/code]

I understood what you mean MorganS actual I am an Electrical and Electronics engineer, but I should handle that code, my boss wanted me to do that, so I need your help guys..I also know nothing about Interrupts..

+cattledog I am trying to calculate 2 flows and after that the differences of these two flow will give me leakage of the pipe. But first I want to get 2 different start and stop outputs and after that by writing a basic if clause I will subtract them in order to find the leakage on the pipe. Thank you for your interest.