Likely, your mistake is declaring n2pulse as int, it overflows and results getting unpredictable http://arduino.cc/en/Reference/Micros
Yes it was. I changed and it works as expected.
From what I've read about interrupts, the interrupt service routine is supposed to do an absolute bare minimum, such as setting a state flag.
I'd prefer the ISR to just take the difference between current and previous readings and store it, leaving the lengthy floating point calculations to be done outside the ISR.
Thats another thing i will care more from now on.
On another note, I'm wondering why pin 2 is named "stew"... smiley-cool
I like sometimes to call the variables fancy names, "Moqueca" is a brazilian fish dish,
I´m interested in the sensor you are using, can you pls post a link or something ?
Te sensor is a CKP (crankshaft position sensor from a mazda 6 engine), you will find it easy in any car junkyard. Mine is from a japanese brand, DENSO, and honestly i don t have any technical data about it, and googled already.
The Bosch ones are much more easy to find and also the related technical data.
Send me a PM with your mail and i will mail a Bosch catalogue with this kind of data.
Thanks again everyone.