Discussion in "8051 Discussion Forum" started by    zoomto    Dec 21, 2010.
Tue Dec 21 2010, 04:40 pm
#1
hi everyone,

im working on a proj SERVO MOTOR BASED ROBOTIC ARM using 89C51 micro controller..im using 5 servo motors in the proj. im new to usage of servos. i know that diff servos uses diff pulse widths for its left,right,neutral positions..the servo im using is:TOWER PRO MG995(Digi High Speed)..im facing few problems in the motor rotations..

im using +5v(dc) for the motor..the signal pin of the servo is connected to the microcontroller port pin via 10k resistor.initially ive started working on one servo and im also giving the code ive developed for that. can the same code be used by all the other servos?also please tell me the precautions to take for completing the proj successfully..please respond at the earliest..its very very urgent..

THANK U IN ADVANCE........

code is below:

/*FOR SERVO-2 FROM TOP..*/

#include<reg51.h>
#include<stdio.h>

void serial_init();
void MSDelay(unsigned char);
void NDelay();
void MSADelay();
void MSCDelay();



sbit svm2=P2^3;
unsigned char dat;
unsigned char i;

void main()
{
svm2=0; /*configuring the signal pin as o/p port pin*/
while(1)
{
serial_init();

printf("\nTHIS IS THE TEST TO IMPLEMENT CONTROL OF SERVO MOTOR...\n\n");
printf("\nPress '1' to rotate in Anti Clock direction\n\n");
printf("\nPress '2' to rotate in Clock direction\n\n");
printf("\nPress '3' to stay in Neutral position\n\n\n");

while(RI==0);
dat=SBUF;
RI=0;

switch(dat)
{
case 0X31:

for(i=0;i<18;i++)
{
svm2=1;
MSADelay();
svm2=0; /*1.25 msec pulses--0 deg-anti clock*/
MSDelay(15);
}
break;

case 0X32:

for(i=0;i<18;i++)
{

svm2=1;
MSCDelay(); /*1.75 msec pulses--180 deg-clock*/
svm2=0;
MSDelay(15);
}
break;

case 0X33:

for(i=0;i<18;i++)
{

svm2=1;
NDelay(); /*1.5 msec pulses--90 deg-neutral*/
svm2=0;
MSDelay(15);
}
break;

default:
;;;
break;
}//switch

}//while
}//main

void MSDelay(unsigned char cnt)
{
unsigned char j;
TMOD=0x10; /*1 ms delay*/
for(j=0;j<cnt;j++)
{
TH1=0xfc;
TL1=0x66;
TR1=1;
while(TF1==0);
TR1=0;
TF1=0;
}
}

void NDelay()
{
TMOD=0x10;
TH1=0xfa;
TL1=0x99;
TR1=1; /*1.5 ms delay*/
while(TF1==0);
TR1=0;
TF1=0;
}

void MSADelay()
{
TMOD=0x10;
TH1=0xfb;
TL1=0x7f;
TR1=1; /*1.25 ms delay*/
while(TF1==0);
TR1=0;
TF1=0;
}
void MSCDelay()
{
TMOD=0x10;
TH1=0xf9;
TL1=0xb3;
TR1=1; /*1.75 ms delay*/
while(TF1==0);
TR1=0;
TF1=0;
}
void serial_init()
{
TMOD=0x20;
SCON=0x52; /*serial initialization*/
TH1=-3;
TR1=1;
}
Tue Dec 21 2010, 11:34 pm
#2
HI zoomto.jitendra
ur code looking like fine
upload ur diagram as u mention 10 k resistor how that connected
look this code as ur reference
http://www.8051projects.info/blogs.asp?view=plink&id=147
Wed Dec 22 2010, 03:02 pm
#3
Thank You Majoka for ur quick reply..

actually i am told by someone to use 100k b/w signal pin of servo and microcontroller port pin..but with 100k servo is not taking its rotation..then ive used 10k instead of 100k..

