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 support@ccsinfo.com

Servo Position Control Problem

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



Joined: 24 Jan 2010
Posts: 1

View user's profile Send private message

Servo Position Control Problem
PostPosted: Sun Jan 24, 2010 7:01 am     Reply with quote

First of all, I don't know a lot about servos or CCS C programming.

I use 16F877A PIC and Spring RC Servo motor, I tried the available codes on this forum but it did not work.

I want to make the positioning of this servo on the way I like, how can I do it? Can you supply me any codes.

Code:
#include <16f877a.h>
#fuses HS, NOWDT, NOPROTECT // Set Fuses
#use delay(clock = 1000000) // Synchronize with the Oscillator
#define servo PIN_C0

void forward();
void backwards();

void main()
{

while(1)
  {
   backwards();
   delay_ms(5000);
   forward();
   delay_ms(5000);
  }
}

void forward()

output_high(servo);
delay_ms(2);
output_low(servo);
delay_ms(18);
}

void backwards()
{
output_high(servo);
delay_ms(.5);
output_low(servo);
delay_ms(19.5);
delay_ms(16);
}
septillion



Joined: 21 Jan 2010
Posts: 13

View user's profile Send private message

PostPosted: Sun Jan 24, 2010 8:54 am     Reply with quote

delay_ms expects a int16 value, not a float. 0.5 won't work.
bungee-



Joined: 27 Jun 2007
Posts: 206

View user's profile Send private message

PostPosted: Sun Jan 24, 2010 11:24 am     Reply with quote

RC servos are controlled with pulse train. You send a pulse to a servo every 20ms, width of pulse determines where the servo will go and it is typically from 1ms to 2ms in length.

Now said that, you should use search on forum. There is a lot of code posted here.

Go to the forum's search page:
http://www.ccsinfo.com/forum/search.php
Put this in the search box:
RC SERVO
Set it to "Search for all Terms".
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