Society of Robots - Robot Forum

Electronics => Electronics => Topic started by: aruna1 on April 30, 2010, 12:01:44 PM

Title: urgent servo help
Post by: aruna1 on April 30, 2010, 12:01:44 PM
hi
i just received two metal gear servos i ordered two weeks ago from ebay
http://cgi.ebay.com/ws/eBayISAPI.dll?ViewItem&item=290424210724 (http://cgi.ebay.com/ws/eBayISAPI.dll?ViewItem&item=290424210724).

my problem is both servos only rotate in clock wise direction.that is they can move from 1500us--> 2200us but fail to move 2200us-->1500us. so i have to rotate arm manually by hand.

this is the code I'm using (CCS C v4.084 on 12F675)

Code: [Select]
#include "G:\Aruna\My Electronic projects\servo tester\main.h"

void main()
{
   INT16 preset = 0;
   INT16 time = 1500;
   INT16 temp1 = 0;
   INT16 temp2 = 0;
   INT16 i = 0;
   INT16 j = 0;
   setup_adc_ports (sAN2|VSS_VDD);
   setup_adc (ADC_CLOCK_INTERNAL);
   setup_timer_0 (RTCC_INTERNAL|RTCC_DIV_1);
   setup_timer_1 (T1_DISABLED);
   setup_comparator (NC_NC);
   setup_vref (FALSE);
   //set_adc_channel (2);
   //delay_us (100);
   
   // TODO: USER CODE!!
   
   WHILE (1)
   {
 
     
         output_high (PIN_A4);
         delay_us (2000);
         output_low (PIN_A4);
         delay_us (20000 - 2000) ;

     
   }
}

can someone tell is there anything I'm doing wrong or are these servos faulty coz i need to return them asap if they are faulty
Title: Re: urgent servo help
Post by: Razor Concepts on April 30, 2010, 02:56:23 PM
You won't be able to return them easily. Basically you would send it off to China and hope in a few months they will refund you.

 If you want your  money back, claim that you never received your items - usually they dont ship with tracking so you will win the case. Not entirely ethical but I had to do it once for a product that I received that was a scam.
Title: Re: urgent servo help
Post by: aruna1 on April 30, 2010, 03:03:03 PM
You won't be able to return them easily. Basically you would send it off to China and hope in a few months they will refund you.

 If you want your  money back, claim that you never received your items - usually they dont ship with tracking so you will win the case. Not entirely ethical but I had to do it once for a product that I received that was a scam.
they didnt provide a tracking number.if i do this will they refund me?
Title: Re: urgent servo help
Post by: Razor Concepts on April 30, 2010, 05:34:16 PM
Well, you should really see if the servo is faulty or not. If it can move one direction in a range, it should move the other way. Is your code the latest version because all you have it doing is sending the 2000us signal and thats it.
Title: Re: urgent servo help
Post by: aruna1 on April 30, 2010, 09:09:32 PM
this is my latest code,still not working

Code: [Select]
#include "G:\Aruna\My Electronic projects\servo tester\main.h"

void main()
{
   INT16 preset = 0;
   INT16 time = 1500;
   INT16 temp1 = 0;
   INT16 temp2 = 0;
   INT16 i = 0;
   INT16 j = 0;
   setup_adc_ports (sAN2|VSS_VDD);
   setup_adc (ADC_CLOCK_INTERNAL);
   setup_timer_0 (RTCC_INTERNAL|RTCC_DIV_1);
   setup_timer_1 (T1_DISABLED);
   setup_comparator (NC_NC);
   setup_vref (FALSE);
   //set_adc_channel (2);
   //delay_us (100);
   
   // TODO: USER CODE!!
   
   WHILE (1)
   {
      /* preset = read_adc ();

      WHILE ( ! adc_done ())
      {
      }

     
      temp1 = preset / 1023;
      temp2 = 1800 * temp1;
      time = 600 + temp2;
      temp1 = 0;
      temp2 = 0; */
     
      FOR (i = 0; i < 150; i++)
      {
         output_high (PIN_A4);
         delay_us (2200);
         output_low (PIN_A4);
         delay_us (20000);
      }

      FOR (i = 0; i < 150; i++)
      {
         output_high (PIN_A4);
         delay_us (1500);
         output_low (PIN_A4);
         delay_us (20000) ;
      }

      FOR (i = 0; i < 150; i++)
      {
         output_high (PIN_A4);
         delay_us (900);
         output_low (PIN_A4);
         delay_us (20000) ;
      }

     
     
     
     
     
     
     
     
   }
}
Title: Re: urgent servo help
Post by: Cristi_Neagu on May 01, 2010, 04:54:17 AM
Hi

The code above won't work.

The period of the pulses is 20000ms. But since you're doing a delay of 2200ms before that, the total period is 22200ms. Not good.
Why aren't you using the internal timer?
Title: Re: urgent servo help
Post by: aruna1 on May 01, 2010, 06:51:50 AM
Hi

The code above won't work.

The period of the pulses is 20000ms. But since you're doing a delay of 2200ms before that, the total period is 22200ms. Not good.
Why aren't you using the internal timer?
hi
its us not ms
Title: Re: urgent servo help
Post by: amando96 on May 01, 2010, 07:25:50 AM
Build a servo tester:
http://www.aaroncake.net/CIRCUITS/servocon.asp (http://www.aaroncake.net/CIRCUITS/servocon.asp)
Title: Re: urgent servo help
Post by: Cristi_Neagu on May 01, 2010, 07:50:08 AM
hi
its us not ms

Heh....sorry :D just replace ms with us in everything i said above. I said ms while i was thinking us.

And a servo tester will at least tell you if the servo is defective or your code needs some tweaking.

Good luck.