Folks,
I had the TMC 2100 driver working fine with my project, using simple Step and Dir pins and the excellent TeensyStep library. I've just received TMC2130 drivers and want to use them instead. They are controlled via SPI, and I'm having a devil of a time getting them to work.
I feel like I'm missing something. This is the basic example sketch that comes with the TMC2130Stepper library. I've got the SDO and SDI pins from the driver connected to pins 12 and 11 on the Teensy respectively, the SCK connected to pin 13, the CS to Pin 10. Step and Dir pins are connected. I get output on the Serial, but the motor does nothing.
I had the TMC 2100 driver working fine with my project, using simple Step and Dir pins and the excellent TeensyStep library. I've just received TMC2130 drivers and want to use them instead. They are controlled via SPI, and I'm having a devil of a time getting them to work.
I feel like I'm missing something. This is the basic example sketch that comes with the TMC2130Stepper library. I've got the SDO and SDI pins from the driver connected to pins 12 and 11 on the Teensy respectively, the SCK connected to pin 13, the CS to Pin 10. Step and Dir pins are connected. I get output on the Serial, but the motor does nothing.
Code:
/** * Author Teemu Mäntykallio
* Initializes the library and turns the motor in alternating directions.
*/
#define EN_PIN 6 // Nano v3: 16 Mega: 38 //enable (CFG6)
#define DIR_PIN 3 // 19 55 //direction
#define STEP_PIN 4 // 18 54 //step
#define CS_PIN 10 // 17 64 //chip select
bool dir = true;
#include <TMC2130Stepper.h>
TMC2130Stepper driver = TMC2130Stepper(EN_PIN, DIR_PIN, STEP_PIN, CS_PIN);
void setup() {
Serial.begin(9600);
while(!Serial);
Serial.println("Start...");
driver.begin(); // Initiate pins and registeries
driver.rms_current(600); // Set stepper current to 600mA. The command is the same as command TMC2130.setCurrent(600, 0.11, 0.5);
driver.stealthChop(1); // Enable extremely quiet stepping
digitalWrite(EN_PIN, LOW);
}
void loop() {
digitalWrite(STEP_PIN, HIGH);
delayMicroseconds(3);
digitalWrite(STEP_PIN, LOW);
delayMicroseconds(3);
uint32_t ms = millis();
static uint32_t last_time = 0;
if ((ms - last_time) > 2000) {
if (dir) {
Serial.println("Dir -> 0");
driver.shaft_dir(0);
} else {
Serial.println("Dir -> 1");
driver.shaft_dir(1);
}
dir = !dir;
last_time = ms;
}
}