Go Down

Topic: Servo Control - Smooth Motion (Read 22682 times) previous topic - next topic

kmmankad

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 :)

AWOL

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.

kmmankad

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.

rumoon

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

kmmankad

Code: [Select]

#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.

zoomkat

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
Google forum search: Use Google Search box in upper right side of this page.
Why I like my 2005 Rio Yellow Honda S2000  https://www.youtube.com/watch?v=pWjMvrkUqX0

rumoon

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

bld

Yes, will move from one to the other, then back, and so on, with a 15 milliseconds delay for each step
captain-slow.dk | non contagious!

zoomkat

#8
Aug 22, 2010, 02:34 am Last Edit: Aug 22, 2010, 02:35 am by zoomkat Reason: 1
Quote
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?
Google forum search: Use Google Search box in upper right side of this page.
Why I like my 2005 Rio Yellow Honda S2000  https://www.youtube.com/watch?v=pWjMvrkUqX0

rumoon

Sorry; the code posted by kmmankad

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?

rumoon

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.

zoomkat

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.
Google forum search: Use Google Search box in upper right side of this page.
Why I like my 2005 Rio Yellow Honda S2000  https://www.youtube.com/watch?v=pWjMvrkUqX0

vinceherman

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


raidthewood

Quote
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!

Go Up