Replies: 5 comments
-
Hi Eebel, I just uploaded it together with ServoEasing.h. Thanks Ps. Speed of 600 for all servos seems a bit high, since the maximum physical speed of my servos is 350. Just use 150 and you can omit the 150 in And instead of
you may use
|
Beta Was this translation helpful? Give feedback.
-
Thanks for the feedback. I misunderstood the easeToD command. I though the D part was a delay/time period for the movement. I did not understand it was a speed. I'll adjust my code accordingly. The only question I have is if I have two continuous rotation servos that have different values for the not moving, wouldn't one of them be wrong if there is only one value for all of them? Or are certain brands close enough that if you have one of that brand then another will behave the same. I don't know as I haven't added the second continuous rotation servo to my droid yet. Tim |
Beta Was this translation helpful? Give feedback.
-
OK, I missed that you use the easeToD() command and you were totally right with the assumption, that the parameter was a delay. Sorry. The problem with the rotational servo is to know at which value it is stopping. This value must be the value chosen if you call write(0); Armin |
Beta Was this translation helpful? Give feedback.
-
Beta Was this translation helpful? Give feedback.
-
Glad to hear :-) |
Beta Was this translation helpful? Give feedback.
-
Hi,
I have the following test code simulating a door opening, a tool moving and then the continuous rotation servo extending a buzz saw on a linear rail, when I push a button. When I push a second button, the process reverses. However, the continuous rotation servo initially turns the wrong way for a bit before reversing to the proper direction. I am using a limit switch in the design so the servo doesn't bottom out and grind when the buzz saw is fully retracted and so it doesn't move during the initialization process when I first start the droid if the buzz saw is fully retracted.
Am i calling the functions wrong to cause this behavior?
https://youtu.be/Wnc6wn5G4MA
Tim
/*
*/
//2016.12.08
#include "ServoEasing.h"
int ledPin = 5;
int buttonApin = 9;
int buttonBpin = 8;
int limitSwitchPin = 22;
const int SERVO1_PIN = 0;
const int SERVO2_PIN = 1;
const int SERVO3_PIN = 2;
ServoEasing Servo1(PCA9685_DEFAULT_ADDRESS, &Wire);
ServoEasing Servo2(PCA9685_DEFAULT_ADDRESS, &Wire);
ServoEasing Servo3(PCA9685_DEFAULT_ADDRESS, &Wire);
ServoEasing Servo11(PCA9685_DEFAULT_ADDRESS, &Wire);
byte leds = 0;
ServoInfo S1_Info;
ServoInfo S2_Info;
ServoInfo S3_Info;
ServoInfo S11_Info;
void setup()
{
pinMode(ledPin, OUTPUT);
pinMode(buttonApin, INPUT_PULLUP);
pinMode(buttonBpin, INPUT_PULLUP);
pinMode(limitSwitchPin, INPUT_PULLUP);
S1_Info.servoName = "GripperDoor";
S1_Info.minDeg = 90;
S1_Info.maxDeg = 0;
S1_Info.pwmNum = 1;
S1_Info.pinNum = 0;
S2_Info.servoName = "GripperLifter";
S2_Info.minDeg = 68;
S2_Info.maxDeg = 130;
S2_Info.pwmNum = 1;
S2_Info.pinNum = 1;
S3_Info.servoName = "Gripper";
S3_Info.minDeg = 72;
S3_Info.maxDeg = 120;
S3_Info.pwmNum = 1;
S3_Info.pinNum = 2;
S11_Info.servoName = "BuzzSlide";
S11_Info.minDeg = 100;
S11_Info.maxDeg = -100;
S11_Info.pwmNum = 1;
S11_Info.pinNum = 11;
//Silence the servos
Servo1.detach();
Servo2.detach();
Servo3.detach();
Servo11.detach();
}
void loop()
{
if (digitalRead(buttonApin) == LOW)
{
digitalWrite(ledPin, HIGH);
Servo3.easeToD(S3_Info.maxDeg,200);
Servo2.easeToD(S2_Info.minDeg,200);
Servo1.easeToD(S1_Info.minDeg,200);
Servo11.startEaseTo(100);//<---initially turns wrong way here, then works correctly
Servo1.detach();
Servo2.detach();
Servo3.detach();
}
if (digitalRead(buttonBpin) == LOW)
{
digitalWrite(ledPin, LOW);
Servo1.easeToD(S1_Info.maxDeg,300);//door
Servo2.easeToD(S2_Info.maxDeg,300);//lifter
Servo3.easeToD(S3_Info.maxDeg,150);
Servo3.easeToD(S3_Info.minDeg,150);
Servo3.easeToD(S3_Info.maxDeg,150);
Servo3.easeToD(S3_Info.minDeg,150);
Servo3.easeToD(S3_Info.maxDeg,150);
Servo3.easeToD(S2_Info.minDeg,150);
Servo11.write(-100);
delay(1500);
Servo1.detach();
Servo2.detach();
Servo3.detach();
Servo11.detach();
}
if (digitalRead(limitSwitchPin) == HIGH){
//Run the servo until it reaches the limit
Servo11.update();
}
else{
//limit is reached, stop the servo
Servo11.detach();
}
}
Beta Was this translation helpful? Give feedback.
All reactions