Slowing down servo movement.


hi
i'm trying run servo steppers , need slow servo down quite bit.
the code have here doing want, servo reaches end position quickly.
i've tried using delay , millis interrupt it, can't figure out how steppers moving @ same time. servo finishes run , the steppers start theirs.

code: [select]
#include <accelstepper.h>
#include <varspeedservo.h>

#define halfstep 5
#define fullstep 8

#define motorpin1 4
#define motorpin2 5
#define motorpin3 6
#define motorpin4 7

#define motorpin5 8
#define motorpin6 9
#define motorpin7 10
#define motorpin8 11

varspeedservo servo;

const int panacc = 10.0;
const int panspeed = 200; // 1.1 min
const int dollyacc = 10.0;
const int dollyspeed = 1400; // 800 = 3 min. runtime 1400/2 max/min

accelstepper stepper1(halfstep, motorpin1, motorpin2, motorpin3, motorpin4);
accelstepper stepper2(halfstep, motorpin5, motorpin6, motorpin7, motorpin8);

const int buttonpin = 2;
int buttonstate = 0;

void setup() {
 
  servo.attach(3);
  servo.write(50,5,false);
  stepper1.setmaxspeed(dollyspeed);
  stepper1.setacceleration(dollyacc);
  stepper1.move(1);
 
  stepper2.setmaxspeed(panspeed);
  stepper2.setacceleration(panacc);
  stepper2.move(-1);
 
  pinmode(buttonpin,input);
 
}

void loop() {
 
  buttonstate = digitalread(buttonpin);
  if (buttonstate == low){
    servo.write(150,1,false);
    stepper1.move(140000); // + away - home 140000 = full
    stepper2.move(8800); // + ccw - cw 4400 ~ 90 deg.
  }
  stepper1.run();
  stepper2.run();
}

when tell servo move, it's kicking horse , yelling giddy-up! takes off screaming destination position. can do? tell go position, short ways off. again , again, small increments, , suitable intervals (not delay()s) between movements. servo appear move slower.


Arduino Forum > Using Arduino > Programming Questions > Slowing down servo movement.


arduino

Comments

Popular posts from this blog

invalid use of void expresion in FlexiTimer2 library

error: a function-definition is not allowed here before '{' token

LED Strip Code