Skip to content
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

PWM frequency #18

Open
kjkent opened this issue Aug 3, 2023 · 2 comments
Open

PWM frequency #18

kjkent opened this issue Aug 3, 2023 · 2 comments

Comments

@kjkent
Copy link

kjkent commented Aug 3, 2023

Hi there, and thanks for writing this useful library! Do you have any plans to implement the ability to set the PWM frequency, and would you be open to a PR that implements this? My L298N makes a pretty harsh whine at the frequency it's currently at.

Thanks!

@AndreaLombardo
Copy link
Owner

Hi, thank you for your appreciation.
Unfortunately right now I don't have much time to spend on this project.
If you have a solution to the problem, it would be interesting to see it.
Thank you!

@kjkent
Copy link
Author

kjkent commented Aug 28, 2024

Hey @AndreaLombardo! Super late follow-up as I've only recently found time myself to look at this.

So the standard Arduino analogWrite() uses a set Hz value for its PWM, I think it's ~500-900Hz depending on IC/pin.

It's fairly easy to implement a frequency change on, e..g., an ESP-32 (which is the platform I'm using), but, doing so seems to conflict with the use of Arduino's functions which will expect the PWM to be at its standard frequency. Straying from such ruins the portability the library has, so its not much of a PR-able solution.

My next step is to see how Arduino manages cross-compatibility with its existing library. Also, Particle seems to have an API that's based on, and extends, Arduino, and their analogWrite() accepts a third argument for frequency. As they produce dev kits across multiple IC platforms, their codebase may hold some good tips!

I'll report back if/when I figure anything useful out (see you next year! 👋 😆)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants