Page 2 of 3

Re: PWM controlled fan tacho wrong

Posted: Mon Jan 06, 2020 9:42 pm
by maxus1998
I discovered that using a longer cable from the pull up resistor to the reading pin seems to bring correct readings.
Because of this I tried using a 330 Ohm Resistor instead of the longer cable which also seemed to work...

My goal is to turn this into a PCB. Would I need to add those resistors there too? This would need addittional 8 resistors...
Any idea how that behavior works?

Re: PWM controlled fan tacho wrong

Posted: Tue Jan 07, 2020 2:25 am
by ESP_Sprite
Hard to say without scope readings... we have no clue what's going on on that line at the moment, especially because the fan electronics itself is more-or-less a black box. (On a side note, your worry about having to design in 8 resistors is... interesting. If I were in your position, I'd just design in the positions for those resistors regardless, and fill them with 0 ohm links if they turned out to be unnecessary.)

Re: PWM controlled fan tacho wrong

Posted: Tue Jan 07, 2020 5:04 am
by maxus1998
I am happy to use those additional 8 resistors, I am just not sure if it is the correct solution,

What exactly do you mean with scope readings? Did you just miss my post with the pictures or would you want to see something else?

Re: PWM controlled fan tacho wrong

Posted: Tue Jan 07, 2020 9:16 am
by ESP_Sprite
Ah, I'm sorry - I indeed missed the readings because of the pagination of the topic.

From what I can see, your issue may very well be that the ESP32 is triggering on noise induced by the regulation of the fan; adding a R in the line probably creates a RC-filter in combination with the implicit capacitance of your wiring and the ESP32 pin. Can you try removing the resistor and adding a capacitor of, say, 1nF from the tacho output to ground? In combination with the pullup, this sort-of makes the RC network more explicit and should filter out the spikes in a more deterministic way.

Re: PWM controlled fan tacho wrong

Posted: Tue Jan 07, 2020 10:41 pm
by maxus1998
Adding the 1nf capacitor did indeed help. The values seem quite realistic but a bit high now. I read 3000rpm ok my 400-2000 rpm fan, while the slower noctua one looked fine.
I will try to use a slightly higher value capacitor tomorrow and get some new measurements with the capacitors.

Re: PWM controlled fan tacho wrong

Posted: Wed Jan 08, 2020 2:57 am
by ESP_Sprite
Sure. If you want to go all-in, you can also have the series resistance in to create a 'proper' RC filter (so fan tacho out - resistor to 3.3V - series resistor - capacitor to gnd - esp32 input pin).

Re: PWM controlled fan tacho wrong

Posted: Wed Jan 08, 2020 9:03 pm
by maxus1998
I swapped the 1nf capacitor now for a 680pf and the values read by the ESP32 seems to be fine. The Corsair fan reaches right around 2000RPM and the noctua one about 1600RPM, both values are the manufacturer specifications for the maximum speed.

I can't spot any difference on the oscilloscope when using the capacitors. I don't know why but I guess I will take it as it is

So many thanks for your help!

I will ask back if I have any other awkward problems with this setup again

Re: PWM controlled fan tacho wrong

Posted: Wed Feb 19, 2020 7:25 pm
by jelly32
Just to let you know, I had exactly the same challenge and was very happy to find this thread.
I don't have an oscilloscope, but I tried a lot of combinations of pullup resistors and RC filters.
I got the best results with: fan tacho out - pullup resistor 10k to 3.3V - series resistor 3.3k - capacitor 100 pF to gnd - esp32 input pin
It works successfully with a noctua fan (max 1500 rpm) and a cpu fan (max 2400 rpm).

Re: PWM controlled fan tacho wrong

Posted: Fri May 08, 2020 2:20 am
by JohnnyG
I'm attempting to do the same thing. Is the code in the original post all that is needed?

I have a NF-A4x20 5V PWM fan. I am not even sure if the esp32 can drive that thing. I already have the temp code and webpage on/off swatch working so I want to stick with the esp32. If the esp32 won't drive it directly, I could switch over to an Arduino...I just like the esp32 a lot better.

You do you all think?

Thanks
JohnnyG

Re: PWM controlled fan tacho wrong

Posted: Thu Jun 25, 2020 5:26 pm
by ShakataGaNai
jelly32 wrote:
Wed Feb 19, 2020 7:25 pm
I got the best results with: fan tacho out - pullup resistor 10k to 3.3V - series resistor 3.3k - capacitor 100 pF to gnd - esp32 input pin
It works successfully with a noctua fan (max 1500 rpm) and a cpu fan (max 2400 rpm).
Jelly32 - Do you have a drawing of this? Even a quick sketch. I'm happened across this post and am trying to replicate your setup. My circuit design skills are only meh. Thank you so much!