cesanta / mongoose-os

Mongoose OS - an IoT Firmware Development Framework. Supported microcontrollers: ESP32, ESP8266, CC3220, CC3200, STM32F4, STM32L4, STM32F7. Amazon AWS IoT, Microsoft Azure, Google IoT Core integrated. Code in C or JavaScript.
https://mongoose-os.com
Other
2.51k stars 429 forks source link

ESP8266 - PWM limit at 10kHz #462

Closed pankleks closed 5 years ago

pankleks commented 5 years ago

Hello,

It looks like PWM freq. is limited to 10kHz directly in the code:

https://github.com/mongoose-os-libs/pwm/blob/master/src/esp8266/esp_pwm.c#L150

10kHz is not enough for applications like FAN control.

ESP8266 is capable of running PMW at 25kHz - tested with direct Arduino code.

Forum discussion for ref:

https://forum.mongoose-os.com/discussion/3735/pwm-at-25khz

Thanks!

pimvanpelt commented 5 years ago

If you're controlling fans, I recommend you use a PWM Fan Controller. I have this particular unit in a deployment, and it works just fine. You can set PWM speeds (both RPM and duty cycle) via I2C. That sounds a lot more reliable than using bitbanging PWM from the MCU (and as a bonus, the chip will give you 5 channels).

pankleks commented 5 years ago

Thanks - looks like neat chip, although it adds another component to the system and if 8266 is capable of doing something I find no reason to add separate component.

I'm currently running 8266 controlling 2 fans independently on separate pins (running arduino code) for 24/7 - all is stable and chip is not even hot.

Chip you mentioned is cheap but it still cost nearly same as 8266 itself:)

rojer commented 5 years ago

ok, in my testing 25 KHz definitely works, even 40 KHz does. i'm removing the check and let you guys figure out what makes sense for yourself.

pankleks commented 5 years ago

Thank you!