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

multi servo motor driving

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



Joined: 18 Dec 2006
Posts: 20
Location: europe (Turkey)

View user's profile Send private message

multi servo motor driving
PostPosted: Sat Aug 04, 2007 6:51 am     Reply with quote

hi everybody

i m trying to make robot arm with servo motors but i cant find anyway to drive more than 2 servos
Code:

#include <16F877.h>
#use delay(clock=4000000)
#fuses XT,NOWDT,NOPROTECT,NOLVP
#use rs232(baud=2400,parity=N,xmit=PIN_C6,rcv=PIN_C7,bits=8)
#include <lcd.c>

int x,pot0,pot1,i;
int16 srv1, srv2;
float kx;

#int_RDA
void RDA_isr()
{
      x=getc();
}

void data_bekle()     //for my RF hardware (not matter)
{
     for(;;){
        if(x==85)break;
        }
    for(;;){
       if(x==255)break;
    }
    for(;;){   
       if(x!=255)break;
    }
 }

void servo1(int value){
   if(value<=127){
         kx=value/127.0;
         srv1=500+(int16)(kx*1000);
         }   
   if(value>127){
         kx=value/127.0;
         srv1=1500+(int16)((kx-1)*1000);
         }   
   for(i=0;i<1;i++){
        output_high(pin_d2);
         delay_us(srv1);
         output_low(pin_d2);
         delay_us(3000-srv1);
         delay_ms(17);
         }
}

void servo2(int value){
   if(value<=127){
         kx=value/127.0;
         srv2=500+(int16)(kx*1000);
         }      
   if(value>127){
         kx=value/127.0;
         srv2=1500+(int16)((kx-1)*1000);
         }   
   for(i=0;i<1;i++){
        output_high(pin_d3);
         delay_us(srv2);
         output_low(pin_d3);
         delay_us(3000-srv2);
         delay_ms(17);
         }
}

void main()
{
   enable_interrupts(INT_RDA);
   enable_interrupts(GLOBAL);   
   lcd_init();
   
   for(;;)
   {
               
         data_bekle();
         pot0=x;           
         data_bekle();
         pot1=x;           
               
         
         servo1(pot0);
         servo2(pot1);      
         
         lcd_gotoxy(1,1);
         printf(lcd_putc, "y=%u   x=%u   \ns1=%lu s2=%lu   ",pot0,pot1,srv1,srv2);
     
   }      
}

i wrote these codes and it works good but sometimes servos are shaking although values are constant on lcd

On the code servo1() and servo2() functions are generating servo delays for pwm that coming axis datas from a analog joystick.

is there anyone to help me about multiple servo driving algorithm
_________________
live fast, never rest and do your best
PCM programmer



Joined: 06 Sep 2003
Posts: 21708

View user's profile Send private message

PostPosted: Tue Aug 07, 2007 5:02 pm     Reply with quote

You could look for CCS code with http://www.google.com by using
this search string:
Quote:
"#use delay" int char servos

Here's one result, where someone is trying to emulate an SSC servo
controller.
http://academic1.bellevue.edu/robots/ssc5a.c
Not all of the code in there may be useful. He's created his own UART,
because he's doing it all in a PIC that doesn't have hardware UART.
The remainder of his code may need some improvement too, but at
least it can give you some ideas.

Notes on SSC servo controllers:
http://www.seetron.com/ssc_faq.htm
http://www.trossenrobotics.com/store/p/3191-SSC-32-Servo-Controller.aspx
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