lower PWM freq. for driving a Servo


I've got a problem using the PWM module of my PIC18Fxx2 to drive a R/C Servo. My PIC runs at 20MHz which I cannot change. The lowest frequency, that I can get is then 1.22kHz (using x16 prescaler and PR2=0xFF) which is too fast for the Servo. Is there some way of using the postscaler to get down the frequency? Trying to change the postscaler apparently made no difference. Though I read in the datasheet of the PIC that "The postscaler could be used to have a servo update rate at a different frequency than the PWM output."

Hope you can help me in this matter! Thanks, Stefan

Reply to
Loading thread data ...

One solution is to avoid using the PWM mode of the timers in the PIC. Instead, use the Output Compare mode. It involves a little more work on your part because you will have to respond to each OC interrupt and adjust the Compare Register for the next OC event. But for low frequencies, you have plenty of CPU time to do it, especially if you are running at 20MHz. I once wrote a PWM routine for a 12C671 running at 4MHz. It was capable of 0 to 100% duty cycle at 2000 Hz or lower.

-Robert Scott Ypsilanti, Michigan (Reply through this forum, not by direct e-mail to me, as automatic reply address is fake.)

Reply to
Robert Scott

ElectronDepot website is not affiliated with any of the manufacturers or service providers discussed here. All logos and trade names are the property of their respective owners.