Society of Robots - Robot Forum

Software => Software => Topic started by: airman00 on July 21, 2009, 08:37:26 PM

Title: Low Frequency from PWM
Post by: airman00 on July 21, 2009, 08:37:26 PM
Can I reliably generate a really low frequency from the PWM channel of an AVR 16 bit timer?
By low I mean something like 30 hertz.

Thanks in advance
Title: Re: Low Frequency from PWM
Post by: Kirk on July 22, 2009, 06:21:10 PM
It should be no problem. I have a friend that sets a 16bit timer to about 50Hz and uses the low PWM values to run R/C servos.
  In fact since the PWM is purely hardware and thus glitch free (so they say) there is no reason that you could not go to 0.5 Hz or less.
Kirk
Title: Re: Low Frequency from PWM
Post by: Webbot on July 22, 2009, 07:27:36 PM
It depends on your mcu clock speed.
The prescaler allows you to divide this by a constant value such 128. - in which case your timer is incremented every CPU/128.
With a 16 bit timer then you can set the PWM cycle time to be anything up to 65,535.

So with a 16MHz clock and 128 prescaler then you can go to 16MHz / (128 * 65535) = 1.9 Hz
Title: Re: Low Frequency from PWM
Post by: Admin on August 10, 2009, 07:15:57 AM
You can always use a really low frequency oscillator crystal, and set low speed clock fuses and dividers :P