Tmc2208+arduino uno+push button

Hello, I am very new to Arduino; I have designed a program to use three motors with three a4988 drivers that move by button; I have managed to get it to work but I have wanted to update them to the TMC 2208 to avoid noise and I can't get it to do anything.

const int dirPin = 2;    
const int stepPin = 3;  
const int dirPin2 = 4;    
const int stepPin2 = 5;  
const int dirPin3 = 6;    
const int stepPin3 = 7;  

const int boton1 = 8;
const int boton2 = 9;
const int boton3 = 10;
const int boton4 = 11;
const int boton5 = 12;
const int boton6 = 13;



void setup() {
  pinMode(dirPin, OUTPUT);
  pinMode(stepPin, OUTPUT);
  pinMode(dirPin2, OUTPUT);
  pinMode(stepPin2, OUTPUT);
  pinMode(dirPin3, OUTPUT);
  pinMode(stepPin3, OUTPUT);

  pinMode(boton1,INPUT_PULLUP);
  pinMode(boton2,INPUT_PULLUP);
  pinMode(boton3,INPUT_PULLUP);
  pinMode(boton4,INPUT_PULLUP);
  pinMode(boton5,INPUT_PULLUP);
  pinMode(boton6,INPUT_PULLUP);

}

void loop() {

  if(digitalRead(boton1)==LOW){    
     digitalWrite(dirPin, HIGH);

    digitalWrite(stepPin, HIGH);
    delayMicroseconds(1500);       

    digitalWrite(stepPin, LOW);
    delayMicroseconds(1500);
    }
  
  if(digitalRead(boton2)==LOW){    

     digitalWrite(dirPin, LOW);

    digitalWrite(stepPin, HIGH);
    delayMicroseconds(1500);       

    digitalWrite(stepPin, LOW);
    delayMicroseconds(1500);
   
    }
   
   if(digitalRead(boton3)==LOW){    
     digitalWrite(dirPin2, HIGH);

    digitalWrite(stepPin2, HIGH);
    delayMicroseconds(1500);       

    digitalWrite(stepPin2, LOW);
    delayMicroseconds(1500);
    }
  
   if(digitalRead(boton4)==LOW){    
     digitalWrite(dirPin2, HIGH);

    digitalWrite(stepPin2, HIGH);
    delayMicroseconds(1500);       

    digitalWrite(stepPin2, LOW);
    delayMicroseconds(1500);
    }

   if(digitalRead(boton5)==LOW){    
     digitalWrite(dirPin3, HIGH);

    digitalWrite(stepPin3, HIGH);
    delayMicroseconds(1500);       

    digitalWrite(stepPin3, LOW);
    delayMicroseconds(1500);
    }
  
  if(digitalRead(boton6)==LOW){    

     digitalWrite(dirPin3, LOW);

    digitalWrite(stepPin3, HIGH);
    delayMicroseconds(1500);       

    digitalWrite(stepPin3, LOW);
    delayMicroseconds(1500);
   
    }

   
}

This is the connection I am using, nothing moves, but when I connect the enable to gnd it shakes and tries to move but does not finish turning

The photo I have posted is how I have it working with the a4988; The connection I use for the TMC is the same but I add a cable from the enable to gnd

Try connecting your power supply grounds together.

I have the arduino connected through the vin pin with 12v, and all the gnd's tied together, I don't know if that's what you meant.

using chatgpt it gave me this different code

#include <AccelStepper.h>

// Definir pines para los motores
#define STEP1_PIN 3
#define DIR1_PIN 2
#define MS1_PIN 7
#define MS2_PIN 6

#define STEP2_PIN 5
#define DIR2_PIN 4
#define MS1_PIN_2 10
#define MS2_PIN_2 11

#define STEP3_PIN A0
#define DIR3_PIN A1
#define MS1_PIN_3 A2
#define MS2_PIN_3 A3

// Crear instancias de AccelStepper
AccelStepper stepper1(AccelStepper::DRIVER, STEP1_PIN, DIR1_PIN);
AccelStepper stepper2(AccelStepper::DRIVER, STEP2_PIN, DIR2_PIN);
AccelStepper stepper3(AccelStepper::DRIVER, STEP3_PIN, DIR3_PIN);

// Pines para botones
#define BUTTON1_DIR1 8
#define BUTTON1_DIR2 9
#define BUTTON2_DIR1 12
#define BUTTON2_DIR2 13
#define BUTTON3_DIR1 A4
#define BUTTON3_DIR2 A5

