1

So im using a esp8266 and a tmc2130 stepper driverto control a nema 17 stepper motor. I am having a few problems with setting the correct rpm. I want to set the rpm to 4,5. Heres my code:

#include <Stepper.h>
const int stepsPerRevolution = 200; // change this to fit the number of steps per revolution
#define motorSteps 200 //the same value as the steps per revolution above

// initialize the stepper library on pins D5 to D8
Stepper myStepper(stepsPerRevolution, D5,D6,D7,D8);

int stepCount = 0; // number of steps the motor has taken

void setup() {
myStepper.setSpeed (4,5);
}

void loop() {
// step one step:
myStepper.step(1);
stepCount++;
delay(1);
}

I think the delay is a problem because it waits every step a millisecond and so the rpm is not the right. But i think i can not delete the delay because it must be there because the driver can not faster execute this task i guess so any suggestions? Thanks in advance.

0 Answers0