Go Down

Topic: [Help] Issues while using servo-motors (Read 1 time) previous topic - next topic

GuillaumeDo

Hi !
I'm new to the forum, I am having issues while trying to use a servo-motor with my Arduino Uno
The code I am using is :


#include <Servo.h>
Servo myservo;
int flag=0;
void setup() {
 
myservo.attach(2);
myservo.write(96);
delay(2000);

}

void loop()
{

  if (flag==0)
  {
  myservo.write(141);
  delay(2000);
  myservo.write(51);
  delay(2000);
 // flag=1;
 
  }
 else
 {
  myservo.detach();
  delay(2000);
 }
 
}


The code works perfectly when using a USB cable.
The problem is that I want to use an external power supply (a 10V battery)
When I try to run the code with the battery, the motor does shit, going one way, then the other, not as I'm asking in the code.....

Has anyone ever had any similar problem?

Thanks in advance
Guillaume

PaulS

Quote
Has anyone ever had any similar problem?
Yes, when I didn't have things wired properly. How DID you wire the power supply and the servo to the Arduino?
The art of getting good answers lies in asking good questions.

GuillaumeDo

#2
May 09, 2016, 05:28 pm Last Edit: May 09, 2016, 05:36 pm by GuillaumeDo
Yes, when I didn't have things wired properly. How DID you wire the power supply and the servo to the Arduino?
Wow that's a quick answer !

the Servo is a 3 wired basic servo : 5V, GND, command.
5V is connected to the 5V of my Arduino
GND... well to the GND
the command wire is on the second PWM on my Arduino


For the Power Supply, I have attached a jack output to my battery. The jack is implemented in the Arduino Uno

EDIT :
here's my battery :
http://www.gotronic.fr/art-accu-modelisme-nimh-9-6v-2ah-5772.htm
I checked the voltage level and it's in the Arduino Specs
I will provide photos of my setup if you need some

PaulS

Quote
5V is connected to the 5V of my Arduino
The Arduino is not intended to power a servo. They suck way too much current.

That's why you got the 10V power supply. It is THAT wiring that matters.
The art of getting good answers lies in asking good questions.

GuillaumeDo

The Arduino is not intended to power a servo. They suck way too much current.

That's why you got the 10V power supply. It is THAT wiring that matters.
The thing is that my project only requires one servo....
It works like a charm when I connect it on USB to my computer... So I guess the Arduino is able to provide enough current for one single servo

Photo of the setup :

http://g26i.imgup.net/WP_20160519ae8.jpg

When I unplug the USB, the functioning is completely erratic....

http://b14i.imgup.net/WP_20160506381.jpg


That's kind of a mystery for me... this is like the easiest thing I ever did on Arduino :/

PaulS

Quote
It works like a charm when I connect it on USB to my computer... So I guess the Arduino is able to provide enough current for one single servo
The Arduino is probably being stressed to hell and back, but, hey, you can always get another one when it dies.

Quote
When I unplug the USB, the functioning is completely erratic....
The fault is NOT with the Arduino. Whatever is providing the power to the Arduino is NOT up to the task.

Repeat after me: Servos suck a lot of current.
The art of getting good answers lies in asking good questions.

GuillaumeDo

So what should I do? i'm kinda lost right here. I understand I shouldn't use the Arduino to supply current to the servo, so I should use my battery instead?

The battery is 10V, should I pick the 10V and lower it with some voltage divider? ( Only have resistors right here...)

PaulS

Quote
so I should use my battery instead?
Yes!

Quote
The battery is 10V, should I pick the 10V and lower it with some voltage divider? ( Only have resistors right here...)
The servo won't like 10V, so, yes, you'll need to lower it. Think about HOW a voltage divider accomplishes that task, though. The excess voltage is wasted as heat. The amount of heat depends on the voltage drop AND the current flowing.
The art of getting good answers lies in asking good questions.

Cactusface

Paul,
        How many times do we have to tell them! NOT to power servos and motors from the (Any) Arduino 5v pin!!


Mel.
Open your mind! But not too far, your brains might fall out.
Also like Photography, model building and my 300+ Cacti and Succs.

PaulS

Paul,
        How many times do we have to tell them! NOT to power servos and motors from the (Any) Arduino 5v pin!!


Mel.
Once more, per damned fool that thinks that the Arduino is a nuclear power plant.
The art of getting good answers lies in asking good questions.

Southpark

#10
May 22, 2016, 07:43 am Last Edit: May 22, 2016, 07:48 am by Southpark
The code works perfectly when using a USB cable.
The problem is that I want to use an external power supply (a 10V battery)

When using external supply.... ie battery.... connect the ground of the battery to the ground of arduino.

And if the motor etc can't handle 10V.... then a driver circuit or voltage lowering circuit is needed as well.

shadrach

hi,  I am very happy to come across this forum,  as i have a similar  problem...  I am working on creating  a six servo robotic arm controlled  by the leap Motion sensor for my final  year project.  I  am a total amateur to arduino and writing  sketches,  having  problems in  all areas including
1. interfacing the leap Motion sensor to my arduino uno.
2. connecting the six servo motor to the servo  shield.
3. getting  the right sketch to run the setup.
powering the servo.
thanks

PaulS

Quote
as i have a similar  problem.
You've already started your own thread, so why are you posting here? You are not contributing anything to this thread.
The art of getting good answers lies in asking good questions.

Go Up