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...
@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.
@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.