I am trying to drive a linear actuator using an Arduino Uno and DFRobot Motor Shield, TMC260_Stepper_Motor_Driver_Shield_SKU__DRI0035-DFRobot , and when i run the programme, the StallGuard LED on the board turns on and the linear actuator pulses and gets hot very quickly. Does anyone have any suggestions to make this work?
#include <SPI.h>
#include <TMC26XStepper.h>
//we have a stepper motor with 20 steps per rotation,CS pin 6, dir pin 4, step pin 5 and a current of 800mA
TMC26XStepper tmc26XStepper = TMC26XStepper(20,6,4,5,800);
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.SPI_setCoilCurrent(500);
tmc26XStepper.setMicrosteps(128);
tmc26XStepper.setStallGuardThreshold(100,0);
Serial.println("config finished, starting");
Serial.println("started");
tmc26XStepper.SPI_setSpeed(50); //Set speed at 80 RPM
tmc26XStepper.SPI_step(20); //set step at -200 steps, that is to say stepper will turn a circle reverse
tmc26XStepper.spi_start() ; //start stepper
delay(4000); //delay 2s
tmc26XStepper.SPI_step(20); // set step at 200 steps, stepper will turn a circle forward
tmc26XStepper.spi_start() ;
delay(4000);
tmc26XStepper.SPI_setSpeed(50); // Set speed at 100 RPM
tmc26XStepper.SPI_step(-40); // stepper will turn 1.5 circles reverse
tmc26XStepper.spi_start() ;
delay(4000);
tmc26XStepper.SPI_setSpeed(120); // Set speed at 120 RPM
tmc26XStepper.SPI_step(40); // stepper will turn 2 circles forward
tmc26XStepper.spi_start() ;
delay(4000);
}
void loop() {
// put your main code here, to run repeatedly:
}
#include <SPI.h>
#include <TMC26XStepper.h>
//we have a stepper motor with 20 steps per rotation, CS pin 2, dir pin 6, step pin 7 and a current of 800mA
TMC26XStepper tmc26XStepper = TMC26XStepper(20,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(60,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();
}
If it is that stepper motor then configure your driver to the indicated phase current of 500mA. This will give a motor power consumption of 10W and consequential heat.
Thank you, I have got the shaft moving now however as the shaft is moving the stallguard LED is flashing still when it couldnt have stalled due to being able to move and not at its end. Is this something to do with the stallguard threshold?
It is difficult to detect stall conditions with stepper motors, and the threshold usually needs to be tuned for a specific motor. Perhaps the driver is not a good match for the motor you have chosen.
i'm curious, how would you detect stall on a stepper motor?
on a DC motor, the max current is the supply voltage divided by the winding resistance. this should never occur unless the motor stops turning because BEMF would reduce the effect voltage across the winding
wouldn't the max current on a stepper motor be the voltage divided by the coil resistance. there is no BEMF except while it stepping. that current wouldn't be any greater if it hasn't reached the target position, would it?