View Single Post
Old 05-20-2008, 12:21 PM   #103 (permalink)
needs more cowbell
dcb's Avatar
Join Date: Feb 2008
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
Originally Posted by Yoshi View Post
arduino 0011 was release on March 28, and they changed the millis() on April 18.
timer0_clock_cycles variable is defined instead of timer0_overflow_count.
Nice catch We will have to add an #ifdef to do the right thing when arduino 12 comes out.

Originally Posted by Yoshi View Post
No, I don't think so.
I observe the injector pulse width and RPM number are changing individually and no relations between them.
Sorry, what I meant was that if you get X number of injector pulses in a second, then you probably have an indication of RPM, at least for most vehicles. Or if you know the time between pulses (not the pulse width).

Originally Posted by Yoshi View Post
I saw "attachInterrupt" source and found it's just initializing interrupt register.
I believe you'll see unstable calc results without setting cli().
I looked it up in the datasheet. Interrupts are disabled by default when an interrupt occurs:
"When an interrupt occurs, the Global Interrupt Enable I-bit is cleared and all interrupts are disabled. The user software can write logic one to the I-bit to enable nested interrupts. All enabled interrupts can then interrupt the current interrupt routine. The I-bit is automatically set when a Return from Interrupt instruction -RETI-is executed."

My concern with leaving the interrupts disabled is that while processing an injector interrupt, we WILL eventually lose some vss interrupts, or vice versa. So I may try to enable nested interrups so we don't lose data and try and make the code "interrupt safe", as it were.

Originally Posted by Yoshi View Post
//attach the vss/buttons interrupt
ISR( PCINT1_vect ){ 
  static byte vsspinstate=0;
Regarding to your code above, I think the "vsspinstate" variable has to be a global.
A method static variable will retain its value between calls. The variable just isn't accessible outside the method is the only difference with global. That code does need revamping though. I think there is more resolution available at low speeds if we keep track of the milliseconds between vss pulses rather than just a count. But not a big deal.


Last edited by dcb; 05-20-2008 at 12:32 PM..
  Reply With Quote