analogWrite - PWM frequency and resolution #8881
ThomasManz
started this conversation in
General
Replies: 2 comments 1 reply
-
the function __analogWriteFreq seems not set the limit to the input seq. |
Beta Was this translation helpful? Give feedback.
0 replies
-
I think you the lower frequency that you want to create, can write a task
do it by yourself
…On Fri, May 19, 2023 at 10:17 AM cloudPic ***@***.***> wrote:
the function __analogWriteFreq seems not set the limit to the input seq.
I hava the same question:why not support the 50hz or lower ?it will not
cause any problem.
—
Reply to this email directly, view it on GitHub
<#8881 (comment)>,
or unsubscribe
<https://github.com/notifications/unsubscribe-auth/AAFR5TON27FHE5NDM4LCHATXG3J2BANCNFSM6AAAAAAVSSSJCE>
.
You are receiving this because you are subscribed to this thread.Message
ID: ***@***.***>
--
This email (including any attachments) is confidential and may be legally
privileged. If you received this email in error, please delete it
immediately and do not copy it or use it for any purpose or disclose its
contents to any other person. Thank you.
本电邮(包括任何附件)可能含有机密资料并受法律保护。如您不是正确的收件人,请您立即删除本邮件。请不要将本电邮进行复制并用作任何其他用途、或透露本邮件之内容。谢谢。
|
Beta Was this translation helpful? Give feedback.
1 reply
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
Hello,
I wanted to create a PWM signal with 20 ms period / 50 Hz for an average servo motor. I´m aware that only frequencies above 100 Hz are officially supported, so I´ve expected that calling
analogWriteFreq(50);
would just create a 100 Hz signal.But this was not the case, actually a 50 Hz signal was created but with a wrong duty period. I think the root cause is the function __analogWriteFreq():
Arduino/cores/esp8266/core_esp8266_wiring_pwm.cpp
Lines 35 to 44 in 32323e5
I would suggest the final call should be
_setPWMFreq(analogFreq);
otherwise the module keeps calculating with the corrected frequencyanalogFreq
but the actual frequency is the maybe illegal requested one.Side question: why does this module limit the frequency to > 100 Hz when e. g. 50 Hz seems to work??
Additionally I had problems with increasing the resolution - it works fine up to 13 bits with
analogWriteResolution(13);
, as soon as I set it to 14, 15, or 16 (even with a "legal" frequency) then the duty period is not correct any more. I did not analyze this issue - did anyone else have the same problem or even knows the root cause?Final question: I realized that when using PWM then
loop()
is executed with the frequency of the PWM signal - is this the expected behavior? Is there a way to avoid that and getloop()
executed as often as possible?Best regards,
Thomas
Beta Was this translation helpful? Give feedback.
All reactions