PWM question

Hi, I got a tricky question...

I has alterate the timer 2 frequenzy (I had lern how to do it by modificating the three last bits), but I would like to know somethin, when you do not tuch the timer frequenzy, your range is between 0-255, so what is it going to be my new range? is it the new top I had put?

Did I explain myself...?

Yes. If you set the TOP value to something less than 255 then that TOP value is the maximum PWM value you can use.

Thank you very much! and what if my top value had begin to small, like 100... it doesn't leave me a good range... should I change the prescaler, and stuff to get a bigest range?

For PWM it's more important to have the range (255) than to have a specific frequency.

Why do you want to change the frequency?

The 255 steps of resolution for the arduino analogWrite() PWM function is a basic hard limit of the function. However one can use a map function to convert a larger range of numbers, such that they will be scaled down and converted linearly to a 0-255 step range, and that may be all you require, depending on the requirement and objective of your project.

Lefty

I'm driving a DC motor and I need 20Khz PWM, but doing that it becam that my range is from 0 to 100, so you recomend me map it?

joamanya:
I'm driving a DC motor and I need 20Khz PWM, but doing that it becam that my range is from 0 to 100, so you recomend me map it?

First, why do you feel you have a need to change the arduino default PWM frequency to 20khz just to modulate the power going to a simple DC motor? Only when we fully understand your need/justification can we work towards a 'best' recommendation.

Lefty

If you use the PWM library, you can determine both the frequence and resolution

http://arduino.cc/forum/index.php/topic,117425.0.html