Go Down

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

Hi all,


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

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!

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


Grumpy_Mike

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

Confirm your email address

We need to confirm your email address.
To complete the subscription, please click the link in the email we just sent you.

Thank you for subscribing!

Arduino
via Egeo 16
Torino, 10131
Italy