Quote:
Originally Posted by s2man
I thought we were sending three values from the controller: 1) VSS pulse count per second (or other interval). 2) Injector pulse count per second. 3) Injector pulse width. Which cycles are you referring to?
|
Three is probably good enough and what I have the dummy signal generator doing above. The other value was the elapsed time according to the freeduino, but in thinking about it we probably don't need it.
Quote:
Originally Posted by s2man
data will be sent as characters, one byte each, via serial communication.
|
Can we use the above output format?
Quote:
Originally Posted by s2man
Gathering these data will use all of three our timer/counters.
|
Is there a way to just use one timer to figure out when a second has passed? Coyote mentioned that an interrupt could be made to occur when the injector goes hi and again when low, so it should be a matter or recording the "current time" on the injectorHI interrupt and subtracting it from the "current time" on the injectorLO interrupt and adding it to this seconds totals. I.e. borrow the code from millis() and see if we can make a micros() function? I can look into that if you like.
My understanding is that external interrputs are handled by specific functions, not necessarily timers.
so very rough sketch (assuming we can come up with micros()):
Code:
unsigned long injHiMS
unsigned long injCount
unsigned long vssCount
unsigned long injHiStart
processInjHi(){
injHiStart = micros();
}
processInjLo(){
injHiMS += micros()-injHiStart
injCount ++
}
processvssHI(){
vssCount++
}
processOneSecondEvent(){
//copy and reset the values first thing in case an interrupt occurs
// serial comm (or LCD displaying) is going to take awhile
//and shouldn't be top priority.
unsigned long tmpInjHiMS = injHiMS
injHiMS=0
unsigned long tmpInjCount = injCount
injCount=0
unsigned long tmpvssCount = vssCount
vssCount=0
Serial.print(tmpIinjHiMS, HEX);
Serial.print(",");
Serial.print(tmpInjCount, HEX);
Serial.print(",");
Serial.println(tmpvssCount, HEX);
}
unsigned long micros(){
uhh....
}
See also:
http://www.arduino.cc/en/Reference/AttachInterrupt