DIR0035 TMC260 motor DRIVER shield library problem

Hello everyone,

I am working on controlling a bipolar stepper motor with an ARDUINO MEGA 2560R3 with a a stepper motor driver shield DIR0035 TMC260.

I don't understand how is working the differents functions of the library furnished with the shield.
I want to control the motor with STEP/DIR mode.

  1. tmc26XStepper.setSpeed(speed); => In the example of the manufacturer, they say to put the speed in rpm but when you put the speed in rpm it is not the real speed the motor is running. Besides in the example they give, we see that the value of the speed is growing in the program but physically the motor turns at the same speed all the time. I don't understand why.
  2. tmc26XStepper.step(…); + tmc26XStepper.move(); => I don’t understand how it’s working.
    I tried a simple program :
void loop() 
{
  if (!tmc26XStepper.isMoving()) 
  {
    tmc26XStepper.setSpeed(1000);
    tmc26XStepper.step(10000000);
  } 
  tmc26XStepper.move();
}

But the motor doesn’t move at all and I don’t understand why.

I go check on the functions in the library "TMC26XStepper.h", but I can't explain why it's not working.

Thank you in advance for helping.

P.S: Does the arduino monitor can affect the speed if it's slow down the program ??

1 Like

Did you set the right Steps Per Revolution when you created the stepper object? Did you choose a speed within the capability of the stepper? Try slower speeds until you find a speed that works.

You call ".move()" each time through loop() to give the stepper library a chance to do a step. The ".step()" function tells the library how far to go and in which direction. The ".isMoving()" function tells you if the stepper is in the middle of a move or not.

Did you try the library example program?

#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 800mA
TMC26XStepper tmc26XStepper = TMC26XStepper(200,6,4,5,800);
int curr_step;
int speed =  0;
int speedDirection = 100;
int maxSpeed = 1000;

void setup() {
  Serial.begin(9600);
  Serial.println("==============================");
  Serial.println("TMC26X Stepper Driver Demo App");
  Serial.println("==============================");
  //set this according to you stepper
  Serial.println("Configuring stepper driver");
  //char constant_off_time, char blank_time, char hysteresis_start, char hysteresis_end, char hysteresis_decrement
  tmc26XStepper.setSpreadCycleChopper(2,24,8,6,0);
  tmc26XStepper.setRandomOffTime(0);

  tmc26XStepper.setMicrosteps(128);
  tmc26XStepper.setStallGuardThreshold(4,0);
  Serial.println("config finished, starting");
  Serial.println("started");
}

void loop() {
  if (!tmc26XStepper.isMoving()) {
    speed+=speedDirection;
    if (speed>maxSpeed) {
      speed = maxSpeed;
      speedDirection = -speedDirection;
    } else if (speed<0) {
      speedDirection = -speedDirection;
      speed=speedDirection;
    }
    //setting the speed
    Serial.print("setting speed to ");
    Serial.println(speed);
    tmc26XStepper.setSpeed(speed);
    //we want some kind of constant running time - so the length is just a product of speed
    Serial.print("Going ");
    Serial.print(10*speed);
    Serial.println(" steps");
    tmc26XStepper.step(10*speed);
  } else {
    //we put out the status every 100 steps
    if (tmc26XStepper.getStepsLeft()%100==0) {
      Serial.print("Stall Guard: ");
      Serial.println(tmc26XStepper.getCurrentStallGuardReading());
    }
  }
  tmc26XStepper.move();
}

Hello,

Thank you for helping.
My motor is 1.8° so 200 steps by turn so it's ok.

So I tried lower speed and I saw a change of speed even if it's slower than it should be and seems to go to 40rpm maximum. It's very under my motor specifications. I will try an other power supply.

Thank you for explaining the functions, it's what I understood. So I don't understand why my small program doesn't work.
It did test the example program and it's working but I do not see speed change because of the 40rpm I guess...

Besides I did others tests and I saw that if don't have the line in the program, the motor doesn't move at all. I don't understand why.

tmc26XStepper.getCurrentStallGuardReading()

Can you please post a link to spec/data of the stepper?

Is it a geared stepper?

Thanks.. Tom... :smiley: :+1: :coffee: :australia:

Here the datas of the motor :

So, I did some others tests and if I decrease the number of microsteps given in the example the maximum speed I can reach increase.
Is it because the program is too slow to handle the delay between two microsteps?

I still do no understand why I need this line of program to work :

tmc26XStepper.getCurrentStallGuardReading()

So, I don't really move on for my project.
Still don't understand why the program need the line :

tmc26XStepper.getCurrentStallGuardReading()

Still don't understand why the number of microsteps give me a maximum speed I can reach...

Besides, I burned the shield sending it a simple line of command I've already did all the afternoon with success.

void avance_moteur(int qte_uL)
{
      float nbr_tr;
      int nbr_stp;
      nbr_tr=(22.05+(((qte_uL*1000)/0.4)*1.8))/2;
      tmc26XStepper.setEnabled(HIGH); 
      tmc26XStepper.setSpeed(50);    //Set speed at 50
      nbr_stp =round(nbr_tr*200*32); // moteur a 200 pas par tour*nbr micropas
      tmc26XStepper.step(nbr_stp);  
      Serial.println(nbr_stp);
      while(tmc26XStepper.getStepsLeft()>0)
         {
          tmc26XStepper.getCurrentStallGuardReading();
          tmc26XStepper.move(); //start stepper
         } 
      tmc26XStepper.setEnabled(LOW); 
}

If someone have any explanations... I ordered a second shield but I'am afraid to burn it also.

1 Like

anyone?

1 Like

Struggling with exactly the same problem and have exactly the same question :smiling_face_with_tear:
It is really weird, that changing this "if block" causes to stepper not move.
If I find the solution, of course, I'll post it here for you. But at the same time I'm looking for help as well

I found out the source of problem.
So turned out, that the library .zip file on the wiki site is incomplete, or something like that.
https://github.com/interactive-matter/TMC26XStepper here download the library here and import it.
THEN, open your User\Documents\Arduino\libraries and DELETE the library from the wiki.
I found this from the fact, that for some reason function "tmc26XStepper.start()" wasn't working for me even thought it was in the library description.

Also read the library file here https://github.com/interactive-matter/TMC26XStepper/blob/master/TMC26XStepper.h, it explains much much more then wiki. Basically, the wiki is almost useless and will confuse you.

I hope this will help you, at least it solved the question for me.

Hello borchezz,

Thank you for your help . I will look at it and let you know.

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