Author Topic: GWS S03T servo control  (Read 2695 times)

0 Members and 1 Guest are viewing this topic.

Offline kalu125Topic starter

  • Jr. Member
  • **
  • Posts: 12
  • Helpful? 0
GWS S03T servo control
« on: October 02, 2010, 09:33:17 AM »
Hi,
Im adding IR range finder to my $50 robot. i want my range finder to detect objects rather than tracing a object. for that i want my scan servo turn 0 position 90 (neutral) position and 180 position. i have already modified my $50 robot to use 8MHz clock because a added UART functionality to it.  i tried to control my scan servo angle as follows,

servo_scan(232);  //  (23/0.992)*1.25*8
servo_scan(278);  //  (23/0.992)*1.5*8
servo_scan(325);  //  (23/0.992)*1.75*8

void servo_scan(signed long int speed)
{   
   PORT_ON(PORTD, 4);
   delay_cycles(speed);      
   PORT_OFF(PORTD, 4);
   delay_cycles(1600);
}

but servo doesn't work as i hoped ???
please let me know how can i control my servo in the way that i want
Thanks

Offline waltr

  • Supreme Robot
  • *****
  • Posts: 1,944
  • Helpful? 99
Re: GWS S03T servo control
« Reply #1 on: October 02, 2010, 11:52:09 AM »
Quote
but servo doesn't work as i hoped
and how exactly doesn't it work?
What is it not doing or what is it doing wrong?
« Last Edit: October 02, 2010, 03:28:13 PM by waltr »

Offline david0305

  • Beginner
  • *
  • Posts: 6
  • Helpful? 0
Re: GWS S03T servo control
« Reply #2 on: October 02, 2010, 01:37:50 PM »
Well sorry cant help you on that

Offline kalu125Topic starter

  • Jr. Member
  • **
  • Posts: 12
  • Helpful? 0
Re: GWS S03T servo control
« Reply #3 on: October 02, 2010, 06:31:13 PM »
Quote
but servo doesn't work as i hoped
and how exactly doesn't it work?
What is it not doing or what is it doing wrong?

it rotates some amount and stops there.
but when i burn my ATmega8 with 50_robot_sharpIR hex file it works.
im using GWS S03T servo, does anyone know whether it is 90 degrees or 180 degrees? spec says nothing  ???
« Last Edit: October 02, 2010, 08:27:56 PM by kalu125 »

Offline kalu125Topic starter

  • Jr. Member
  • **
  • Posts: 12
  • Helpful? 0
Re: GWS S03T servo control
« Reply #4 on: October 03, 2010, 01:17:58 AM »
Quote
but servo doesn't work as i hoped
and how exactly doesn't it work?
What is it not doing or what is it doing wrong?

it rotates some amount and stops there.
but when i burn my ATmega8 with 50_robot_sharpIR hex file it works.
im using GWS S03T servo, does anyone know whether it is 90 degrees or 180 degrees? spec says nothing  ???

im still stuck ??? does any body have an idea??
i opened up my servo and when it comanned by servo_scan(278);
it comes to the center position from both ends.
what i did is, turn servo feed back hone to one end manually and switch on my mcu wich including above command program.
then it comes to centre position.
again switch off the mcu and bring servo feed back hone to other end, and switch on my mcu.
servo turns to center position.

so i thought that servo_scan(278); will bring my servo to netral (90 degree) position.

but when i command it as
                servo_scan(278); //90
      servo_scan(200); //0
      servo_scan(278); //90
      servo_scan(340); //180

it gets stuck  ???
« Last Edit: October 03, 2010, 01:20:45 AM by kalu125 »

Offline KurtEck

  • Robot Overlord
  • ****
  • Posts: 217
  • Helpful? 12
Re: GWS S03T servo control
« Reply #5 on: October 03, 2010, 08:10:09 AM »
Sorry I don't have the $50 robot, so I may not be able to fully answer this.

It is difficult to know what is going on.  Is this your complete program?   That is you call your servo scan function 4 times with different angles and that is it?

