-
Notifications
You must be signed in to change notification settings - Fork 209
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
More flexible PWM_Controller #97
Comments
This is the ESP32.cpp
|
Inadvertently working on this while adding support for the ESP32-S3. Moving over to LEDC from FastPWM. I'm getting issues though because in order to use LEDC's auto-timer allocation, esp32:esp32 >3.0.0 needs to be used, and when switching over to the development branch for that core I just get drowned in compile errors when trying to build a program from within OpenPLC |
Esp32_fastPWM is already using ledc timers... My example in the comments is working with a esp32 wroom board. |
Might be more appropriate to add comments to the PR I just opened: #106
Internally yes, but looking at the GitHub repos it seems that the maintainer of ESP32_fastPWM no longer intends to maintain it. This wouldn't be aproblem if it worked properly, however I found that (at least on my board) it was not able to do a duty cycle of 0% or 100%, which was extremely inconvenient.
It helps a lot because it means that we are no longer statically defining mappings of timers and channels. It means that you can use all timers your board has built in, not just the ones defined in esp32.cpp. This in turn allows for the channel fed to the PWM_CONTROLLER block to simply correlate to a pin on your board, instead of ones statically defined in esp32.cpp
I was able to verify that there were issues with FastPWM on the S3, however have not been able to debug my LEDC implementation yet because of some funky versioning problems. Went into more detail in the draft PR |
Managed to get all the code on my end sorted out, and if you're still looking for a better PWM_CONTROLLER implementation I'd appreciate some testing of the code in my PR. It likely won't merge until 3.0.0 of arduino-esp32 is released, however as far as I've observed it's pretty stable (why I'd appreciate some testing) Breaking change from a code side is that the CHANNEL of the PWM_CONTROLLER block now directly correlates to the pin you want to do PWM on. |
Hi Thiago,
i just realized that the call of a single pwm_controller function block will trigger the creation of all possible PWM_Instances.
So all possible pwm pins are reserved for pwm, even if only 1 channel/pin is used.
I did some reading and realised that if a pin is dedicated to a PWM_Instance, it cannot be used for something else.
So i think something like this is not needed:
I then played around and ended up with this solution without the
void init_pwm()
functionWith this, only the pins/channels that are used at the PWM-Controller instances are reserved for PWM.
All other unused potential pwm pins can be used as digital/analog input/output.
I have carried out tests with different constellations on my ESP32 board. So with different numbers of pwm pins and digital IOs.
It seems to work.
Wanna also give it a try?
The text was updated successfully, but these errors were encountered: