CCS C Software and Maintenance Offers
FAQFAQ   FAQForum Help   FAQOfficial CCS Support   SearchSearch  RegisterRegister 

ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

CCS does not monitor this forum on a regular basis.

Please do not post bug reports on this forum. Send them to CCS Technical Support

Is CCP_PWM too fast for an RC servo?

 
Post new topic   Reply to topic    CCS Forum Index -> General CCS C Discussion
View previous topic :: View next topic  
Author Message
weg22



Joined: 08 Jul 2005
Posts: 91

View user's profile Send private message

Is CCP_PWM too fast for an RC servo?
PostPosted: Tue Apr 18, 2006 1:16 pm     Reply with quote

Hi all,

I am now trying to use the CCP pin to generate a PWM signal (as opposed to the INT_TIMER0 in my last post). However, I think the frequency needed to control an RC servo (a 20 ms period = 50 Hz) isn't feasible with my 10 MHz oscillator. The code below generates a 625 Hz PWM signal, but I need 50 Hz for it to work. Does anyone know of a workaround for this (without swapping my crystal)?

Thanks in advance,
weg

Code:

include <16F877.H>
#include <stdlib.h>
#include <math.h>

#define LED PIN_C0

#fuses HS,NOWDT,NOPROTECT,PUT,NOLVP
#use delay(clock=10000000)

void main()
{
   
   output_high(LED); delay_ms(1500);
   output_low(LED); delay_ms(1500);
   
   // setup PWM output
   setup_ccp1(CCP_PWM); // pwm output
   setup_timer_2(T2_DIV_BY_16, 255, 1);

   while(1)
   {
        output_high(LED);
      set_pwm1_duty(5);
   }
}
PCM programmer



Joined: 06 Sep 2003
Posts: 21708

View user's profile Send private message

PostPosted: Tue Apr 18, 2006 1:31 pm     Reply with quote

See this thread for a low frequency software PWM example:
http://www.ccsinfo.com/forum/viewtopic.php?t=20050
Display posts from previous:   
Post new topic   Reply to topic    CCS Forum Index -> General CCS C Discussion All times are GMT - 6 Hours
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum


Powered by phpBB © 2001, 2005 phpBB Group