RC Servo Ramp (speed)

LINIX Brushless, VEXTA Brushless, RC Servo, DC Geared, Linear, Stepper, Tamiya.....

RC Servo Ramp (speed)

Postby selebeq » Sat Jan 09, 2010 9:56 am

Hi, Ober Choo and all cytron member

I am a student at Melaka, I got a project about controlling 8 RCservo motors on PORTB. Currently I am using MPlab Hitech-C compiler, 16F877A & 20MHz. I can control position but my problem now is how to control RC servo speed (ramp)?

Can PIC16F877A do a ramp program? Using which PIN? CCP? T0M1L Or T1M1L? Or it can only be done using DSPIC

Can you teach me the theory behind it or if you dont have time, could you just give me reference book or website. I have been searching on internet but cannot find it.

Thank you very much for your time and it is a big help if anyone can share some knowledge with me.
selebeq
Freshie
 
Posts: 4
Joined: Sat Jan 09, 2010 9:35 am

Re: RC Servo Ramp (speed)

Postby hyng » Sat Jan 09, 2010 11:10 am

Let's say if you want the servo to rotate from 1.0ms to 2.0ms. In full speed, servo will directly turn to the desire final position. However if you want it to be slow down, then you have to divide the time in few section. For example, you can gradually add 0.1ms from 1.0ms to 2.0ms. Then it will slow down the servo!!
User avatar
hyng
Moderator
 
Posts: 292
Joined: Thu Apr 16, 2009 11:35 am

Re: RC Servo Ramp (speed)

Postby selebeq » Sat Jan 09, 2010 9:38 pm

ok :shock:

because I have more than 2 RC servo , I have to generate PWM manually using loop.

exp:

CODE: SELECT_ALL_CODE

int i;

void main()

{
while(1)
  {

    (i=0;i>50;i++)
      {
          portB=0x00;
          delay_us(1000);
          portB=0x01;
          delay_us(19000);
       }

    (i=0;i>50;i++)
       {
          portB=0x00;
          delay_us(2000);
          portB=0x01;
          delay_us(18000);
       }
   }
}



This example I try to move the RC servo from 0 - 180 deg..

1) To make the servo ramp, do I have to change from i++ to i=i+0.1?

2) Is the i>50 have effect on RC servo speed if I increase or decrease or it is just to make it hold RC servo longer?

3) I see in some RC servo controller board, it can support up to 63 ramp rate. what is that mean? Is it a change in i++?
selebeq
Freshie
 
Posts: 4
Joined: Sat Jan 09, 2010 9:35 am

Re: RC Servo Ramp (speed)

Postby selebeq » Thu Jan 14, 2010 2:35 pm

Hello~ I need help or suggestion~
selebeq
Freshie
 
Posts: 4
Joined: Sat Jan 09, 2010 9:35 am

Re: RC Servo Ramp (speed)

Postby hyng » Thu Jan 14, 2010 3:50 pm

Maybe you do some experiment on it.

Here are the suggestion. You may divide the pulse loop into few section instead of two only (19000 and 18000). You can have more loop from 19000, 18900, 18800 ..... to 1800 and then from 18000, 18100, ... to 19000. About the max i value, i hope you can test on it. But i think 50 for each loop is ok.
User avatar
hyng
Moderator
 
Posts: 292
Joined: Thu Apr 16, 2009 11:35 am

Re: RC Servo Ramp (speed)

Postby selebeq » Thu Jan 14, 2010 4:45 pm

what I found when I tried to control the speed was that they responded with a sequence of jerks rather than smooth motion?? :?
selebeq
Freshie
 
Posts: 4
Joined: Sat Jan 09, 2010 9:35 am

Re: RC Servo Ramp (speed)

Postby ober » Fri Jan 15, 2010 6:43 pm

try to divide into smaller section.
Ober Choo
Cytron Technologies Sdn Bhd
www.cytron.com.my
User avatar
ober
Moderator
 
Posts: 1486
Joined: Wed Apr 15, 2009 1:03 pm

Re: RC Servo Ramp (speed)

Postby aurora » Fri Jan 15, 2010 8:15 pm

Are you using any transistor circuit to drive the servo, or is it direct drive from the PIC output? If you are using typical direct drive, then the code should be:
CODE: SELECT_ALL_CODE
          portB=0x01;
          delay_us(1000);
          portB=0x00;
          delay_us(19000);


If not, make sure you are using #use delay (clock=20000000)

The for loop which you are using, it drives the servo to first position, hold for 1 sec, drive to second position, hold for 1 sec. To do speed control, you need to change the delay_us(var) so it varies.

The easiest method:
CODE: SELECT_ALL_CODE
int i;
long j;
long k;

    (i=0;i>50;i++)
      {
          j=i*20;
          k=20000-j;
          portB=0x00;
          delay_us(j);
          portB=0x01;
          delay_us(j);
       }


But please check your compiler, if it the delay_us support 16-bit variable. I'm using CCS, and it doesn't. :?
aurora
Discoverer
 
Posts: 126
Joined: Sun Jun 07, 2009 4:52 pm


Return to DC Motor

Who is online

Users browsing this forum: No registered users and 11 guests

cron