Go Down

Topic: Jerky servo!!! (Read 2620 times) previous topic - next topic

vishalapr

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 == 8)
  {
    Serial.println("Centering");
    VishalServo.writeMicroseconds(1500);
  }
 
  else
  {
    Serial.println("Invalid!"); 
  }
}

AWOL

"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.

vishalapr

What does cross posted mean

AWOL

#3
Apr 29, 2011, 06:30 pm Last Edit: Apr 29, 2011, 06:35 pm by AWOL Reason: 1
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.
"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.

zoomkat

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.
Google forum search: Use Google Advanced Search and use Http://forum.arduino.cc/index in the "site or domain:" box.

vishalapr

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

jn

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.

vishalapr

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

vishalapr


vishalapr

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

AWOL

You don't need caps, just a separate supply with adequate capacity.
"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.

vishalapr


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

vishalapr

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

Thanks

AWOL

Four AA cells should do the trick.
"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.

vishalapr

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

Go Up