Author Topic: PWM frequency versus clock speed  (Read 9522 times)

0 Members and 1 Guest are viewing this topic.

Offline SimonTopic starter

  • Global Moderator
  • *****
  • Posts: 17814
  • Country: gb
  • Did that just blow up? No? might work after all !!
    • Simon's Electronics
PWM frequency versus clock speed
« on: January 12, 2010, 08:22:49 pm »
what sort of relationship is there between the clock speed and the maximum PWM frequency of a pic ? (12F615 / 16F88 in my case) and not only the maximum PWM frequenct but resolution and frequency versus clock speed ?
 

Offline jahonen

  • Super Contributor
  • ***
  • Posts: 1054
  • Country: fi
Re: PWM frequency versus clock speed
« Reply #1 on: January 12, 2010, 08:53:37 pm »
The PIC timer counts Fosc/4 rate (or lower with prescaler), so with 4 MHz clock, the timer clock frequency is 1 MHz.

PWM frequency is same than timer rollover-rate, which in turn is timer clock/(counts per rollover), so if you have 1 MHz timer clock and timer has 256 counts (8 bits resolution), the PWM frequency will be ~3.9 kHz.

Regards,
Janne
 

Offline SimonTopic starter

  • Global Moderator
  • *****
  • Posts: 17814
  • Country: gb
  • Did that just blow up? No? might work after all !!
    • Simon's Electronics
Re: PWM frequency versus clock speed
« Reply #2 on: January 12, 2010, 09:24:46 pm »
aha right I though it was something like that I just didn't realise that there was the 4X prescaler, so if I was going to sacrifice resolution say make it 7 bits I could run at a frequency of 7.2 KHz ? (given the 4 MHz clock and /4 prescaler)
 

Offline jahonen

  • Super Contributor
  • ***
  • Posts: 1054
  • Country: fi
Re: PWM frequency versus clock speed
« Reply #3 on: January 12, 2010, 09:30:20 pm »
4 MHz was only an example. 16F88 runs up to 20 MHz, so maximum timer clock is 5 MHz. That gives you 19.5 kHz PWM frequency @ 8 bits resolution.

Regards,
Janne
 

Offline SimonTopic starter

  • Global Moderator
  • *****
  • Posts: 17814
  • Country: gb
  • Did that just blow up? No? might work after all !!
    • Simon's Electronics
Re: PWM frequency versus clock speed
« Reply #4 on: January 12, 2010, 09:57:28 pm »
Yes I see, what I'm saying is can I sacrifice resolution for frequency ? if it comes down to counts can I say a clock speed of 4 MHz 1 MHz counter 3.9 KHz frequency @ 8 bits, or 7.2 KHz @ 7 bits ?
 

Offline jahonen

  • Super Contributor
  • ***
  • Posts: 1054
  • Country: fi
Re: PWM frequency versus clock speed
« Reply #5 on: January 13, 2010, 03:52:59 pm »
Certainly you can make trade-offs between resolution and frequency. PIC16F88 datasheet table 9-3 @ page 87 lists some combinations @ 20 MHz. Resolution does not need to be integer number of bits, for example setting PR2 to 99 yields resolution of log2(99) ~= 6.64 bits.

Regards,
Janne
 


Share me

Digg  Facebook  SlashDot  Delicious  Technorati  Twitter  Google  Yahoo
Smf