with 10k, servo is rotating along with the code ive given u yesterday..but not accurately..for example if i asked it to take left direction, it takes left for a while and then immediately it takes right with a jerk..also servo is taking different left,right,neutral positions on different iterations im performing, i.e. im facing problem in bringing servo to neutral position..

im attaching my rough circuit diagram as u asked it..sorry yar im unable to find the option for attaching the file..i will xplain u how i connected 10K resistor..one end of resistor to signal pin of servo and other end connected to port pin..


please reply immediatly..
Wed Dec 22 2010, 04:51 pm
#4
hi zoomto.jitendra
ru refer to that code that i posted in ur thread
u also forget to attach diagram
do not create new thread for same problem it produce confusion
just click on " reply to thread " at the bottom of page
now i delete ur duplicate thread
Thu Dec 23 2010, 08:31 pm
#5
one thing about servo you forgot is.. you have to feed the signal at every fixed interval so its not like you give it once and motor change the position. getting me?

read this for basics of servo motor.
http://www.seattlerobotics.org/guide/servos.html

The pulse width or duration of signal changes depending upon type of servo you're using so you have to take a close look at the datasheet of servo motor you are using to find out that duration.

[Topic moved to 8051 Discussion forum]
Fri Dec 24 2010, 03:06 pm
#6
Hi mazoka & Bhargav..

I want to show u my circuit connection..but im unable to find out the option for attaching the file in the "Quick Reply"..pls help me how to do this?
Fri Dec 24 2010, 03:16 pm
#7
ya sory .. ive got the option..im attaching my rough circuit diagram..also is +5v dc enough for the servo supply?..as i told u im using 5 servo motors (MG995 & SG 5010)..top two servos of my arm are of SG 5010 and rest are MG995...are the pulse widths for the two types of servos are same?if possible can u send me the datasheets of this two types of servos..?

also im taking +5V dc supply to all the servos from the micro controller board only..is that fine or any problem with that?
Sat Dec 25 2010, 12:11 am
#8
hi zoomto.jitendra

im attaching my rough circuit diagram..also is +5v dc enough for the servo supply


i can't see ur attachment still
and power of 5 volt is sufficient or not it depend on ur motor
refer to motor data sheet its power rating is mention there

are the pulse widths for the two types of servos are same?


u also has to refer the data sheet it is best way

if possible can u send me the datasheets of this two types of servos..?


ru search it in Google or its manufacturer site

also im taking +5V dc supply to all the servos from the micro controller board only..is that fine or any problem with that?


normally always prefer to separate the controller and motor supply
because as motor start and run it produce noise in power rails and often controller hangs or malfunction
but in case of servo it should be ok
Mon Dec 27 2010, 02:47 am
#9
You can attach pitures in two way..
First:
1. Upload picture to any image hosting site like tinypic.com
2. Get the direct link after upload
3. put them in your reply between [img] and [/ img] tags (remove spaces)

Second:
Use "post reply" button to post your reply instead of using quick reply form. There you will get attach file option.
Tue Dec 06 2011, 03:01 pm
#10
hey frnds i saw all ur discussions.... even i am too in a project of robot arm... but i never knw anythng about robot arm.. even though interested in doing dat in a efficient way... please help me... thanks in advance... :-)

Get Social

Information

Powered by e107 Forum System

Downloads

Comments

AntoniaRoons
Fri Apr 19 2024, 09:59 pm
carpinteyrowrl
Fri Apr 19 2024, 02:51 pm
DonaldJAX
Fri Apr 19 2024, 01:08 pm
Lewisuhakeply
Thu Apr 18 2024, 06:00 pm
Darrellciz
Thu Apr 18 2024, 11:07 am
Charlessber
Thu Apr 18 2024, 09:29 am
BartonSem
Thu Apr 18 2024, 04:56 am
DonaldKnown
Thu Apr 18 2024, 12:24 am