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.
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.
tmc26XStepper.step(…); + tmc26XStepper.move(); => I don’t understand how it’s working.
I tried a simple program :
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();
}
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.
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 :
Struggling with exactly the same problem and have exactly the same question
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.