Measuring time between pulses (10 - 5000 milliseconds inbetween)
NickeA
Posts: 5
Hi!
I'm trying to build a fuel consumtion monitor for my power boat. I´m planning to use a flow sensor that gives 2500 pulses per liter of petrol that passes through it. My problem is finding a way to measure the frequency of the pulses since there may be anything from 10 milliseconds between the pulses (pushing the Chevy V8 hard) to perhaps 2-5 seconds between the pulses (engine idling).
option 1 - using COUNT to count the number of pulses during one second or so wont work since there will be so few pulses per second (less than one in the very low end) that the accuracy will be low.
option 2 - using PULSEIN to measure the time between the pulse wont work in the low end either since the function times out already after 131 milliseconds.
How would you guys solve this?
BR / Nicke
I'm trying to build a fuel consumtion monitor for my power boat. I´m planning to use a flow sensor that gives 2500 pulses per liter of petrol that passes through it. My problem is finding a way to measure the frequency of the pulses since there may be anything from 10 milliseconds between the pulses (pushing the Chevy V8 hard) to perhaps 2-5 seconds between the pulses (engine idling).
option 1 - using COUNT to count the number of pulses during one second or so wont work since there will be so few pulses per second (less than one in the very low end) that the accuracy will be low.
option 2 - using PULSEIN to measure the time between the pulse wont work in the low end either since the function times out already after 131 milliseconds.
How would you guys solve this?
BR / Nicke
Comments
You could also use an external counter with a BS2, reading the count a couple of times a second using a PAUSE for timing. If the count hasn't changed, you just wait to check again. If the counter overflows, use a COUNT statement. You'd need to ignore some readings when the fuel consumption is changing rapidly.
Knowing the time between readings, all consumption calculations can be done.
A 4024 binary counter is a possible choice. You wouldn't need to take all the outputs into the Stamp. Just enough to cover the pulses accumulating between readings, say 4 or 5 bits.
Cheers,
BR / Nicke
The ordinary BASIC stamp can execute the inner DO:LOOPs at over 1000 per second, but it will be a bit different for the high and the low. The factors at the end are chosen to make each part and the total come out in milliseconds from rising edge to rising edge. The calibration step takes a bit of effort and a source of 1Hz square wave, but it can be pretty good once done.
More comments at this URL, old pre PBASIC 2.5. The last snippet there includes a timeout in the loops, so they don't get stuck if the process being monitored comes to a dead stop.
I developed the CT515 to deal with exactly this kind of problem. It is even more acute with things like rain gages and anemometers, which cover a wide range of frequencies down through sub-Hz to a complete stop.