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

CCP, PWM and Hobby servo

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



Joined: 24 May 2007
Posts: 97

View user's profile Send private message

CCP, PWM and Hobby servo
PostPosted: Thu Jun 07, 2007 7:53 am     Reply with quote

Hello,

I am working on an application which involves moving a hobby servo, in function of the ADC conversion of the RSSI signal.

Up till now - I think it was easier - I was always thinking on using 2 PIC processors, one for the ADC and another one for the servo.

In this version the two pics were talking to each other over HW UART, and that works well.

However a response to one of my posts got me thinking, that I could use the hardware CCP to time the pulses for the servo - this would eliminate the second PIC.

Can this be really done by the HW CCP module, I mean the PIC would be multitasking? Because I need the code to run on the PIC and in the mean time provide a stable pulse signal for the servo. The pulses for the servo are variable depending on the values received from the ADC between 0.7ms to 2.3ms - and these occur every 20ms.

I plan to use the 16F88 for this application.

Thankx, Ox.
rnielsen



Joined: 23 Sep 2003
Posts: 852
Location: Utah

View user's profile Send private message

PostPosted: Thu Jun 07, 2007 8:29 am     Reply with quote

This should be feasible. When you write the code for the A/D don't use the built-in functions but rather set the 'GO/DONE' bit to start the conversion and then monitor it to detect when it is finished. Do all of this in your main() so that the CCP module can take priority over the A/D.

Ronald
Ttelmah
Guest







PostPosted: Thu Jun 07, 2007 9:43 am     Reply with quote

You can use the inbuilt functions:

read_adc(ADC_START_ONLY);

will start the ADC, and not wait for it.

read_adc(ADC_READ_ONLY);

Returns the last conversion.

You can monitor go/done, or just ensure there is enough time delay between these.

Best Wishes
SherpaDoug



Joined: 07 Sep 2003
Posts: 1640
Location: Cape Cod Mass USA

View user's profile Send private message

PostPosted: Thu Jun 07, 2007 12:49 pm     Reply with quote

The servo has a minimum pulse width of 0.7ms. That should be plenty of time for the A/D.

Start the servo output
Start the A/D
Read the A/D
Do math
Wait the rest of the 0.7ms
Wait the calculated time
Stop the servo output
_________________
The search for better is endless. Instead simply find very good and get the job done.
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