For your servos to work properly (assuming analog servos) you need to provide it a pulse about every 20ms.  So you probably want your program to loop for a certain length of time at each pulse width.  Also understand that your program tells it to go instantly from 0 to 90 degrees, it does not actually do any scanning, but jumps as fast as it can.  and then you tell it to snap back... My guess is that is not really what you want and your servos will not appreciate it much. 

Note: I have not verified your timings to see if they are valid, but you might try something that looks more like:
Code: [Select]
init i;
for (;;) {
    for (i=200; i <=340; i++)
        servo_scan(i);
    for (i=340; i >=200; i--)
        servo_scan(i);
}
Now assuming that each call to servo_scan takes maybe 20ms, then one scan in one direction would take about 140 calls * 20ms or about 2.8 seconds.  If this is too slow, than change your increment, if too fast make a couple of calls each time...

Kurt

Offline kalu125Topic starter

  • Jr. Member
  • **
  • Posts: 12
  • Helpful? 0
Re: GWS S03T servo control
« Reply #6 on: October 03, 2010, 09:53:19 AM »
Sorry I don't have the $50 robot, so I may not be able to fully answer this.

It is difficult to know what is going on.  Is this your complete program?   That is you call your servo scan function 4 times with different angles and that is it?

For your servos to work properly (assuming analog servos) you need to provide it a pulse about every 20ms.  So you probably want your program to loop for a certain length of time at each pulse width.  Also understand that your program tells it to go instantly from 0 to 90 degrees, it does not actually do any scanning, but jumps as fast as it can.  and then you tell it to snap back... My guess is that is not really what you want and your servos will not appreciate it much. 

Note: I have not verified your timings to see if they are valid, but you might try something that looks more like:
Code: [Select]
init i;
for (;;) {
    for (i=200; i <=340; i++)
        servo_scan(i);
    for (i=340; i >=200; i--)
        servo_scan(i);
}
Now assuming that each call to servo_scan takes maybe 20ms, then one scan in one direction would take about 140 calls * 20ms or about 2.8 seconds.  If this is too slow, than change your increment, if too fast make a couple of calls each time...

Kurt

Thanks for the reply Kurt,

yes my approach is compleately wrong. i thought that when i command servo_scan(200); it will move to 0 position and when i command it servo_scan(278); it will move to 90 degree position and when servo_scan(325); it will move to 180 degree position. it is a totally wrong, i understood it by working on it almost 3days.

whait i want to do is move the servo to 0 degree positon then see whether some object is there using IR range finder mounted on servo. sen move the servo to 90 degee position and do the same thing. next at 180 degree position.

now im rtying with following code, it also dont move the servo perfectly but servo is now rotating some angle.
still i dont have clear idea about the values i should pass to servo_scan() function.
im using ATmega8 and configured ti use 8Mhz clock.

void servo_scan(signed long int speed)
{
   
   PORT_ON(PORTD, 3);
   delay_cycles(speed);      
   PORT_OFF(PORTD, 3);//keep off
   //delay_cycles(1600);
   //delay_cycles(371-speed);
}

void left(void)
{
  servo_scan(278);
  servo_scan(280);
  servo_scan(282);
  servo_scan(284);
  servo_scan(286);
  servo_scan(288);
}

void right(void)
{
  servo_scan(278);
  servo_scan(276);
  servo_scan(274);
  servo_scan(272);
  servo_scan(270);
  servo_scan(268);
}

void middle(void)
{
  servo_scan(278);
  servo_scan(278);
  servo_scan(278);
  servo_scan(278);
  servo_scan(278);
  servo_scan(278);
}

int main(void)
   {
   
   configure_ports(); // configure which ports are analog, digital, etc.
   a2dInit(); // initialize analog to digital converter (ADC)
   a2dSetPrescaler(ADC_PRESCALE_DIV32); // configure ADC scaling
   a2dSetReference(ADC_REFERENCE_AVCC); // configure ADC reference voltage

   //rprintf("Initialization Complete\r\n");
   /**************************************************/

   
   /*********ADD YOUR CODE BELOW THIS LINE **********/
   


   while(1)
     {       
      middle();
      left();
      middle();
      right();

           delay_cycles(4000);   
   }
       
   return 0;
   }



 


data_list