I Want to know that how to generate the 50 -60 hz frequency by using pwm . If any body have any idea about then please tell me .
I Want to know that how to generate the 50 -60 hz frequency by using pwm . If any body have any idea about then please tell me .
Hi Rahil,
PWM can be converted to voltage using a lowpass filter - a simple R-C can be enough. To generate a sinusoidal voltage at such a filter the pulse width must be modulated sinusoidally.
pulse width = sine (time) * MaxPulseWidth
Time can be a simple count that increments with time. The increments must occur at a rate that forces the sine of the count to roll over to the same value 120 times per second. For example the sine of 360 degrees is the same as 0 degrees or 180 degrees or 720 degrees. So you could make the counter increment at a rate of 360 steps in 1/60th of a second. You can also reset the count when it reaches 360. The sine of the count will vary from 0 to 1, so it must be multiplied by the maximum pulse width before being sent to your PWM generator.
Note that the frequency of the PWM signal should be much higher than the 60 Hz you are trying to create and the lowpass filter should have a cutoff frequency above 60 Hz.
Doug
Sir thank you for your reply . But i have another question about it that if I want to generate a 50 -60 hz freq. form atmega 16 then how can I do it ?
Hi Rahil,
You could start by trying something like this which generates a slow triangle wave:
PWM Signal Generation using AVR Timers
Then shorten the timing until the brightness loop is ramping up and down 60 times per second. (60 Hz triangle wave)
Replace the resistor with 10 Kohm and the LED with a 1 microfarad capacitor and measure the voltage waveform across the capacitor.
Then replace the "brightness" values with sinusoidal values instead of triangle wave values.
Doug
hi
2 things . all the info Doug provided are completely correct and precise(as a matter of fact I was going to mention the filtering of a square wave by LP filter)
another thing is if you have atmega16 (as far as I know it has DAC) why you are going to use timer/pwm method instead of DAC?!
hi
2 things . all the info Doug provided are completely correct and precise(as a matter of fact I was going to mention the filtering of a square wave by LP filter)
another thing is if you have atmega16 (as far as I know it has DAC) why you are going to use timer/pwm method instead of DAC?!