PWM signal Generation

Hi everybody,

I try to generate 1khz %5pulse width electrical car pilot signal from arduino mega2560.How can i do it? Please

help. Thanks..

oguzderin:
I try to generate 1khz %5pulse width electrical car pilot signal from arduino mega2560.How can i do it? Please

1 kHz is 16 MHz / 16000.
If you use a 16-bit timer you can set TOP to 15999 to get 1 kHz and OCRxx to 800 to get 5%.
If you use an 8-bit timer you need to get TOP below 256. 16000/256 = 62.5 so you need the smallest prescale greater than 62.5. I think that's 64. 16000/64 = 250 so set TOP to 249 to get 1 kHz and OCRxx to 12 or 13 to get 4.8% or 5.2%.