View Single Post
Old 01-23-2009, 04:47 AM   #1 (permalink)
EcoModding Lurker
Join Date: Dec 2008
Location: USA
Posts: 8
Thanks: 0
Thanked 1 Time in 1 Post
Instant GPH jitter fix

I noticed the instant GPH value jumping around at idle between 2 fairly stable values, eg. .12 .12 .12 .15 .12 .12 .12 .12 .15 .12 .12

I looked at the code and found what seems to be an error in how the instant injector time is calculated. Injector pulses are counted toward the instant calculation but if the trailing "off" portion of the cycle isn't complete the elapsed time containing the pulse isn't counted. So you get a spurious GPH increase whenever this happens. This error only affects the instant GPH and MPG values. Current and tank values are accurate.

I fixed it by counting the instant pulse time and elapsed time together at the end of the injector pulse (so the "off" portion begins each cycle) and now the instant GPH value is rock solid.

void processInjOpen(void){      
  injHiStart = microSeconds();  
void processInjClosed(void){      
  long t =  microSeconds();
  long x = elapsedMicroseconds(injHiStart, t)- parms[injectorSettleTimeIdx];       
  if(x >0)
    tmpTrip.injHius += x;       

  if (tmpInstInjStart != nil) {
    if(x >0)
      tmpInstInjTot += x;     
  } else {
    tmpInstInjStart = t;
  tmpInstInjEnd = t;

  Reply With Quote