Trinamic TMC2209 Stall Guard - help please

Hey, I recently got the TMC2209 stepper motor driver to use along with my NEMA 17, and I have no issues getting it to work, but I'm having trouble trying to use some features such as Stall Guard as can be demonstrated here:

I tried following the github examples and documentation, but for the love of me I just can't get anything out of it, and I think it really lacks, there is also barely any non 3D printed related examples and documentation which makes it just really hard.

So I tried to use the following example:

It would seem(not sure...) that the example uses MEGA board, but I only own uno/nano so I decided to try it with the uno and just change the relevant pins to PWM pins on the arduino uno.

I ended up with the code below:

Wiring:
I'm using the arduino 12v and 5v to power up the TMC2209 5v/12v ports.
NEMA 17 wiring - A/B - 1/2 pins(standard)
TMC2209 EN pinout - Arduino pin D7
TMC2209 STEP pinout - Arduino pin D6

TMC2209 DIR pinout - Arduino pin D5

I just can't find ANY non 3D Printer/SKR examples on the internet, so would really love to get some information.
I obviously tried adjusting the STALL_VALUE from 0 to 255, but nothing actually worked, I don't think that's really the issue though, when trying to read the serial output I'm just getting bunch of question marks:

-> \⸮⸮⸮⸮⸮⸮⸮⸮⸮⸮⸮⸮⸮⸮⸮⸮⸮⸮⸮⸮⸮⸮⸮⸮⸮⸮⸮⸮⸮⸮⸮⸮⸮⸮⸮⸮⸮⸮⸮⸮⸮⸮⸮⸮⸮⸮⸮⸮⸮⸮⸮⸮⸮⸮⸮⸮⸮⸮⸮⸮⸮⸮⸮⸮⸮⸮⸮⸮⸮⸮⸮⸮⸮⸮⸮⸮⸮⸮⸮⸮⸮⸮⸮⸮⸮⸮⸮⸮⸮⸮⸮⸮⸮⸮⸮⸮⸮⸮⸮⸮⸮⸮⸮⸮⸮⸮⸮⸮⸮⸮⸮⸮⸮⸮⸮⸮⸮⸮⸮⸮⸮⸮⸮⸮⸮⸮⸮

So that would make sense that it doesn't work, I would assume it's not specifically a code issue, but possibly some errors I'm making with incorrect pinouts or the way I set everything up, but again due to lack of documentation I really have no idea what is wrong and why.

Any help would be much appreciated! Thanks!

The video says the stall detect can be pinned out or read from SPI - so you need to interface to either of
these methods I think.

First you need to change the baud rate of your serial output to match that in your code.(115200) You also have to connect the TX and RX pin to the Arduino and define it in your code. On my board it is done by connecting PDN pin closest to the pot to the arduino and with an 1k resistor as shown here:

Then you want to use this driver code instead:
TMC2209Stepper driver(SW_RX, SW_TX, R_SENSE, DRIVER_ADDRESS);

You should then be able to read stallguard values.

12bit35mm:
First you need to change the baud rate of your serial output to match that in your code.(115200) You also have to connect the TX and RX pin to the Arduino and define it in your code. On my board it is done by connecting PDN pin closest to the pot to the arduino and with an 1k resistor as shown here:
BIGTREETECH-TMC2209-V1.2/manual/TMC2209-V1.2-manual.pdf at master · bigtreetech/BIGTREETECH-TMC2209-V1.2 · GitHub

Then you want to use this driver code instead:
TMC2209Stepper driver(SW_RX, SW_TX, R_SENSE, DRIVER_ADDRESS);

You should then be able to read stallguard values.

Wow! The github link is amazing! So short and detailed to the point it's amazing.
I actually somewhat was able to get it to work by using the following example I found:

But I encountered some issues there which I wasn't able to overcome yet.
I did manage to get the motor to stop upon stall, but I had 2 issues:

  1. The documented way of getting the motor back up again(ENN=HIGH, LOW) just didn't work for me.
  2. I was not able to accurately detect a stall:
    There should be a few ways to detect a stall, either by the SG_RESULT() < STALL_THRESHOLD, or by reading the DIAG values, the issue is that none of them was consistent for me....
    DIAG values were not accurate before/in stall, and the SG_RESULT was also inaccurate in a similar way, which lead me to being unable to get it to work really and I left it aside due to lack of time.

This week I tried getting back to it, but something even worse happened, I just couldn't get the stall guard to work at all. I used exactly the same code, exactly the same hardware. The hardware was set aside untouched and I obviously verified that all the pins are correct, I have no idea why that happens, I spent 2 days on it and then again due to lack of time had to set it aside.

I'm wondering if I should try to use SPI(I think??) instead of UART, I'm really not familiar with that stuff...The previous stepper motors I worked with were much simpler to use, due to them being more common I guess, finding help with trinamic's drivers is pretty hard and a bit frustrating, cause I'm smashing my head over things that are not extremely complicated, but just lacks some actual use case examples in my opinion.
Still, once I'll get everything to work it would probably be worth it :slight_smile:

Thanks!

This topic was automatically closed 120 days after the last reply. New replies are no longer allowed.