Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Servos Moving Very slow #14

Open
priest6479 opened this issue May 1, 2023 · 1 comment
Open

Servos Moving Very slow #14

priest6479 opened this issue May 1, 2023 · 1 comment

Comments

@priest6479
Copy link

Everything seems to be working as expected but I have noticed my Servos are moving extremely slow.

Initially I have powered this from my laptop, now a standard USB phone charger, no change

I am running SG90 Servos as well

@priest6479
Copy link
Author

I found the solution on a Thingiverse comment.... This fixed my slow servo issue

For anyone else that had a problem with their servos moving really slow and not traveling their full arc, here is a modified speed-servo.cpp:

include "speed-servo.h"

const int SLOW_MOVE_STEPS = 1;
const int Fast_MOVE_STEPS = 5;

void SpeedServo::attach(uint8_t pin) {
_servo.attach(pin,544,2570);
}

// Valid position: 0-180.
void SpeedServo::moveNowTo(int newPosition) {
_lastPosition = newPosition;
_servo.write(newPosition);
}

// Valid position: 0-180.
void SpeedServo::moveFastTo(int newPosition) {
_moveTo(newPosition, Fast_MOVE_STEPS);
}

// Valid position: 0-180.
void SpeedServo::moveSlowTo(int newPosition) {
_moveTo(newPosition, SLOW_MOVE_STEPS);
}

// Valid position: 0-180.
void SpeedServo::_moveTo(int newPosition, unsigned long stepDelay) {
if(newPosition > _lastPosition) {
for (int pos = _lastPosition; pos <= newPosition; pos = pos + stepDelay) {
_servo.write(pos);
}
} else {
for (int pos = _lastPosition; pos >= newPosition; pos = pos - stepDelay) {
_servo.write(pos);
}
}

_lastPosition = newPosition;
}

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant