Go Down

Topic: Problem controling a 360° winch servo (Read 835 times) previous topic - next topic

ico7liv

Jul 22, 2017, 10:33 pm Last Edit: Jul 22, 2017, 10:39 pm by ico7liv
Hello Arduino community :)

I just received a  360° winch servo (model : SW5513-6MA), and after some hours working with it, I really dont understand how it works.


My goal is to be able to stop into 3 differents positions : 0° / 120° / 240°


My code:
Code: [Select]
#include <Servo.h>

Servo myservo;

int pos = 0;
int now = 0;
int next;

void setup() {
  Serial.begin(115200);
}

void loop() {

    Serial.println("goto +120°");
      myservo.attach(7);
    next = now+120;
  for (pos = now ; pos <= next ; pos += 1) {
    // in steps of 1 degree
    myservo.write(pos);
    delay(15);
  }
  Serial.print("position : ");
  now = myservo.read();
  Serial.println(now);
    myservo.detach();


  delay(3000);

}


Serial résult :
Code: [Select]

goto +120°
position : 180
goto +120°
position : 180
goto +120°
position : 180
goto +120°
position : 180
goto +120°
position : 180
goto +120°
position : 180
goto +120°
position : 180
goto +120°



Physical result : the servo turns more than 360° everytime, instead of +120°

Thanks for your help, and informations about 360 winch servo you could give me :)


Robin2

Post a link to the datasheet or user manual for the servo. Have you got a continuous rotation servo? If so you can't control the position. Only the speed and direction.

Slow things down a lot and print the value of pos for each movement of the servo. Maybe increment in steps of 10 degrees to reduce the number of steps for testing. Also print the value of next.

Move the line myservo.attach(7); into setup() and delete the line myservo.detach();

The function myServo.read() is pretty useless as it just tells you what you already know - the last position commanded.


...R
Two or three hours spent thinking and reading documentation solves most programming problems.

ico7liv

Thanks for your help Robin2 :)

I dont have any datasheet for this SW5513-6MA servo. I waiting for Hobbyking answer about it..

It's supposed to be a WINCH servo, not a continous rotation servo. So I should be able to control the position, right ?

Here is a new test, where my goal is to go the the 90° position.


CODE
Code: [Select]

#include <Servo.h>

Servo myservo;

int pos = 0;

void setup() {
  Serial.begin(115200);
  myservo.attach(7);

}

void loop() {

    Serial.println("BEGIN : goto 90°");
    for (pos = 0 ; pos < 90 ; pos += 10) {
    myservo.write(pos);
    Serial.println(pos);
    delay(150);
  }

    delay(3000);

}



SERIAL CONSOLE
Code: [Select]
BEGIN : goto 90°
0
10
20
30
40
50
60
70
80
BEGIN : goto 90°
0
10
20
30
40
50
60
70
80
BEGIN : goto 90°
0
10
20
30
40
50
60
70
80


Servo behavior (video) : 
It turns more than 180°. Then go back -180° I dont know why.

slipstick

It's a winch servo, intended to wind a rope round a drum. Most winch servos travel for several turns not just 360 degrees. And judging from the comments on the Hobbyking page this one does too...one comment says 4.5 turns in each direction another says 6 turns total.

If true that suggests that a movement of 120 degrees is going to correspond roughly to write(25) or (35),  though I'd be using writeMicroseconds() for better control. If you try the example Knob sketch it should be very easy to check exactly what the servo is doing.

Steve

Robin2

@ico7liv, why didn't you post the link that @slipstick found?

I have a feeling, from looking at that and other sail winch servos on the Hobby King page that the OP's servo just works through 360 degrees. Other servos list the number of turns. Alternatively the 25T in the name means that it can do 25 turns - which seems unlikely.

In any case the way servos are controlled means that servo.write(0) is one extreme of the motion and servo.write(180) is the other extreme even is the actual number of degrees moved is far greater.

If it really is a 360 degree servo then servo.write(90) would make it go to 180 degrees etc.

And, as @slipstick has said it would be much better to use servo.writeMicroseconds() for finer control.

...R
Two or three hours spent thinking and reading documentation solves most programming problems.

Go Up