Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Help for smooth motion #289

Open
tomassasovsky opened this issue Oct 28, 2024 · 8 comments
Open

Help for smooth motion #289

tomassasovsky opened this issue Oct 28, 2024 · 8 comments

Comments

@tomassasovsky
Copy link

tomassasovsky commented Oct 28, 2024

Hey there! I'm trying to make simple movements with the motor, having it just move at a constant speed. I'm facing an issue where the motor makes a stuttering sound, sorta sounds like a locomotive. The motion is not smooth at all, it's very interrupted.

Running this with a TMC2209 V2.0 and ESP32-WROOM-32.

I'm using the code from the example:

#include "FastAccelStepper.h"

// As in StepperDemo for Motor 1 on ESP32
#define dirPinStepper 18
#define enablePinStepper 26
#define stepPinStepper 14

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

void setup() {
  engine.init();
  stepper = engine.stepperConnectToPin(stepPinStepper);
  if (stepper) {
    stepper->setDirectionPin(dirPinStepper);
    stepper->setEnablePin(enablePinStepper);
    stepper->setAutoEnable(true);

    // If auto enable/disable need delays, just add (one or both):
    // stepper->setDelayToEnable(50);
    // stepper->setDelayToDisable(1000);

    stepper->setSpeedInUs(1000);  // the parameter is us/step !!!
    stepper->setAcceleration(100);
    stepper->move(1000);
  }
}

void loop() {}
@tomassasovsky tomassasovsky changed the title Support for smooth motion Help for smooth motion Oct 28, 2024
@gin66
Copy link
Owner

gin66 commented Oct 28, 2024

I would assume, this is not a sw issue. Could you please check the cable ? Especially ground connections are often cause of unexpected behaviors.

@tomassasovsky
Copy link
Author

Very well might be. Do I need to add any capacitors, resistors, etc. to my circuit?

@gin66
Copy link
Owner

gin66 commented Oct 28, 2024

I do not know your setup. Do you have an oscilloscope or similar to check, that the steps are generated properly ? Or just start without FastAccelStepper and control the stepper with a loop, which contains just a toggle of step pin and a delay ?

@tomassasovsky
Copy link
Author

I don't have an oscilloscope, no. Could you provide an example snippet for that?

@gin66
Copy link
Owner

gin66 commented Oct 28, 2024

Something like:

// As in StepperDemo for Motor 1 on ESP32
#define dirPinStepper 18
#define enablePinStepper 26
#define stepPinStepper 14

void setup() {
   pinMode(dirPinStepper, OUTPUT);
   pinMode(stepPinStepper, OUTPUT);
   pinMode(enablePinStepper, OUTPUT);

   digitalWrite(dirPinStepper, LOW);
   digitalWrite(stepPinStepper, LOW);
   digitalWrite(enablePinStepper, LOW);
}

void loop() {
   digitalWrite(stepPinStepper, digitalRead(stepPinStepper) == LOW ? HIGH:LOW);
   delay(50); // => one step in 2*50ms, so 10 steps/s
}

@tomassasovsky
Copy link
Author

I tried your code with a delay of 1ms which is closer to the speed I need, and it's very noisy.

https://github.com/user-attachments/assets/1ffbf29e-eb48-4f73-a4be-34a9379bf9a6

@gin66
Copy link
Owner

gin66 commented Oct 28, 2024

Thanks for sharing the video. If this low level code does not work, then something is wrong with the hardware.: Ground connection, assignment of dir/step/enable to the gpio, cable from stepper to stepper controller - especially the pin assignment, is the power supply strong enough, are the cables not too long, is the uC constantly rebooting….? Good luck in your endeavor

@gin66
Copy link
Owner

gin66 commented Nov 14, 2024

any updates ?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants