Quote:
Originally Posted by Yoshi
|
Nice catch
We will have to add an #ifdef to do the right thing when arduino 12 comes out.
Quote:
Originally Posted by Yoshi
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).
Quote:
Originally Posted by Yoshi
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.
Quote:
Originally Posted by Yoshi
Code:
//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.
Thanks!