Pages: [1] 2   Go Down
Author Topic: Arduino + Servo Help  (Read 1201 times)
0 Members and 1 Guest are viewing this topic.
0
Offline Offline
Jr. Member
**
Karma: 1
Posts: 71
Arduino rocks
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

I'm trying to set up Arduino to use the Sweep code on a servo I have.
I am using an Arduino Uno and this servo: http://toysdownunder.com/light-weight-servo-3-7g.html

I plugged the gnd in, the signal cable to digital pin 9 and the power cable to 5V. When I plugged it into 5V however the Arduino would turn off, take it out and it would start back up again. So I plugged the power cable into 3.3V and the Arduino would stay.

Anyway this setup isn't working for me, as the servo isn't working. Is this because the servo I am using is busted from me trying to use it on 5V when it is recommended for 4.8V? Or perhaps its because the Arduino is feeding off the power from the USB? Any troubleshooting advice would be great.
Logged

New Jersey
Offline Offline
Faraday Member
**
Karma: 48
Posts: 3407
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Generally, the arduino can't supply enough current to drive a servo, you need to use a separate power supply & tie the grounds together.
Logged

0
Offline Offline
Jr. Member
**
Karma: 1
Posts: 71
Arduino rocks
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

I hooked it up to a lab power supply and set it to roughly 4.8V (hard to tell as it is an analog interface). Still no go but I haven't tied the grounds together, what do you mean by this?
Logged

0
Offline Offline
Jr. Member
**
Karma: 1
Posts: 71
Arduino rocks
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

I would also like to add upon using the read() function of the Servo library, it just constantly reports 1 (even if i manually change the position by hand)
Logged

New Jersey
Offline Offline
Faraday Member
**
Karma: 48
Posts: 3407
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

I hooked it up to a lab power supply and set it to roughly 4.8V (hard to tell as it is an analog interface). Still no go but I haven't tied the grounds together, what do you mean by this?

Ground on the servo power supply and ground on the arduino need to be connected
Logged

0
Offline Offline
Full Member
***
Karma: 0
Posts: 192
Arduino rocks
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

I am actually powering 5 servos with a single arduino and it works fine.
Logged

Left Coast, CA (USA)
Offline Offline
Brattain Member
*****
Karma: 331
Posts: 16514
Measurement changes behavior
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

I am actually powering 5 servos with a single arduino and it works fine.

Then you might be using especially small servos with possibly little or no machincal load on them and possibly not trying to have them all move at the same time. Servos have motors in them and are best powered from external voltages sources capable of supplying much more current then the Arduino USB or external power connector is designed to provide. What you are doing is not a recommended practice.

Lefty
Logged

0
Offline Offline
Full Member
***
Karma: 0
Posts: 192
Arduino rocks
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

I am actually powering 5 servos with a single arduino and it works fine.

Then you might be using especially small servos with possibly little or no machincal load on them and possibly not trying to have them all move at the same time. Servos have motors in them and are best powered from external voltages sources capable of supplying much more current then the Arduino USB or external power connector is designed to provide. What you are doing is not a recommended practice.

Lefty


Here, i do power them all at the same time, they do have a good amount of load, and here is my instructable with a video: http://www.instructables.com/id/Arduino-Wireless-Animatronic-Hand/
Logged

Ohio
Offline Offline
Full Member
***
Karma: 0
Posts: 227
Arduino Hexapod
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

I would also like to add upon using the read() function of the Servo library, it just constantly reports 1 (even if i manually change the position by hand)

The servo read method does nothing to report the actual position of the servo.
It only reports the last value sent with a servo write.
Logged

Left Coast, CA (USA)
Offline Offline
Brattain Member
*****
Karma: 331
Posts: 16514
Measurement changes behavior
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset


[/quote]

Here, i do power them all at the same time, they do have a good amount of load, and here is my instructable with a video: http://www.instructables.com/id/Arduino-Wireless-Animatronic-Hand/
[/quote]

Very impressive project. What is the power source for the arduino/breadboard +5VDC that is driving the servos?

Lefty
Logged

0
Offline Offline
Jr. Member
**
Karma: 1
Posts: 71
Arduino rocks
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

OK so I still can't get this going,

Servo has signal connected to digital 9, positive connected to lab power supply, negative connected to lab power supply, and there is also a wire connecting the negative lab power supply terminal with the gnd in the arduino.

Yet no movement, I am following the Sweep tutorial (and the model is posted in the original post)
Logged

Ohio
Offline Offline
Full Member
***
Karma: 0
Posts: 227
Arduino Hexapod
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Do you have another servo you can try?
Do you have and RC transmitter/receiver that you can hook the servo to to test it for proper operation?
Logged

Copenhagen, Denmark
Offline Offline
Edison Member
*
Karma: 25
Posts: 1133
Have you testrun your INO file today?
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Well, I recently did this and it worked fine for me 1st time. Still what are the possible source for errors and have you checked them all?
1: Wiring. The picture of  your servo is Brown, red, orange, the schematic on the Sweep tutorial shows Black, Red, Yellow. You have the orange to pin 9, the brown to GND and the Red to +5V, right?
1a: Check the wiring again.  smiley-razz  Good connections? Is there actually power? To BOTH the Servo and Arduino?
2: Loaded the "wrong" program into the Arduino, or not loaded at all.
2a: Program not running (something is blocking Arduino execution) Modify Sweep with digitalWrite(13,HIGH) before the first for-loop and the same with "LOW" before th other, to verify that your loop is looping. (the onboard LED blinks, slowly). Alternativly put insome Serial.print() calls. This loop will run whether the servo is connected or not.
3: The Servo is broken. See previous suggestions by vinceherman

That servo shown on your picture seems tiny enough to power from your Arduino. If it takes too much power, the Arduino would reset. You might notice that on the starnge/modified LED blink
Logged

0
Offline Offline
Tesla Member
***
Karma: 114
Posts: 8915
Arduino rocks
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Simple servo test code that should make your servo move if power, wiring, the servo, etc are ok.

Code:
// 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(1); 
    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="";
  }
}

Logged

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

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

Quote
I would also like to add upon using the read() function of the Servo library, it just constantly reports 1 (even if i manually change the position by hand)

It has been pointed out that the read method only reports the last value written.
Maybe this is telling us something about the sketch the OP is using.

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.

Pages: [1] 2   Go Up
Jump to: