Searching a proper Stepper Motor library for driver TMC2209 V1.3 which works with ESP Wroom32 E

I am Using TMC2209 V1.3 by Bigtree Tech.
I want to be able to move it in clockwise, Anticlockwise, Move slow , Fast , With current control. I did not found any library containing all these at one.

Please help me

Current control is not a software feature. It is usually done using an external, adjustable resistor or similar. As for driving your stepper, pretty much any library offers CW, CCW and speed control.

What have you tried and why didn't it meet your needs?

You also forgot to post a link to the motor to which this is connected to. Also what librarie(s) did yo try?

I tried library TMC Stepper and TMC2209 . Around all examples i tried of TMC Stepper library on Bidirectional / Unidirectional folders. Logs are printed. Motor doesn't moves. I have a Nema23 stepper motor......I am using ESP Wroom 32E.

I tried another library A4988 with A4988 driver to test motor is functional. But I want to use TMC Stepper.

I tried codes available on very long discussion for TMC 2209, in all of code my stepper didn't moved...

Connections I tried - 2A, 2B, 1A, 1B - motor
V Io - 5v , Gnd - Gnd
Vs - 12V external , Gnd - external ground
Step, dir, Enable, Reset I took and connected.

But motor doesn't moves in any of the codes ...

That defines the frame, not the electrical characteris. Post those as well as your annotated schematic and code.

We are trying but can only work with the information you give us.

Its 4 wire motor. 2 wires fpr each coil. Works with current .2 Amps with A4988 driver.
image

Motor and Drivera are like image i uploaded.

I need a library which works for ESP wroom 32E.

Hi gilshultz Thanks, but we are in quick urgency of this solution, can we get bit fast response

....
With ESP no any working library for TMC2209 i found. Can you help me there.

From that I would assume it is connected correctly and you have a software problem but without posting your code we cannot help. Hopefully somebody here familiar with the part will check your code.

I am using "Stallguard_TMC2209" example present in TMCStepper library. It doesn't work at all. How can arduino allows such libraries with bunch of errors for first time compilation without a change . I am using esp wroom 32E.

I I wanted a working code atleast with basic functionality.

gilshultz No any library related to TMC2209 in arduino IDE worked for me directly with ESP Wroom 32 E after direct flash and proper pin/UART selection. So i would like to request you to suggest me library first which is working and has most functions of TMC2209 inside it like move clockwise, anti clock, precise left / right movement, current and UART communication.

Atleast for testing my motor........It library should run and must move my motor. :pensive:

/**  That is the code /library i am trying to use currently
 * Author Teemu Mäntykallio
 *
 * Plot TMC2130 or TMC2660 motor load using the stallGuard value.
 * You can finetune the reading by changing the STALL_VALUE.
 * This will let you control at which load the value will read 0
 * and the stall flag will be triggered. This will also set pin DIAG1 high.
 * A higher STALL_VALUE will make the reading less sensitive and
 * a lower STALL_VALUE will make it more sensitive.
 *
 * You can control the rotation speed with
 * 0 Stop
 * 1 Resume
 * + Speed up
 * - Slow down
 */
#include <TMCStepper.h>

#define MAX_SPEED        40 // In timer value
#define MIN_SPEED      1000

#define STALL_VALUE     100 // [0..255]

#define EN_PIN           25 // Enable
#define DIR_PIN          26 // Direction
#define STEP_PIN         27 // Step
// #define SW_RX            63 // TMC2208/TMC2224 SoftwareSerial receive pin
// #define SW_TX            40 // TMC2208/TMC2224 SoftwareSerial transmit pin
#define SERIAL_PORT Serial2 // TMC2208/TMC2224 HardwareSerial port
#define DRIVER_ADDRESS 0b00 // TMC2209 Driver address according to MS1 and MS2

#define R_SENSE 0.11f // Match to your driver
                      // SilentStepStick series use 0.11
                      // UltiMachine Einsy and Archim2 boards use 0.2
                      // Panucatt BSD2660 uses 0.1
                      // Watterott TMC5160 uses 0.075

// Select your stepper driver type
//TMC2209Stepper driver(&SERIAL_PORT, R_SENSE, DRIVER_ADDRESS);
//TMC2209Stepper driver(SW_RX, SW_TX, R_SENSE, DRIVER_ADDRESS);

using namespace TMC2208_n;

// Using direct register manipulation can reach faster stepping times
#define STEP_PORT     PORTF // Match with STEP_PIN
#define STEP_BIT_POS      0 // Match with STEP_PIN

ISR(TIMER1_COMPA_vect){
  //STEP_PORT ^= 1 << STEP_BIT_POS;
  digitalWrite(STEP_PIN, !digitalRead(STEP_PIN));
}

