makerbase-mks / MKS-StepStick-Driver

Include MKS TMC2209, MKS TMC2225, MKS TMC2208, MKS TB67S109 and so on
https://www.aliexpress.com/store/group/StepStick-Driver/1047297_517009799.html?spm=a2g0o.detail.0.0.1116202bOPx9IV
54 stars 15 forks source link

Weird UART problem with ESP32 #11

Open Angelo13C opened 3 months ago

Angelo13C commented 3 months ago

Hi! I have a MKS TMC2209 v2.0 silentstepstick driver connected to a custom PCB that I made. I am using the TMC2209 arduino library to communicate with my driver, this is the code (it's a slightly modified example present in the library's repo):

#include <TMC2209.h>

// This example will not work on Arduino boards without HardwareSerial ports,
// such as the Uno, Nano, and Mini.
//
// See this reference for more details:
// https://www.arduino.cc/reference/en/language/functions/communication/serial/

HardwareSerial & serial_stream = Serial1;

const long SERIAL_BAUD_RATE = 115200;
const int DELAY = 1000;
const int RX_PIN = 17;
const int TX_PIN = 18;

// Instantiate TMC2209
TMC2209 stepper_driver;

void setup()
{
  Serial.begin(SERIAL_BAUD_RATE);

  stepper_driver.setup(serial_stream,SERIAL_BAUD_RATE,TMC2209::SERIAL_ADDRESS_0, RX_PIN, TX_PIN);
  stepper_driver.setReplyDelay(10);
}

void loop()
{
  if (stepper_driver.isSetupAndCommunicating())
  {
    Serial.println("Stepper driver is setup and communicating!");
    Serial.println("Try turning driver power off to see what happens.");
  }
  else if (stepper_driver.isCommunicatingButNotSetup())
  {
    Serial.println("Stepper driver is communicating but not setup!");
    Serial.println("Running setup again...");
    stepper_driver.setup(serial_stream);
  }
  else
  {
    Serial.println("Stepper driver is not communicating!");
    Serial.println("Try turning driver power on to see what happens.");
  }
  Serial.println();
  delay(DELAY);
}

Now it always prints "Stepper driver is not communicating!"... The weird thing is that I attached my oscilloscope to the PDN_UART pin of the driver and this is what I see

image

As you can see the ESP32 sends the data to the driver, the driver replies but the 0 bits of the reply don't go all the way down to 0V but stay around 2.4V.. which is really weird, and probably my ESP32 doesn't recognize 2.4V as a low value (because it's too high voltage).

Do you have any idea what the problem could be?

I connected my driver like in this image: https://github.com/makerbase-mks/MKS-StepStick-Driver/issues/6#issuecomment-1296336860

The only thing is that the I/O voltage is 3.3V and not 5V (because I am not using an Arduino but I am using an ESP32)

Angelo13C commented 3 months ago

I think it's related to this problem: https://community.particle.io/t/p2-module-tmc2209-driver-tx-rx-pullup-issue-possibly-preventing-bidirectional-comms/64194

But I can't understand how to solve it (I am using an ESP32-S3-WROOM-1 and not the one in the link.. but the problem is similar, probably a pull up resistor?)