Using capacitorcs with TMC2209 Stepper Driver

Hello

I have project using Stepper Drivers as they are easier to control precise movement and are quieter than a dc motor. I initially had a few problems getting starting but had those issues were resolved by suggestions of some great people from this forum and everything worked perfectly fine until recently. Now my stepper motors are intermittently moving as soon as it is connected to the Arduino, once the Arduino powers up it stops moving and obeys the commands that I send.

This is really strange as I have made no changes since it was previously working, the only thing I done was add the ESP32 library & preferences as I wanted to compare the ESP32 & Arduino.

I have changed the cables, breadboard, Arduino board, stepper driver and stepper motor, I've even connected the stepper driver to a separate 5v power for the logic.

I read on a previous post that it was recommended to add capacitors to the stepper driver as residual voltage during connection to it can put it in a state of high/low before commands are received. So, can someone please advise where in my circuit do I add the capacitors and what capacitor do I add?

Thanks in advance.

Please identify the Arduino, and post code, wiring diagram and links to the motors, the motor driver and the motor power supply.

Problems during bootup can be caused by undefined or unexpected states on the MCU pins, and those cannot be corrected by adding capacitors to the motor driver (which is dubious advice in any case).

Did you use the ENable pin of the driver.
Leo..

I have;
Arduino mega
nema 17 motors (1.5 amps) & nema 23 (2 amp)
24 v 5A power supply
TMC2209 stepper driver

This is a stripped down version of my code:

#include <MobaTools.h>

const byte stepPin = 43;   // pulse pin was 5
const byte dirPin  = 9; //43; 
const int stepsPerRev = 1600;   
long  targetPos =  0;//  18000; 1000; 
long nextPos;
//#define CYCLETIME 100


MoToStepper myStepper ( stepsPerRev, STEPDIR );
MoToTimer pause;                    // Pause between stepper moves
bool stepperRunning;

int MotorDirection =1;
int StartMotor =0;
int RUNONCE = 0;
String    command;
// ------------------------------------------- setup FUNCTION -------------------------------------------
// 
//     put main code here, to run once:
//
// ----------------------------------------------------------------------------------------------------------------


void setup() {
   Serial.begin(9600);
  
  myStepper.attach( stepPin, dirPin );
    myStepper.setSpeed( 2500 );  // 60 Rev/Min ( if stepsPerRev is set correctly ) previously 600,  500 runs a bit quiter
   pause.setTime( 100 );

     delay(3000);
  stepperRunning = false; // was set to  true
     Serial.println("ready to go!!!!");
}

// ------------------------------------------- LOOP FUNCTION -------------------------------------------
// 
//     put main code here, to run repeatedly:
//
// ----------------------------------------------------------------------------------------------------------------


void loop() {

if (Serial.available()){
command = Serial.readStringUntil('\n');
command.trim();

if (command.equals("1"))
{
  Serial.println("command 1 recieved");
 motor_cw() ; 
stepperRunning = true; 
}

else if  (command.equals("2")){
    Serial.println("command 2  recieved");
    motor_ccw() ; 
    stepperRunning = true; 
}
  
else if  (command.equals("d")){ 
  myStepper.stop( );

  }
 
}
 
}



// ------------------------------- motor_cw FUNCTION -------------------------------------------
// 
//     Rotate motor  clock wise
//
// ----------------------------------------------------------------------------------------------------------------

void motor_cw() {
 Serial.println("clock wise");
 Serial.print(targetPos);
 targetPos = targetPos - 1000;
   myStepper.moveTo( targetPos );

// MotorDirection =1;

     StartMotor =1; // if i am only testing one rotation set StartMotor =0;
}

// ------------------------------- motor_ccw FUNCTION -------------------------------------------
// 
//     Rotate motor counter clock wise
//
// ----------------------------------------------------------------------------------------------------------------
void motor_ccw() {

  Serial.println("counter clock wise");
   Serial.print(targetPos);
  targetPos = targetPos + 1000;
  myStepper.moveTo( targetPos ); 

// MotorDirection =2;
 
    StartMotor =1; // if i am only testing one rotation set StartMotor =0;
}

I purchased a CNC shield as it already has capacitors soldered to the board so I thought it was worth a try and amazingly it works fine. I am absolutely convinced that this was to do with the stepper motor having a problem with some sort of voltage management from the power supply when connected directly to the breadboard, I don't see any other explanation or it could be cheap connectors used on the breadboard.

Even though no one helped me with a solution on this forum I thought it would still be helpful to provide information about the solution that worked for me in case someone else had a similar problem.

I definitely recommend purchasing a CNC shield if someone is having a similar issue and want a quick fix. Something like this:;https://www.amazon.co.uk/Akozon-Expansion-Stepper-Heatsink-Engraver/dp/B07DMSWR92/ref=sxin_16_pa_sp_search_thematic_sspa?content-id=amzn1.sym.8a568856-906e-49e2-9994-a7e0ba8118ab%3Aamzn1.sym.8a568856-906e-49e2-9994-a7e0ba8118ab&cv_ct_cx=cnc+shield&keywords=cnc+shield&pd_rd_i=B07DMSWR92&pd_rd_r=04d8f5f4-a751-4c28-bef9-523a73a5e759&pd_rd_w=z2yld&pd_rd_wg=cc3Sn&pf_rd_p=8a568856-906e-49e2-9994-a7e0ba8118ab&pf_rd_r=C8WMC6MZ8Z9G3Z7EETCC&qid=1679142977&sbo=RZvfv%2F%2FHxDF%2BO5021pAnSA%3D%3D&sr=1-3-1c12e6fc-61d1-41ee-8e02-a6ca5f2da604-spons&sp_csd=d2lkZ2V0TmFtZT1zcF9zZWFyY2hfdGhlbWF0aWM&psc=1&smid=AT1Q9BWPH6Y68.

This CNC shield is supposed to sit directly on top of an Arduino uno but it does not have to be configured that way. I have drawn out a diagram below that shows how you can connect the shield to any Arduino/MCU by using jumper cables.

I don't know what rating is the on board capacitors used because it is fixed on the CNC board in a way which would require me to bend the capacitor legs too much to read the rating, there is also an onboard fuse and resistor. When I am ready to make my prototype board I will get the correct ratings of the capacitors, onboard fuse and resistor to solder to my prototype board but for I will just connect it manually.

Hope this helps.

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