![]() | ![]() | ![]() |
| | #1 |
|
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. | |
| |
| | #2 |
|
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?
| |
| |
| | #3 |
|
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. | |
| |
| | #4 |
|
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. | |
| |
| | #5 |
|
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. | |
| |
| | #6 |
|
pls refresh the page..
| |
| |
| | #7 |
|
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;
}
}
Last edited by duffy; 27th January 2009 at 10:31 PM. | |
| |
| | #8 |
|
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.. | |
| |
| | #9 |
|
If P3.2 == 1, does the servo move at all?
| |
| |
| | #10 |
|
nope.. there is no movement at all.. it only responds when p3.2==0 | |
| |
| | #11 |
|
Did you remove the conditional statement on the timer function call?
| |
| |
| | #12 |
|
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?.. | |
| |
| | #13 |
|
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.
| |
| |
| | #14 |
|
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. | |
| |
| | #15 |
|
Try switching these two TH0/TL0 around - Code: TH0 = 0xFA; // 1.5ms
TL0 = 0x24;
}
else {
TH0 = 0xF8; // 2.0ms
TL0 = 0x31;
| |
| |
|
| 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 |