Electronic Projects, forums and more.

Go Back   Electronic Circuits Projects Diagrams Free > Electronics Categories > Robotics Chat


Robotics Chat Specific to discussions about robots and the making of.

Reply
 
Tools
Old 22nd January 2009, 03:40 AM   #1
Default Basic Servo Motor doubt

Hi,
I bought a Futuba s3003 servo
They say with 20ms delay and range b/w 1-2 ms u can control the rotation.
Should the PWN be continously sent to the motor?..
doubt: if i do,the motor continously rotates till mechanical limits.

i believe 1.5 ms is the mid position.

This is the CODE sample for 1.5 ms
when external input to 3.2 pin of 89c51 is given,i enable the servo..

================================================== ====
void main()
{
TMOD = 0x01;
TH0 = 0xB1;
TL0 = 0xE0;
EX0=1;
EA = 1;
ET0 = 1;
TR0 = 1;

if(P3_2 == 0)
{
void timer0_0();
}
}

void timer0_0 () interrupt 0
{
if(F0){
F0 = 0;
TH0 = 0xB1; // 20ms
TL0 = 0xE0;
P1_0 = 0;
TF0 = 0;
return;
}
else {
F0 = 1;
TH0 = 0xFA; // 1.5ms
TL0 = 0x24;
P1_0 = 1;
TF0 = 0;
return;
}
}

also i find one more issue..if 2ms is for counter clockwise..the servo still rotates in the same clk wise direction..

Last edited by puremobi; 23rd January 2009 at 02:58 PM.
puremobi is offline  
Old 25th January 2009, 10:06 AM   #2
Default

Yes, 1-2ms on, remainder of the 20ms off, sent continuously, 1.5ms is the center. If it runs to the limits, it means the timing is off. Are you using a 12mhz clock?
duffy is offline  
Old 26th January 2009, 02:17 PM   #3
Default hi

hi,
firstly ,thank you very much for the reply...
No i am using 11.0592 MHz..
if i send the pulse continously,how does it stop at ,lets say 90 degrees?..
in my above code...it doesnt stop at 90 degrees.

can u pls clarify this point.." the timing is off"..
does it mean..a 0 pulse should be sent from the microcontroller at all time to the motor?

One more note: the seller told me ..its a 24ms servo..

Last edited by puremobi; 26th January 2009 at 02:21 PM.
puremobi is offline  
Old 26th January 2009, 03:55 PM   #4
Default

At 11mhz looks like your code is going to deliver a 1.37ms pulse. Shorter pulses = clockwise, looking at the top of the servo, so it is going to be more clockwise. You need to reduce
TH0 = 0xFA; // 1.5ms
TL0 = 0x24;

Also, check the pulse on a scope. Make sure you are sending what you think you are sending.
duffy is offline  
Old 27th January 2009, 08:44 PM   #5
Default

hi,
i did a try..there is problem..the servo keeps goin to its limits..
this is the code
pls do check..
this is what happens
whenever i insert zero to pin 3.2(variable n)
the servo rotates ,else no rotation.
how can i make it specific..like a defined rotation of 90 degrees?..its not happening here..

==============
void main()
{
TMOD = 0x01;
TH0 = 0xB1;
TL0 = 0xE0;
EX0=1;
EA = 1;
ET0 = 1;
TR0 = 1;
=============
if(n== 0)
{

timer0_0();
}

}


void timer0_0 () interrupt 0
{

if(F0){
F0 = 0;
TH0 = 0xed; //20ms
TL0 = 0xff;
p = 0;
TF0 = 0;
return;
}
else {
F0 = 1;

TH0 = 0xFA; // 1.5ms
TL0 = 0x98;
p = 1;
TF0 = 0;
return;
}
}

Last edited by puremobi; 27th January 2009 at 08:47 PM.
puremobi is offline  
Old 27th January 2009, 08:47 PM   #6
Default

pls refresh the page..
puremobi is offline  
Old 27th January 2009, 10:27 PM   #7
Default

I see the problem - you have to set up a condition for that port pin INSIDE the timer interrupt. Don't make the timer itself conditional, it just runs continuously.
Code:
void main()
{
TMOD = 0x01; 
TH0 = 0xB1;
TL0 = 0xE0;
EX0=1;
EA = 1;
ET0 = 1;
TR0 = 1;
void timer0_0();
}

