Okay then. The experiment worked. By excluding very high elapsed times, I've eliminated the high GPH readings.
Here's my changes:
Code:
void processInjClosed(void){
// long t = microSeconds();
// long x = elapsedMicroseconds(injHiStart, t)- parms[injectorSettleTimeIdx];
unsigned long t = microSeconds();
unsigned long s = parms[injectorSettleTimeIdx]; //set to 72
unsigned long x = elapsedMicroseconds(injHiStart, t);
if (x >= s && x < parms[pulsewidthLimit]) { //elapsed time within range of settling time(72) and upper threshold(3000)
x -= s; //then normal pulse, subtract settling time
}else{
x = 0; //otherwise pulse width assumed to be zero
}
// if(x >0) //no longer needed, x is guaranteed to be zero or greater
tmpTrip.injHius += x;
tmpTrip.injPulses++;
if (tmpInstInjStart != nil) {
// if(x >0) //no longer needed, x is guaranteed to be zero or greater
tmpInstInjTot += x;
tmpInstInjCount++;
} else {
tmpInstInjStart = t;
}
tmpInstInjEnd = t;
}
I found info for my injector that indicates the settling time should be 615uS using Yoshi's formula. I scaled that down to 72uS for the ECU signal based on the ratio of the ECU to injector pulsewidth.
The maximum pulsewidth that I've seen during normal operation is 1904uS. That's a full throttle run to redline. I've set the upper limit of the pulsewidth to 3000. I don't expect any combination of normal operation will get close to that pulsewidth.
So, the acceptable range of pulsewidths is constrained to 72-2999. Any elapsed time greater than that is assumed to be a flatline ECU signal.
In my experiment, the GPH now seems to operate normally, i.e. it drops to zero when coasting.
Now that I've found a solution, I'll merge the changes back into a clean copy of v0.75 and test it in the car for a while. I still need to fine tune the uS/gal setting for the ECU signal.