waspinator / AccelStepper

Fork of AccelStepper
http://www.airspayce.com/mikem/arduino/AccelStepper/
Other
146 stars 86 forks source link

Run bug! #23

Open Zhehua-Hu opened 1 year ago

Zhehua-Hu commented 1 year ago

While I set Xaxis.move,Yaxis.move both negtive, both of two motor not run.

I am using ESP32 with arduino & TMC2209 driver.

I have tested that 3 type work and only 1 type not work.

Code:

#include <Arduino.h>

#include <AccelStepper.h>
AccelStepper Xaxis(1, 16, 17); // step, direction
AccelStepper Yaxis(1, 25, 26); // step, direction
void setup() {
    int x_circle = 3200;
    int y_circle = 3200;

    Xaxis.setMaxSpeed(x_circle*8);
    Yaxis.setMaxSpeed(y_circle*8);
    Xaxis.setAcceleration(1*x_circle);
    Yaxis.setAcceleration(1*y_circle);

    // work!
//    Xaxis.move(1*x_circle);
//    Yaxis.move(1*y_circle);

    // work!
//    Xaxis.move(1*x_circle);
//    Yaxis.move(-1*y_circle);

    // work!
//    Xaxis.move(-1*x_circle);
//    Yaxis.move(1*y_circle);

    // NOT WORK!
    Xaxis.move(-1*x_circle);
    Yaxis.move(-1*y_circle);
}
void loop() {
    Xaxis.run();
    Yaxis.run();

}
Zhehua-Hu commented 1 year ago

@waspinator my email: woodyhu2019@gmail.com. Thank you firstly!