Smooth control of servo motors and drive
HTML-код
- Опубликовано: 10 сен 2024
- Motors can be commanded to accelerate and decelerate smoothly to positions. In this video I show methods to drive motors simultaneously so they start/stop together and also how to control their acceleration
I wish to use a servo to control the traverse movement for a pickup winding machine. With guitar pickup winding there are various and varied scatter patterns used to enhance the tone produced by the pickups. The analog way of controlling the traverse pattern uses a rotating non-circular cam disk that pushes a spring loaded shaft that has a guide for the wire feeder that, in turn controls the accumulation of wire on the bobbin. I would rather use an Arduino to control the movements of the servo and therefore control the scatter pattern of the winding and have it accumulate evenly or ad-hoc in a scatter pattern on the bobbin. I am hoping to fully understand the mathematics and coding I would need to achieve my goal without overcomplicating it.
Arduino Uno program for linear control:
#include
Servo turretservo;
Servo gripservo;
void setup() {
turretservo.attach(5);
gripservo.attach(46);
}
double theta1(double theta_s, double theta_e, double tf)
{
double a0;
static unsigned long ts;
static double endt;
static double thet;
double t;
if (endt != theta_e)
{
ts = millis();
endt = theta_e;
}
a0 = (theta_e - theta_s) / tf;
t = (double)(millis() - ts) / 1000;
if (t
Thanks for the explanations of formulas
How is this an improvement over the AccelStepper library?
Hi, I'm a beginner. I just finished assembled my robot arm.
I want to use this code to move the servo smoothly but there is no need to loop back and forth.
I want it to move by using value from potentiometer.
Right now it's kind of jittering and shaking the whole body of the arm.
How to modify your code?
That’s probably a power supply issue. Mine was doing the same thing until we fixed that.
@@kirleyq1394 Can you share your code?
Hi can i have tour Word file?.thanks
Servo program Arduino Mega for cubic polynomial control:
#include
Servo turretservo;
Servo gripservo;
void setup() {
turretservo.attach(5);
gripservo.attach(46);
}
double theta1(double theta_s, double theta_e, double tf)
{
double a0, a1, a2, a3;
static unsigned long ts;
static double endt;
static double thet;
double t;
if (endt != theta_e)
{
ts = millis();
endt = theta_e;
}
a0 = theta_s;
a1 = 0;
a2 = 3 / (tf * tf) * (theta_e - theta_s);
a3 = -2 / (tf * tf * tf) * (theta_e - theta_s);
t = (double)(millis() - ts) / 1000;
if (t
bad