Go Down

Topic: Servo spinning problem (Read 386 times) previous topic - next topic

RockAli

Hi , I have a problem with my microservo . Im making a little car controlled with an Arduino Uno board. The problem here is that when the board receives a positive angle of spin the servo works very slow , otherwise when it receives a negative angle or cero it works perfectly. I cant put them both to work at 0 because they'd spin in the same direction and the car wouldn't work so I'd aprecciate any kind of help.

Thank you

bluexdynasty

Hi rock,

I'm not an expert and still pretty new in using Arduinos, but I recently worked with a servo motor. May I ask if you have a Continuous rotation servo (since you said you were making a car)? or what kind of servo do you have?

That is because if you have a continuous rotation servo, what you input is not an angle, but the speed servo.write (speed) and depending on your reference point (stop speed) it would determine what is fast/slow.
i.e. if my reference point is 90 and I put 91 would be slow in one direction and 89 would be slow in the other direction. The farther away(eg. 180) from the reference point the faster it is in that specific direction.

I hope that somewhat helps, if not I'm sorry :(

zoomkat

Perhaps you can show your code and explain positive and negative angles. Also, how is the servo powered and wired to the arduino?
Consider the daffodil. And while you're doing that, I'll be over here, looking through your stuff.   8)

RockAli

Im using a normal servo , but modified to rotate 360 degrees. The problem here is that when I put an especified value in the program (lets say a positive one) it rotates clockwise and slow , If I put a negative one or 0 it rotates counterclockwise and fast (not really fast , but the speed Im looking for) . Im just starting with arduino and I'm kinda a noob so pls help me  :D.


int VelMotorLeft = 0;                // Speed of the left engine
  int VelMotorRight = 0;                // Speed of the right Engine
  VelMotorLeft=90-SMotorLeft*30*Marcha;
  VelMotorRight=90+SMotorRight*30*Marcha; (What I mean with negative or positive value is here)



So , you are saying that I have to make a difference between my "stop speed" and my "forward speed" in the program??

Thanks

zoomkat

Servo test code below you can use to check your DIY continuous rotation servo. Note that the stopped control value depends on the current pot/resistor setup in the servo. These types of modified standard servos usually have a control band of +- 100us from the stopped value (if 1500us is the stopped value, full speed one direction would be 1600us and full speed the other direction would be 1400us).

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, 500, 2500);  //the pin for the servo control, and range if desired
  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)

RockAli

Hi , zoomkat , I tried your program on so many values . When I set the ms value from 500 to 850 and it works perfectly ,if I go further it starts to turn to the other side (what I need) , but it goes slow as usual , what can it be???

zoomkat

Quote
what can it be???


You don't describe how you modified your servo, so my best guess is, assuming you left the original pot in the servo, is that you need to adjust the pot. A typical way is to remove the gears so the pot can be adjusted, send the servo a 1500us control command, then carefully adjust the pot until the servo motor stops rotating. You might want to put a very tiny drop of hot glue or similar removable glue on the pot shaft so it won't drift. Then reassemble the servo and test. The stopped command should be ~1500us. Below is some tinkering I've done.

http://www.lynxmotion.net/viewtopic.php?f=31&t=6388
Consider the daffodil. And while you're doing that, I'll be over here, looking through your stuff.   8)

RockAli

Ok thank you , if that is the problem maybe I f**ed up with the glue the day I modified the servo , now maybe it wont move. Thanks the same

Go Up