Society of Robots - Robot Forum

Software => Software => Topic started by: bakil on July 21, 2007, 05:10:10 AM

Title: software pwm
Post by: bakil on July 21, 2007, 05:10:10 AM
can just somebody explain how i can calculate the period that a led needs to be off and on at lets say 3.69mhz (or use something else but mention it  :D)

my goal is to build a function that you give a % and then the led is burning at that %



//------------ old topic -------------\\
does anyone of you people at societyofrobots know how to make an software PWM for fading a LED

my microcontroller runs at 4khz (i think this is the most easy frequency)

-> i know its something like 1micro seconde on and 3 microseconds off etc
Title: Re: software pwm
Post by: Steve Joblin on July 21, 2007, 07:32:36 AM
If you tell us what microcontroller you are using and what language you are programming it in, I am sure we can help you.
Title: Re: software pwm
Post by: bakil on July 21, 2007, 08:15:46 AM
ow woops im srry

i use C

atmega16L programmed with the stk500 board
Title: Re: software pwm
Post by: Steve Joblin on July 21, 2007, 02:20:22 PM
This was designed for PICs, but it may work for Atmegas as well... http://www.micro-examples.com/public/microex-navig/doc/097-pwm-calculator.html
Title: Re: software pwm
Post by: Admin on July 22, 2007, 08:43:02 AM
If you have your LED off for 3us and on for 1us, that means your LED will only be 1us/(1us+3us) = 25% bright.