adapting water flow meter code

Hi everyone, i'm brand new to arduino i have flashed a few leds written a few messages to an lcd but i would love to make a water flow meter. i have found this code: WaterFlowGauge/WaterFlowGauge.pde at master · practicalarduino/WaterFlowGauge · GitHub which would be brilliant however i wondered how feasible it would be to adapt the code so that instead of showing two total amounts of water flowed it would show the max and minimum flow rate recorded?
Any pointers and advise would be greatly appreciated!

Thanks for reading

Luke

create global variables at the top

float minFlowRate = 99999;
float maxFlowRate = 0;

and then in the loopjust after:
flowRate = ...

add the lines
if (flowRate < minFlowRate) minFlowRate = flowRate;
if (flowRate > maxFlowRate) maxFlowRate = flowRate;

and print them

Great!, coded it up just waiting on my flow sensor to arrive to test.
Thanks for your help rob much appreciated! :wink:

Luke

I don't know how you can get a sensible minimum and I have doubts about the max.

I did the bleeding obvious for the latter, using the simplest test

if (flowRate > max)
{
max = flowRate;
}

but immediately removed it as the results were meaningless. Even if you are only interested in one second bursts of flow, those reading might still be meaningless. I am rewriting the code so that it only displays every ten seconds and uses an average of the previous ten one-second readings. I guess, if you need maximums, it would be better if you did the same thing first. I also guess you could then also get the minimums by skating under a high target, provided you can guarantee continuous flow, or are just using this for some short- term operation.

Think I understand nick, basically because flow rate is updating every second the minimum and maximum flow rates recorded would only relate to that particular second?

Not really. It's more a matter of trusting what you see. For me, the real problem is that, while the reader can be extraordinarily accurate over the long term the instantaneous readings are simply too erratic to be any value. If you just want the maximum flow rate, even if it is only happening for less than two seconds, maybe its OK. If you want something that is more representative, then I suggest averaging several readings is a better bet.

As it stands the Oxer programme is just too tedious to use due entirely to the frequency of the display. By the time you have grasped a reading you are seeing something that is absurdly different and you can't keep track of what the hell is happening.

I believe taking the count over 10000 millis would be just as effective as averaging ten readings over 1000 millis intervals.

My turbines are currently out of service and I have not been able to check any of this yet.