Pages: [1]   Go Down
Author Topic: Modifying PWM frequency and smoothing  (Read 509 times)
0 Members and 1 Guest are viewing this topic.
Offline Offline
Newbie
*
Karma: 0
Posts: 14
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Hi all,


I am an Arduino newbie, and have ordered both nano and mega boards for playing around with for various projects  smiley-grin - 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  smiley
Logged

Global Moderator
Offline Offline
Brattain Member
*****
Karma: 473
Posts: 18695
Lua rocks!
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

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:
1/ (.00000000625 * 2^10) = 156250 Hz

In 16-bit fast PWM mode it would be:

Code:
1/ (.00000000625 * 2^16) = 2441 Hz
Logged

Offline Offline
Newbie
*
Karma: 0
Posts: 14
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Thanks :-)
Logged

Manchester (England England)
Offline Offline
Brattain Member
*****
Karma: 596
Posts: 33271
Solder is electric glue
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

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.
Logged

Pages: [1]   Go Up
Jump to: