Hello Community!
After some struggling i finally got the TMC5160 to play with Arduino and a Nema23 stepper motor. I opted for this driver as I understand it can handle heavier currents - and the eventual build I envision would benefit from having more torque available.
Current setup is:
- TMC5160 (QHV5160 from fysetc QHV5160 - FYSETC WIKI)
- Nema23, two phase, 2.8A, 1.8° stepper motor (https://www.tinytronics.nl/product_files/001939_JK57HS76-2804-76A%20datasheet.pdf)
- Arduino Uno.
- Lab power supply. Since the motor only achieves 2.8A at peak, I assumed that 70% of this, ≈2A per coil, should be safe - the lab supply is therefore set to 24V 4A max draw.
My code is based on the famous TMCstepper library (GitHub - teemuatlut/TMCStepper) and the example from Watterotts 5160 driver (which doesnt seem to be available anymore, hence the Fysetc driver) (GitHub - watterott/SilentStepStick: Stepper Motor Driver based on a Trinamic TMC2100 / TMC2130 / TMC2208 / TMC2209 / TMC5160.).
From reading on the forum + trial and error I understand that the driver expects a VM-in to boot properly, and as such i practice to turn on the lab supply before turning on the arduino, or at least reset it subsequently. I also learned (the hard way) that Fysetc marks individual coils as A1/2 and B1/2, while watterotts drivers marks them opposite 1A/B and 2A/B.... took a while!
My question is: How do i get the motor to run faster, and what would be the max speed of the motor?
The datasheet(S) does not provide any information on this - but from calling the supplier I understand that most steppers should be able to run safely at 500RPM. With providing a pulsewidth of 1 microsecond, i can achieve only around 120RPM... and for the usual 10ms, slower even.
I have read a couple of posts that found serial prints can slow down the clock rate of the arduino, jeopardising the pulse width. But i have no Serial prints (only when its not running properly)... I also tried accellstepper library, as this allegedly should max out at 4000 - but in all my experience this library just makes for incredibly slow movement.
I should maybe also mention that i set microstepping to 1, as the 200 full steps are fine for this configuration. When it was set to 16, the motor would just sing an uncomfortable song... No clue why!
On a more general note: The driver also seems slightly unreliable. Randomly, it will drop into Open Load A and Open Load B status, and shut off the motor. But not necessarily correlated to strain or long operation. Its just a bit... flakey?
I hope this is enough information. I've run out of things to debug and try. Suggestions are much appreciated!
Peace
UPDATE EDIT in case anyone is also struggling with this driver:
- microsteps() expects 0 for proper full step configuration. TIL: read source codes more often:)
- As kindly suggested by jremington: To gain higher speeds, an acceleration profile is needed. A simple loop raising step frequency will do the trick.
- The driver is still unpredictable. Stops working after a few hours of running (not too hot)...
#include <TMCStepper.h>
#define EN_PIN 7 //enable
#define DIR_PIN 8 //direction
#define STEP_PIN 9 //step
#define CS_PIN 10 //CS
#define MOSI_PIN 11 //SDI/MOSI
#define MISO_PIN 12 //SDO/MISO
#define SCK_PIN 13 //CLK/SCK
#define R_SENSE 0.075f
TMC5160Stepper tmc = TMC5160Stepper(CS_PIN, R_SENSE);
void setup()
{
pinMode(EN_PIN, OUTPUT);
pinMode(DIR_PIN, OUTPUT);
pinMode(STEP_PIN, OUTPUT);
digitalWrite(EN_PIN, HIGH); //deactivate driver for now...
digitalWrite(DIR_PIN, LOW);
digitalWrite(STEP_PIN, LOW);
//SPI setup on hardware pins: 10, 11, 12, 13
pinMode(SS, OUTPUT);
pinMode(MOSI, OUTPUT);
pinMode(MISO, INPUT);
pinMode(SCK, OUTPUT);
digitalWrite(SS, HIGH);
digitalWrite(MOSI, LOW);
digitalWrite(MISO, HIGH);
digitalWrite(SCK, LOW);
Serial.begin(9600); //init serial port and set baudrate
Serial.println("\nRestart ");
tmc.begin();
tmc.toff(4);
tmc.blank_time(24);
tmc.en_pwm_mode(true); //Enable StealthChop (quiet driving)
tmc.pwm_autoscale(true); //Some say this is needed?
tmc.microsteps(1); //NB - adding 16 microstep resolution breaks?
tmc.rms_current(2000); //Motor runs 2.8A peak ≈ keep it round 2 for good measure.
digitalWrite(EN_PIN, LOW); //Enable motor
}
void loop(){
static uint32_t last_time = 0;
uint32_t ms = millis();
if ((ms - last_time) > 1000) //DIAGNOSTICS run
{
last_time = ms;
if (tmc.diag0_error()) {
Serial.println(F("DIAG0 error"));
}
if (tmc.ot()) {
Serial.println(F("Overtemp."));
}
if (tmc.otpw()) {
Serial.println(F("Overtemp. PW"));
}
if (tmc.s2ga()) {
Serial.println(F("Short to Gnd A"));
}
if (tmc.s2gb()) {
Serial.println(F("Short to Gnd B"));
}
if (tmc.ola()) {
Serial.println(F("Open Load A"));
}
if (tmc.olb()) {
Serial.println(F("Open Load B"));
}
}
//make steps
digitalWrite(STEP_PIN, HIGH)
delayMicroseconds(10);
digitalWrite(STEP_PIN, LOW);
delayMicroseconds(10);
}