My car has a tachometer output, with square 0-12V signal (verified with an oscilloscope), frequency is from 20Hz to 500Hz.I've made a small input adaptor to have a square 0-5V input for the arduino, which is working as far I can see on my DSO Nano V2 (low cost oscilloscope).

The problem is: the frequency measured by the arduino is moving continuously. It's never stable.

I've tried with a square signal generated from the DSO Nano and the measure is stable.

My opinion is: there is some noise on the input signal in the car which is measured by the arduino. The library I use is simply counting the rises on the input regarding the time, and noise could make some rises.

Here is the adaptor circuit for the input. I'm using the ULN2803 as a driver for LEDs, and there was 2 network unused, so I've take one to do the trick.

You need to condition the noisy signal better. I'd propose a low-pass RC stage with a cut-off around 1 to 2 kHz, followedby a schmitt-trigger to generate clean logic signals.

You should also filter out really high frequencies with a 100pF capacitor directly across the incoming cable (alwaysworth doing for slow signal sources, such as audio, to cut out most of the radio-frequency interference).

A suitable RC stage would be 10k in series to 10nF to ground - cutoff around 1600Hz. You also need to reduce to 5Vsignal level and feed to a schmitt trigger stage such as a 74HC14 inverter.

Now for the theory:

Logic signals need to transition from LOW to HIGH (or vice versa) very fast (millions of volts per second) - this isessential for correct circuit operation. Anything can happen if the signal changes too slowly (many multiple pulsesmay be registered, the circuit may temporarily go into a high-current-dissipation state, it may oscillate at radiofrequencies).

Thus a schmitt-trigger gate is needed to clean up the unknown noisy signal before the Arduino. Schmitt-triggersclean up any slow transition with positive feedback and guarantee fast transitions (and reject noise spikes completelybelow a threshold amplitude).

But you likely have noise spikes from the car ignition all over your signal - low pass filtering can knock the amplitudeof these right down to below the level the schmitt-trigger will recognise.

Just with the RC network before the darlington, no more bad ready, the frequency measure is steady

I need to improve the speed now, my tachometer has a refresh rate of 1sample/second, it's really too slow

Thank you for your help

I'm glad it works.

One of the difficult decisions with a digital tachometer is what to use for an update speed. I prefer an analog tachometer for that reason. You could consider using a digital bar graph or if possible a sort of "pie chart" to simulate the good things about an analog readout. Keep the digital for "cruising".