Go Down

Topic: hobby servo to arduino (Read 823 times) previous topic - next topic

roboarm

Hello guys, I just bought new hobby servo Track Star TS910. I am currently having trouble controlling my servo. Whenever I tell my servo to move to 180 degree using servo.write, it did turn to a certain position, and when I tell it to move to 0 degree, it does nothing. I did try to tell it to move to 90 degree from 180 degree, but the servo blade only turns 45 degrees. I've tried using sweep code examples to move from 0-180, instead the servo only moves like 90 degrees or something. What did I miss? Any help will be appreciated. Here's the simple code I use to tell the servo to move.




#include <Servo.h>
Servo servo;

void setup(){
servo.attach(3);

Serial.begin(57600);
}
void loop(){
servo.write(90);
}

outsider

#1
Oct 08, 2016, 12:02 pm Last Edit: Oct 08, 2016, 12:16 pm by outsider
How are you powering the servo? Powering it from Arduino is not a good idea, you should have a separate 5 or 6 volt source. The program you posted won't do anything, the servo.attach(3) automatically sets the servo to 90, servo.write(90) will only move it to where it already is, try the example program "Sweep" or "Knob" in the Servo library.
Just checked web page & it says 6 to 7.4 volts and I would think at least 1.5 Amps.

outsider

Try this little sketch to test your servo, type a number ( 0 - 180) in the serial monitor and hit [ENTER], start at 90 and work your way toward 0,  5 degrees at a time, then from 90 to 180 to make sure the servo can go end to end without binding.
Code: [Select]

#include <Servo.h>
Servo servo;


int pos = 0;

void setup() {
  // initialize serial:
  Serial.begin(57600); //set serial monitor baud rate to match
  servo.attach(3);
}

void loop() {
  // if there's any serial available, read it:
  while (Serial.available() > 0) {

    // look for the next valid integer in the incoming serial stream:
    int pos = Serial.parseInt();
    pos = constrain(pos, 0, 180);
    servo.write(pos);
    Serial.println(servo.read());
  }
}

roboarm

#3
Oct 08, 2016, 02:22 pm Last Edit: Oct 08, 2016, 04:43 pm by roboarm
 I power it directly using 7,4 V battery LiPo, and I also didn't forget to connect the ground to arduino. I tried using your code.Servo will only move to 150 degree maximum. If I type 151 or more, servo wont move anymore, so does 35 degree minimum. Which means my servo will only move from 150 to 35 degrees (thats like 115 degrees of turn). What I dont understand is the turn itself is not accurate. Assuming my horn position at 150 degree is 0, which means in order to turn of the horn as far as 90 degree, I must type : 150-90 = 60 degrees. So when I typed 60, it didnt really turn 90 degrees. Instead, the real "90 degree" turn is at 45. Maybe in order to control it to move to desired position, I should multiply it by correction factor to cover for the "error".

MarkT

Its a hobby servo, its not a precision engineered component.  Most servos have a range of 120 degrees or
a bit more.  Robotics servos can have much more useful specs, and cost more.
[ I DO NOT respond to personal messages, I WILL delete them unread, use the forum please ]

Go Up