Pages: [1] 2   Go Down
Author Topic: Jerky servo!!!  (Read 2270 times)
0 Members and 1 Guest are viewing this topic.
Offline Offline
Sr. Member
****
Karma: 0
Posts: 298
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

I have made a robot with 2 gear motors, a led and a servo

I have written in my code that when I press 1,2,3,7,5,9 some functions go on like the robot moving forward etc

The 2 motors are used to move the robot and the servo and led are used as a gun turret.

When I give commands to my motors my servo goes jerky for a while and stops but some times it goes jerky and never stops unless I plug out the arduino.

Please help me to solve this problem

The code is :

#include <Servo.h>

int LedPin1 = 12;
int LedPin = 13;
int MotorPin1 = 9;
int MotorPin2 = 10;
int servoPin = 11;

Servo VishalServo;

void setup()
{
  digitalWrite(LedPin, HIGH);
  Serial.begin(9600);
  pinMode(LedPin, OUTPUT);
  pinMode(LedPin1, OUTPUT);
  pinMode(MotorPin1, OUTPUT);
  pinMode(MotorPin2, OUTPUT);
  VishalServo.attach(servoPin);
  VishalServo.writeMicroseconds(1500);
  delay(2000);
}

void loop()
{
  while (Serial.available() == 0);
  int val = Serial.read() - '0';
 
  int i = VishalServo.read();
 
  if (val == 2)
  {
   Serial.println("Robot is On");
   digitalWrite(MotorPin1, HIGH);
   digitalWrite(MotorPin2, HIGH);
   delay (1000);
   digitalWrite(MotorPin1, LOW);
   digitalWrite(MotorPin2, LOW);
  }
 
  if (val == 1)
  {
   Serial.println("Robot is turning left");
   digitalWrite(MotorPin2, HIGH);
   delay(1000);
   digitalWrite(MotorPin2, LOW);
  }
 
  if (val == 3)
  {
   Serial.println("Robot is turning right");
   digitalWrite(MotorPin1, HIGH);
   delay(1000);
   digitalWrite(MotorPin1, LOW);
  }
 
  if (val == 7)
  {
  Serial.println("Turning left");
  VishalServo.write(i+30);
  }
 
   if (val == 9)
  {
  Serial.println("Turning right");
  VishalServo.write(i-30);
  }
 
   if (val == 5)
  {
   Serial.println("Shoot");
   digitalWrite(LedPin1, HIGH);
   delay(25);
   digitalWrite(LedPin1, LOW);
  }
 
  if (val == smiley-cool
  {
    Serial.println("Centering");
    VishalServo.writeMicroseconds(1500);
  }
 
  else
  {
    Serial.println("Invalid!"); 
  }
}
Logged

Global Moderator
UK
Offline Offline
Brattain Member
*****
Karma: 291
Posts: 25859
I don't think you connected the grounds, Dave.
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Cross posted.
Logged

"Pete, it's a fool looks for logic in the chambers of the human heart." Ulysses Everett McGill.
Do not send technical questions via personal messaging - they will be ignored.

Offline Offline
Sr. Member
****
Karma: 0
Posts: 298
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

What does cross posted mean
Logged

Global Moderator
UK
Offline Offline
Brattain Member
*****
Karma: 291
Posts: 25859
I don't think you connected the grounds, Dave.
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

It means you've been very very naughty and upset people by posting the same question in different parts of the forum.

This wastes time, so don't do it.
« Last Edit: April 29, 2011, 11:35:57 am by AWOL » Logged

"Pete, it's a fool looks for logic in the chambers of the human heart." Ulysses Everett McGill.
Do not send technical questions via personal messaging - they will be ignored.

0
Offline Offline
Tesla Member
***
Karma: 141
Posts: 9470
Arduino rocks
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Quote
When I give commands to my motors my servo goes jerky for a while and stops but some times it goes jerky and never stops unless I plug out the arduino.

Probably inadequate power supply.
Logged

Consider the daffodil. And while you're doing that, I'll be over here, looking through your stuff.   smiley-cool

Offline Offline
Sr. Member
****
Karma: 0
Posts: 298
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Ok  AWOL

But could anyone please tell me how to solve this problem

I will give you a link to where I bought the servo:
http://cgi.ebay.com/2X-Micro-9g-Servo-Futaba-Hitec-HS-55-GWS-walkera-RC-/320669312249?pt=Radio_Control_Parts_Accessories&hash=item4aa96164f9
And the servo jerks even when I connect it to 3 V or  5 V on the arduino.

Please reply fast as I only have a couple more days to finish this project and submit it to my school for a science lesson.

Thanks
Logged

Zapopan, Mexico
Offline Offline
Newbie
*
Karma: 0
Posts: 10
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Im having the same issue, the servo shakes when stopping in a position.
And sometimes the program stops responding so i have to restart the circuit.
I also believe that it has something to do with power supply because i think a got rid of the unresponsiveness or lock of the program by adding some caps on the power rails to provide maybe a little bit more of juice when the servo needs it.
The Jerkiness and shaking was reduced a little and also giving instructions to the servo not to fast reduces it.

Try with some caps from VCC to GND, add several values in parallel for example 0.1uf, 1uf, 10uf and 100uf.

Regards.
Logged

Offline Offline
Sr. Member
****
Karma: 0
Posts: 298
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

zoomkat could you tell me how to make the power supply adequate the....
Please.....
Logged

Offline Offline
Sr. Member
****
Karma: 0
Posts: 298
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Ok i'll try
Logged

Offline Offline
Sr. Member
****
Karma: 0
Posts: 298
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

But I do not have any capacitors, Ihve lost about 100 in a packet I had before.I'snt there any other way...
Logged

Global Moderator
UK
Offline Offline
Brattain Member
*****
Karma: 291
Posts: 25859
I don't think you connected the grounds, Dave.
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

You don't need caps, just a separate supply with adequate capacity.
Logged

"Pete, it's a fool looks for logic in the chambers of the human heart." Ulysses Everett McGill.
Do not send technical questions via personal messaging - they will be ignored.

Offline Offline
Sr. Member
****
Karma: 0
Posts: 298
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

You don't need caps, just a separate supply with adequate capacity.

how do I make that have connected all the grounds together except the Servo's and the LED's as those two grounds have been connected to the arduino's ground inputs,but I have connected one of the arduino's ground pin to the rest of the grounds of the motors,batteries etc.

So could you please tell me how to send it a seperate supply with adequate capacity.

Thanks
Logged

Offline Offline
Sr. Member
****
Karma: 0
Posts: 298
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Someone please give me instruction on what to do to get rid of these problems(detailed instructions if possible)

Thanks
Logged

Global Moderator
UK
Offline Offline
Brattain Member
*****
Karma: 291
Posts: 25859
I don't think you connected the grounds, Dave.
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Four AA cells should do the trick.
Logged

"Pete, it's a fool looks for logic in the chambers of the human heart." Ulysses Everett McGill.
Do not send technical questions via personal messaging - they will be ignored.

Offline Offline
Sr. Member
****
Karma: 0
Posts: 298
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

What do you mean... How and where am I supposed to connect those 4 AA batteries
Logged

Pages: [1] 2   Go Up
Jump to: