Flowmeter with no interrupts 32U4

Hi guys!

I have a question and I need some help, I triend many times but obtained zero results.

I want to measure two waterflows through two pipes with two flowmeters connected to an Arduino Pro Micro, those one with a spinning wheel, that means, the flow is linear related with the frequency. I have the formula, but not the way to measure the frequency.

The problem is I CAN NOT USE INTERRUPTS, I am hardware forced to use pin D6 and D7. D7 has INT but D6 has no INT nor PCINT.

So, how can I proceed to measure the flow without blocking to much the other sensors reading (temperature, pressure etc) and I2C JSON sending to a connected RaspberryPi?

Thanks in advance, everything works, but I didn´t find the way to implement this...

Greetings!

Raphael M. Trautmann

Can you use pin change interrupts (there's a library) on the Pro Micro?

I guess, but pin D6 does not work with PCINT...

Just poll the pins. No need for interrupts with a flowmeter.

Of course, you will not be able to use delay() in the polling loop, or you will miss pulses.

pin D6 does not work with PCINT

What makes you believe this?

No INT or PCINT on pin 6 here: https://www.arduino.cc/en/Hacking/PinMapping32u4.
Pin 6 is not in the list here: Usage · GreyGnome/EnableInterrupt Wiki · GitHub.

@RTDesigns, why are you forced to use pin 6 ?
Can you cheat a little by connecting another pin to pin 6 ?
The solution by jremington (just poll the pins) should work. What is the maximum frequency and the minimal pulse duration of the flow meter ? Can you show the sketch ?

I would just do as post #3 suggest. Your flow sensor outputs a number of pulses per unit of flow. So measure the High time and Low time on a pin. High time + Low time is the period and 1/Period is the frequency. Now depending on the sensor K factor (pulses per unit of measure) you derive the flow rate. You do not need an interrupt to measure flow.

Ron

jremington:
Just poll the pins. No need for interrupts with a flowmeter.

Of course, you will not be able to use delay() in the polling loop, or you will miss pulses.
What makes you believe this?

Yeah I know, I should do it with millis(). Okay thanks a lot!! I wil try!!!! :slight_smile:

Koepel:
No INT or PCINT on pin 6 here: https://www.arduino.cc/en/Hacking/PinMapping32u4.
Pin 6 is not in the list here: Usage · GreyGnome/EnableInterrupt Wiki · GitHub.

@RTDesigns, why are you forced to use pin 6 ?
Can you cheat a little by connecting another pin to pin 6 ?
The solution by jremington (just poll the pins) should work. What is the maximum frequency and the minimal pulse duration of the flow meter ? Can you show the sketch ?

I am forced to use this pins because I designed and ordered a PCB, with this asignations.
For now I didn´t calculate frequency or pulse duration, but I guess not very high frequency, because its a flowmeter in a piping with a lower flowrate than the water coming from a water tap.
I didn´t have anything done with this in the sketch, just this:

/**

  • Caudales: 2 sensores, caudalímetro
    */
    // Pines asociados
    const static byte FLOW1_PIN = 6;
    const static byte FLOW2_PIN = 7;
    // Número de sensores
    const static byte FLOW_NMETERS = 2;
    // Valor de las medidas
    float flowMeasures[FLOW_NMETERS];
    // Para debug

void printFlows();

I can´t cheat pins because everyone is assigned, I have about 9 temperature sensors, 4 pressure sensors, etc...

I will try like you guys told me, polling!! Thanks!

Ron_Blain:
I would just do as post #3 suggest. Your flow sensor outputs a number of pulses per unit of flow. So measure the High time and Low time on a pin. High time + Low time is the period and 1/Period is the frequency. Now depending on the sensor K factor (pulses per unit of measure) you derive the flow rate. You do not need an interrupt to measure flow.

Ron

Thanks!! I will try this yeah!

This topic was automatically closed 120 days after the last reply. New replies are no longer allowed.