Sorry, I was quite bussy, I'll try to finish the documentation later today. I will apear on Wiki pages.
ESP32 maximum PWM frequency
Re: ESP32 maximum PWM frequency
Re: ESP32 maximum PWM frequency
Just to close the loop, I just noticed that the PWM wiki page is online. Thanks @loboris!
Re: ESP32 maximum PWM frequency
@laboris Would it be possible to add a feature so you could programmatically invert or offset the duty cycle of some of the channels on a timer?
Re: ESP32 maximum PWM frequency
All PWM channels using the same timer have the same frequency and phase.
PWM channel started with different timer will have some random offset depending on time when the timer was started.
It could be possible to synchronize two PWMs, each using a different timer, in such way that one is started at the known time after the other.
That time would be the phase offset between channels.
If that time is half the timer period and the channels period and duty cycles are the same, the PWM's outputs would be inverted.
I'll test it and add that option if it works as expected.
Re: ESP32 maximum PWM frequency
Thanks, that would be very helpful.loboris wrote: ↑Tue Jan 30, 2018 7:34 pmAll PWM channels using the same timer have the same frequency and phase.
PWM channel started with different timer will have some random offset depending on time when the timer was started.
It could be possible to synchronize two PWMs, each using a different timer, in such way that one is started at the known time after the other.
That time would be the phase offset between channels.
If that time is half the timer period and the channels period and duty cycles are the same, the PWM's outputs would be inverted.
I'll test it and add that option if it works as expected.
Re: ESP32 maximum PWM frequency
Hi, lobo, tremendous work!loboris wrote: ↑Tue Jan 30, 2018 7:34 pmAll PWM channels using the same timer have the same frequency and phase.
PWM channel started with different timer will have some random offset depending on time when the timer was started.
It could be possible to synchronize two PWMs, each using a different timer, in such way that one is started at the known time after the other.
That time would be the phase offset between channels.
If that time is half the timer period and the channels period and duty cycles are the same, the PWM's outputs would be inverted.
I'll test it and add that option if it works as expected.
Any ideas on how to synchronize two PWMs?
I have seen an option:
#define MCPWM_EN_SYNC 0 //Make this 1 to test sync submodule of mcpwm, sync timer signals
in ESP32-IDF
examples/peripherals/mcpwm/mcpwm_basic_config/main/mcpwm_basic_config_example.c
Idea 1) STM32 module in micropython exposes underlying hardware registers. Reading and writing those registers allows for pretty comfortable control of timers/PWM pins. However, the only option to start two PWM pins with predefined phase shift is through @asm_thumb code. This seems not to be available in ESP32 micropython. Is inline C code possible?
Idea 2) writing my own C code for starting two PWM channels on two given Pins and exposing the function to micropython
Which do you think leads to faster results?
Tried to implement @micropython.asm_xtensa decorator for ESP32, but it fails with CPU crash.
What is the status of the inline assembler for the new ESP32 dual core processors?
Roberthh wrote: ↑Mon Jan 15, 2018 9:13 pm...
https://github.com/micropython/micropyt ... d2db3ff4a3
Code: Select all
@micropython.asm_xtensa def do_loop(): movi(a2, 0x60000300) # GPIO Base address movi(a5, 0x10) # set/clear bit 4 movi(a3, 10) # loop ...
-
- Posts: 35
- Joined: Thu Feb 13, 2020 10:10 pm
Re: ESP32 maximum PWM frequency
I know that this is an old post, but I want to know if there are any news. I mean, I'm trying to generate Three-phase PWM with complementary and dead time. Can't find a way to do that with Micropython.
- OlivierLenoir
- Posts: 126
- Joined: Fri Dec 13, 2019 7:10 pm
- Location: Picardie, FR
Re: ESP32 maximum PWM frequency
Have a look at post viewtopic.php?f=2&t=7774&start=10 about MicroPython and Power Electronics - Electrical machine control. It may answer part of your questions.
Olivier Lenoir
https://gitlab.com/olivierlenoir
https://gitlab.com/olivierlenoir