Continue to Site

Welcome to our site!

Electro Tech is an online community (with over 170,000 members) who enjoy talking about and building electronic circuits, projects and gadgets. To participate you need to register. Registration is free. Click here to register now.

  • Welcome to our site! Electro Tech is an online community (with over 170,000 members) who enjoy talking about and building electronic circuits, projects and gadgets. To participate you need to register. Registration is free. Click here to register now.

ESP32 PWM 'singing' Fan

Status
Not open for further replies.

Wp100

Well-Known Member
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
 
Last edited:
Use 12k to 20k Hz. The 12k May be barely noticeable but unlikely the 20k will be noticed. Seems like very high frequency but your motor won't care. The big capacitor on the mosfet gate can cause heating of the Mosfet because you are slowing switching times. Remove these caps, especially if you are using higher PWM frequencies.
 
PS - the steel actually changes dimensions under a magnetic field and can cause an audible noise. The general solution is to operate above or below human hearing frequencies.
Note that LEDs do not change dimensions so they do not create noise under PWM control.

 
Thanks for the replies.

Tried 12k , 20k and even 100khz but no change in the fan noise ..??

The cap had been removed.

Will have to find some different make of fan and change the actual port pin and see if that makes any difference ...

Also have a bank of leds at 1k hz on another pin to the same type of logic level mosfet , and that fades from 0 to 255 etc ok .
 
Do you have a 4 wire fan? If so, you can feed the PWM pin without the need for a mosfet. From memory, the PWM has to be about 24kHz.

Many Arduinos do PWM at something like 600Hz which can be a big problem.

Mike.
 
Do you have a 4 wire fan? If so, you can feed the PWM pin without the need for a mosfet. From memory, the PWM has to be about 24kHz.

Many Arduinos do PWM at something like 600Hz which can be a big problem.

Mike.
That's the cool part of the ESP32 that the OP said he is using (see title). The Ledc commands lets you set up PWM at any frequency and resolution within allowable physics. .

It can do 5kHz at 13 bits of resolution or 10k at 12-bits and 40k at 10bits or 160kHz at 8bits and so on.
I don't use anything else lately.
 
Is the singing only happening at very low duty cycles or all duty cycles. If you change from 90 to 100% will it sing. Or only when you traverse the whole 1 to 100%?
 
I found it strange that it didn't "sing" with a Nano but does with the ESP. Could it be the different operating voltage causing the mosfet to not fully turn on?

Mike.
 
To Clarify - the Arduino Nano version, ( original Nano , not the new ones, clone board) the PWM was at the default 500hz , but it was running at 3v3 as I changed its voltage regulator to 3v3 so it was compatible with things like the touch screen and sensors etc. The 12v fan worked fine and quiet on that system.

The ESP32 is using the same 1A 5v and 1A 12v PSU and LL Mosfet board, so thats the only difference .

I can replicate the system on the bench using a different PSU and get the same results, however If I use a different mofset board that has an opto input, the fan does not sing.

The fans I am using are just 2 wire, chosen because they are made with clear plastic as they are visible and that they were low noise.

Will try and find some other fans and see what results I get.

Thanks
 
To Clarify - the Arduino Nano version, ( original Nano , not the new ones, clone board) the PWM was at the default 500hz , but it was running at 3v3 as I changed its voltage regulator to 3v3 so it was compatible with things like the touch screen and sensors etc. The 12v fan worked fine and quiet on that system.

The ESP32 is using the same 1A 5v and 1A 12v PSU and LL Mosfet board, so thats the only difference .

I can replicate the system on the bench using a different PSU and get the same results, however If I use a different mofset board that has an opto input, the fan does not sing.

If a different mosfet board cures it, that sounds like it's not switching correctly.
 
Finally got two more fans, (black plastic body) both different makers, and neither of them 'sing' when driven by the ESP32 yet revert to the orignal Clear plastic fan and it sings away, at any pwm setting eg 255, 125 or 85 or any frequency up to 100k hz. ( it does not sing if using 12v direct)

The Mosfet, driven direct, via 220r and 100k pull down, is the same type as used in the opto/mosfet module and the same mosfet when we used the Nano board which did not cause the original Clear plastic fan to sing.

So still no idea why that fan sings, seems its a combination between this particular fan and the ESP32, but as said eariler its on show and really wanted a clear plastic body, but they seem far and few between and the few that are seem to be from the same maker.

Seems the answer will be to update the working system with an opto coupled mosfet board as that does stop the singing.
 
Status
Not open for further replies.

Latest threads

New Articles From Microcontroller Tips

Back
Top