Pages: [1]   Go Down
Author Topic: Servo's speed  (Read 3029 times)
0 Members and 1 Guest are viewing this topic.
Offline Offline
Newbie
*
Karma: 0
Posts: 41
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Hello smiley I searched for the same topic, as I am going to write, but I didn't find. So, I am going to do a robot and I need to change the speed of micro servo motors. I am using these micro servos: http://cgi.ebay.com/2X-Micro-9g-Servo-Futaba-Hitec-HS-55-GWS-walkera-RC-/290498904979?pt=Radio_Control_Parts_Accessories&hash=item43a3158393#ht_2675wt_1139


So, is there any possibility to control these micro servos speed?

Thanks for answering
Logged

Manchester (England England)
Offline Offline
Brattain Member
*****
Karma: 602
Posts: 33371
Solder is electric glue
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

Generally you don't control the speed of a servo. You can adjust the voltage slightly to make it run faster or slower but generally this is not an option.
Logged

Offline Offline
Newbie
*
Karma: 0
Posts: 41
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Thanks for quick replay!
Logged

Ohio
Offline Offline
Full Member
***
Karma: 0
Posts: 227
Arduino Hexapod
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Another approach is to slice its movement up into small pieces, and spread those out over time.
That is what I do for my hexapod.
Logged

Offline Offline
Newbie
*
Karma: 0
Posts: 41
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

I am thinking about this too. Could you give me some example, how does it look like?

thanks!
Logged

Global Moderator
UK
Offline Offline
Brattain Member
*****
Karma: 290
Posts: 25773
I don't think you connected the grounds, Dave.
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Quote
Could you give me some example, how does it look like?
Well, at its simplest, it is just a "for" loop with a delay.
Code:
for (int i = startAngle; i < endAngle; ++i) [
  myServo.write (i);
  delay (someDelayTime);
}
where someDelayTime is something like (totalTransitTime / (endAngle - startAngle)),
though this simple  method doesn't always work well for multiple servos.
Logged

"Pete, it's a fool looks for logic in the chambers of the human heart." Ulysses Everett McGill.
Do not send technical questions via personal messaging - they will be ignored.

Ohio
Offline Offline
Full Member
***
Karma: 0
Posts: 227
Arduino Hexapod
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

And I did it slightly differently.
I calculate where I want the servo to be every 20ms.
I tell the servo to go there, and then wait for the next 20ms slick to come by.

This timing matches the frequency of the signal being sent to the servo, so it is about as smooth as a typical hobby servo can be.

Let me push a bit of code through and connect a servo, and I will show you what I mean.

Logged

0
Offline Offline
Tesla Member
***
Karma: 141
Posts: 9470
Arduino rocks
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

The below might be of interest:

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

Consider the daffodil. And while you're doing that, I'll be over here, looking through your stuff.   smiley-cool

0
Offline Offline
Newbie
*
Karma: 0
Posts: 42
Writing Arduino code is fun!
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

There is an established library available for the Arduino for controling servo speed. It can be found at:
http://rapidshare.com/files/425318464/VarSpeedServo.zip.

I recently finished a project to control 7 RC servos to open and close model railroad turnouts (slowly, instead of snapping open and close) with this library as the core of the code.

Hope this helps!

David G.
Logged

Offline Offline
Newbie
*
Karma: 0
Posts: 6
Persistence is sometimes better than knowledge
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

I just wrote this after cobbling together several different sketches I found on the web and it seems to work fairly well:

Code:
// 4 button 2 servo controller w pot slew v 3.d
#include <Servo.h>

  Servo servo1;          // define servo aliases
  Servo servo2;
  #define leftPin 2        // define buttons attached to pins
  #define rightPin 3
  #define upPin 4
  #define downPin 5
  int pos1 = 90;          // set angle when inialitized
  int pos2 = 135;
 
     #define POT 3        // pot to analog pin 3
     int potValue = 0;    // variable for pot value
                         
void setup()
{
  servo1.write(pos1);  // Put servo1 at home position
  servo2.write(pos2);  // Put servo1 at home position
   
  servo1.attach(10);    // attaches the servo on pin 9 to the servo object
  servo2.attach(9);     // attaches the servo on pin 10 to the servo object

  pinMode(leftPin, INPUT);   
  pinMode(rightPin, INPUT); 
  pinMode(upPin, INPUT);     
  pinMode(downPin, INPUT);
}

void loop()
{
//pot control 
  {
      potValue = analogRead(potValue);                // reads the value of the potentiometer
                                                      // (value between 0 and 1023)
      potValue = potValue/4;                          // convert from 0-1023 to 0-255
       
  }
// left/right servo control
  if(digitalRead(leftPin) == HIGH)        // left button instructions 
  {
   // in steps of 1 degree
   if( pos1 > 0)
--pos1;
    servo1.write(pos1);   // tell servo to go to position in variable 'pos1'
    delay(potValue);    
  }
  if(digitalRead(rightPin) == HIGH)       // right button instructions 
  {
   if( pos1 < 180)
++pos1;
    servo1.write(pos1);   // tell servo to go to position in variable 'pos1'
    delay(potValue);
   }

// up/down servo control 
 
   if(digitalRead(upPin) == HIGH)         // up button instructions 
   {
   // in steps of 1 degree
   if( pos2 > 0)
--pos2;
    servo2.write(pos2);   // tell servo to go to position in variable 'pos2'
    delay(potValue);    
   }
   if(digitalRead(downPin) == HIGH)        // down button instructions 
   {
   if( pos2 < 180)
++pos2;
   servo2.write(pos2);   // tell servo to go to position in variable 'pos2'
   delay(potValue);
   }
}

At first it was written so a numerical parameter was inserted in the int potValue = 0; section but my need requires me to adjust the speed on-the-fly.

I can send you the numerical sketch is you wish.

This sketch controls two servos but it can be pared down if needed.

Good luck.

Peace.
Logged

Offline Offline
Newbie
*
Karma: 0
Posts: 10
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Hi everyone!!!
Currently i am trying to use RC transmitter to control the speed of my servo from moving from left to right...
Is this possible? & how would i going to write my code?
Hope any kind soul will reply my question...
Thanks!!! smiley
Logged

Seattle, WA USA
Offline Offline
Brattain Member
*****
Karma: 601
Posts: 48543
Seattle, WA USA
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Quote
Currently i am trying to use RC transmitter to control the speed of my servo from moving from left to right...
Is this possible?
Yes.

Quote
how would i going to write my code?
Using the IDE works for most people. If you don't like it, you can use any external editor you like.
Logged

Pages: [1]   Go Up
Jump to: