I’m trying to measure RPM using an int0 (highest priority).
The problem is: Every few seconds I get a “spike” at exactly double the frequency.
It seems to be more apparent at low frequencies (<10Hz).
The input circuit is as in picture below.
I’m using a proper signal generator and an oscilloscope… the input signal is solid and it’s a 0-10V signal.
For code, I tried different options. Right now, I reduced it to the most simple logic, but the problem still persists:
volatile unsigned long t;
unsigned long RPMtimePrev;
volatile unsigned long RPMperiod;
int RpmScale=100; //constant for scaling the input
RPM formula I’m using for calculating the RPM:
Any idea what might be causing the problem?