mirror of
https://github.com/bdring/Grbl_Esp32.git
synced 2025-09-03 03:13:25 +02:00
Added Trinamic SPI tests
Connection is tested for each driver using the libraries driver.test_connection(); feature at startup. Responds with one of these 3 messages for each configured driver. - [MSG:X Trinamic driver test passed] - [MSG:X Trinamic driver test failed. Check connection] - [MSG:X Trinamic driver test failed. Check motor power]
This commit is contained in:
@@ -134,12 +134,16 @@
|
||||
|
||||
void Trinamic_Init()
|
||||
{
|
||||
uint8_t testResult;
|
||||
|
||||
grbl_sendf(CLIENT_SERIAL, "[MSG:TMCStepper Init using Library Ver 0x%06x]\r\n", TMCSTEPPER_VERSION);
|
||||
|
||||
SPI.begin();
|
||||
|
||||
#ifdef X_TRINAMIC
|
||||
TRINAMIC_X.begin(); // Initiate pins and registries
|
||||
testResult = TRINAMIC_X.test_connection();
|
||||
trinamic_test_response(testResult, "X");
|
||||
TRINAMIC_X.toff(5);
|
||||
TRINAMIC_X.microsteps(settings.microsteps[X_AXIS]);
|
||||
TRINAMIC_X.rms_current(settings.current[X_AXIS] * 1000.0, settings.hold_current[X_AXIS]/100.0);
|
||||
@@ -149,6 +153,8 @@ void Trinamic_Init()
|
||||
|
||||
#ifdef Y_TRINAMIC
|
||||
TRINAMIC_Y.begin(); // Initiate pins and registries
|
||||
testResult = TRINAMIC_Y.test_connection();
|
||||
trinamic_test_response(testResult, "Y");
|
||||
TRINAMIC_Y.toff(5);
|
||||
TRINAMIC_Y.microsteps(settings.microsteps[Y_AXIS]);
|
||||
TRINAMIC_Y.rms_current(settings.current[Y_AXIS] * 1000.0, settings.hold_current[Y_AXIS]/100.0);
|
||||
@@ -158,6 +164,8 @@ void Trinamic_Init()
|
||||
|
||||
#ifdef Z_TRINAMIC
|
||||
TRINAMIC_Z.begin(); // Initiate pins and registries
|
||||
testResult = TRINAMIC_Z.test_connection();
|
||||
trinamic_test_response(testResult, "Z");
|
||||
TRINAMIC_Z.toff(5);
|
||||
TRINAMIC_Z.microsteps(settings.microsteps[Z_AXIS]);
|
||||
TRINAMIC_Z.rms_current(settings.current[Z_AXIS] * 1000.0, settings.hold_current[Z_AXIS]/100.0);
|
||||
@@ -167,6 +175,8 @@ void Trinamic_Init()
|
||||
|
||||
#ifdef A_TRINAMIC
|
||||
TRINAMIC_A.begin(); // Initiate pins and registries
|
||||
testResult = TRINAMIC_A.test_connection();
|
||||
trinamic_test_response(testResult, "A");
|
||||
TRINAMIC_A.toff(5);
|
||||
TRINAMIC_A.microsteps(settings.microsteps[A_AXIS]);
|
||||
TRINAMIC_A.rms_current(settings.current[A_AXIS] * 1000.0, settings.hold_current[A_AXIS]/100.0);
|
||||
@@ -176,6 +186,8 @@ void Trinamic_Init()
|
||||
|
||||
#ifdef B_TRINAMIC
|
||||
TRINAMIC_B.begin(); // Initiate pins and registries
|
||||
testResult = TRINAMIC_B.test_connection();
|
||||
trinamic_test_response(testResult, "B");
|
||||
TRINAMIC_B.toff(5);
|
||||
TRINAMIC_B.microsteps(settings.microsteps[B_AXIS]);
|
||||
TRINAMIC_B.rms_current(settings.current[B_AXIS] * 1000.0, settings.hold_current[B_AXIS]/100.0);
|
||||
@@ -185,6 +197,8 @@ void Trinamic_Init()
|
||||
|
||||
#ifdef C_TRINAMIC
|
||||
TRINAMIC_C.begin(); // Initiate pins and registries
|
||||
testResult = TRINAMIC_C.test_connection();
|
||||
trinamic_test_response(testResult, "C");
|
||||
TRINAMIC_C.toff(5);
|
||||
TRINAMIC_C.microsteps(settings.microsteps[C_AXIS]);
|
||||
TRINAMIC_C.rms_current(settings.current[C_AXIS] * 1000.0, settings.hold_current[C_AXIS]/100.0);
|
||||
@@ -228,4 +242,19 @@ void trinamic_change_settings()
|
||||
#endif
|
||||
}
|
||||
|
||||
void trinamic_test_response(uint8_t result, const char *axis)
|
||||
{
|
||||
grbl_sendf(CLIENT_SERIAL, "[MSG:%s Trinamic driver test ", axis);
|
||||
if (result) {
|
||||
grbl_sendf(CLIENT_SERIAL, "failed.");
|
||||
switch(result) {
|
||||
case 1: grbl_sendf(CLIENT_SERIAL, " Check connection]\r\n"); break;
|
||||
case 2: grbl_sendf(CLIENT_SERIAL, " Check motor power]\r\n"); break;
|
||||
}
|
||||
}
|
||||
else {
|
||||
grbl_sendf(CLIENT_SERIAL, "passed]\r\n");
|
||||
}
|
||||
}
|
||||
|
||||
#endif
|
@@ -27,6 +27,7 @@
|
||||
#include <TMCStepper.h> // https://github.com/teemuatlut/TMCStepper
|
||||
void Trinamic_Init();
|
||||
void trinamic_change_settings();
|
||||
void trinamic_test_response(uint8_t result, const char *axis);
|
||||
#endif
|
||||
|
||||
#endif
|
@@ -113,7 +113,7 @@ uint8_t spindle_get_state() // returns SPINDLE_STATE_DISABLE, SPINDLE_STATE_CW
|
||||
void spindle_set_speed(uint32_t pwm_value)
|
||||
{
|
||||
#ifndef SPINDLE_PWM_PIN
|
||||
grbl_sendf(CLIENT_SERIAL, "[MSG: set speed...no pin defined]\r\n");
|
||||
//grbl_sendf(CLIENT_SERIAL, "[MSG: set speed...no pin defined]\r\n");
|
||||
return;
|
||||
#else
|
||||
#ifndef SPINDLE_ENABLE_OFF_WITH_ZERO_SPEED
|
||||
|
Reference in New Issue
Block a user