I have a tmc2209 driver. I think it is v2.1 as it has the tx and rx pins. I want to control 3 nema17s with 3 of these drivers. I have having problems as I want control them using UART. There are different suggestions everywhere. How to actually connect them? Below is my code just for one but it is not working. I will upload my schematic too. I am using this code, found on this forum but closed.
#include <TMCStepper.h>
#include <HardwareSerial.h>
#define STEP_PIN 12
#define SERIAL_PORT Serial
#define R_SENSE 0.11f
#define DRIVER_ADDRESS 0b00
#define MICROSTEPS 16
TMC2209Stepper driver(&SERIAL_PORT, R_SENSE, DRIVER_ADDRESS);
void setup() {
SERIAL_PORT.begin(115200); // INITIALIZE UART TMC2209
Serial.begin(115200);
delay(500);
Serial.println(F("Serial Initialized"));
driver.begin(); // Initialize driver
driver.toff(5); // Enables driver in software
driver.rms_current(600); // Set motor RMS current
driver.microsteps(MICROSTEPS);
driver.pwm_autoscale(true); // Needed for stealthChop
driver.en_spreadCycle(false); // false = StealthChop / true = SpreadCycle
driver.shaft(false);
Serial.print(F("microsteps: ")); Serial.println(driver.microsteps());
Serial.print(F("current: ")); Serial.println(driver.rms_current());
}
void loop() {
digitalWrite(STEP_PIN, HIGH);
delay(3.6);
digitalWrite(STEP_PIN, LOW);
delay(3.6);
}
