Previous in Forum: Wanted: Cheap, Nail / Metal-Picking Electomagnet for Yard Clearing   Next in Forum: Timed Shut-Off Valves for Gases
Close
Close
Close
Rate Comments: Nested
Anonymous Poster

Timers for PWM Generation

07/01/2008 11:05 AM

Hello,

I am looking for some tutorials explaining in depth about how Timers can be used for PWM generation in microcontrollers..would appreciate any help.. !!!

How calculations are done for control registers for desired frequencies etc..typically looking for ATMega 128

googling didnt help much :-(

Thnks

Reply
Interested in this topic? By joining CR4 you can "subscribe" to
this discussion and receive notification when new comments are added.
Power-User

Join Date: Jun 2008
Location: TR
Posts: 142
Good Answers: 1
#1

Re: Timers for PWM Generation

07/02/2008 5:41 PM

Hello Guest,

i don't know the names of pwm registers for ATMega but the general method for pwm generation is as below...

You must load "duty value register" result of a calculation or result of an ADC of an input etc...

You must load "period register" with a value that depends on your update needs...

While Ti = instruction time, (may be equal Tosc/4 or Tosc/2 etc.. depending on processor used), PRval = period register value and DRval = duty register value :

period = PRval x Ti and,

duty cycle = DRval x Ti.

As you know the frequency equals inverse of period. Say Ti = 1 μsecond, then pwm period will be "PRval" μseconds and frequency of pwm will be (1 / PRval) MHz.

Thats all Guest!

Reply
Reply to Forum Thread

Previous in Forum: Wanted: Cheap, Nail / Metal-Picking Electomagnet for Yard Clearing   Next in Forum: Timed Shut-Off Valves for Gases
You might be interested in: IC Timers, Mechanical Timers

Advertisement