Questions About Servos

This is mainly about continuous rotation servos.

Can you control the angle of a continuous rotation servo? I haven't found a working code for it yet. (It's always 0-180 but, I'd like it to be 0-360)

How do you control the speed of the servo? And direction?

Is the Servo.h library meant for continuous rotation servos too?

Could you guys post some code meant solely for continuous rotation servos?

I've searched many codes and all I've been able to do is make it rotate. :-?

Thanks! I'm sure this'll be useful for others. :D

Can you control the angle of a continuous rotation servo?

If you're talking about a modded R/C servo, no, you can't. It isn't really a servo anymore - no feedback.

How do you control the speed of the servo?

Pretty much, you can't. There may be a small amount of control either side of the null position, but it is usually quite load dependent.

And direction?

Experimentation. If you try timings which would put the servo at 90 degrees (depends where the pot was left or how well-balanced the resistors are), you should find a point where it stops. Use the "writeMicroseconds" method for fine control. (depending on Servo library version, you can write the pulse lengths directly to the "write" method too)

Is the Servo.h library meant for continuous rotation servos too

You can use it, but they're not servos anymore, they're geared motors with a single wire direction control.

Could you guys post some code meant solely for continuous rotation servos

You need to experiment for yourself - any values we give for the stationary point may well be off for your devices (and your devices themselves may all be different).

If you wire up a pot, and map the 0..1023 range to something like 544..2500, use these values as parameters to "writeMicroseconds" and print them to the serial, you should be able to get close to the null position pretty quickly.

My servo is the one from sparkfun http://www.sparkfun.com/commerce/product_info.php?products_id=9347

Since it's not modded, it is possible to control angle without the servo.h library?

It is a servo, because sparkfun said it was. (otherwise I will return it and say You lied to me.)

So i can control the angle. I guessing the code is myservo.write(pos) It's not quite working, when i type 90 or 270, it doesn't go to that spot. You mentioned writeMicroseconds, would that involve a different method of controlling the servo with the servo.h library?

Still not sure if i can control speed.

Direction, could it be myservo.write(0-pos) ?

Still not sure if servo.h works with (Legit) continuous rotation servos.

Tell them they lied. A servomotor has a feedback mechanism, yours doesn't.

So i can control the angle.

No, you can't.

It's not quite working, when i type 90 or 270, it doesn't go to that spot.

You need to experiment with values around 90 (or see below), to find the stationary point.

http://www.sparkfun.com/datasheets/Robotics/servo-360_e.pdf Pulse widths above 1.5ms (1500us) gives clockwise rotation, below anti-clockwise.

[edit]If you write a sketch to write an "angle" of 90, you should then be able to use the trim control on the (ex-) servo to set your stationary point. Then values greater than 90 will start it rotating in one direction, and values less than 90 will set it going in the other. [/edit]

I figured that out right when you edited it.

I called sparkfun, they said that i don’t have a position servo, i have a speed and direction servo.

I’m perfectly fine with that.

And, right when you edited, i found out how to control speed using servo.h library.

Important*
myservo.write(speed);

myservo is the object you name your servo.

speed is 0 - 180

if speed is 90, thats dead stop
if 85 then its slow moving left
if 95 then its slow moving right
if 180 then fastest moving right
if 0 then fastest moving left

This is only for continuous rotation servo.

if 90 is not your dead stop, then there is a little adjusting knob on the side of your servo. Just make speed = 90 and adjust the servo until it has stopped. If theres an adjustment knob.

A good way to test the whole spectrum:

#include <Servo.h> 
int speed = 0;
Servo myservo; 
 
void setup() 
{ 
  speed = 0;
  myservo.attach(9);  
} 
 
 
void loop() 
{     
      speed++;                         // increment speed by one each loop
      if (speed > 180) {                 //set limit to be 180
        speed = 0;                          // return to 0 if limit reached
      }
      myservo.write(speed); 
      delay(25); 
}

NB, not all modded servos have an adjustment knob. And, no, you don't have a servo, despite what Sparkfun say - there is no feedback mechanism.

Thank you AWOL!
Hope this helps everyone else too.

By the way, is THAT Hal 9000 as your profile image?

That still gives me nightmares.
HAL = IBM
Go ahead, increment each letter of HAL by one. :o

Yea, I guess I don’t have a servo. By definition it must have a feedback mechanism.

Its just a normal motor controlled by adjusting power and polarity (speed and direction). (Sort of)

The nice thing is I can use pwm to control it.

I’m, definitely not going to return it, because its Christmas and I need something to play with. :smiley:

Feedback mechanism, if i had one, would that mean the arduino could double-check where the servo is?

Feedback mechanism, if i had one, would that mean the arduino could double-check where the servo is?

I'm pretty sure Servos have a small potentiometer attached to the shaft to tell it it's current position, allowing it to adjust itself based on what you send down the data line. The Arduino simply tells it where to go, and it figures out when it's there.

I'm pretty sure Servos have a small potentiometer attached to the shaft to tell it it's current position, allowing it to adjust itself based on what you send down the data line.

That is correct. However for modified servos converted for continuous rotation the pot is either mechanically disconnected from the moving gear train, or replaced with two fixed resistors. A modified servo is no longer a servo, but rather morphed into a bi-directional variable speed geared motor.

Lefty

So ALL continuous rotation servos do NOT have a potentiometer of some sort to send back info to itself?

What if my “servo” had a rotary encoder instead to act as a potentiometer.

Would that at the same time allow it to be continuous and angle adjustable? Along with speed and direction adjustment?

I think i might be onto something ;D :smiley:

I think i might be onto something

In theory that would work. However not as easy a project as it my seem. ;)

Lefty

Well, thanks everyone.

I got my "servo" to do something I'm pleased with.

Look at above comments to see how to control continuous rotation servos.

Note: Continuous rotation servos ARE NOT servos, just motors controllable in direction and speed.

If no one makes/patents the rotary encoder idea in 7 years, then I will cause I'll be 23. :P

The nice thing is I can use pwm to control it

Ah...no. Really, don't try to feed it PWM from the Arduino. It might appear to work, but it won't do your ex-servo or your power supply any good. Always use PPM from the library.