Description
Hello. I have the problem to probably connect to the uart of the TMC 2209. I have some experiences with Arduino and stepper drivers, but not that much to be able to figure out what my issue is. I used your example for the bidirectional communication to analyze the stallGuard behavior. Sadly, I didn't get the stepper to connect. The plan is to use the stepper as a cable cutting machine and detect if the isolation was cut and stop. I added the pinout plan for the EspDuino on the CNCShield and also added my cabling. And yes I know nobody likes the espduino+CNCShield mix because the pins are mixed up but with the ESP you have 3 Serial ports and can still use the board with some workarounds.
I tried to show my setup as clearly as possible.
The code that I used
#include <TMC2209.h>
TMC2209 cutter;
HardwareSerial & serial_stream = Serial2;
const long SERIAL_BAUD_RATE = 115200;
const int DELAY = 1000;
// current values may need to be reduced to prevent overheating depending on
// specific motor and power supply voltage
const uint8_t RUN_CURRENT_PERCENT = 20;
const int32_t VELOCITY = 20000;
const uint8_t STALL_GUARD_THRESHOLD = 50;
const int RX_PIN = 2;
const int TX_PIN = 4;
const int enablePin = 12;
//CNC-Shield with ESPduino
//#define STEP_X 26
//#define STEP_Y 25
//#define DIR_X 16
//#define DIR_Y 27
void setup()
{
Serial.begin(115200);
pinMode(enablePin, OUTPUT);
digitalWrite(enablePin, LOW);
cutter.setup(serial_stream, SERIAL_BAUD_RATE, TMC2209::SERIAL_ADDRESS_0, RX_PIN, TX_PIN);
cutter.setRunCurrent(RUN_CURRENT_PERCENT);
cutter.setStallGuardThreshold(STALL_GUARD_THRESHOLD);
cutter.enable();
cutter.moveAtVelocity(VELOCITY);
}
void loop()
{
if (not cutter.isSetupAndCommunicating())
{
Serial.println("Stepper driver not setup and communicating!");
return;
}
Serial.print("run_current_percent = ");
Serial.println(RUN_CURRENT_PERCENT);
Serial.print("stall_guard_threshold = ");
Serial.println(STALL_GUARD_THRESHOLD);
uint16_t stall_guard_result = cutter.getStallGuardResult();
Serial.print("stall_guard_result = ");
Serial.println(stall_guard_result);
Serial.println();
delay(DELAY);
}