void setup() {
  // Configuración de pines de microstepping
  pinMode(MS1_PIN, OUTPUT);
  pinMode(MS2_PIN, OUTPUT);
  pinMode(MS1_PIN_2, OUTPUT);
  pinMode(MS2_PIN_2, OUTPUT);
  pinMode(MS1_PIN_3, OUTPUT);
  pinMode(MS2_PIN_3, OUTPUT);

  // Configurar microstepping (ajusta según tus necesidades)
  digitalWrite(MS1_PIN, LOW);
  digitalWrite(MS2_PIN, LOW);
  digitalWrite(MS1_PIN_2, LOW);
  digitalWrite(MS2_PIN_2, LOW);
  digitalWrite(MS1_PIN_3, LOW);
  digitalWrite(MS2_PIN_3, LOW);

  // Configuración de pines de botones
  pinMode(BUTTON1_DIR1, INPUT_PULLUP);
  pinMode(BUTTON1_DIR2, INPUT_PULLUP);
  pinMode(BUTTON2_DIR1, INPUT_PULLUP);
  pinMode(BUTTON2_DIR2, INPUT_PULLUP);
  pinMode(BUTTON3_DIR1, INPUT_PULLUP);
  pinMode(BUTTON3_DIR2, INPUT_PULLUP);

  // Configuración de velocidad y aceleración
  stepper1.setMaxSpeed(1000);
  stepper1.setAcceleration(500);
  stepper2.setMaxSpeed(1000);
  stepper2.setAcceleration(500);
  stepper3.setMaxSpeed(1000);
  stepper3.setAcceleration(500);
}

void loop() {
  // Motor 1
  if (digitalRead(BUTTON1_DIR1) == LOW) {
    stepper1.setSpeed(200); // Establecer velocidad
    stepper1.runSpeed(); // Mover motor
  } else if (digitalRead(BUTTON1_DIR2) == LOW) {
    stepper1.setSpeed(-200); // Establecer velocidad negativa
    stepper1.runSpeed(); // Mover motor
  } else {
    stepper1.stop(); // Detener motor
  }

  // Motor 2
  if (digitalRead(BUTTON2_DIR1) == LOW) {
    stepper2.setSpeed(200);
    stepper2.runSpeed();
  } else if (digitalRead(BUTTON2_DIR2) == LOW) {
    stepper2.setSpeed(-200);
    stepper2.runSpeed();
  } else {
    stepper2.stop();
  }

  // Motor 3
  if (digitalRead(BUTTON3_DIR1) == LOW) {
    stepper3.setSpeed(200);
    stepper3.runSpeed();
  } else if (digitalRead(BUTTON3_DIR2) == LOW) {
    stepper3.setSpeed(-200);
    stepper3.runSpeed();
  } else {
    stepper3.stop();
  }
}

I can't get it to work either

You are dealing with software and hardware.

What exact TMC2208-board are you using?
It is always a good idea to look up the datasheet of the used chips.
The TMC2208 has an enable-pin. Depending on what exact TMC2208-board you are using it might be that the enable-Input is free-floating and requires to be connected to either GND or Vcc.

Or it might be that this connection is already on the board.

Very important connect / disconnect stepper-motor only if powersupply is switched OFF.

Stepper-motors have coils. Coils can produce high voltage-spikes when you connect or disconnect
a coil from the power-supply. A single voltage-spike can destroy the stepper-motor-driver.

So make sure that you have switched off your power-supply before you connect / disconnect steppermotor-wires.

Do never play or change the stepper-motorwires while powersupply is switched on.
Make sure that your stepper-motor-wires have a real tight connection so they will not loose contact.

re-wiring motor-wires while the power-supply is switched on is the wrong thing to do.

Really what I'm looking for is to be able to control three motors by pushbuttons; It is to sibir and lower a curtain, I want to control all three with an Arduino; I managed it with the first program I put in using the a4988 drivers (I have it connected to an expansion board), but they make a lot of noise. I have purchased some tmc2208 v1.2 and when I place them on the expansion board it does not work, I have also tried it without a board and nothing; I have played a little with chatgpt as I put in the following post but I have not been able to get it to move the motors either.

dear @golfo

did you really read what I have posted before?

What exact TMC2208-board are you using? There are many companies that build TMC2208-boards. And their products can deviate on details.

These details are important. If you really want help provide a link to exact that TMC2208-driver board that you have.

More guiding questions:

Did you check if your TMC2208-board is fully pin-compatible with the A4988 board,
so you can use it as a drop in replacement?

If you look at this comparising picture the pinout of these two boards are different

Did you do the test to connect the EN-input to ground / 5V?

This is a schematic I found here

No idea if this is exactly your TMC2208-board.

Yes, I read it, but it was my fault that I was using a translator and I didn't understand it well. The driver I purchased is this one.

If you do a careful comparising of each and every pin between the A4988-driver and the TMC2208-driver:

what differencies to do read?

I provided you with a lot of information.
I asked you mutliple questions that you did not answer yet.

Now it is up to you to use the information directly or to answer the questions.
Simply posting a online graphic of your TMC2208-driver board is not enough for really analysing the problem.

You will have to answer the questions and / or do the suggested modifications.

driver

Sorry, I thought the TMC2208 model was always the same; I bought it on Aliexpress.

The program I was using only uses the power connections, the motor connections and the two dir and step pins; since the TMC has those pins, I thought it would be compatible as well.

Your program does not use the power-supply connections.
What do you think will happen if you take away the powersupply-wires?

The schematic that you posted

shows an additional connection between two pins of the A4988 board.

Are you able to identify which connection this is?

If you want more help. You will have to post a detailed description of what you have done for analysing / testing
or
asking specific questions.

You seem to use this forum like any kind of chat-app.
If you want decent help / support you have to provide detailed information.
So far you are just posting one ot two short sentences that do not help analysing the problem.

I have written this mutliple times.
If you do another post that is un-informative as the postings you posted until now (exception the pinout picture) I will just answer with a link to tips how to improve your posting style.

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