View previous topic :: View next topic |
Author |
Message |
BLL
Joined: 11 Nov 2006 Posts: 181 Location: Birmingham, UK
|
12F1840 PWM Generation |
Posted: Mon Aug 05, 2019 12:11 pm |
|
|
Hi,
I want to control a model r/c servo from the 1840. I need to be able to select either 830 us or 1500us pulse width.
I have looked at lots of posts on PWM, but am still not seeing the wood for the trees! I am using the internal oscillator at 16MHz.
Can someone please help me out, so I can understand how to achieve this?
Thanks
Brian |
|
|
PCM programmer
Joined: 06 Sep 2003 Posts: 21708
|
|
|
Ttelmah
Joined: 11 Mar 2010 Posts: 19539
|
|
Posted: Mon Aug 05, 2019 12:59 pm |
|
|
You can't.
You need to perhaps use the CCP, rather than the PWM.
Problem is a servo pulse is normally repeated at 25mSec intervals.
From your master clock, the slowest the PWM can go is 245Hz.
The PWM is designed to provide _fast_ pulses without needing CPU
overhead. Not to provide slow pulses like this.
I posted a routine to handle a servo pulse in percent here:
<http://www.ccsinfo.com/forum/viewtopic.php?t=50914&highlight=servo>
This uses the CCP. You'd need 33 for 830uSec. |
|
|
BLL
Joined: 11 Nov 2006 Posts: 181 Location: Birmingham, UK
|
|
Posted: Tue Aug 06, 2019 1:59 am |
|
|
Hi Ttelmah
Thanks again for your help - I shall go and study your code.
Brian |
|
|
|