Pages: [1]   Go Down
Author Topic: HELP! Servo keeps running (with just attach() method)!!  (Read 1552 times)
0 Members and 1 Guest are viewing this topic.
Offline Offline
Newbie
*
Karma: 0
Posts: 3
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Hi,

I am afraid my micro servo might be broken, but I wanted to confirm it by asking you guys a question.

I was building a very simple project - push a button and servo turns 180-degrees - for my kid's school project. I got it to work, but while I turned around for like 5 minutes, my kid did something with the board and now servo keeps turning.

I took the pushbutton out and tried putting servo in different digital pins, and it didn't make a difference. I also tried to isolate the problem by commenting out most of the code.  Even with just attach() method, it makes the servo keep turning......  I am afraid my servo is somehow busted....  smiley-sad

Can someone tell me if I am doing something obviously wrong? I really appreciate your help in advance!!!

Board setup:
Uno 5V to breadboard +
Uno GND to breadboard -
Servo (Hitec 31055S HS-55) red cable to breadboard +
Servo black cable to breadboard -
Servo yellow cable to Uno digital pin #12

Code:
Code:
#include <Servo.h>
 
//int buttonPin = 7;  
int servoPin = 12;
 
Servo servo;  
int angle = 0;   // servo position in degrees
 
void setup()
{
  servo.attach(servoPin);
//  pinMode(buttonPin, INPUT);
}

void loop()
{
//  val = digitalRead(buttonPin);
//  if (val == HIGH) {
//    servo.write(180);
//    delay(3000);
//    servo.write(0);
//  }
}
« Last Edit: March 15, 2013, 12:22:06 am by yangtheman » Logged

USA, FL
Offline Offline
God Member
*****
Karma: 14
Posts: 688
A life? Where can I download one of those?
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Do you have a link to the Servo you purchased?  Sounds like you bought a continuous rotation servo.
Logged

//LiNK

Offline Offline
Newbie
*
Karma: 0
Posts: 3
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Do you have a link to the Servo you purchased?  Sounds like you bought a continuous rotation servo.

Here is the servo I bought. http://www.amazon.com/gp/product/B0006O3WNW/ref=oh_details_o00_s01_i00?ie=UTF8&psc=1

No, I had it work to go from 0 to 180, and back to 0....  But somehow after my kid did something, it just started to turn endlessly....  smiley-sad
Logged

Johannesburg. UTC+2
Online Online
Faraday Member
**
Karma: 82
Posts: 3846
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Quote
Sounds like you bought a continuous rotation servo.

But that wouldn't explain why it was working, and now it's not....

A way to test that would be to send it to position 90, which if I understand things correctly is 0 speed on a continuous servo, with position 0 being max speed one way and 180 being max speed the other. (Although from what I read here it's not always 90 exactly, try values either side.)

Your 0 would indeed be sending it off in circles if it's a continuous servo.
Logged

The Elders of the Internet know who I am.....
Get me on LinkedIn: za.linkedin.com/in/jimbrownza/

Offline Offline
Newbie
*
Karma: 0
Posts: 3
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset


A way to test that would be to send it to position 90, which if I understand things correctly is 0 speed on a continuous servo, with position 0 being max speed one way and 180 being max speed the other. (Although from what I read here it's not always 90 exactly, try values either side.)

Your 0 would indeed be sending it off in circles if it's a continuous servo.

I can't even do that because as soon as I connect signal wire, it starts turning....
Logged

Johannesburg. UTC+2
Online Online
Faraday Member
**
Karma: 82
Posts: 3846
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Quote
I can't even do that because as soon as I connect signal wire, it starts turning....

Oh yeah, my bad...

I can't think what the problem might be- something mechanical probably... if your son perhaps wrenched the horn past one of the end stops could that have done this?- I don't know. (I do know that one of the mods you need to make to a normal servo to make it continuous is remove the end stops.)
Logged

The Elders of the Internet know who I am.....
Get me on LinkedIn: za.linkedin.com/in/jimbrownza/

0
Offline Offline
Tesla Member
***
Karma: 141
Posts: 9470
Arduino rocks
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Servo test code.

Code:
// zoomkat 10-22-11 serial servo test
// type servo position 0 to 180 in serial monitor
// or for writeMicroseconds, use a value like 1500
// for IDE 0022 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.writeMicroseconds(1500); //set initial servo position if desired
  myservo.attach(7);  //the pin for the servo control
  Serial.println("servo-test-22-dual-input"); // so I can keep track of what is loaded
}

void loop() {
  while (Serial.available()) {
    char c = Serial.read();  //gets one byte from serial buffer
    readString += c; //makes the string readString
    delay(2);  //slow looping to allow buffer to fill with next character
  }

  if (readString.length() >0) {
    Serial.println(readString);  //so you can see the captured string
    int n = readString.toInt();  //convert readString into a number

    // auto select appropriate value, copied from someone elses code.
    if(n >= 500)
    {
      Serial.print("writing Microseconds: ");
      Serial.println(n);
      myservo.writeMicroseconds(n);
    }
    else
    {   
      Serial.print("writing Angle: ");
      Serial.println(n);
      myservo.write(n);
    }

    readString=""; //empty for next input
  }
}

Logged

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

Queens, New York
Online Online
Faraday Member
**
Karma: 84
Posts: 3426
"Of all the things I've ever lost, I miss my mind the most" -Ozzy Osbourne
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Quote
Uno 5V to breadboard +

Your running it off the arduino 5V line? Servos usually need 6V to work properly.

Quote
No, I had it work to go from 0 to 180, and back to 0....  But somehow after my kid did something, it just started to turn endlessly.... 
He might have broken the pot inside the servo, and it is trying to set itself back to center. Some servos are setup to when you apply power to the signal wire, it automatically rotates and centers the servo. If the pot is broken, it will never be able to find center.
Logged

Created Libraries:
NPV2 (NewPasswordV2),  TFT_Extension, OneWireKeypad, SerialServo.
Will provide libraries if asked in PM or forum.

Offline Offline
God Member
*****
Karma: 27
Posts: 829
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

ok, let's back up. Connecting just the positive supply and ground to your servo, does it do anything?

Is it only when the signal pin is connected, or only when the servo.attach function is called?
Logged

the land of sun+snow
Offline Offline
Faraday Member
**
Karma: 158
Posts: 2888
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

Quote
now servo keeps turning.
I don't understand what this means. Just keep rotating forever?

If it's a regular servo, and not a continuous rotation servo, then it sounds like the servo
horn got twisted past its mechanical stop, and the stop broke off, and the internal
potentiometer is damaged - as in having the wiper torn off too.
Logged

Rapa Nui
Offline Offline
Edison Member
*
Karma: 60
Posts: 2066
Pukao hats cleaning services
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

You cannot power a servo from arduino directly. A servo may drain 0.8A when actuating.. You need a separate power source for a servo..
Logged

Offline Offline
God Member
*****
Karma: 27
Posts: 829
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

With all due respect to those saying he can't power it off the arduino... clearly he can because he claims that it was working. His problem is that the motor constantly is running, not that it isn't running at all. So, apparently he CAN run it off the arduino directly (unless he made a mistake in describing how he is powering it.) Definitely not advisable, but completely irrelevant to the problem that he is having.

Perhaps he is actually powering the breadboard with a beefier supply and also running the arduino from that? But, still, irrelevant to his problem.
Logged

Pages: [1]   Go Up
Jump to: