teemuatlut / TMC2130Stepper

Arduino library for Trinamic TMC2130 Stepper driver
MIT License
159 stars 50 forks source link

ESP8266 (Wemos D1) in combination with stepper motor driver tmc2310, heat problem and force hold problem. #102

Open eleminer opened 2 years ago

eleminer commented 2 years ago

Hello all, I've been trying to connect a stepper motor driver to a Nema 17 and a Wemos D1 (ESP8266) for several days now. I now have a sketch where the motor turns and is also very very quiet. (not audible). The motor draws 400mA at 12V and gets very very warm. Can anyone help me with this? Why does the motor get so warm? On my 3D printer, for example, it stays completely cold. :/

#define EN_PIN    13
#define DIR_PIN   0
#define STEP_PIN  2
#define CS_PIN    5
#define MOSI_PIN  12
#define MISO_PIN 4
#define SCK_PIN  14

bool dir = true;

#include <TMC2130Stepper.h>
TMC2130Stepper driver = TMC2130Stepper(EN_PIN, DIR_PIN, STEP_PIN, CS_PIN, MOSI_PIN, MISO_PIN, SCK_PIN);

void setup() {
  Serial.begin(9600);
  while (!Serial);
  Serial.println("Start...");
  driver.begin();           // Initiate pins and registeries
  driver.rms_current(300);  // Set stepper current to 600mA. The command is the same as command TMC2130.setCurrent(600, 0.11, 0.5);
  driver.stealthChop(1);    // Enable extremely quiet stepping
  driver.microsteps(32);
  driver.chopper_mode(1);
  driver.random_off_time(1);

  digitalWrite(EN_PIN, LOW);

  Serial.print("DRV_STATUS=0b");
  Serial.println(driver.DRV_STATUS(), BIN);
}

void loop() {
  digitalWrite(STEP_PIN, HIGH);
  delayMicroseconds(150);
  digitalWrite(STEP_PIN, LOW);
  delayMicroseconds(150);
  uint32_t ms = millis();
  static uint32_t last_time = 0;
  if ((ms - last_time) > 10000) {
    if (dir) {
      Serial.println("Dir -> 0");
      driver.shaft_dir(0);
    } else {
      Serial.println("Dir -> 1");
      driver.shaft_dir(1);
    }
    dir = !dir;
    last_time = ms;
  }
}
eleminer commented 2 years ago

I use this stepper motor. https://www.pollin.de/productdownloads/D310453D.PDF