Hi,
I'm trying to control my tmc 2209 via UART with an Arduino Uno. I found this forum post and followed it as good as I could.
Here is my wiring:
And here is my code:
#include <TMCStepper.h>
#define STEP_PIN 3
#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);
}
It also kinda works. The motor turns with the expected microstepping and the serial print also returns the correct values for microstepping and the current.
The Problem is that the step stick uses the current value set by the screw and not the value set by UART.
I don't know why but no matter what current value I set via UART the motor always uses 200ma even if the serial Print reports that the value was set to 600ma. And if I now start to turn the screw the current changes.
I thought the value set by the screw is overwritten if UART is configured?
Any ideas?
