Problems to control the Trinamic TOS-100 Motor shield

Dear Community,

ich have problems to control my stepper with the TOS-100 shield.

I’m using a Arduino Uno, Trinamic TOS-100 and a Nanotec Stepper

When I use the example sketch from the TOS the motor is running. Now I tried to write my own.

My problem is now that the motor rotates continuously.

If I add a delay of 2000ms the motor does not rotate, but is buzzing only.

If I add a stop, I have the same problem.

The motor should rotate 200 steps, then stop and turn back to 2000ms 200 steps.

Maybe you could help me to find my fault.

Looking foreward to your answers

Kind regards

Timm

The Code looks like:

#include <SPI.h>
#include <TMC26XStepper.h>

//we have a stepper motor with 200 steps per rotation, CS pin 2, dir pin 6, step pin 7 and a current of 300mA
//TMC26XStepper tmc26XStepper = TMC26XStepper(200,2,6,7,900);

TMC26XStepper tmc26XStepper = TMC26XStepper(200,2,6,7,900);
int curr_step;
int speed = 0;
int speedDirection = 100;
int maxSpeed = 1000;

void setup(){

tmc26XStepper.setSpreadCycleChopper(2,24,8,6,0);
tmc26XStepper.setRandomOffTime(0);

tmc26XStepper.setMicrosteps(32);
tmc26XStepper.setStallGuardThreshold(4,0);

tmc26XStepper.setSpeed(30); // Motorgeschwindigkeit 30rpm
tmc26XStepper.start();

}

void loop(){
tmc26XStepper.step(200);

tmc26XStepper.move(); //Starte Motor

}

I know it's been a while - but was there any movement ahead with this problem? i have the board and It's hooked up to my UNO board. wired correctly - but no stepper movement.

Russ from Coral Springs, Fl

ich have problems to control my stepper with the TOS-100 shield.

You did not provide a link to the shield.

#include <TMC26XStepper.h>

You didn’t provide a link to the library.

My problem is now that the motor rotates continuously.

That’s what you are telling it to do:

  tmc26XStepper.step(200);
 
  tmc26XStepper.move();    //Starte Motor

If I add a delay of 2000ms the motor does not rotate, but is buzzing only.

But, you didn’t show us where you added the delay().

The motor should rotate 200 steps, then stop and turn back to 2000ms 200 steps.

You are not telling it to do that, so you should not expect it to do that.

Hi,

I've got exactly the same problem with the TOS-100 shield.

I want to turn the stepper 200 steps, wait 500ms, put HIGH on pin3, wait 2000ms put LOW in pin3 and repeat the sequence 50 times.

void loop() {

  tmc26XStepper.setSpeed(10);
  tmc26XStepper.step(200);
  
  tmc26XStepper.move();

tmc26XStepper.stop();




}

just makes the stepper run endlessly

Link to the library:

https://github.com/trinamic/TMC26XStepper

Any help is much appreciated

If you want to move the motor the other way I'd guess you'll have to provide a negative value to step(). Displacement and velocity are signed values.

Hi Mark,

thanks for pointing. Now I'm a step farther (ho, ho, ho)

The behaviour is a bit strange

the code

void loop() {

  tmc26XStepper.setSpeed(10);
  tmc26XStepper.step(200);
  tmc26XStepper.move();
  
  tmc26XStepper.step(-200);
  tmc26XStepper.move();
  
  
  //tmc26XStepper.step(1000);
  //tmc26XStepper.move();

}

leads to 200 steps clockwise, then 200 steps counterclockwise

removing the comments of the last block leads to a stepper running endlessly clockwise, obviously ignoring the first two blocks regarding the steps

WTF?

void loop() {

  tmc26XStepper.setSpeed(10);
  tmc26XStepper.step(500);
  tmc26XStepper.move();
  
  tmc26XStepper.setSpeed(1);
  tmc26XStepper.step(-500);
  tmc26XStepper.move();
  


}

leads to 500 steps CW speed 10 endless steps CCW speed 10

void loop() {

  tmc26XStepper.setSpeed(10);
  tmc26XStepper.step(500);
  tmc26XStepper.move();
  
  tmc26XStepper.setSpeed(50);
  tmc26XStepper.step(-500);
  tmc26XStepper.move();
  


}

