Go Down

### Topic: Modifying PWM frequency and smoothing (Read 693 times)previous topic - next topic

#### rendeverance

##### Apr 18, 2012, 12:34 am
Hi all,

I am an Arduino newbie, and have ordered both nano and mega boards for playing around with for various projects  - Very excited!

Anyway I am wanting to control the Arduino over USB (which I believe I can do by loading Firmata onto the Arduino), which in turn I wish to output a 0-10V control signal. I aim to output this through the use of basic RC smoothing circuit and a rail-rail OPAMP.

My question is, how much resolution can I achieve?

If the PWM frequency is increased, I presume I can modify the circuit to get a smoother output?

Can anyone advise? I would be most grateful.

Kind regards

Rendeverance

#### Nick Gammon

#1
##### Apr 18, 2012, 01:05 am
Timer 1 is a 16-bit timer so presumably you can get 16 bit resolution using PWM.

I have some stuff about timers here:

http://www.gammon.com.au/forum/?id=11504

With a prescaler of 1 you can get a frequency of 31.25 kHz in 8-bit phase correct mode (because it takes 512 clock cycles at 62.5 nS per clock) or 62.50 kHz in 8-bit fast PWM mode (256 clock cycles).

You can have a different frequencies with the trade-off of different resolution. So for example in 10-bit fast PWM mode it will take 10 clock cycles, so your frequency would be:

Code: [Select]
` 1/ (.00000000625 * 2^10) = 156250 Hz`

In 16-bit fast PWM mode it would be:

Code: [Select]
` 1/ (.00000000625 * 2^16) = 2441 Hz`
Please post technical questions on the forum, not by personal message. Thanks!

http://www.gammon.com.au/electronics

#2
Thanks :-)

#### Grumpy_Mike

#3
##### May 27, 2012, 09:44 am
Quote
I am wanting to control the Arduino over USB (which I believe I can do by loading Firmata onto the Arduino),

If you do you can't do any fancy stuff like changing the PWM frequency, or increasing the resolution from 8 bits.

Go Up

Please enter a valid email to subscribe