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