View Single Post
Old 08-31-2011, 08:19 AM   #2 (permalink)
winker
EcoModding Lurker
 
Join Date: Nov 2009
Location: UK
Posts: 18
Thanks: 0
Thanked 2 Times in 2 Posts
Here is my modified code (pin 10 was setup to output the digitaly processed signal (i.e. the square wave)

It use the injector settle parameter to determine if it is seeing a start pulse (I have mine currently set to 80uS, which as you can see works quite well).

Code:
#define dspInjectorPin 10

boolean lookForOpenPulse = true;


void processInjOpen(void){      
  //20110831 AJT Peak and Hold ;)
  if(lookForOpenPulse){
    injHiStart = microSeconds();
    digitalWrite(dspInjectorPin,HIGH);  
  }
}      

void processInjClosed(void){
  //20110831 AJT Peak and Hold ;)
  long t =  microSeconds();
  long x =  elapsedMicroseconds(injHiStart, t);   
  if(x<parms[injectorSettleTimeIdx]){
    lookForOpenPulse=false;
  } 
  else {
    //    if(!lookForOpenPulse){
    tmpTrip.injHius += x;       
    tmpTrip.injPulses++;      
    if (tmpInstInjStart != nil) {
      tmpInstInjTot += x;     
      tmpInstInjCount++;
    } 
    else {
      tmpInstInjStart = t;
    }  
    tmpInstInjEnd = t;
    //    }
    lookForOpenPulse=true;
    digitalWrite(dspInjectorPin,LOW);  
  }
}

pinMode(dspInjectorPin,OUTPUT);

The following is a trace showing the injector input at the top, and the digitally processed signal (pin10) out. Looks good!

https://picasaweb.google.com/lh/phot...eat=directlink

and zoomed in (note small spike is injector opening and large spike is injector closing).

https://picasaweb.google.com/lh/phot...eat=directlink

and the following shows a close up at idle of my injector signal

https://picasaweb.google.com/lh/phot...eat=directlink

Last edited by winker; 09-01-2011 at 04:39 PM.. Reason: Found bug in code, so before any comments added sorted it.
  Reply With Quote
The Following User Says Thank You to winker For This Useful Post:
California98Civic (09-08-2011)