Pages: [1]   Go Down
Author Topic: Ramp up'/Soft start from power up  (Read 1602 times)
0 Members and 1 Guest are viewing this topic.
Offline Offline
Newbie
*
Karma: 0
Posts: 21
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

I am using the 'VarSpeedServo' library, which is fantastic and I believe was contributed by 'Korman'.

My question; is there a way to soft start the servos, i,e, get them to move to their start position from power up without jumping at full speed?

Can it be done through the Arduino or can it be done with electronics?

Quote
#include <VarSpeedServo.h>


const int mainPin1 = 3;
const int mainPin2 = 5;          
const int mainPin3 = 10;
const int mainPin4 = 11;
const int ServoMin = 850;   // Minimum pulse width for servos in ms.
const int ServoMax = 2100;   // Maximum pulse width for servos in ms.

int buttonPin = 13;
int buttonState = 1;

VarSpeedServo ServoHighHandRotate;
VarSpeedServo ServoHighHandTip;
VarSpeedServo ServoLowHandRotate;
VarSpeedServo ServoLowHandTip;

//*****************************************************************

void setup() {

  pinMode(buttonPin, INPUT);
  ServoHighHandRotate.attach (mainPin1, ServoMin, ServoMax);
  ServoHighHandTip.attach (mainPin2, ServoMin, ServoMax);
  ServoLowHandRotate.attach (mainPin3, ServoMin, ServoMax);
  ServoLowHandTip.attach (mainPin4, ServoMin, ServoMax);
}

//*****************************************************************

//Left Hand (High Hand) rotate clockwise         (180)
//Left Hand (High Hand) rotate anti-clockwise    (0)
//Left Hand (High Hand) tip forwards             (180)
//Left Hand (High Hand) tip backwards            (0)

//Right Hand (High Hand) rotate clockwise         (180)
//Right Hand (High Hand) rotate anti-clockwise    (0)
//Right Hand (High Hand) tip forwards             (0)
//Right Hand (High Hand) tip backwards            (180)



//*****************************************************************

void loop() {

  //buttonState = digitalRead(buttonPin);
  //if (buttonState == HIGH)
  {
    ServoHighHandRotate.slowmove (90, 20);  //All Hands move to centre
    ServoHighHandTip.slowmove (90, 20);     //All Hands move to centre
    ServoLowHandRotate.slowmove (90, 20);   //All Hands move to centre
    ServoLowHandTip.slowmove (90, 20);      //All Hands move to centre
    delay(4000);

    {
      ServoHighHandRotate.slowmove (180, 20);  //Left hand Rotate clockwise
      ServoLowHandRotate.slowmove (180, 20);  //Right hand Rotate clockwise
      delay(3000);

      {
        ServoHighHandTip.slowmove (0, 20);   //Left hand Tip backward
        ServoLowHandTip.slowmove (180, 20);  //Right hand Tip backward
        delay(1500);

        {
          ServoHighHandTip.slowmove (180, 20);  //Left hand Tip forward
          ServoLowHandTip.slowmove (0, 20);     //Right hand Tip forward
          delay(2500);

          {
            ServoHighHandTip.slowmove (90, 20);  //Left hand backward to centre
            ServoLowHandTip.slowmove (90, 20);   //Right hand backward to centre
            delay(1500);

            {
              ServoHighHandRotate.slowmove (0, 20);  //Left hand Rotate anti-clockwise
              ServoLowHandRotate.slowmove (0, 20);  //Right hand Rotate anti-clockwise
              delay(5000);

              {
                ServoHighHandRotate.slowmove (90, 20);  //Left hand Rotate clockwise to centre
                ServoLowHandRotate.slowmove (90, 20);  //Right hand Rotate clockwise to centre
                delay(3000);

                {
                  ServoHighHandTip.slowmove (0, 20);   //Left hand Tip backward
                  ServoLowHandTip.slowmove (180, 20);  //Right hand Tip backward
                  delay(1500);

                  {
                    ServoHighHandTip.slowmove (180, 20);  //Left hand Tip forward
                    ServoLowHandTip.slowmove (0, 20);     //Right hand Tip forward
                    delay(2500);

                    {
                      ServoHighHandTip.slowmove (90, 20);  //Left hand Tip backward to centre
                      ServoLowHandTip.slowmove (90, 20);   //Right hand Tip backward to centre
                      delay(1500);

                      //--------Start of Combined Movements--------------------

                      {
                        ServoHighHandRotate.slowmove (180, 20);  //Left hand Rotates clockwise
                        ServoLowHandRotate.slowmove (0, 20);     //Right hand Rotates anti-clockwise
                        delay(3000);

                        {
                          ServoHighHandRotate.slowmove (0, 20);    //Left hand Rotates anti-clockwise
                          ServoLowHandRotate.slowmove (180, 20);   //Right hand Rotates clockwise
                          delay(1500);

                          {
                            ServoHighHandTip.slowmove (0, 20);   //Left hand Tip backward
                            ServoLowHandTip.slowmove (180, 20);  //Right hand Tip backward
                            delay(1500);

                            {
                              ServoHighHandTip.slowmove (180, 20);  //Left hand Tip forward
                              ServoLowHandTip.slowmove (0, 20);     //Right hand Tip forward
                              delay(2500);

                              {
                                ServoHighHandTip.slowmove (90, 20);   //Left hand Tip backward to centre
                                ServoLowHandTip.slowmove (90, 20);    //Right hand Tip backward to centre
                                delay(1500);

                                {
                                  ServoHighHandRotate.slowmove (180, 20);  //Left Hand Rotate clockwise
                                  ServoLowHandRotate.slowmove (0, 20);     //Right Hand Rotate anti-clockwise
                                  delay(1000);

                                  {
                                    ServoHighHandTip.slowmove (0, 20);    //Left hand Tip backward
                                    ServoLowHandTip.slowmove (180, 20);   //Right hand Tip backward
                                    delay(1500);

                                    {
                                      ServoHighHandTip.slowmove (180, 20);  //Left hand Tip forward
                                      ServoLowHandTip.slowmove (0, 20);     //Right hand Tip forward
                                      delay(2500);

                                      {
                                        ServoHighHandTip.slowmove (90, 20);  //Left hand Tip backward to centree
                                        ServoLowHandTip.slowmove (90, 20);   //Right hand Tip backward to centre
                                        delay(1500);
                                        {
                                          ServoHighHandRotate.slowmove (90, 20);  //Left Hand Rotate anti-clockwise to centre
                                          ServoLowHandRotate.slowmove (90, 20);   //Right Hand Rotate clockwise to centre
                                          delay(1000);



                                        }
                                      }
                                    }
                                  }
                                }
                              }
                            }
                          }
                        }
                      }
                    }
                  }
                }
              }
            }
          }
        }
      }
    }
  }
}
Logged

