cattledog:
Series resistors are often used to reduce ringing with fast switched lines. I think the Google path to follow is "series resistor in digital lines".10K however sounds high.
Did you ever try your interrupt on FALLING instead of RISING. The ringing one the edges can be different, and the high/low hysteresis transitions values are also different. You often get less problems on one edge or the other.
Sure, I tried both RISING and FALLING, no difference whatsoever.
I was looking for some info on how is this typically implemented on PC motherboards (after all, this is what usually drives these fans). I found a couple of very similar circuit diagrams (images attached), differing mostly in values of the resistors used. Both pull-up the tacho output to +12V (not +5V, even though this is available on a motherboard), then use a voltage divider to provide a safe voltage for the motherboard to read. I'm wondering about the significance of this, if there's just an open collector transistor in the fan, why use 12V instead of 5V? Could it be that using 12V signal would be more resistant to noise? Or is it the most universal solution that would suit all the types and varieties of tacho sensor outputs used by fan manufacturers? One of the two diagram also include a 100 uF cap between the fan's +12V and GND.
cattledog:
Take a look at this low pass filter design tool.(Sample)RC Low-pass Filter Design Tool - Result -
Rise time to 90% with your design is 2.3 ms. You could try with a bigger resistor or capacitor to soften the rise even more. Using readily available resistors, 47K or 47K+22K = 69K might work better.
Thanks for the link. 0.1 uF are the biggest ceramic caps I have, I could put two in parallel. My friend told me electrolytic caps (which I have in bigger capacities) are not as good for filtering noise.
For now, the only way I can evaluate some changes is either it works properly, or it doesn't work at all. I think without an oscillograph further fiddling with the Rs and Cs can be an uncertain game.
hzrnbgy:
The datasheet is the go to for anything so that's where I would startI don't have an Arduino UNO on hand to test but this one compiles on the Arduino IDE
Thanks for the code and detailed explanations, very educational! I will try it out soon and report back.
Yes, timer0 is used by Arduino's timekeeping functions. So, delay(), millis(), micros() would not work properly. Timer2 is also 8-bit like timer0, I think I should try using that one for PWM.

