flowmeters

Testing with 1 flowmeter. ok


Testing with 2 flowmeters. It's not ok.

I am working in a beer heat exchanger prototype. that flowmeters are going to show the mass velocity (L/min.) that goes into each channel (wort and water).
![](http://img594.imageshack.us/img594/1083/img00326.jpg
The flowmeter 1 gives the mass velocity in both colums and flowmeter2 acts in the same way.
![](http://img254.imageshack.us/img254/9744/problemxz.jpg

The code I have applied since then

volatile int NbTopsFan1; //measuring the rising edges of the signal
volatile int NbTopsFan2;
float Calc;
float Vazao;
int hallsensor1 = 2;    //The pin location of the sensor
int hallsensor2 = 3; 

void rpm ()     //This is the function that the interupt calls 
{ 
  NbTopsFan1++;  //This function measures the rising and falling edge of the hall effect sensors signal
  NbTopsFan2++;
} 
// The setup() method runs once, when the sketch starts
void setup() //
{ 
  pinMode(hallsensor1, INPUT); //initializes digital pin 2 as an input
  pinMode(hallsensor2, INPUT); 
  Serial.begin(9600); //This is the setup function where the serial port is initialised,
  attachInterrupt(0, rpm, RISING); //and the interrupt is attached
  attachInterrupt(1, rpm, RISING);
} 
// the loop() method runs over and over again,
// as long as the Arduino has power
void loop ()    
{
  NbTopsFan1 = 0;	//Set NbTops to 0 ready for calculations
  NbTopsFan2 = 0;
  sei();		//Enables interrupts
  delay (1000);	//Wait 1 second
  cli();		//Disable interrupts
  Calc = (NbTopsFan1 * 7.50 / 60.00); //(Pulse frequency x 60) / 7.5Q, = flow rate in L/hour 
  Vazao = (NbTopsFan2 * 7.5 / 60.00 );

  Serial.print (Calc, 5); //Prints the number calculated above
  Serial.print (" L/min"); //Prints "L/hour" and returns a  new line
  Serial.print ("   ");
  Serial.print (Vazao, 5);
  Serial.print (" L/min");
  Serial.println ();

So, I can't figure out why each flowmeter gives its response in both columns.))

the problem

plate heat exchanger prototype

Serial.print (Calc, 5); //Prints the number calculated above
Serial.print (" L/min"); //Prints "L/hour" and returns a new line
Serial.print (" ");
Serial.print (Vazao, 5);
Serial.print (" L/min");
Serial.println ();

Serial.print (" L/min"); //Prints "L/hour" and returns a new line

Hour ?

returns a new line

no it wont...........Serial.println prints on a new line try using that "Between" your code to split the flow meters

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

Both interrupts call the same ISR

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

The ISR always increments both variables so they will always have the same value

  Calc = (NbTopsFan1 * 7.50 / 60.00); //(Pulse frequency x 60) / 7.5Q, = flow rate in L/hour 
  Vazao = (NbTopsFan2 * 7.5 / 60.00 );

You perform the same calculation on both variables then output them.

Is it any surprise that both columns of the output are the same ?

You have the same handler assigned to each interrupt source. Within the ISR, you increment both fan counters without distinguishing which one caused the interrupt. You should just create two different ISRs (rpm1 and rpm2) and increment the appropriate counter within each one.