Hi frnds :),
I am a new guy in this field.so ,i really need a help.
I am doing a project on online object tracking.I have made a 3 dof robot with 3 servos attached.Using simulink and matlab , i am able to get the co-ordinates of any moving object and convert it to angles for rotation of the servo motors in the robot joints.Servos are controlled using arduino uno.
While i am using the example sweep program in arduino, the motors are rotating perfectly,ie, 30 deg for 30 deg. But while doing real time tracking,ie, angle values are continuously sent, the motors are not rotating as expected. 3 angles are there. output from matlab is as in the sequnce.angle 1, angle2,angle3 for base , middle and gun.(robot,s 3 joints).they are send in that sequence.but,whatever changes in angular values occur,they wil rotate only in some specified 2 or 3 angles for any output value.
I dont know what to do.Can anybody please help me, I am nearing the end of my project work and hav to make it correct as soon as possible.Please do respond
i wil paste my arduino command here
#include <Servo.h>
int ibyte;
int mymotors=0;
int i=0;
Servo gun; //AT 9
Servo middle;//AT 10
Servo base;// AT 11
void setup()
{
gun.attach(9); // attaches the servo on pin 9 to the servo object
middle.attach(10);
base.attach(11);
Serial.begin(9600);
// delay(2500);
}
void loop()
{
mymotors = i%3;
if(Serial.available())
{
ibyte =0;
//Serial.listen()
if(mymotors==0)
{
ibyte=Serial.read();
base.write(ibyte);
delay(500);
//base.write(90);
//Serial.write(ibyte);
}
if(mymotors==1)
{
ibyte=Serial.read();
middle.write(ibyte);
delay(500);
//middle.write(70);
}
if(mymotors==2)
{
ibyte=Serial.read();
gun.write(ibyte);
delay(500);
//gun.write(90);
}
i = i+1;
}
}
ALso, please do tell me..is there any specific code or something in arduino that can make the robot go to its home position.