Hi, i'm trying to use an MKS TMC2209 V2 (the v2 is of the MKS board, the tmc2209 is a v1.2) together with an ESP32S to control a NEMA 17 1.5A stepper motor (17HS4401).
I'm have a couple of issues currently, that i haven't been able to get my head around. Firstly is that the stepper is quite loud and vibrates a good deal when turning. It also heats up quite a bit, slightly past what i would consider the too hot to keep fingers on for an extended period of time. I don't have much experience with them, so i'm not sure what settings to change to improve this behavior
Second issue is that I'm pretty sure I'm not using the UART connection correctly as the serial monitor is not report the microsteps the code is setting and instead outs 256. I don't know if this is because I'm not reading it right or maybe not controlling the driver correctly.
Lastly, in between the serial prints, my serial monitor is filled with hundreds of
"E (687692) gpio: gpio_set_level(226): GPIO output gpio_num error"
and i've got no idea why.
My code is shown below, as is a drawing of my wiring, plus a few photos of the actual setup
The code is sourced mostly from this forum post: Using a TMC2209 silent stepper motor driver with an arduino - #14 by monkeyfist
I think i covered everything and provided the right stuff, but if anyone needs other info I'd be happy to provide.
Any help on the specific problems i listed or just general knowledge is very appreciated, thanks!
#include <SpeedyStepper.h> //Simple & good stepper library, get it.
#include <TMCStepper.h>
#define DIR_PIN 34 // Direction
#define STEP_PIN 35 // Step
#define SERIAL_PORT Serial2 // HardwareSerial port
#define DRIVER_ADDRESS 0b00 // TMC2209 Driver address according to MS1 and MS2
#define R_SENSE 0.11 // 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
bool shaft = false; // ONLY NEEDED FOR CHANGING DIRECTION VIA UART, NO NEED FOR DIR PIN FOR THIS
TMC2209Stepper driver(&SERIAL_PORT, R_SENSE, DRIVER_ADDRESS);
SpeedyStepper stepper;
void setup() {
stepper.connectToPins(STEP_PIN, DIR_PIN); // INITIALIZE SpeedyStepper
SERIAL_PORT.begin(115200); // INITIALIZE UART TMC2209
Serial.begin(115200);
delay(500);
Serial.println(F("Serial Initialized"));
driver.begin(); // Initialize driver
driver.toff(5); // Enables driver in software
driver.rms_current(600); // Set motor RMS current
driver.microsteps(2); // Set microsteps to 1/2
driver.pwm_autoscale(true); // Needed for stealthChop
// driver.en_spreadCycle(true); // Toggle spreadCycle for smooth & silent operation
stepper.setCurrentPositionInSteps(0); // Set zero position
stepper.setSpeedInStepsPerSecond(400); //Set Speed
stepper.setAccelerationInStepsPerSecondPerSecond(400); //Set acceleration, smaller value for super smooth direction changing
}
void loop() {
uint16_t msread = driver.microsteps();
Serial.print(F("Read microsteps via UART to test UART receive : ")); Serial.println(msread);
Serial.println(F("Move 6400 steps forward at 600ma"));
driver.rms_current(1000);
stepper.moveToPositionInSteps(6400);
Serial.println(F("Wait 3sec and turn current low so you can turn the motor shaft"));
driver.rms_current(10);
delay(3000);
Serial.println(F("Move back to 0 position at 300ma"));
driver.rms_current(300);
stepper.moveToPositionInSteps(0);
//MOVE MOTOR VIA UART AND CHANGE DIRECTION VIA SOFTWARE, IT RUNS AS LONG AS YOU LET IT... PROBABLY ONLY USEFUL WITH ENCODER. THE VALUE SETS ONLY THE SPEED.
// driver.VACTUAL(16000); //SET SPEED OF MOTOR
// delay(2000); // MOTOR MOVES 2 SEC THEN STOPS
// driver.VACTUAL(0); //STOP MOTOR BY SETTING SPEED TO 0
// shaft = !shaft; // REVERSE DIRECTION
// driver.shaft(shaft); // SET DIRECTION
}