How to control motor driver?

Hello!

i could need some insights on how to control my new stepper motor:
i got the 17HS15-1504S-X1 and the tmc2208.
Now i need the RPM of about 100.
For now i did most like this: Stepper Motor Driver TMC2208 - FabLab Kannai - Fab Academy 2022
But wasnt able to use the tmc-lib since i dont understand the sample of the imported lib completly and was scared of doing something wrong :frowning:

Wiring like this

Right now im using this code for testing:

/*
  SilentStepStick TMC2208/TMC2209 Example
  Rsense: 0.11 Ohm
  Other examples/libraries can be found here:
  https://github.com/teemuatlut/TMCStepper
  https://github.com/trinamic/TMC-API
  https://github.com/manoukianv/TMC2208Pilot
  Example source code free to use.
  Further information: https://learn.watterott.com/license/
*/

// Note: You also have to connect GND, 5V/VIO and VM.
//       A connection diagram can be found in the schematics.
#define EN_PIN    7 //enable (CFG6)
#define STEP_PIN 8 //step
#define DIR_PIN 9 //direction

void setup()
{
  //set pin modes
  pinMode(EN_PIN, OUTPUT);
  digitalWrite(EN_PIN, HIGH); //deactivate driver (LOW active)
  pinMode(DIR_PIN, OUTPUT);
  digitalWrite(DIR_PIN, LOW); //LOW to CCW
  //digitalWrite(DIR_PIN, HIGH); //HIGH to CW
  pinMode(STEP_PIN, OUTPUT);
  digitalWrite(STEP_PIN, LOW);

  digitalWrite(EN_PIN, LOW); //activate driver
}

void loop()
{
  //make steps
  digitalWrite(STEP_PIN, HIGH);
  delay(2);
  digitalWrite(STEP_PIN, LOW);
  delay(2);
}

But even with delay(1) its to slow. I thought it would mean 2ms per step, with 200 steps=> 400ms per full rotation. But it takes roughly 3seconds per full rotation. So this might be due to the step-length (e.g. full step, half, 1/4 ..).
But where do i control this - since it doesnt seem to be controlled via software.

Also: for the small stepper motor of the arduno starter kit i used the stepper.h -lib. With that i could set the speed to e.g 300 or something like this. Is it possible to use this lib while using the tmc or is it like "one or the other"?
Im sorry, its like there is SO MUCH knowledge online - but im confused by all the different aproaches, wiring, components..

What I see is your loop() code is telling the stepper to step many thousands of time per second. You need to compute the number of steps per second to give you the RPM you need. Then delay the number of milliseconds after each step to give the motor time to react to the step pulse. You do know the number of steps you motor need to make one revolution, don't you?

Robin2's simple stepper program tutorial may have information of interest.

To achieve higher speeds you will need to accelerate the motor. It cannot reach those speeds from a dead stop. Use the AccelStepper or the MobaTools stepper libraries. I think MobaTools easier to learn.

The Stepper library that comes with the Arduino IDE will not support step/dir type drivers like the TNC2208, TMC2209, A4988, DRV8825, ...

Thanks for your replys!

I want to have like 120 RPM.
That's 2 full rotations per second. The stepper got 200 steps, so 400 steps per second. So 400 times per sec high and then low. With a delay of 1 ms it would be 500 steps per sec, which is way faster than its going.

I will definitely look into the mobatools, looks like a good start.

Like I said, I got the lib from TMC, I guess I should take a look into the documentation of that...

Remember that a stepper motor, by design must STOP between steps because that could be the last step needed.

This topic was automatically closed 180 days after the last reply. New replies are no longer allowed.