From 1f27377ce639d72e465bccf2ce9711166aa38eb4 Mon Sep 17 00:00:00 2001 From: bdring Date: Wed, 19 Aug 2020 11:32:58 -0600 Subject: [PATCH] Trinamic status (#563) * Adding extended testing and status - checks for shorts, opens, temt, p/s issues * Update - test function now looks for - connectiviy - motor power - coil shorts - temp issues * Update Machine.h * Update spi_daisy_4axis_xyyz.h --- Grbl_Esp32/src/Grbl.h | 2 +- Grbl_Esp32/src/Motors/TrinamicDriver.cpp | 34 +++++++++++++++++++++++- 2 files changed, 34 insertions(+), 2 deletions(-) diff --git a/Grbl_Esp32/src/Grbl.h b/Grbl_Esp32/src/Grbl.h index 8218d263..c9bc2753 100644 --- a/Grbl_Esp32/src/Grbl.h +++ b/Grbl_Esp32/src/Grbl.h @@ -23,7 +23,7 @@ // Grbl versioning system #define GRBL_VERSION "1.3a" -#define GRBL_VERSION_BUILD "20200813" +#define GRBL_VERSION_BUILD "20200819" //#include #include diff --git a/Grbl_Esp32/src/Motors/TrinamicDriver.cpp b/Grbl_Esp32/src/Motors/TrinamicDriver.cpp index 4d5bd043..42c159c7 100644 --- a/Grbl_Esp32/src/Motors/TrinamicDriver.cpp +++ b/Grbl_Esp32/src/Motors/TrinamicDriver.cpp @@ -105,7 +105,39 @@ namespace Motors { case 2: grbl_msg_sendf(CLIENT_SERIAL, MSG_LEVEL_INFO, "%s Trinamic driver test failed. Check motor power", _axis_name); return false; - default: grbl_msg_sendf(CLIENT_SERIAL, MSG_LEVEL_INFO, "%s Trinamic driver test passed", _axis_name); return true; + default: + // driver responded, so check for other errors from the DRV_STATUS register + + TMC2130_n ::DRV_STATUS_t status { 0 }; // a useful struct to access the bits. + status.sr = tmcstepper->DRV_STATUS(); + + bool err = false; + // look for open loan or short 2 ground on a and b + if (status.s2ga || status.s2gb) { + grbl_msg_sendf(CLIENT_SERIAL, + MSG_LEVEL_INFO, + "%s Motor Short Coil a:%s b:%s", + _axis_name, + status.s2ga ? "Y" : "N", + status.s2gb ? "Y" : "N"); + err = true; + } + // check for over temp or pre-warning + if (status.ot || status.otpw) { + grbl_msg_sendf(CLIENT_SERIAL, + MSG_LEVEL_INFO, + "%s Driver Temp Warning:%s Fault:%s", + _axis_name, + status.otpw ? "Y" : "N", + status.ot ? "Y" : "N"); + err = true; + } + + if (err) + return false; + + grbl_msg_sendf(CLIENT_SERIAL, MSG_LEVEL_INFO, "%s Trinamic driver test passed", _axis_name); + return true; } }