desbr
April 15, 2025, 8:12pm
1
Cruel Doubt
How to control the PWM frequency (speed) of Arduino ports?
This is my doubt.
I know that the PWN ports are (3,5,6,9,10,11).
However, the digital ports (3,9,10,11) have a maximum speed of 490Hz.
And the digital ports (5,6) have a maximum speed of 980Hz.
I am having doubts about creating a code that uses a potentiometer in a voltage divider entering A0 that controls this speed.
For example, ports (3,5,6,9).
(3,9) when rotating goes from 0Hz to 490Hz.
(5,6) when rotating the same potentiometer goes from 0Hz to 980Hz.
Could someone help me, I'm a dunce when it comes to programming. I only know electricity.
Thank you very much in advance.
I'm guessing that your code controls the duty cycle, not the frequency. For example, analogWrite() doesn't change the frequency.
I've never played with this, but Secrets of Arduino PWM talks about ways of changing the PWM frequency. I assume there are possible side-effects when you mess with the registers and it might affect other timer-related operations.
kmin
April 15, 2025, 8:45pm
3
What is rotating?
It's always 490Hz, duty cycle changes if you code so.
DaveX
April 15, 2025, 8:51pm
4
Rather than PWM, do you want something like the tone() -based built-in examples? Maybe the pitch-follower?
desbr
April 15, 2025, 11:34pm
5
My question is how to make it work on the brushless motor ESC.
I read on the internet that it works with the program that is used to move the servo motor.
However, I tested it and mine did not work.
I was thinking that it was the pulse speed that the servo library was low.
That's why I thought about increasing it.
But I also believe that these purchases from Aliexpress came defective. Neither of the 2 ESCs I bought worked!
But the example codes from the IDE worked with my servo motors.
b707
April 15, 2025, 11:49pm
6
Please show the code. Discuss an issues in the code without the code itself is pointless.
desbr:
digital ports (3,9,10,11) have a maximum speed of 490Hz.
And the digital ports (5,6) have a maximum speed of 980Hz.
(3,9) when rotating goes from 0Hz to 490Hz.
(5,6) when rotating the same potentiometer goes from 0Hz to 980Hz.
Sorry, but all these are very far from reality.
I would recommend you to start from reading a some arduino tutorials about timers and PWM.
pert
April 16, 2025, 2:12am
7
I moved your topic to an appropriate forum category @desbr .
In the future, when creating a topic please take some time to pick the forum category that best suits the subject of your topic. There is an "About the _____ category " topic at the top of each category that explains its purpose.
This is an important part of responsible forum usage, as explained in the "How to get the best out of this forum " guide . The guide contains a lot of other useful information. Please read it.
Thanks in advance for your cooperation.
Hi, @desbr
Can you please post a link to specs/data of thr brushless motor?
Does it have a built in driver?
If not then you will need to use one between the controller and the motor.
You will also need a power supply for the motor.
Tom....
If you REALLY want to vary the PWM frequency, there are a couple of ways, but the most flexible is probably to implement software PWM.
The limitation of SPWM will be the maximum frequency, but should be high enough for most requirements,