Log FuelFlow -Reading 4 frequency inputs (digital on/off) and logging to SD card

zenseidk:
In this new version I changed the pgenPreviousMicros to static unsigned long as you suggested, but to no effect, apparently. pgen is still not working.

I don't see that change in the version you attached.

The basic use of nowMicros in pulseMeasure() looks OK, but I think there is a problem due to the fact you're using it in a FOR loop. It would probably work by mistake. I would expect it to detect (nowMicros - previousMicros > 1000000) is true for the first element in the loop, write the entry to the log and then update previousMicros so that the condition is no longer true for the subsequent loop iterations. The SD output shouldn't be inside the FOR loop, should it?

unsigned long nowMicros = micros();
for (int i = 0; i < qty; i++) 
{
    digital read, change detection, pulse length calculation, flow rate calculation, update cumulative total
}
if (nowMicros - previousMicros > 1000000UL) 
{
    previousMicros += 1000000UL;
    write stats to SD
}