teemuatlut / TMC2130Stepper

Arduino library for Trinamic TMC2130 Stepper driver
MIT License
159 stars 50 forks source link

DIAG0 & DIAG1 pin for stall detection #79

Closed ziyangwang007 closed 5 years ago

ziyangwang007 commented 5 years ago

Hi,

I tried to use DIAG0 & DIAG1 Outputs for quick reaction.

I used DIAG0 for "over temperture pre warning" at first. it works well, because I check the "otpw" by SPI. The results by SPI is same with results by DIAG PIN. A part of my code is like this: driver.diag0_otpw(true); driver.diag0_int_pushpull(true); //active high Serial.println(digitalRead(DIAGPin)); //DIAG Serial.println(driver.checkOT()); //SPI

It works.

But for stall detection, it only works when I use SPI cummunication. I could read stallguard and SG_RESULTS. But stall detection doesn't work by DIAG0 or DIAG1. A part of my code is like this: //driver.diag0_stall(true); //driver.diag0_int_pushpull(true); //active high //driver.diag0_int_pushpull(false); //active low driver.diag1_stall(true); driver.diag1_pushpull(true); //active high //driver.diag1_pushpull(false); //active low Serial.println(driver.stallguard()); //SPI Serial.println(digitalRead(DIAGPin)); //DIAG

I tried several times, but DIAG0 or DIAG1 output pin doesn't work for stall detection. Do you have any ideas?

Thanks!

ziyangwang007 commented 5 years ago

Sorry, I forget to set “TCOOLTHRS”. It is ok now.