View previous topic :: View next topic |
Author |
Message |
RNR107
Joined: 19 Dec 2014 Posts: 23
|
High performance PWM on PIC16F1786 |
Posted: Fri Dec 19, 2014 10:12 am |
|
|
Hi all,
I am looking for a way to control a servo motor via PWM.
I am currently able to do it using the simple PWM mode, but this only give me a 10bits precision which is not sufficient in this particular application.
I understand from the 16F1786 datasheet that it is possible to get 16 bits using the PSMC module.
1- Am I reading the datasheet right? Can I get 16 bits PWM ?
2- Any example code anywhere I could look at ?
(I know it would be easier to use a 16bit PIC but only have a CCS license for the 8 bits PICs)
Thank you!
RNR |
|
|
PCM programmer
Joined: 06 Sep 2003 Posts: 21708
|
|
Posted: Fri Dec 19, 2014 2:51 pm |
|
|
It has a 16-bit time base, but I don't see any CCS functions to support
the PSMC controller in the 16F1786.h file. I think you will have to write
your own functions, and write to the PSMC registers.
Are you sure you need that PIC ? Here is a method to get more
resolution for servo pulses, by using the CCP Compare module:
http://www.ccsinfo.com/forum/viewtopic.php?t=44328 |
|
|
asmboy
Joined: 20 Nov 2007 Posts: 2128 Location: albany ny
|
|
Posted: Fri Dec 19, 2014 3:18 pm |
|
|
Quote: |
control a servo motor
|
"servo" covers Lot of territory and you are not very specific.
are we talking about a model airplane style
pulse width- proportional type
positioning servo here ?
though you are calling this "PWM" is it in reality to produce
position control pulses of high resolution and precision?
can you state the make and model of your servo? |
|
|
RNR107
Joined: 19 Dec 2014 Posts: 23
|
|
Posted: Mon Dec 22, 2014 2:53 am |
|
|
asmboy wrote: |
"servo" covers Lot of territory and you are not very specific.
are we talking about a model airplane style
pulse width- proportional type
positioning servo here ?
though you are calling this "PWM" is it in reality to produce
position control pulses of high resolution and precision?
can you state the make and model of your servo? |
Hi ASMBoy,
The sevo I am using is positioning servo used on model planes I think.
It's an S3001 from Futaba.
It requieres a 20ms periode PWM signal and I am only interested in pulses between 1.2ms and 1.9ms (6 to 9.5% duty).
RNR |
|
|
RNR107
Joined: 19 Dec 2014 Posts: 23
|
|
Posted: Mon Dec 22, 2014 2:56 am |
|
|
PCM programmer wrote: | It has a 16-bit time base, but I don't see any CCS functions to support
the PSMC controller in the 16F1786.h file. I think you will have to write
your own functions, and write to the PSMC registers.
Are you sure you need that PIC ? Here is a method to get more
resolution for servo pulses, by using the CCP Compare module:
http://www.ccsinfo.com/forum/viewtopic.php?t=44328 |
Hi PCM Programmer,
This could be an option as long as it let me change the duty on the fly witout losing any pulses during the change...
I'll have a look at that. Could be just what I need... :-) Thank you!
RNR |
|
|
|