need faster pwm

Go To Last Post
4 posts / 0 new
Author
Message
#1
  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Hello I've used the tiny26 in the past & generated a nice 50Khz PWM, though I was notoverly pleased with the relatively low resolution.. I have a new design all built up with the mega48 & was happy it has a lot more timer capabilites & many other features. I was glad to see it offers up to 16bit PWM resolution & was looking to use about 12 bits.

However, much to my surprise, it seems that using a 10bit PWM can give you only about 7KHz (with internal 8MHz clock). In 16 bit mode, the results are even much lower (about 122 Hz). Is there any way around this (have I missed something)??? I was looking to set up the internal PLL (what I set up on the tiny26), but couldn't figure out how to access it in the mega48.

Any thought comments, workarounds, or other parts that can give a high freq (>20khz) & decent resolution (10 bits or better) PWM.

Hoyt

When in the dark remember-the future looks brighter than ever.   I look forward to being able to predict the future!

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Looks like you can have 7bit resolution and 500kHz max PWM on the tiny26.

8)

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

The pwm clock is pwm freq * 2^(# of bits), so for your mega48 that is 7000 * 1024 = 7.1MHz. Translate that into what you want you get 20000 * 4096 = 81.8MHz! Thats not going to happen with an AVR! What are you trying to do with the PWM that requires such resolution? D/A conversion would best be served by using the appropriate DAC device!

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

The mega48 doesn't have a PLL. The resolution of the tiny26 pwm could be increased in software. Set up the pwm at 8 bit resolution which gives 250KHz. Use the top 8 bits of your 10 bit value for the pwm hardware value. Then in a timer increase the value by 1 for a time corresponding to the lower 2 bits. Thus you can get 10 bits at 62.5KHz or 11 bits at 31.25KHzk

Ralph Hilton