0

Control speed of a Parallax Feedback 360 Motor
Moderators: adafruit_support_bill, adafruit

Please be positive and constructive with your questions and comments.

Control speed of a Parallax Feedback 360 Motor

by MidnightSparks on Thu Jun 24, 2021 7:38 am

external-content.duckduckgo.com.jpg
external-content.duckduckgo.com.jpg (204.34 KiB) Viewed 96 times

QUESTION: When using a Parallax Feedback 360 servo with the appropriate control library ("FeedBackServo.h") Is the speed of the servo also adjustable?

PROBLEM: When I use the servo, it goes from "OFF" to 100% of it's rotational speed instantaneously. I'm trying to have the speed gradually increase upon starting, and also gradually decreasing in speed when it's coming to the end.

I've looked through the library but didn't find anything useful. However, I did note that the library also makes use of the "Servo.h" library - which I've previously used to control the speed of a different type of servo. Unfortunately, I don't know how to accomplish what I need using the two libraries. Would it be possible to combine these two sketches?

(Working sketch to control the Parallax Feedback 360 servo)
Code: Select all | TOGGLE FULL SIZE
#include <Wire.h>
#include "FeedBackServo.h"

#define FEEDBACK_PIN 2  //Servo1 - Define feedback signal pin (Yellow wire)
#define SERVO_PIN 3  //Servo1 - Define control pin (White wire)

FeedBackServo Servo1 = FeedBackServo(FEEDBACK_PIN);  //Servo1 - Set feedback signal pin number

int Cycle = 0;


void setup()
{
  Serial.begin(115200);

  Servo1.setServoControl(SERVO_PIN);  //Set servo control pin number
  Servo1.setKp(1.0);
}

void loop()
{
  if (Cycle <= 9)
  {
    Serial.print("Cycle #");
    Serial.println(Cycle);

    //SERVO1 START POSITION
    Servo1.rotate(220, 3);

    Serial.print("Forward Angle: ");
    Serial.println(Servo1.Angle());

    delay(5000);

    //SERVO1 END POSITION
    Servo1.rotate(325, 3);

    Serial.print("Backward Angle: ");
    Serial.println(Servo1.Angle());
    Serial.println();

    delay(5000);

    Cycle = Cycle + 1;
  }
}


(Working sketch to gradually increase/decrease the speed of a 180 degree servo)
Code: Select all | TOGGLE FULL SIZE
#include <Servo.h>

Servo myservo;

int pos = 0;


//---------------


void setup()
{
  Serial.begin(115200);
  myservo.attach(9);
  myservo.write(0);
  delay(1000);
}


//---------------


void loop()
{
  delay(1000);
 
  for (pos = 0; pos <= 180; pos += 1)
  {
    myservo.write(pos);              // tell servo to go to position in variable 'pos'
  }

  delay (1000);

  for (pos = 180; pos >= 0; pos -= 1)
  {
    myservo.write(pos);              // tell servo to go to position in variable 'pos'
  }
}

MidnightSparks
 
Posts: 4
Joined: Sun Jun 13, 2021 8:53 am

Re: Control speed of a Parallax Feedback 360 Motor

by adafruit_support_bill on Thu Jun 24, 2021 3:34 pm

That is not a library that we maintain. But looking at the source code, there is no control for the servo seek speed. It relies on the servo's internal control algorithm which is not tunable.

This is pretty much standard for RC servos and the usual technique is to control the speed in your code by performing incremental moves over time.

adafruit_support_bill
 
Posts: 81550
Joined: Sat Feb 07, 2009 10:11 am

Re: Control speed of a Parallax Feedback 360 Motor

by MidnightSparks on Sun Jun 27, 2021 12:52 pm

Thank you Bill. I appreciate the info.

MidnightSparks
 
Posts: 4
Joined: Sun Jun 13, 2021 8:53 am

Please be positive and constructive with your questions and comments.