Go Down

Topic: Servo's Freezing (Read 5156 times) previous topic - next topic

sspence65

Mar 04, 2012, 04:17 pm Last Edit: Mar 04, 2012, 04:25 pm by Steve Spence Reason: 1
I have a hxt900 servo, and when using both example sketches included in Arduino 1.0, the servo (and a second identical one) freeze, quit, operate erratically, etc. Checked the wiring to make sure it's solid, and correct. I also checked to see the pot was being read properly.

The "L" light on my 2560 lights at the same time the servo "shifts" 2-5 degrees or so (every 9 seconds)

Anyone else having similar issues?

Code: [Select]
// Controlling a servo position using a potentiometer (variable resistor)
// by Michal Rinott <http://people.interaction-ivrea.it/m.rinott>

#include <Servo.h>

Servo myservo;  // create servo object to control a servo

int potpin = 0;  // analog pin used to connect the potentiometer
int val;    // variable to read the value from the analog pin

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

void loop()
{
  val = analogRead(potpin);            // reads the value of the potentiometer (value between 0 and 1023)
//  Serial.println(val);
  val = map(val, 0, 1023, 0, 179);     // scale it to use it with the servo (value between 0 and 180)
  myservo.write(val);    // sets the servo position according to the scaled value
//  Serial.println(val);
  delay(15);                           // waits for the servo to get there
}
Steve Spence - KK4HFJ

wildbill

How is it powered? If from the Arduino, that's likely your problem.

sspence65

yes, it's powered from the arduino, which is powered from my laptop usb.
Steve Spence - KK4HFJ

wildbill

Servos generally draw more current than the Arduino can supply, indeed you may well damage it in this way. You need an external power supply for the servos and connect ground from it to Arduino ground.

sspence65

That did the trick. I found that that particular servo can peak at 750ma, so no wonder. Two AA's in series fixed it up for me. Thanks. I'll post the video, schematic, etc., shortly at http://arduinotronics.blogspot.com/
Steve Spence - KK4HFJ

retrolefty

Quote
Two AA's in series fixed it up for me.


That sounds rather strange and most likely dangerous for the servos? In series with what? If in series with the arduino +5vdc that would give the servos +8vdc to their power input, which is much higher then the common 4.5to 6vdc power specification for most hobby servos and risks damaging the servos.

Lefty

sspence65

#6
Mar 04, 2012, 05:31 pm Last Edit: Mar 04, 2012, 05:47 pm by Steve Spence - KK4HFJ Reason: 1
Two AA's in series is 3v. A little low for this servo, but it's what I had, and worked fine.

http://youtu.be/0qJrkS7ItS4

http://arduinotronics.blogspot.com/2012/03/fun-with-servos.html

http://tech.groups.yahoo.com/group/arduinohome/
Steve Spence - KK4HFJ

zoomkat

Below is the typical servo wiring setup for an arduino. 4 AA batterys in series would gvie ~6v for best servo performance. Note that the servo power supply and arduino grounds need to be connected.

Google forum search: Use Google Search box in upper right side of this page.
Why I like my 2005 Rio Yellow Honda S2000  https://www.youtube.com/watch?v=pWjMvrkUqX0

sspence65

That's what I ended up doing.

Steve Spence - KK4HFJ

Go Up