Tuesday, August 13, 2019

Compiling TMCStepper for ESP32

I was trying to test TMC2130 support for the MRR ESPA and MRR ESPE using Marlin 2.0 bugsfix. However, I kept running into problems.

It started with the lack of SoftwareSerial.h.  Searching around, there is a EspSoftwareSerial library. But even using that didn't work for me. There were errors about override and such.

Then I came upon these issues in the TMCStepper repo.
ESP32 is no SoftwareSerial Compatible Platform
ESP32 compatibility

It seems the issue is that TMCStepper library has defined the ESP32 as capable of software serial. Which, technically, it is, but the available libraries to support software serial on the ESP32 somehow does not work well with the TMCStepper library. The workaround is to remove ESP32 from the list of platforms which are capable of software serial.

In TMCStepper.h, change:
#define SW_CAPABLE_PLATFORM defined(__AVR__) || defined(TARGET_LPC1768) || defined(ARDUINO_ARCH_ESP32) || defined(ARDUINO_ARCH_STM32F1)
to:
#define SW_CAPABLE_PLATFORM defined(__AVR__) || defined(TARGET_LPC1768) || defined(ARDUINO_ARCH_STM32F1)

Marlin 2.0 should then compile without errors.

Next step, flash the firmware onto the MRR ESPA/ESPE and check that the stepper motor actually moves.

4 comments:

Teck said...

A PR has been generated to solve the software serial issue for the ESP32 when using the TMCStepper library.

Remove ESP32 from list of SW_CAPABLE_PLATFORMs

Hopefully, this gets merged into the library, and people no longer need to make their own changes.

Teck said...

Test printing now on the MRR ESPE (which uses I2S to drive the stepper motors), with TMC2130 in SPI mode for X and Y axes. A significant reduction in noise. Let's see how the 5-hour print goes, since my stepper drivers are the BIGTREETECH ones with the chip on the top of the board instead of the bottom, so there may be cooling issues.

Teck said...

Small problem. The printer is now so much quieter during printing (compared to when I was using A4988 drivers) that I almost forget I am printing something. It is a happy problem, though.

I am still running A4988 drivers on the Z and E0 motors, but the noise generated is really small. Also, I am using the X and Y TMC2130 drivers in SPI mode, hybrid, so at moves above 100mm/s, there is a bit of noise. But only a bit, and a lot less than A4988 drivers.

For board cooling, I am using a 80mm x 80mm x 10mm 24V fan.

My 5015 radial fan for part cooling can still be heard when it kicks in at 100%. But I usually run it at 50% for cooling. 100% only kicks in when layer time is less than 10s.

All in, the conclusion is that with just two TMC2130 drivers, there is a significant reduction in noise.

Teck said...

The PR has been merged, so there is no need to edit the header file by hand anymore. ESP32 has been removed from the list of software serial platforms.