gin66 / FastAccelStepper

A high speed stepper library for Atmega 168/328p (nano), Atmega32u4, Atmega 2560, ESP32, ESP32S2, ESP32S3, ESP32C3, ESP32C6 and Atmel SAM Due
MIT License
301 stars 70 forks source link

Stepper motor unable to exceed 1 rpm without vibrating #202

Closed skemp117 closed 10 months ago

skemp117 commented 12 months ago

Hey, this is such a cool library. Thanks for making it.

I'm getting heavy vibrations and stalling as I increase the revolutions per second stepper->setSpeedInHz(rps*3200); It was struggling above 2ish, gets extremely rough around 5, and stops entirely around 7. I suspect that the shaft speed isn't actually as high as it is being set to, it feels like it is only doing 2 ish rps.

I'm using BIGTREETECH TMC2209 drivers at 16x microstepping on a Azteeg X3 Pro board. The step pin is 46, and I have the build_flags = -Werror -Wall -DFAS_TIMER_MODULE=5 set. I'll attach the code below. I appreciate any help. I've tried changing both the motor and stepper drivers many times. I've double checked the VRef, and it is set correctly. The drivers are old, maybe they just suck.

#include "FastAccelStepper.h"

#define ENABLE_PIN 62
#define DIR_PIN   48
#define STEP_PIN  46

#define MICROSTEPS 16
#define STEPS_PER_REV 200 //1.8 degrees per step, 3200 steps per rev at 16 microsteps

#define MICROSTEPS_PER_REV MICROSTEPS*STEPS_PER_REV

int step_cnt = 0;

FastAccelStepperEngine engine = FastAccelStepperEngine();
FastAccelStepper *stepper = NULL;

void setup() {
  engine.init();
  stepper = engine.stepperConnectToPin(STEP_PIN);
  if (stepper) {
    stepper->setEnablePin(ENABLE_PIN);
    stepper->setAutoEnable(true);
    stepper->setDirectionPin(DIR_PIN);

    stepper->setSpeedInHz(1*3200);       // steps/s
    stepper->setAcceleration(200);    // steps/s²
    stepper->runForward();
  }
}

void loop() {
    // stepper->move(3200*10);
}
gin66 commented 12 months ago

There could be several reasons:

For investigation:

skemp117 commented 11 months ago

Thanks for the detailed reply!

Do you recommend any small footprint boards you'd recommend. Maybe like the bigtreetech skr mini e3 v2.0?

gin66 commented 11 months ago

Thanks for all the answers and sharing the video. This is definitely not the expected behavior and actually the NEMA-17 is running at very low speed. Just have checked with simulator (simavr) up to 10kSteps/s and all is as expected. As per issue #50, one user has reported timer module 5 to work.

Assume the NEMA-17 is not broken, then I am currently running out of ideas, what the problem could be. Sorry for this.

skemp117 commented 11 months ago

Oh well,

Do you recommend any small footprint boards you'd recommend. Maybe like the bigtreetech skr mini e3 v2.0?

gin66 commented 11 months ago

I cannot recommend any of the boards out there. For FastAccelStepper development I have made an own pcb, where I can mount an arduino nano and an esp32dev at the same time and can control in total eight stepper motors using A4988 drivers. Perhaps one of the users can provide you with recommendations.

gin66 commented 10 months ago

stale