nr Bundaberg, Australia
Offline Offline
Tesla Member
***
Karma: 129
Posts: 8601
Scattered showers my arse -- Noah, 2348BC.
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

Whoa, what's with all the {}s?

Quote
is there a way to soft start the servos, i,e, get them to move to their start position from power up without jumping at full speed?
Put some code in setup() that loops and moved the servos slowly to their positions.

______
Rob
« Last Edit: October 16, 2012, 07:34:55 am by Graynomad » Logged

Rob Gray aka the GRAYnomad www.robgray.com

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

For some reason I thought the {} were needed, but obviously not!

I'm a real beginner at all this as you can tell.

I'll try using code from the 'sweep' sketch example I found in the library. Would that, or something like it, be the way to go?
Logged

New Jersey
Online Online
Faraday Member
**
Karma: 70
Posts: 3738
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Quote
My question; is there a way to soft start the servos, i,e, get them to move to their start position from power up without jumping at full speed?

Not without additional hardware: when you attach the servos, they will immediately try to move at full speed to whatever position you're telling them to go to. You can vary this by setting the position before the attach, but the problem is that you likely don't know what position the servos are in when you power up. You can remedy this with encoders or as a workaround, you can always set the servo positions to known values on shutdown.
Logged

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

The adding code to the setup part of the sketch didn't work and I figured that it may need more hardware.
Many thanks for the advice
Logged

nr Bundaberg, Australia
Offline Offline
Tesla Member
***
Karma: 129
Posts: 8601
Scattered showers my arse -- Noah, 2348BC.
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

Quote
The adding code to the setup part of the sketch didn't work
But what code did you add?

Wildbill is right though, you don't know the position when power is applied so any ramping scheme may still cause a sudden initial movement.

______
Rob
Logged

Rob Gray aka the GRAYnomad www.robgray.com

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

I tried a variation of what I already had and also something similar to the sweep command from the library.
Both worked at the setup point but at 'power on' there was still a jump.

I guess I need something that will dial up the power to the servos or use an encoder.
I think I'll leave it this time and look into it at a later date.

Thanks for the advice
Logged

Pages: [1]   Go Up
Jump to: