Go Down

Topic: servo motor problem (Read 5881 times) previous topic - next topic

benci

Hi all!

I'm quite new to the arduino UNO board, but i've already experimented the basic stuff (leds and so on). Now i'm tryin to use a servo motor (the blue bird bms-371), following various tutorial and using the example provided with arduino itself (the sweep example).
 I'm writing here 'cause i cannot get it working... Wired the red to the +5V on arduino, the brown to the GND e the orange to pin 9. Nothing appens. The same if the arduino board is powered via regulated dc wall adaptor. The only "movement" that i've been able to get appens when i disconnect and reconnect the +5V. In this case there is a little movement (say 5°).

What i'm doing wrong?

Thanks!

Grumpy_Mike

#1
Jan 14, 2011, 12:39 pm Last Edit: Jan 14, 2011, 12:40 pm by Grumpy_Mike Reason: 1
Quote
What i'm doing wrong?

I don't know as you haven't given anything to go on like a photo of what your setup is, or the code that you are trying to use. (use the # icon when posting).

Appen then something will happen.

zoomkat

#2
Jan 14, 2011, 04:39 pm Last Edit: Jan 14, 2011, 04:39 pm by zoomkat Reason: 1
Quote
Wired the red to the +5V on arduino


This is probably your problem. You generally can not power a servo or motor directly from an arduino. You need to use an external power supply.
Google forum search: Use Google Advanced Search and use Http://forum.arduino.cc/index in the "site or domain:" box.

benci

I've gone not too deep in details because i've followed the tutorial proposed in the arduino servo library reference. This one: http://arduino.cc/en/Tutorial/Sweep to be precise.
Same code and same circuit.

zoomkat

Quote
Same code and same circuit.


Is it working for you? The below from the tutorial is generally bad info on powering a servo. Servos can use more power than can be supplied from a USB port.

Quote
The power wire is typically red, and should be connected to the 5V pin on the Arduino board.
Google forum search: Use Google Advanced Search and use Http://forum.arduino.cc/index in the "site or domain:" box.

arbarnhart

#5
Jan 14, 2011, 06:22 pm Last Edit: Jan 14, 2011, 06:32 pm by arbarnhart Reason: 1
Quote
This is probably your problem. You generally can not power a servo or motor directly from an arduino. You need to use an external power supply.


To do much meaningful work with a decent sized servo or run multiples I agree. But to run the sweep example I disagree. I have run steering servos while the Arduino was powered by USB many times out of convenience to adjust trim. I looked up that servo and it is 4.8v analog and should work fine unloaded. As far as wires go, I see some odd color choices in pictures.  The +5 is always the center wire (except Airtronics!) and the darker of the two outside wires should be ground.

Do you have a servo tester?

benci

Quote
Is it working for you?

No, it's not working. That's why i'm posting here...
Quote
Servos can use more power than can be supplied from a USB port.

Yes, i know. So i've tried powering the arduino board from a wall adapter, suppling 6 volts and up to 1amp (from his specs).
So, for what i know, it should'n be a powering problem.

benci

Quote
Do you have a servo tester?

No, i don't have one. But i've tried with two different servos, one of which as been reported to me as working (was used in a car model).

zoomkat

Quote
Yes, i know. So i've tried powering the arduino board from a wall adapter, suppling 6 volts and up to 1amp (from his specs).
So, for what i know, it should'n be a powering problem.


If you are powering the arduino from the wallwart via the arduino external power connector, this could be an issue, as the external connector usually requires something like 7v minimum for the power regulator chip to supply 5v to the board. You need to connect the servo red wire directly to the wallwart 6v, and have a common ground between the wallwart and the arduino board. If that doesn't work, then there are probably other issues that are in play.
Google forum search: Use Google Advanced Search and use Http://forum.arduino.cc/index in the "site or domain:" box.

cr0sh

Really - your answer will come a lot quicker if you post your code, post pictures of your setup, perhaps an image of your schematic.

You can tell us all you want that you are using the example - but that ultimately tells us nothing, because we don't know for certain whether you hooked it up properly, etc. For all we know, your breadboard may be the culprit!

Please - show us the circuit and the code!

:)
I will not respond to Arduino help PM's from random forum users; if you have such a question, start a new topic thread.

arbarnhart

#10
Jan 14, 2011, 06:33 pm Last Edit: Jan 14, 2011, 06:37 pm by arbarnhart Reason: 1
Try a different pin in the PWM range that you haven't used in any other tutorials. Just change the pin number in the code to match.

EDIT - Just saw the kat's catch on your 6v wall wart. He is right; you need to go to something higher.

benci

Quote
if you post your code, post pictures of your setup, perhaps an image of your schematic.

Ok. Here's the code:
Code: [Select]
#include <Servo.h>

Servo myservo;  // create servo object to control a servo
               // a maximum of eight servo objects can be created

int pos = 0;    // variable to store the servo position

void setup()
{
 myservo.attach(9);  // attaches the servo on pin 9 to the servo object
}


void loop()
{
 for(pos = 0; pos < 180; pos += 10)  // goes from 0 degrees to 180 degrees
 {                                  // in steps of 1 degree
   myservo.write(pos);              // tell servo to go to position in variable 'pos'
   delay(50);                       // waits 15ms for the servo to reach the position
 }
 for(pos = 180; pos>=1; pos-=10)     // goes from 180 degrees to 0 degrees
 {                                
   myservo.write(pos);              // tell servo to go to position in variable 'pos'
   delay(50);                       // waits 15ms for the servo to reach the position
 }
}

Two little changes from the base example:
incremented delay (from 15 to 50 ms) and modified step size from 1 to 10 in for loop (obviously i've tried with the values in the example too)
And here's a picture of the whole:

arbarnhart

Have you tried it powered by USB?
No it isn't good practice in general, but it should have 5v on the 5v line that way (with 6v wall wart going through a VR, it's a different story).

benci

Quote
Have you tried it powered by USB?

Yes, i've tried with both: via USB and via wallwart

zoomkat

If the below is your servo, then its small size should allow it to possibly do some unloaded movement using the arduino 5v source (it is speced for 4.8v and I saw a post saying to not use 6v). Below is some simple servo test code I use that might be of use looking for your problem.

http://www.hobbycity.com/hobbycity/store/uh_viewItem.asp?idProduct=9444

Code: [Select]

// zoomkat 10-4-10 serial servo test
// type servo position 0 to 180 in serial monitor
// for writeMicroseconds, use a value like 1500
// for IDE 0019 and later
// Powering a servo from the arduino usually DOES NOT WORK.

String readString;
#include <Servo.h>
Servo myservo;  // create servo object to control a servo

void setup() {
 Serial.begin(9600);
 myservo.attach(7);  //the pin for the servo control
 Serial.println("servo-test-21"); // so I can keep track of what is loaded
}

void loop() {

 while (Serial.available()) {
   delay(10);  
   if (Serial.available() >0) {
     char c = Serial.read();  //gets one byte from serial buffer
     readString += c; //makes the string readString
   }
 }

 if (readString.length() >0) {
   Serial.println(readString);  //so you can see the captured string
   int n;
   char carray[6]; //converting string to number
   readString.toCharArray(carray, sizeof(carray));
   n = atoi(carray);
   myservo.writeMicroseconds(n); // for microseconds
   //myservo.write(n); //for degees 0-180
   readString="";
 }
}
Google forum search: Use Google Advanced Search and use Http://forum.arduino.cc/index in the "site or domain:" box.

Go Up