Hi,
Had an Arduino Nano feeding a IRLB8721 mosfet to a 12v 120mm pc type fan, using the standard PWM at 500hz and 8 bit, which all worked fine and quietly.
Transfered and updated the pwm code to an ESP32 with the same frequency but this time the fan spins ok, but emits a loudish high frequency sound, almost like singing.
Tried 1000hz and 2000hz, 8 bit but still the same
I first tried to reproduce it on the bench, but the first time used an opto coupled mosfet board and the fan worked quietly, but if I connected th ESPs pin direct to the mosfet, with or without the usual base and pull down resistors, it just starts to 'sing' again.
Don't have a scope handy atm and a volt meter just shows normal voltages.
Any suggestions whats causing this problem and how to overcome it ?
Edit - seems anything 200nf or greater across the Mosfets gate and ground stops the singing, though would still be interested to know what the difference / cause is, the ESP32s internal hardware or a software setting ?
All we are using is -
const int coolfanPIN = 14;
pinMode(coolfanPIN, OUTPUT);
ledcSetup(0, 500, 8);
ledcAttachPin(14, 0);
ledcWrite(0, coolpwmFlag); // =255