Hello,
I was working with TMC2209 Driver to run a stepper motor and control the current with Arduino Uno Board. Strangely, even when i set rms_current() the current was not setting. When i searched online, I saw a method to check Driver Status and when i did so, it was showing '0' which means that the driver is disable.
Here is the sketch. If anyone can help than please reply as soon as possible.
#include <TMCStepper.h>
#include <AccelStepper.h>
#define DIR_PIN 7 // Direction
#define STEP_PIN 6 // Step
#define SW_RX 0 // TMC2208/TMC2224 SoftwareSerial receive pin
#define SW_TX 1 // TMC2208/TMC2224 SoftwareSerial transmit pin
#define SERIAL_PORT Serial // TMC2208/TMC2224 HardwareSerial port
#define DRIVER_ADDRESS 0b00 // TMC2209 Driver address according to MS1 and MS2
#define R_SENSE 0.11f
TMC2209Stepper driver(SW_RX, SW_TX, R_SENSE, DRIVER_ADDRESS);
AccelStepper stepper(1, STEP_PIN, DIR_PIN);
void setup() {
Serial.begin(115200);
pinMode(STEP_PIN, OUTPUT);
pinMode(DIR_PIN, OUTPUT);
driver.beginSerial(115200); // SW UART drivers
stepper.setMaxSpeed(1000);
stepper.setSpeed(500);
driver.begin(); // SPI: Init CS pins and possible SW SPI pins
driver.toff(5); // Enables driver in software
driver.rms_current(100); // Set motor RMS current
driver.microsteps(16); // Set microsteps to 1/16th
driver.I_scale_analog(false);
Serial.println("Driver initialized. RMS current: " + String(driver.rms_current()));
Serial.println("Driver status: " + String(driver.DRV_STATUS(), HEX));
}
void loop() {
stepper.runSpeed();
}
Here's what i'm getting when i check the Driver Status :
Thanks @Paul_KD7HB Sir For Your Reply And Letting Me Know About Such A Thing. I Switched The Serial Pins From 0 & 1 To 2 & 3 And Used SoftwareSerial Library. The End Result Was Still The Same In Serial Monitor. The Driver Status Is Still '0' And The Current Is Not Setting.
Did I Do Something Wrong Or Have To Add Something Else ? Thanks Again For Your Current Help But I Hope Anyone Can Help Me A Little More ?
Here's The Code After I Switched The Pins :
#include <TMCStepper.h>
#include <AccelStepper.h>
#include <SoftwareSerial.h>
#define DIR_PIN 7 // Direction
#define STEP_PIN 6 // Step
#define SW_RX 2 // TMC2208/TMC2224 SoftwareSerial receive pin
#define SW_TX 3 // TMC2208/TMC2224 SoftwareSerial transmit pin
#define SERIAL_PORT Serial // TMC2208/TMC2224 HardwareSerial port
#define DRIVER_ADDRESS 0b00 // TMC2209 Driver address according to MS1 and MS2
#define R_SENSE 0.11f
TMC2209Stepper driver(SW_RX, SW_TX, R_SENSE, DRIVER_ADDRESS);
AccelStepper stepper(1, STEP_PIN, DIR_PIN);
SoftwareSerial mySerial(SW_RX, SW_TX);
void setup() {
Serial.begin(115200);
mySerial.begin(115200);
pinMode(STEP_PIN, OUTPUT);
pinMode(DIR_PIN, OUTPUT);
driver.beginSerial(115200); // SW UART drivers
stepper.setMaxSpeed(1000);
stepper.setSpeed(500);
driver.begin(); // SPI: Init CS pins and possible SW SPI pins
driver.toff(5); // Enables driver in software
driver.rms_current(100); // Set motor RMS current
driver.microsteps(16); // Set microsteps to 1/16th
driver.I_scale_analog(false);
Serial.println("Driver initialized. RMS current: " + String(driver.rms_current()));
Serial.println("Driver status: " + String(driver.DRV_STATUS()));
}
void loop() {
stepper.runSpeed();
}