Servo Motor C40S turning problem

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

Servo Motor C40S turning problem

Postby Jent » Tue Feb 28, 2012 5:23 pm

Hello, good day.

I am testing with servo motor C40S brought from cytron, I followed the instruction from datasheet which setting pulse width 1.0ms for anticlockwise, 1.5ms for neutral position, 2.0ms for clockwise with 20ms pulse period.

But what weird is, when i set the pulse width to 1.0ms, servo turns clockwise, 2.0ms turns anticlockwise. And the 1.5ms pulse width is totally not matched for servo to turn to the neutral position.

When the servo turn to the right, if i pressed switch2 (which set for pulse width 1.5ms), the servo totally turned to the left but not the middle. As the same way when the servo turn to the left, if i pressed switch2, the servo turned to the right. My coding as follow by using CCS compiler, PIC18F4550, 20Mhz crystal.
CODE: SELECT_ALL_CODE
#include <18F4550.h>
#fuses HS, NOWDT, NOPROTECT, BROWNOUT, PUT, NOLVP
#use delay(clock = 20M, crystal)

#define  SERVO_CONTROL    PIN_B3
#define  SW1         PIN_B0
#define  SW2         PIN_B1
#define  SW3         PIN_B2

void main()
{  unsigned int a;
   set_tris_b(0b00000111); //set port b of pin7-3 as output and input, pin2-0 as input
   output_b(0);
   
   while(true)
   {
       if(!input(SW1)==1)
       {
          for(a=0; a<100; a++)
         {
            output_high(SERVO_CONTROL);   //high with pulse of +5V
            delay_us(2000);                  //delay 2ms for move the servo to right
            output_low(SERVO_CONTROL);    //low pulse of 0V
            delay_us(18000);                 //delay low pulse with 18ms, plus 2ms
                                          // total 20ms for one pulse period
         }
       }
 
       if(!input(SW2)==1)
       {
           for(a=0; a<10; a++)
         {
            output_high(SERVO_CONTROL);   //high with pulse of +5V
            delay_us(1500);                //delay 1.5ms for move the servo to cetre
            output_low(SERVO_CONTROL);    //low pulse of 0V
            delay_us(18500);               //delay low pulse with 18.5ms, plus
                                          // 1.5ms total 20ms for one pulse period
         }
       }
       if(!input(SW3)==1)
       {
           for(a=0; a<100; a++)
         {
            output_high(SERVO_CONTROL);   //high with pulse of +5V
            delay_us(1000);                //delay 1ms for move the servo to left
            output_low(SERVO_CONTROL);    //low pulse of 0V
            delay_us(19000);                 //delay low pulse with 19ms, plus
                                          // 1.0ms total 20ms for one pulse period
         }
       }
   }
}



Hope can get kindly help soon. Thanks..^.^
Jent
Fledgling
 
Posts: 1
Joined: Tue Feb 28, 2012 1:03 am

Re: Servo Motor C40S turning problem

Postby hyng » Tue Feb 28, 2012 5:51 pm

Hi,
The pulse width mentioned in the How RC Works in the datasheet is just an example. As stated clearly in the 2nd paragraph on Page 2: "However, the exact correspondence between pulse width and servo varies from one servo manufacturer to another.1.5ms is not necessarily neutral or middle position."
Anyway, the estimation of pulse width for the C40R is listed in the table on page 4. But even from the same manufacturer, the pulse width range for each servo might be a bit different.
User avatar
hyng
Moderator
 
Posts: 292
Joined: Thu Apr 16, 2009 11:35 am


Return to DC Motor

Who is online

Users browsing this forum: No registered users and 3 guests

cron