Go Down

Topic: Servo uncontrollable (Read 830 times) previous topic - next topic

akkkk

Hi, I've been trying to control a HD-1440A microservo for a while now (http://www.pololu.com/file/0J319/HD-1440A.pdf). I have quite a lot of these, so I'm guessing they are not all defective, although I originally felt I may have been doing something to make them defective.

I'm using the default servo sweep script:

Code: [Select]
// Sweep
// by BARRAGAN <http://barraganstudio.com>
// This example code is in the public domain.


#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 += 1)  // 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(15);                       // waits 15ms for the servo to reach the position
  }
  for(pos = 180; pos>=1; pos-=1)     // goes from 180 degrees to 0 degrees
  {                               
    myservo.write(pos);              // tell servo to go to position in variable 'pos'
    delay(15);                       // waits 15ms for the servo to reach the position
  }
}


and this is how I've connected everything together:



They do 6 full 360 degree turns, before turning 180 degrees the other way. This just repeats. I've included a diagram of my circuit. I'm guessing since the servo has a yellow, red and brown wire, that brown is the negative.

Does anyone know why this is happening? Thanks!

AWOL

Quote
They do 6 full 360 degree turns,

What sort of servo is that?
The PDF you linked says they have a 180 degree limit.
"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.

akkkk

Quote
What sort of servo is that?
The PDF you linked says they have a 180 degree limit.


A broken servo, or a servo that's wired up wrong.

This is the problem I am having.

AWOL

No, really, most servos have mechanical stops that will physically damage them if you try hard enough to rotate them past 180 degrees.

This isn't one of those continuous-rotation ex-servos, is it?
"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.

akkkk

These were all new servos, and I haven't done anything to them, the first servo I ever had stopped working when I forced it round, so I know not to do that.

So if it's wired up correctly I really don't know what is wrong with them. But it's odd that they would all behave this way.

AWOL

Quote
But it's odd that they would all behave this way.

Time to double-check your wiring.
"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.

akkkk

Quote
Time to double-check your wiring.


Is the wiring in the diagram correct?

AWOL

I don't know - I can't read those Fritzing things,
"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.

retrolefty

Quote
They do 6 full 360 degree turns, before turning 180 degrees the other way.


That sounds like you have a servo that has been modified for continuous rotation. Unmodified servos are unable to travel more then around 180 degrees maximum. That means it is no longer a servo but rather like a simple bi-direction variable speed geared motor. As such you need to rethink what your servo commands will actual have the 'servo' do. You no longer have any means to precisely control where it will stop.

Lefty

Krodal

Can you make a fresh start, and use only standard normal things ?

Use 5V for the Servo. You could use the 5V of the Arduino, but the voltage regulator could get hot. Don't use the USB power for that, but use an adapter.
The connector is - + s    ('s' is signal/data). I think you have it wired okay.
Don't use that example code, go for example to 0 degrees, wait 5 seconds, go to 180 degrees, wait 5 seconds, and so on. If they keep on turning they are modified.

What do you call 360 degrees, you could stick red tape to one of the legs.

Did you buy them new in a shop. If so, they are unmodified for sure. Are they used, then they could be modified.

zoomkat

You need to find out what kind of servo you have. Also your battery shows 3.7v, but normal "standard" servos have a minimum operating spec of 4.8v. Make sure the servo, arduino, and battery grounds aer actually connected together. Below is some simple servo test code for use with the serial momitor.

Code: [Select]

// 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
  }
}
Consider the daffodil. And while you're doing that, I'll be over here, looking through your stuff.   8)

Go Up