Go Down

Topic: [reference] analogWrite has to be more specific on frequence (Read 2078 times) previous topic - next topic

lesto

Hi,
from the reference on analogWrite:
Quote
The PWM outputs generated on pins 5 and 6 will have higher-than-expected duty cycles. This is because of interactions with the millis() and delay() functions, which share the same internal timer used to generate those PWM outputs. This will be noticed mostly on low duty-cycle settings (e.g 0 - 10) and may result in a value of 0 not fully turning off the output on pins 5 and 6.


reading this i would expect an error of +-10%, but the truth is that on arduino uno/2009/diecimila etc (don't know about mega and leonardo) the frequency on pin 6 and 6 is DOUBLED, almost 1kHz instead of 500Hz.

This should be pointed out and maybe tell the user this is a feature, not a bug (like, you can have 500Hz PWM on pin x, y, and z, and 1kHz on pin a, b, c)
sei nuovo? non sai da dove partire? leggi qui: http://playground.arduino.cc/Italiano/Newbie

AWOL

Quote
reading this i would expect an error of +-10%,

The reference talks about duty cycle, not frequency in this respect.
"Pete, it's a fool looks for logic in the chambers of the human heart." Ulysses Everett McGill.
Do not send technical questions via personal messaging - they will be ignored.

lesto

yeah, but because duty cicle is linear to pwm, so the error on pwm is 10%

BTW you are right, the real problem is there:
Quote
The frequency of the PWM signal is approximately 490 Hz.

should be changed into
Code: [Select]
The frequency of the PWM signal is approximately 490 Hz on pin x, y,  z and 980Hz on pin a, b, c.
sei nuovo? non sai da dove partire? leggi qui: http://playground.arduino.cc/Italiano/Newbie

leo72

#3
Oct 08, 2012, 02:40 pm Last Edit: Oct 08, 2012, 03:09 pm by leo72 Reason: 1
I agree with lesto. The infos in that page of the Reference aren't accurate.
PWM frequency is ~490 Hz on pins 9, 10 (timer 1), 11, and 3 (timer 2), and ~976 Hz on 5 and 6 (timer 0).pins .

astrobeed


I agree with lesto. The infos in that page of the Reference aren't accurate.
PWM frequency is ~490 Hz on pins 5 and 6 (timer 0), and ~976 Hz on pins 9, 10 (timer 1), 11, and 3 (timer 2).


Is exactly the opposite, pins 5-6 @980 Hz, pins 3-9-10-11 @490 Hz  :)

leo72

#5
Oct 08, 2012, 03:10 pm Last Edit: Oct 08, 2012, 06:02 pm by leo72 Reason: 1
You're right, my mistake. I corrected.

Go Up