Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Tmc2209 current setting not working sometime #287

Open
Akshar062 opened this issue Oct 14, 2023 · 0 comments
Open

Tmc2209 current setting not working sometime #287

Akshar062 opened this issue Oct 14, 2023 · 0 comments

Comments

@Akshar062
Copy link

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant