Servo Control - Smooth Motion

Hi,
I ran the servo example(sweep) with no difficulty.
However,whenever we ask it to move to a specific angle,it does so in steps…Is there some way i can make it do a smooth and continous sweep to that angle??

Thanks :slight_smile:

You need to explain more, and the sort of timessclaes and parameters of "smoothness" you consider acceptable. Posting some code and details of what you want to do and with which servos would help too.

well,by "smoothness" i mean the smooth sweep it performs midway when we run the example 'sweep'.

As for my servo,its a Hitec Sub Micro servo.

Since I got my arduino only yesterday,I am still only exploring the libraries and related examples.

Do you have delays in the code? Post it up so that someone can comment; it’s impossible without it.

#include <Servo.h> 

Servo myservo;

void setup() 
{ 
  myservo.attach(9,600,2400);//Pulse Values for a HiTec Servo
  myservo.write(0);  // set servo to 0
   myservo.write(180); //set sevo to 180
} 

void loop() {}

No great code up there,
All i want to get is a smooth and a non “stepper-like” action when it moves from some angle to another one.

You may want to look at the below page and try that code. If it is not smooth enough, you probably could use writeMicroseconds.

http://arduino.cc/en/Tutorial/Sweep

So (correct me if I'm wrong) that code tries to get the servo to 0 degrees, and then immediately tries to get it all the way to 180 degrees? :o

Yes, will move from one to the other, then back, and so on, with a 15 milliseconds delay for each step

So (correct me if I'm wrong) that code tries to get the servo to 0 degrees, and then immediately tries to get it all the way to 180 degrees?

Which "that code" are you refering to, the posted code, or the code in the link?

Sorry; the code posted by kmmankad

Well,in the sweep example,it performs this smooth swing at one point,but otherwise moves like bld said,15ms-step.

My point is,the same servo with an RC Controller can be used to perform sudden smooth movement,so why not with an arduino?

Try modifying the sweep code with different delays etc. and get used to controlling servos with the Arduino - there’s no reason smooth movement should be impossible imho.

I hope you are not trying to power the servo motor off of the arduino board. For decent motion the servo really needs an external power supply.

Servo movement can be smooth. http://www.vinceherman.net/robot/media/IMG_0071.MOV

I hope you are not trying to power the servo motor off of the arduino board. For decent motion the servo really needs an external power supply.

Great point, i had the same problem. Make sure you are powering the servo with an external power supply...like a 4pack of AAs. Just hook the positive and negative from the power-pack to the positive and negative of the servo. Then the signal wire to the correct pin. Then the servos ground which is also connected to the negative of the power-pack should have another wire from it to the ground on the arduino. Use delays. Without them the arduino will tell it to go back and forth almost instantly and if the servo cant keep up it will just jitter around trying to home in on the signals you are sending it!