void timer0_0 () interrupt 0
{
  if(F0){ 
    F0 = 0; 
    TH0 = 0xB1; // 20ms
    TL0 = 0xE0; 
    P1_0 = 0; 
    TF0 = 0; 
    return; 
  }
  else { 
    F0 = 1; 
    P1_0 = 1; 
    TF0 = 0;
    if(P3_2 == 0)
    {
      TH0 = 0xFA; // 1.5ms 
      TL0 = 0x24; 
    }
    else { 
      TH0 = 0xF8; // 2.0ms 
      TL0 = 0x31; 
    }
    return; 
  }
}
Like that. Also, use code tags and indent or I'll kill you.

Last edited by duffy; 27th January 2009 at 10:31 PM.
duffy is offline  
Old 28th January 2009, 02:28 PM   #8
Default

haha..u cant kill me..but u can try..

Hi again,
I tried the code..this is exactly what happens
Whenever the P3.2 ==0 the servo rotates clockwise,if i give continous zero without a break,the servo rotates clockwise to its limits

there is no counter clockwise rotation(2ms)

am i really missin any basic points here?..will it move anti clockwise in this case(the code above)?

duffy, i have one more file,which mite interest you...pls check it out..
iam gonna get a new breadboard to out this stuff in a day or two..
thanks again..have fun!

=========================
the code in the file is meant to run 8 servos using 89c51.the eg code given inthat is to run the servo in clockwise n anticlockwise upto the extremities w/o any defined timing..i.e.it runs irregularly relative to the timer..
Attached Files
File Type: zip Servo_0.1.zip (15.6 KB, 16 views)
puremobi is offline  
Old 28th January 2009, 03:35 PM   #9
Default

If P3.2 == 1, does the servo move at all?
duffy is offline  
Old 28th January 2009, 11:27 PM   #10
Default

nope..
there is no movement at all..
it only responds when p3.2==0
puremobi is offline  
Old 28th January 2009, 11:45 PM   #11
Default

Did you remove the conditional statement on the timer function call?
duffy is offline  
Old 29th January 2009, 11:08 AM   #12
Default

hi,
yes i had removed..
the timer runs continously.
i guess its supposed to run anti clockwise ..when 3.2 is 1..

what else could be the issue?..
puremobi is offline  
Old 29th January 2009, 12:05 PM   #13
Default

If you have a scope, then check the output signal - it should be a pulse between 1mS and 2mS, repeated every 20mS or so (the 20mS doesn't need to be accurate, only the 1-2mS matters.
__________________
PIC programmer software, and PIC Tutorials at:
http://www.winpicprog.co.uk
Nigel Goodwin is offline  
Old 29th January 2009, 02:19 PM   #14
Default

ok,
i will take it to my univ n check it up..only option i hav.
in keil,there is somethin called..logic view analyser..it shows waveforms from a port pin...any clue abt it?...
i was thinkin of switching to 12Mhz crystal...easy calculations perhaps..

Last edited by puremobi; 29th January 2009 at 02:19 PM.
puremobi is offline  
Old 29th January 2009, 02:23 PM   #15
Default

Try switching these two TH0/TL0 around -

Code:
      TH0 = 0xFA; // 1.5ms 
      TL0 = 0x24; 
    }
    else { 
      TH0 = 0xF8; // 2.0ms 
      TL0 = 0x31;
If everything else is correct, it should at least turn clockwise when p3.2==1. See if that happens.
duffy is offline  
Reply

Tags
basic, doubt, motor, servo

Thread Tools
Display Modes


Similar
Title Starter Forum Replies Latest
Servo motor uaefame Robotics Chat 41 4th December 2008 12:02 AM
Most Basic Doubt Of Digital Electronics!!! tech_vaibhav_eee General Electronics Chat 16 18th August 2008 04:15 AM
PIC basic and Servo Motor! watzmann Micro Controllers 13 22nd October 2007 01:16 AM
Need Servo And Basic Stamp Ii Help ltmhall Robotics Chat 15 11th October 2006 12:40 PM
DC motor, Servo Motor or Step Motor ? wcz Electronic Projects Design/Ideas/Reviews 1 29th June 2005 02:41 PM



All times are GMT. The time now is 05:22 AM.


Electronic Circuits  |  Learning Electronics
eXTReMe Tracker