jremington:

Post a schematic diagram of the circuit (no Fritzing, please), a link to the sensor data sheet, and if possible, show a scope trace of the signal being fed to the Arduino.

I am attaching the circuit, and the signal that I am feeding to arduino from the oscilloscope. Regarding, the sensor data sheet I didn’t find any it gives vp-p + or - 10 V. It’s just a standard pick up magnetic sensor, nothing fancy.

Note:- I am feeding vp-p 0 to 2v to arduino.

cattledog:

As jremington has stressed, getting a clean signal is key to your application.

Do you have a zero index point? → what do you mean by this. The problem with my signal is, it has frequency modulation. So, the time period of pulses always changes. That is why I am stressing too much on calculating time period of each pulse. Check the signal that is being fed so you can get an idea of what I am saying. I am doing all these calculations as you can see in my code.

```
rpm = (freq * 60) / 113; // to calculate the rpm of the flywheel
rpm_exponentialavg = rpm_exponentialavg * 0.99115044 + rpm * 0.00884956; // exponential smoothing average of the rpm being calculated
Inst_speed = rpm_exponentialavg - rpm; // to calculate the instantaneous speed of the flywheel for every tooth
sinval = sin(6*pii* count/113); // to calculate the sine of angle between the teeth in radians.
cosval = cos(6*pii* count/113); // to calculate the cosine of angle between the teeth in radians.
count++; // increment the counter for every tooth passing.
sincomp = sinval * Inst_speed; // to calculate the sine component to perform fourier transformation
coscomp = cosval * Inst_speed; // to calculate the cosine component to perform FT.
// to calculate the exponential smoothing averages of sine and cosine, we get
sincoeffavg = sincoeffavg * 0.017 + sincomp * 0.983;
coscoeffavg = coscoeffavg * 0.017 + coscomp * 0.983;
thirdOrder = 2*sqrt(sincoeffavg*sincoeffavg + coscoeffavg*coscoeffavg)*(2*pii/60)*rpm_exponentialavg*6*pii/60;
```