void setup() {
  Serial.begin(115200);         // Init serial port and set baudrate
  while(!Serial);               // Wait for serial port to connect
  Serial.println("\nStart...");

  SERIAL_PORT.begin(115200);
  // driver.beginSerial(115200);

  pinMode(EN_PIN, OUTPUT);
  pinMode(STEP_PIN, OUTPUT);
  pinMode(DIR_PIN, OUTPUT);
  digitalWrite(EN_PIN, LOW);

  driver.begin();
  driver.toff(4);
  driver.blank_time(24);
  driver.rms_current(400); // mA
  driver.microsteps(16);
  driver.TCOOLTHRS(0xFFFFF); // 20bit max
  driver.semin(5);
  driver.semax(2);
  driver.sedn(0b01);
  driver.SGTHRS(STALL_VALUE);

  // Set stepper interrupt
  {
    cli();//stop interrupts
    TCCR1A = 0;// set entire TCCR1A register to 0
    TCCR1B = 0;// same for TCCR1B
    TCNT1  = 0;//initialize counter value to 0
    OCR1A = 256;// = (16*10^6) / (1*1024) - 1 (must be <65536)
    // turn on CTC mode
    TCCR1B |= (1 << WGM12);
    // Set CS11 bits for 8 prescaler
    TCCR1B |= (1 << CS11);// | (1 << CS10);
    // enable timer compare interrupt
    TIMSK1 |= (1 << OCIE1A);
    sei();//allow interrupts
  }
}

void loop() {
  static uint32_t last_time=0;
  uint32_t ms = millis();

  while(Serial.available() > 0) {
    int8_t read_byte = Serial.read();
    #ifdef USING_TMC2660
      if (read_byte == '0')      { TIMSK1 &= ~(1 << OCIE1A); driver.toff(0); }
      else if (read_byte == '1') { TIMSK1 |=  (1 << OCIE1A); driver.toff(driver.savedToff()); }
    #else
      if (read_byte == '0')      { TIMSK1 &= ~(1 << OCIE1A); digitalWrite( EN_PIN, HIGH ); }
      else if (read_byte == '1') { TIMSK1 |=  (1 << OCIE1A); digitalWrite( EN_PIN,  LOW ); }
    #endif
    else if (read_byte == '+') { if (OCR1A > MAX_SPEED) OCR1A -= 20; }
    else if (read_byte == '-') { if (OCR1A < MIN_SPEED) OCR1A += 20; }
  }

  if((ms-last_time) > 100) { //run every 0.1s
    last_time = ms;

    Serial.print("0 ");
    Serial.print(driver.SG_RESULT(), DEC);
    Serial.print(" ");
    Serial.println(driver.cs2rms(driver.cs_actual()), DEC);
  }
}


What you are asking is about the same as asking a tire manufacturer to make one tire that fits all vehicles. As there are different vehicles, makes, models, you have the same scenario in the Arduino offspring. There are many different engines (processors) in the Arduinos as in vehicles. Can you take a crankshaft from a MAC 12 engine and use it as a replacement for a pinto? You have the same construct in the hardware, for example the code shows access to TCCR1A, some processors do not have that register so the code will not work.

It is well known in the community that not all libraries work with all processors. A big clue is if it directly access any register in the processor. The libraries are posted by volunteers who write them and test them on there equipment. Very few if any of the volunteers have the ability, time, resources to test there library on every Arduino. Arduino and Github post them as a convenience and you will find disclaimers all over.

People that write these libraries again are volunteering and have a very large range of experience, from a noob to a seasoned veteran in C++. So why does Arduino not check every library, who will pay for it? What do you want them to do if a new Arduino comes out?

Understood .... But right now, since no any available library in Arduino IDE moves my motor with ESP Wroom 32E, Can you help me to test my motor driver with TMC2209 code to drive & control my Motor in both directions having precise speed and current control...

I know blh64Faraday I tried my motor with A4988. It works. But in our project we need to use TMC2209 specifically with Esp wroom 32E, which is not happening in our case. No any TMC library available in Arduino IDE is able to move my motor with ESP. This is worried scenario for me.

Because of that I am not able to test my motor with this TMC2209.

I Use TMC2209 V1.3 from bigtreetech

The only thing left is you have some bad hardware. Have you checked the voltages with a meter and the signals with a scope. That is assuming it compiled correctly.

In step pin scope was giving very compact waveforms. Power supplies and GPIO's input/outputs i tried with multimeter, that looked proper.

Firstly, now i am confused which TMC2209 stepper driver library do you think would work for me in ESP Wroom 32E. Is there any library worked for you with ESP using TMC2209??
That would confirm me whether i am using a faulty driver. I will try to flash the same first to test the motor with my current driver.

In mean time I already ordered 2 more pieces of TMC2209 stepper motor driver

No, I do not have the parts or time. Sorry!

A NEMA 23 motor with current of 0.2A will be a high impedance, high voltage motor that may need 24 volt or higher power supply.
What is the part number of the motor?

This is Nema 17 , i am correcting. The link is below

I have bought new Motor driver MKS TMC2209. Can anyone help me out to drive motor via ESP Wroom32 E

Hi , I am trying to drive a Stepper motor using driver MKS TMC2209 with ESP wroom32E.
There are many sample codes in arduino, but 99% of them in the forum are non working with ESp wroom32 E . It is even true with libraries available in Arduino IDE. Is there anyone help me here to drive my motor..... Clock wise, anticlockwise, Controll speed, current. I am using a motor Nema 23 . 4 wire 2 coil stepper motor.

I am suffering on it from many days.