Hi, im using esp32 for control servos and esc.
Due to the standard machine_pwm not supporting different frequencies on different PWM channels, I modified machine_pwm according to the following:
https://github.com/micropython/micropyt ... 280d6731a2
Unfortunately, when I try to set the freq to 50HZ I have an error:
ValueError: Bad frequency 50
Most of the standard serv runs at 50hz.
What can I do ? I am using micropython 1.12 on esp32.
Thanks for help!
PWM - different frequences.
Re: PWM - different frequences.
I don't know much about ESP32, but one of the key things is that the PWM controller is actually based on their LED driver peripheral. This is designed for doing PWM at much higher frequencies (to avoid flicker).
I noticed that the PR you copied the changes from introduces a "low speed" and "high speed" mode. Which one are you using?
Also it might be worth reading https://docs.espressif.com/projects/esp ... esolutions and https://www.espressif.com/sites/default ... ual_en.pdf (chapter 15) for more details on how this works.
Also you said you're controlling ESC and servos, why do you need a different PWM frequency for each? And many servos don't actually need 50Hz, they really just need a specific pulse time.
Re: PWM - different frequences.
I used HIGH for esc and LOW for servos. What do you mean by avoid flicker ?, that at e.g. 50hz it can cause more servo vibration than at e.g. 100hz?
Re: PWM - different frequences.
I mean it's designed for driving dimmable LEDs, where you want to PWM in the hundreds of kilohertz.
Why do you need different frequency for ESC and servos?