Tmc2209 current setting not working sometime With mega

I have made code with three tmc2209 stepper motor driver and Arduino mega i am using driver address to set all driver from one pin and there is one more issue when my RX pin is connected then my motor is making noise and not running properly so i am making it low

#include <TMCStepper.h>
#include <MobaTools.h>

const int EN_PIN = 5;

const int MS1_X = 12;
const int DIR_PIN_XX = 2;
const int STEP_PIN_XX = 3;
const int DRIVER_ADDRESS_XX = 0b01;

const int MS2_Y = 11;
const int DIR_PIN_YY = 6;
const int STEP_PIN_YY = 7;
const int DRIVER_ADDRESS_YY = 0b10;

const int DIR_PIN_ZZ = 8;
const int STEP_PIN_ZZ = 9;
const int DRIVER_ADDRESS_ZZ = 0b00;

const int STEP_PER_REVALUATION = 800;

TMC2209Stepper driverXX(SW_RX, SW_TX, R_SENSE, DRIVER_ADDRESS_XX);
TMC2209Stepper driverYY(SW_RX, SW_TX, R_SENSE, DRIVER_ADDRESS_YY);
TMC2209Stepper driverZZ(SW_RX, SW_TX, R_SENSE, DRIVER_ADDRESS_ZZ);

// Create stepper motor objects
MoToStepper XStepper(STEP_PER_REVALUATION, STEPDIR);
MoToStepper YStepper(STEP_PER_REVALUATION, STEPDIR);
MoToStepper ZStepper(STEP_PER_REVALUATION, STEPDIR);

void setup() {

Serial.begin(115200);

pinMode(EN_PIN, OUTPUT);
pinMode(SW_RX, OUTPUT);
pinMode(MS1_X, OUTPUT);
pinMode(MS2_Y, OUTPUT);

digitalWrite(EN_PIN, LOW);
digitalWrite(MS1_X, HIGH);
digitalWrite(MS2_Y, HIGH);

driverXX.begin(); // SPI: Init CS pins and possible SW SPI pins
driverXX.toff(5); // Enables driver in software
driverXX.rms_current(400); // Set motor RMS current
driverXX.microsteps(16); // Set microsteps to 1/16th
driverXX.I_scale_analog(false); // Use internal voltage reference
driverXX.pwm_autoscale(true); // Needed for stealthChop
//driver.en_spreadCycle(false); // Toggle spreadCycle on TMC2208/2209/2224

driverYY.begin(); // SPI: Init CS pins and possible SW SPI pins
driver.toff(4);
driver.blank_time(24); // Enables driver in software
driverYY.rms_current(100); // Set motor RMS current
driverYY.microsteps(16); // Set microsteps to 1/16th
driverYY.I_scale_analog(false); // Use internal voltage reference
driverYY.pwm_autoscale(true); // Needed for stealthChop
//driver.en_spreadCycle(false); // Toggle spreadCycle on TMC2208/2209/2224

driverZZ.begin(); // SPI: Init CS pins and possible SW SPI pins
driverZZ.toff(5); // Enables driver in software
driverZZ.rms_current(10); // Set motor RMS current
driverZZ.microsteps(16); // Set microsteps to 1/16th
driverZZ.I_scale_analog(false); // Use internal voltage reference
driverZZ.pwm_autoscale(true); // Needed for stealthChop
//driver.en_spreadCycle(false); // Toggle spreadCycle on TMC2208/2209/2224

XStepper.attach(STEP_PIN_XX, DIR_PIN_XX);
XStepper.setSpeed(speed);
XStepper.setRampLen(20);

YStepper.attach(STEP_PIN_YY, DIR_PIN_YY);
YStepper.setSpeed(3000);
YStepper.setRampLen(1000);

ZStepper.attach(STEP_PIN_ZZ, DIR_PIN_ZZ);
ZStepper.setSpeed(3000);
ZStepper.setRampLen(1000);

}

void loop(){
XStepper.rotate(1);
YStepper.rotate(-1);
ZStepper.rotate(1);

digitalWrite(SW_RX,LOW);

}

but my motor some time sets current properly and sometime even if i have not restart motor and stop motor using button or something it will use some random current when i start motor and current is not setting properly when i upload code i have to disconnect board an reconnect then it will set current for first time then same problem

Drawing please.
How is it all wired together?

do you know any website where i can make something like connection diagram

clear pen on paper, then scan or photograph.

Faster to learn than a new tool !


Doc1.pdf (423.0 KB)

Nice drawing !
You have three sources in to RX1, there’s nothing to stop the idle state of the three ‘senders’ from fighting with any legitimate signal from the others source.

maybe use separate tx/rc pairs, or use schottky steering diodes to isolate the signals from each other.

The Tx pins are common from a single source, so there should be no problem.

but driver address should redirect signal to specific drive

const int DRIVER_ADDRESS_ZZ = 0b00;
const int DRIVER_ADDRESS_YY = 0b10;
const int DRIVER_ADDRESS_XX = 0b01;

and do I need rx pin I mean i read in data sheet tmc2209 is can communicate one direction but it is not working

It’s not the data that’s conflicting, it’s the electrical bit states fighting each other.

okay so what should i do when current is not set properly driver is getting really hot and i can't use different pin i am going to change from mega to nano is there other solutions

You’re showing a MEGA, you already have three spare hardware UARTs ?!

yes but it is temporary

This topic was automatically closed 180 days after the last reply. New replies are no longer allowed.