Answer the question
In order to leave comments, you need to log in
How to beat PWM hum on ESP?
Hey! NodeMCU is connected to PWM with LED strip, PSU with a margin, nothing gets hot but buzzes when PWM != 0 || != 100
Googled and it seems like they say that it helps to increase the frequency on arduino, but how to do it for ESP? google doesn't say :(
#define TABLE_LIGHT 12
pinMode (TABLE_LIGHT, OUTPUT);
String strPayload = String((char*)payload); //считываем значение топика
int val = strPayload.toInt(); //конвертируем для шим
int stled = map(val, 0, 100, 0, 1024); //приводим значение 0-100 в значение 1024-0
set_pwm_smooth(stled);
void set_pwm_smooth(int new_pwm) {
static const int pwm_step = 1; // шаг изменения ШИМ
static const int pwm_step_time = 3; // время одного шага изменения ШИМ
static int stled;
int pwm = stled;
while (pwm != new_pwm) {
int next_pwm = pwm + (pwm < new_pwm ? pwm_step : -pwm_step);
if ((pwm < new_pwm && next_pwm > new_pwm) ||
(pwm > new_pwm && next_pwm < new_pwm))
pwm = new_pwm;
else
pwm = next_pwm;
analogWrite(TABLE_LIGHT, pwm);
delay(pwm_step_time);
}
stled = new_pwm;
}
Answer the question
In order to leave comments, you need to log in
1) Decrease pwm_step_time;
2) Try to put the LC filter on the output of the block. Capacitor (Electrolyte+ceramic in parallel) in parallel with the supply, and inductor in series. Check all winding parts in the PSU - chokes and transformers. Coat with varnish if necessary.
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question