Society of Robots - Robot Forum
Software => Software => Topic started by: ecaits on August 13, 2015, 03:30:13 AM
-
I am using Vigor VS 2 servo. As per data sheet, its output angle is >=170 degree and pulse traveling 800 to 2200 μsec.
When I give command of 90 degree to rotate, it rotate slightly more than 90 degree but when I give command of 85 degree then it is looking like exact 90 degree.
I have written simple program as written below.
Servo myservo;
int pos = 0;
void setup()
{
myservo.attach(9);
}
void loop()
{
myservo.write(85);
}
What I require to modify to get the exact angle as per program code.
Thank You,
Regards,
Nirav
-
I'm going to broaden this a bit as I think this may be helpful to other.
So, where you servo winds up at is determined by a variety of factors, how the horn is mounted and how the servo is mounted among them. That and cheap servos are not perfect devices.
When you feed a servo, you want to adjust for that and also constrain it from travelling where it should not go (so it doesn't stall or break).
int desiredValue = 90;
int constrainMin = 30;
int constrainMax = 150;
int offset = -5;
int servoValue = constrain(desiredValue + offset, constrainMin, constrainMax);
myserveo.write(servoValue);
HTH