View Single Post
Old 04-04-2008, 07:28 AM   #2 (permalink)
dcb
needs more cowbell
 
dcb's Avatar
 
Join Date: Feb 2008
Location:
Posts: 5,038

pimp mobile - '81 suzuki gs 250 t
90 day: 96.29 mpg (US)

schnitzel - '01 Volkswagen Golf TDI
90 day: 53.56 mpg (US)
Thanks: 158
Thanked 269 Times in 212 Posts
Quote:
Originally Posted by s2man View Post
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 View Post
data will be sent as characters, one byte each, via serial communication.
Can we use the above output format?

Quote:
Originally Posted by s2man View Post
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
__________________
WINDMILLS DO NOT WORK THAT WAY!!!

Last edited by dcb; 04-04-2008 at 07:59 AM..
  Reply With Quote