leads to endless steps CCW speed 50

this can't be ok, can it?

I want to turn the stepper 200 steps, wait 500ms, put HIGH on pin3, wait 2000ms put LOW in pin3 and repeat the sequence 50 times.

If that is ALL you want to do, all the code goes in setup().

You need a for loop that iterates 50 times. You do not have that now.

You need code to wait 500 milliseconds after the move. You do not have that now.

You need code to put the pin HIGH. You do not have that now.

You need code to wait 2 seconds. You do not have that now.

You need code to put the pin LOW. You do not have that now.

we’re getting closer :slight_smile:

void setup() {
 
  tmc26XStepper.setSpreadCycleChopper(2,24,8,6,0);
  tmc26XStepper.setRandomOffTime(0);
  tmc26XStepper.setMicrosteps(8);
  tmc26XStepper.setStallGuardThreshold(4,0);
  tmc26XStepper.start();
  
  
   tmc26XStepper.setSpeed(20);
   tmc26XStepper.step(-1000);
   tmc26XStepper.step(5000);
   }

void loop() {
  tmc26XStepper.move();
}

leads to 1000 steps CCW.

tmc26XStepper.step(5000);

is being ignored

You haven't provided a link to the library you are using. Without seeing the library, I'd guess that step() check to see if the stepper is where to told it to go last time. If not, it ignores the new input.

i thought that was the link to the library

void setup() {
 
  tmc26XStepper.setSpreadCycleChopper(2,24,8,6,0);
  tmc26XStepper.setRandomOffTime(0);
  tmc26XStepper.setMicrosteps(8);
  tmc26XStepper.setStallGuardThreshold(4,0);
  tmc26XStepper.start();
      
   for (int i = 0; i < 12; i++) {
     
     tmc26XStepper.setSpeed(10);
     tmc26XStepper.step(1000);
     delay(500);
     tmc26XStepper.move();
     
     }
     
   }

void loop() {
  
  
}

leads to taking the stepper 10 (!) steps with a 500ms delay between each step

Moving the tmc26XStepper.move();to the void loop() makes the stepper taking 1000 steps and then stop.

* The most important function is the move(). It checks if the motor has to do a step or not.
* It is important that you call move() as often as possible in your Arduino loop() routine. I suggest
* to use a very fast loop routine and always call it at the beginning or the end.

So, move() causes ONE step.

 * You can always verify with isMoving() or even use stop() to stop the motor before giving it new step directions.
* \sa isMoving(), getStepsLeft(), stop()

So, there are ways to use a while loop, or a for loop, to make the stepper do all the stepping it needs to do.

OMG

So, move() causes ONE step.

and everything makes sense

for those having the same problem, here is the code for turning the stepper a particular distance.

void loop() {
  
  for (int i = 0; i < 5; i++) {
     
     
    tmc26XStepper.step(1000);
    while (tmc26XStepper.getStepsLeft()>0)
      {
       tmc26XStepper.move();
      }
     delay(500);
     
   } 
   
  while(1){}
  
}

Thanks PaulS for your help

The idiom you are probably expected to use is

    while (tmc26XStepper.move ())
    {}

Since move() returns non-zero if there are steps left.

Always read the library's .h file for comments:

/*!
* \brief Central movement method, must be called as often as possible in the lopp function and is very fast.
*
* This routine checks if the motor still has to move, if the waiting delay has passed to send a new step command to the motor
* and manages the number of steps yet to move to fulfill the current move command.
*
* This function is implemented to be as fast as possible to call it as often as possible in your loop routine.
* The more regurlarly you call this function the better. In both senses of 'regularly': Calling it as often as
* possible is not a bad idea and if you even manage that the intervals you call this function are not too irregular helps too.
*
* You can call this routine even if you know that the motor is not miving. It introduces just a very small penalty in your code.
* You must not call isMoving() to determine if you need to call this function, since taht is done internally already and only
* slows down you code.
*
* How often you call this function directly influences your top miving speed for the motor. It may be a good idea to call this
* from an timer overflow interrupt to ensure proper calling.
* \sa step()
*/

[ Even if its as badly written as this! - they could at least have given an example of use. If the docs are really incomprehensible read the code too and if its also incomprehensible, perhaps find a better library? ]