Did someone get these three components running together? My ESP32 just gets restarted all the time.
You better post schematics and code.
Use this link: How to get the best out of this forum - Using Arduino / IDE 1.x - Arduino Forum
I've got it running without restarting now, but the stepper still doesn't spin. I'm getting all 0 in the Serial console. The wiring is described in the code below.
#include <WiFi.h>
#include <TMCStepper.h>
// TMC2209 GND goes to ESP32 GND
// TMC2209 VM goes to ESP32 5V
// TMC2209 VIO goes to ESP32 5V
// TMC2209 A1, A2, B1 and B2 go to NEMA 8 5V bipolar stepper coils: A: red and blue, B: green and black
// #define EN_PIN 7 // Enable pin - not needed, TMC2209 EN pin is grounded
#define DIR_PIN 2 // Direction pin
#define STEP_PIN 3 // Step pin
#define SERIAL_PORT Serial2 // GPIO 16 goes to TMC2209 pin RX, GPIO 17 goes to TMC2209 pin TX
#define DRIVER_ADDRESS 0b00 // TMC2209 Driver address
#define R_SENSE 0.11f // Sense resistor value
TMC2209Stepper driver (&SERIAL_PORT, R_SENSE, DRIVER_ADDRESS);
void setup () {
Serial.begin (115200);
// pinMode (EN_PIN, OUTPUT);
// digitalWrite (EN_PIN, LOW); // Enable driver in hardware
pinMode (DIR_PIN, OUTPUT);
pinMode (STEP_PIN, OUTPUT);
SERIAL_PORT.begin (115200); // Initialize UART
driver.begin (); // Initialize driver
driver.toff (5); // Enable driver
driver.rms_current (800); // Set motor current
driver.microsteps (16); // Set microstepping
}
void loop () {
digitalWrite (DIR_PIN, HIGH); // Set direction
digitalWrite (STEP_PIN, HIGH); // Step delay (10);
digitalWrite (STEP_PIN, LOW);
delay (10);
// Read and print diagnostics
Serial.print ("SG_RESULT: ");
Serial.println (driver.SG_RESULT(), DEC);
// Read DRV_STATUS
uint32_t status = driver.DRV_STATUS ();
Serial.print ("DRV_STATUS: 0x");
Serial.println (status, HEX);
}
Result:
DRV_STATUS: 0x0
SG_RESULT: 0
DRV_STATUS: 0x0
SG_RESULT: 0
DRV_STATUS: 0x0
SG_RESULT: 0
It seems that for some reason I can not establish UART communication with TMC2209. I guess I'll just buy TMC2208 instead.