1
0
mirror of https://github.com/bdring/Grbl_Esp32.git synced 2025-08-31 01:59:54 +02:00

Merge pull request #378 from bdring/Devt

Devt
This commit is contained in:
bdring
2020-04-12 20:12:26 -05:00
committed by GitHub
5 changed files with 316 additions and 42 deletions

View File

@@ -28,7 +28,7 @@
#ifdef N_AXIS
#undef N_AXIS
#endif
#define N_AXIS 3 // can be 3 or 4. (if 3 install bypass jumper next to the A driver)
#define N_AXIS 4 // can be 3 or 4. (if 3 install bypass jumper next to the A driver)
#define USE_TRINAMIC
#define TRINAMIC_DAISY_CHAIN
@@ -37,15 +37,10 @@
// The hardware enable pin is tied to ground
#define USE_TRINAMIC_ENABLE
// allow two motors on an axis
#define USE_GANGED_AXES
#define X_DRIVER_TMC2130 // Which Driver Type?
#define X_RSENSE 0.11f // .11 Ohm...typical of 2130 type 0.075 typical for TMC5160
#define X_STEP_PIN GPIO_NUM_12
#define X_DIRECTION_PIN GPIO_NUM_14
#define X2_STEP_PIN GPIO_NUM_33
#define X2_DIRECTION_PIN GPIO_NUM_32
#define X_TRINAMIC // using SPI control
#define X_CS_PIN GPIO_NUM_17 // Daisy Chain, all share same CS pin

View File

@@ -0,0 +1,98 @@
/*
spi_daisy_4axisxyyz.h
Part of Grbl_ESP32
Pin assignments for a 3-axis with Y ganged using Triaminic drivers
in daisy-chained SPI mode.
https://github.com/bdring/4_Axis_SPI_CNC
2019 - Bart Dring
2020 - Mitch Bradley
Grbl_ESP32 is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
Grbl is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with Grbl_ESP32. If not, see <http://www.gnu.org/licenses/>.
*/
#define MACHINE_NAME "SPI_DAISY_4X_xyyz"
#ifdef N_AXIS
#undef N_AXIS
#endif
#define N_AXIS 3 // can be 3 or 4. (if 3 install bypass jumper next to the A driver)
#define USE_TRINAMIC
#define TRINAMIC_DAISY_CHAIN
// Use SPI enable instead of the enable pin
// The hardware enable pin is tied to ground
#define USE_TRINAMIC_ENABLE
// allow two motors on an axis
#define USE_GANGED_AXES
// Y motor connects to the 1st driver
#define X_DRIVER_TMC2130 // Which Driver Type?
#define X_RSENSE 0.11f // .11 Ohm...typical of 2130 type 0.075 typical for TMC5160
#define X_STEP_PIN GPIO_NUM_12
#define X_DIRECTION_PIN GPIO_NUM_14
#define X_TRINAMIC // using SPI control
#define X_CS_PIN GPIO_NUM_17 // Daisy Chain, all share same CS pin
// Y motor connects to the 2nd driver
#define Y_DRIVER_TMC2130 // Which Driver Type?
#define Y_RSENSE 0.11f // .11 Ohm...typical of 2130 type 0.075 typical for TMC5160
#define Y_STEP_PIN GPIO_NUM_27
#define Y_DIRECTION_PIN GPIO_NUM_26
#define Y_TRINAMIC // using SPI control
#define Y_CS_PIN X_CS_PIN // Daisy Chain, all share same CS pin
// Y2 motor connects to the 2nd driver
#define Y2_DRIVER_TMC2130 // Which Driver Type?
#define Y2_RSENSE 0.11f // .11 Ohm...typical of 2130 type 0.075 typical for TMC5160
#define Y2_STEP_PIN GPIO_NUM_15 // Z on schem
#define Y2_DIRECTION_PIN GPIO_NUM_2 // Z on schem
#define Y2_TRINAMIC // using SPI control
#define Y2_CS_PIN X_CS_PIN // Daisy Chain, all share same CS pin
#define Y_AXIS_SQUARING // optional
// Z Axis motor connects to the 4th driver
#define Z_DRIVER_TMC2130 // Which Driver Type?
#define Z_RSENSE 0.11f // .11 Ohm...typical of 2130 type 0.075 typical for TMC5160
#define Z_STEP_PIN GPIO_NUM_33 // A on schem
#define Z_DIRECTION_PIN GPIO_NUM_32 // A on schem
#define Z_TRINAMIC // using SPI control
#define Z_CS_PIN X_CS_PIN // Daisy Chain, all share same CS pin
// Mist is a 3.3V output
// Turn on with M7 and off with M9
#define COOLANT_MIST_PIN GPIO_NUM_21
#define SPINDLE_PWM_PIN GPIO_NUM_25
#define SPINDLE_ENABLE_PIN GPIO_NUM_4
// Relay operation
// Install Jumper near relay
// For spindle Use max RPM of 1
// For PWM remove jumper and set MAX RPM to something higher ($30 setting)
// Interlock jumper along top edge needs to be installed for both versions
#define DEFAULT_SPINDLE_RPM_MAX 1 // Should be 1 for relay operation
#define PROBE_PIN GPIO_NUM_22
#define X_LIMIT_PIN GPIO_NUM_36
#define Y_LIMIT_PIN GPIO_NUM_39
#define Z_LIMIT_PIN GPIO_NUM_34
#define LIMIT_MASK B0111

View File

@@ -20,7 +20,7 @@
// Grbl versioning system
#define GRBL_VERSION "1.1f"
#define GRBL_VERSION_BUILD "20200407"
#define GRBL_VERSION_BUILD "20200412"
//#include <sdkconfig.h>
#include <Arduino.h>

View File

@@ -40,94 +40,148 @@
the last SPI driver.
*/
#ifndef TRINAMIC_DAISY_CHAIN
#define X_DRIVER_SPI_INDEX -1
#define Y_DRIVER_SPI_INDEX -1
#define Z_DRIVER_SPI_INDEX -1
#define A_DRIVER_SPI_INDEX -1
#define B_DRIVER_SPI_INDEX -1
#define C_DRIVER_SPI_INDEX -1
#else
#define X_DRIVER_SPI_INDEX 1
#define Y_DRIVER_SPI_INDEX 2
#define Z_DRIVER_SPI_INDEX 3
#define A_DRIVER_SPI_INDEX 4
#define B_DRIVER_SPI_INDEX 5
#define C_DRIVER_SPI_INDEX 6
#endif
// TODO try to use the #define ## method to clean this up
//#define DRIVER(driver, axis) driver##Stepper = TRINAMIC_axis## = driver##Stepper(axis##_CS_PIN, axis##_RSENSE);
#ifdef X_TRINAMIC
#ifdef X_DRIVER_TMC2130
TMC2130Stepper TRINAMIC_X = TMC2130Stepper(X_CS_PIN, X_RSENSE, X_DRIVER_SPI_INDEX);
TMC2130Stepper TRINAMIC_X = TMC2130Stepper(X_CS_PIN, X_RSENSE, get_next_trinamic_driver_index());
#endif
#ifdef X_DRIVER_TMC2209
TMC2209Stepper TRINAMIC_X = TMC2209Stepper(X_CS_PIN, X_RSENSE, X_DRIVER_SPI_INDEX);
TMC2209Stepper TRINAMIC_X = TMC2209Stepper(X_CS_PIN, X_RSENSE, get_next_trinamic_driver_index());
#endif
#ifdef X_DRIVER_TMC5160
TMC5160Stepper TRINAMIC_X = TMC5160Stepper(X_CS_PIN, X_RSENSE, X_DRIVER_SPI_INDEX);
TMC5160Stepper TRINAMIC_X = TMC5160Stepper(X_CS_PIN, X_RSENSE, get_next_trinamic_driver_index());
#endif
#endif
#ifdef X2_TRINAMIC
#ifdef X2_DRIVER_TMC2130
TMC2130Stepper TRINAMIC_X2 = TMC2130Stepper(X2_CS_PIN, X2_RSENSE, get_next_trinamic_driver_index());
#endif
#ifdef X2_DRIVER_TMC2209
TMC2209Stepper TRINAMIC_X2 = TMC2209Stepper(X2_CS_PIN, X2_RSENSE, get_next_trinamic_driver_index());
#endif
#ifdef X2_DRIVER_TMC5160
TMC5160Stepper TRINAMIC_X2 = TMC5160Stepper(X2_CS_PIN, X2_RSENSE, get_next_trinamic_driver_index());
#endif
#endif
#ifdef Y_TRINAMIC
#ifdef Y_DRIVER_TMC2130
TMC2130Stepper TRINAMIC_Y = TMC2130Stepper(Y_CS_PIN, Y_RSENSE, Y_DRIVER_SPI_INDEX);
TMC2130Stepper TRINAMIC_Y = TMC2130Stepper(Y_CS_PIN, Y_RSENSE, get_next_trinamic_driver_index());
#endif
#ifdef Y_DRIVER_TMC2209
TMC2209Stepper TRINAMIC_Y = TMC2209Stepper(Y_CS_PIN, Y_RSENSE, Y_DRIVER_SPI_INDEX);
TMC2209Stepper TRINAMIC_Y = TMC2209Stepper(Y_CS_PIN, Y_RSENSE, get_next_trinamic_driver_index());
#endif
#ifdef Y_DRIVER_TMC5160
TMC5160Stepper TRINAMIC_Y = TMC5160Stepper(Y_CS_PIN, Y_RSENSE, Y_DRIVER_SPI_INDEX);
TMC5160Stepper TRINAMIC_Y = TMC5160Stepper(Y_CS_PIN, Y_RSENSE, get_next_trinamic_driver_index());
#endif
#endif
#ifdef Y2_TRINAMIC
#ifdef Y2_DRIVER_TMC2130
TMC2130Stepper TRINAMIC_Y2 = TMC2130Stepper(Y2_CS_PIN, Y2_RSENSE, get_next_trinamic_driver_index());
#endif
#ifdef Y2_DRIVER_TMC2209
TMC2209Stepper TRINAMIC_Y2 = TMC2209Stepper(Y2_CS_PIN, Y2_RSENSE, get_next_trinamic_driver_index());
#endif
#ifdef Y2_DRIVER_TMC5160
TMC5160Stepper TRINAMIC_Y2 = TMC5160Stepper(Y2_CS_PIN, Y2_RSENSE, get_next_trinamic_driver_index());
#endif
#endif
#ifdef Z_TRINAMIC
#ifdef Z_DRIVER_TMC2130
TMC2130Stepper TRINAMIC_Z = TMC2130Stepper(Z_CS_PIN, Z_RSENSE, Z_DRIVER_SPI_INDEX);
TMC2130Stepper TRINAMIC_Z = TMC2130Stepper(Z_CS_PIN, Z_RSENSE, get_next_trinamic_driver_index());
#endif
#ifdef Z_DRIVER_TMC2209
TMC2209Stepper TRINAMIC_Z = TMC2209Stepper(Z_CS_PIN, Z_RSENSE, Z_DRIVER_SPI_INDEX);
TMC2209Stepper TRINAMIC_Z = TMC2209Stepper(Z_CS_PIN, Z_RSENSE, get_next_trinamic_driver_index());
#endif
#ifdef Z_DRIVER_TMC5160
TMC5160Stepper TRINAMIC_Z = TMC5160Stepper(Z_CS_PIN, Z_RSENSE, Z_DRIVER_SPI_INDEX);
TMC5160Stepper TRINAMIC_Z = TMC5160Stepper(Z_CS_PIN, Z_RSENSE, get_next_trinamic_driver_index());
#endif
#endif
#ifdef Z2_TRINAMIC
#ifdef Z2_DRIVER_TMC2130
TMC2130Stepper TRINAMIC_Z2 = TMC2130Stepper(Z2_CS_PIN, Z2_RSENSE, get_next_trinamic_driver_index());
#endif
#ifdef Z2_DRIVER_TMC2209
TMC2209Stepper TRINAMIC_Z2 = TMC2209Stepper(Z2_CS_PIN, Z2_RSENSE, get_next_trinamic_driver_index());
#endif
#ifdef Z2_DRIVER_TMC5160
TMC5160Stepper TRINAMIC_Z2 = TMC5160Stepper(Z2_CS_PIN, Z2_RSENSE, get_next_trinamic_driver_index());
#endif
#endif
#ifdef A_TRINAMIC
#ifdef A_DRIVER_TMC2130
TMC2130Stepper TRINAMIC_A = TMC2130Stepper(A_CS_PIN, A_RSENSE, A_DRIVER_SPI_INDEX);
TMC2130Stepper TRINAMIC_A = TMC2130Stepper(A_CS_PIN, A_RSENSE, get_next_trinamic_driver_index());
#endif
#ifdef A_DRIVER_TMC2209
TMC2209Stepper TRINAMIC_A = TMC2209Stepper(A_CS_PIN, A_RSENSE, A_DRIVER_SPI_INDEX);
TMC2209Stepper TRINAMIC_A = TMC2209Stepper(A_CS_PIN, A_RSENSE, get_next_trinamic_driver_index());
#endif
#ifdef A_DRIVER_TMC5160
TMC5160Stepper TRINAMIC_A = TMC5160Stepper(A_CS_PIN, A_RSENSE, A_DRIVER_SPI_INDEX);
TMC5160Stepper TRINAMIC_A = TMC5160Stepper(A_CS_PIN, A_RSENSE, get_next_trinamic_driver_index());
#endif
#endif
#ifdef A2_TRINAMIC
#ifdef A2_DRIVER_TMC2130
TMC2130Stepper TRINAMIC_A2 = TMC2130Stepper(A2_CS_PIN, A2_RSENSE, get_next_trinamic_driver_index());
#endif
#ifdef A2_DRIVER_TMC2209
TMC2209Stepper TRINAMIC_A2 = TMC2209Stepper(A2_CS_PIN, A_RSENSE, get_next_trinamic_driver_index());
#endif
#ifdef A2_DRIVER_TMC5160
TMC5160Stepper TRINAMIC_A2 = TMC5160Stepper(A2_CS_PIN, A2_RSENSE, get_next_trinamic_driver_index());
#endif
#endif
#ifdef B_TRINAMIC
#ifdef B_DRIVER_TMC2130
TMC2130Stepper TRINAMIC_B = TMC2130Stepper(B_CS_PIN, B_RSENSE, B_DRIVER_SPI_INDEX);
TMC2130Stepper TRINAMIC_B = TMC2130Stepper(B_CS_PIN, B_RSENSE, get_next_trinamic_driver_index());
#endif
#ifdef B_DRIVER_TMC2209
TMC2209Stepper TRINAMIC_B = TMC2209Stepper(B_CS_PIN, B_RSENSE, B_DRIVER_SPI_INDEX);
TMC2209Stepper TRINAMIC_B = TMC2209Stepper(B_CS_PIN, B_RSENSE, get_next_trinamic_driver_index());
#endif
#ifdef B_DRIVER_TMC5160
TMC5160Stepper TRINAMIC_B = TMC5160Stepper(B_CS_PIN, B_RSENSE, B_DRIVER_SPI_INDEX);
TMC5160Stepper TRINAMIC_B = TMC5160Stepper(B_CS_PIN, B_RSENSE, get_next_trinamic_driver_index());
#endif
#endif
#ifdef B2_TRINAMIC
#ifdef B2_DRIVER_TMC2130
TMC2130Stepper TRINAMIC_B2 = TMC2130Stepper(B2_CS_PIN, B2_RSENSE, get_next_trinamic_driver_index());
#endif
#ifdef B2_DRIVER_TMC2209
TMC2209Stepper TRINAMIC_B2 = TMC2209Stepper(B2_CS_PIN, B2_RSENSE, get_next_trinamic_driver_index());
#endif
#ifdef B2_DRIVER_TMC5160
TMC5160Stepper TRINAMIC_B2 = TMC5160Stepper(B2_CS_PIN, B2_RSENSE, get_next_trinamic_driver_index());
#endif
#endif
#ifdef C_TRINAMIC
#ifdef C_DRIVER_TMC2130
TMC2130Stepper TRINAMIC_c = TMC2130Stepper(C_CS_PIN, C_RSENSE, C_DRIVER_SPI_INDEX);
TMC2130Stepper TRINAMIC_c = TMC2130Stepper(C_CS_PIN, C_RSENSE, get_next_trinamic_driver_index());
#endif
#ifdef C_DRIVER_TMC2209
TMC2209Stepper TRINAMIC_C = TMC2209Stepper(C_CS_PIN, C_RSENSE, C_DRIVER_SPI_INDEX);
TMC2209Stepper TRINAMIC_C = TMC2209Stepper(C_CS_PIN, C_RSENSE, get_next_trinamic_driver_index());
#endif
#ifdef C_DRIVER_TMC5160
TMC5160Stepper TRINAMIC_C = TMC5160Stepper(C_CS_PIN, C_RSENSE, C_DRIVER_SPI_INDEX);
TMC5160Stepper TRINAMIC_C = TMC5160Stepper(C_CS_PIN, C_RSENSE, get_next_trinamic_driver_index());
#endif
#endif
#ifdef C2_TRINAMIC
#ifdef C2_DRIVER_TMC2130
TMC2130Stepper TRINAMIC_C2 = TMC2130Stepper(C2_CS_PIN, C2_RSENSE, get_next_trinamic_driver_index());
#endif
#ifdef C2_DRIVER_TMC2209
TMC2209Stepper TRINAMIC_C2 = TMC2209Stepper(C2_CS_PIN, C2_RSENSE, get_next_trinamic_driver_index());
#endif
#ifdef C2_DRIVER_TMC5160
TMC5160Stepper TRINAMIC_C2 = TMC5160Stepper(C2_CS_PIN, C2_RSENSE, get_next_trinamic_driver_index());
#endif
#endif
@@ -138,15 +192,25 @@ void Trinamic_Init() {
machine_trinamic_setup();
return;
#endif
#ifdef X_TRINAMIC
#ifdef X_TRINAMIC
TRINAMIC_X.begin(); // Initiate pins and registries
trinamic_test_response(TRINAMIC_X.test_connection(), "X");
trinamic_test_response(TRINAMIC_X.test_connection(), "X");
TRINAMIC_X.toff(TRINAMIC_DEFAULT_TOFF);
TRINAMIC_X.microsteps(settings.microsteps[X_AXIS]);
TRINAMIC_X.rms_current(settings.current[X_AXIS] * 1000.0, settings.hold_current[X_AXIS] / 100.0);
TRINAMIC_X.en_pwm_mode(1); // Enable extremely quiet stepping
TRINAMIC_X.pwm_autoscale(1);
#endif
#ifdef X2_TRINAMIC
TRINAMIC_X2.begin(); // Initiate pins and registries
trinamic_test_response(TRINAMIC_X2.test_connection(), "X2");
TRINAMIC_X2.toff(TRINAMIC_DEFAULT_TOFF);
TRINAMIC_X2.microsteps(settings.microsteps[X_AXIS]);
TRINAMIC_X2.rms_current(settings.current[X_AXIS] * 1000.0, settings.hold_current[X_AXIS] / 100.0);
TRINAMIC_X2.en_pwm_mode(1); // Enable extremely quiet stepping
TRINAMIC_X2.pwm_autoscale(1);
#endif
#ifdef Y_TRINAMIC
TRINAMIC_Y.begin(); // Initiate pins and registries
trinamic_test_response(TRINAMIC_Y.test_connection(), "Y");
@@ -156,6 +220,16 @@ void Trinamic_Init() {
TRINAMIC_Y.en_pwm_mode(1); // Enable extremely quiet stepping
TRINAMIC_Y.pwm_autoscale(1);
#endif
#ifdef Y2_TRINAMIC
TRINAMIC_Y2.begin(); // Initiate pins and registries
trinamic_test_response(TRINAMIC_Y2.test_connection(), "Y2");
TRINAMIC_Y2.toff(TRINAMIC_DEFAULT_TOFF);
TRINAMIC_Y2.microsteps(settings.microsteps[Y_AXIS]);
TRINAMIC_Y2.rms_current(settings.current[Y_AXIS] * 1000.0, settings.hold_current[Y_AXIS] / 100.0);
TRINAMIC_Y2.en_pwm_mode(1); // Enable extremely quiet stepping
TRINAMIC_Y2.pwm_autoscale(1);
#endif
#ifdef Z_TRINAMIC
TRINAMIC_Z.begin(); // Initiate pins and registries
trinamic_test_response(TRINAMIC_Z.test_connection(), "Z");
@@ -165,6 +239,16 @@ void Trinamic_Init() {
TRINAMIC_Z.en_pwm_mode(1); // Enable extremely quiet stepping
TRINAMIC_Z.pwm_autoscale(1);
#endif
#ifdef Z2_TRINAMIC
TRINAMIC_Z2.begin(); // Initiate pins and registries
trinamic_test_response(TRINAMIC_Z2.test_connection(), "Z2");
TRINAMIC_Z2.toff(TRINAMIC_DEFAULT_TOFF);
TRINAMIC_Z2.microsteps(settings.microsteps[Z_AXIS]);
TRINAMIC_Z2.rms_current(settings.current[Z_AXIS] * 1000.0, settings.hold_current[Z_AXIS] / 100.0);
TRINAMIC_Z2.en_pwm_mode(1); // Enable extremely quiet stepping
TRINAMIC_Z2.pwm_autoscale(1);
#endif
#ifdef A_TRINAMIC
TRINAMIC_A.begin(); // Initiate pins and registries
trinamic_test_response(TRINAMIC_A.test_connection(), "A");
@@ -174,6 +258,16 @@ void Trinamic_Init() {
TRINAMIC_A.en_pwm_mode(1); // Enable extremely quiet stepping
TRINAMIC_A.pwm_autoscale(1);
#endif
#ifdef A2_TRINAMIC
TRINAMIC_A2.begin(); // Initiate pins and registries
trinamic_test_response(TRINAMIC_A2.test_connection(), "A2");
TRINAMIC_A2.toff(TRINAMIC_DEFAULT_TOFF);
TRINAMIC_A2.microsteps(settings.microsteps[A_AXIS]);
TRINAMIC_A2.rms_current(settings.current[A_AXIS] * 1000.0, settings.hold_current[A_AXIS] / 100.0);
TRINAMIC_A2.en_pwm_mode(1); // Enable extremely quiet stepping
TRINAMIC_A2.pwm_autoscale(1);
#endif
#ifdef B_TRINAMIC
TRINAMIC_B.begin(); // Initiate pins and registries
trinamic_test_response(TRINAMIC_B.test_connection(), "B");
@@ -183,6 +277,16 @@ void Trinamic_Init() {
TRINAMIC_B.en_pwm_mode(1); // Enable extremely quiet stepping
TRINAMIC_B.pwm_autoscale(1);
#endif
#ifdef B2_TRINAMIC
TRINAMIC_B2.begin(); // Initiate pins and registries
trinamic_test_response(TRINAMIC_B2.test_connection(), "B2");
TRINAMIC_B2.toff(TRINAMIC_DEFAULT_TOFF);
TRINAMIC_B2.microsteps(settings.microsteps[B_AXIS]);
TRINAMIC_B2.rms_current(settings.current[B_AXIS] * 1000.0, settings.hold_current[B_AXIS] / 100.0);
TRINAMIC_B2.en_pwm_mode(1); // Enable extremely quiet stepping
TRINAMIC_B2.pwm_autoscale(1);
#endif
#ifdef C_TRINAMIC
TRINAMIC_C.begin(); // Initiate pins and registries
trinamic_test_response(TRINAMIC_C.test_connection(), "C");
@@ -192,6 +296,15 @@ void Trinamic_Init() {
TRINAMIC_C.en_pwm_mode(1); // Enable extremely quiet stepping
TRINAMIC_C.pwm_autoscale(1);
#endif
#ifdef C2_TRINAMIC
TRINAMIC_C2.begin(); // Initiate pins and registries
trinamic_test_response(TRINAMIC_C2.test_connection(), "C2");
TRINAMIC_C2.toff(TRINAMIC_DEFAULT_TOFF);
TRINAMIC_C2.microsteps(settings.microsteps[C_AXIS]);
TRINAMIC_C2.rms_current(settings.current[C_AXIS] * 1000.0, settings.hold_current[C_AXIS] / 100.0);
TRINAMIC_C2.en_pwm_mode(1); // Enable extremely quiet stepping
TRINAMIC_C2.pwm_autoscale(1);
#endif
}
// Call this function called whenever $$ settings that affect the drivers are changed
@@ -200,26 +313,57 @@ void trinamic_change_settings() {
TRINAMIC_X.microsteps(settings.microsteps[X_AXIS]);
TRINAMIC_X.rms_current(settings.current[X_AXIS] * 1000.0, settings.hold_current[X_AXIS] / 100.0);
#endif
#ifdef X2_TRINAMIC
TRINAMIC_X2.microsteps(settings.microsteps[X_AXIS]);
TRINAMIC_X2.rms_current(settings.current[X_AXIS] * 1000.0, settings.hold_current[X_AXIS] / 100.0);
#endif
#ifdef Y_TRINAMIC
TRINAMIC_Y.microsteps(settings.microsteps[Y_AXIS]);
TRINAMIC_Y.rms_current(settings.current[Y_AXIS] * 1000.0, settings.hold_current[Y_AXIS] / 100.0);
#endif
#ifdef Y2_TRINAMIC
TRINAMIC_Y2.microsteps(settings.microsteps[Y_AXIS]);
TRINAMIC_Y2.rms_current(settings.current[Y_AXIS] * 1000.0, settings.hold_current[Y_AXIS] / 100.0);
#endif
#ifdef Z_TRINAMIC
TRINAMIC_Z.microsteps(settings.microsteps[Z_AXIS]);
TRINAMIC_Z.rms_current(settings.current[Z_AXIS] * 1000.0, settings.hold_current[Z_AXIS] / 100.0);
#endif
#ifdef Z2_TRINAMIC
TRINAMIC_Z2.microsteps(settings.microsteps[Z_AXIS]);
TRINAMIC_Z2.rms_current(settings.current[Z_AXIS] * 1000.0, settings.hold_current[Z_AXIS] / 100.0);
#endif
#ifdef A_TRINAMIC
TRINAMIC_A.microsteps(settings.microsteps[A_AXIS]);
TRINAMIC_A.rms_current(settings.current[A_AXIS] * 1000.0, settings.hold_current[A_AXIS] / 100.0);
#endif
#ifdef A2_TRINAMIC
TRINAMIC_A2.microsteps(settings.microsteps[A_AXIS]);
TRINAMIC_A2.rms_current(settings.current[A_AXIS] * 1000.0, settings.hold_current[A_AXIS] / 100.0);
#endif
#ifdef B_TRINAMIC
TRINAMIC_B.microsteps(settings.microsteps[B_AXIS]);
TTRINAMIC_B.rms_current(settings.current[B_AXIS] * 1000.0, settings.hold_current[B_AXIS] / 100.0);
#endif
#ifdef B2_TRINAMIC
TRINAMIC_B2.microsteps(settings.microsteps[B_AXIS]);
TTRINAMIC_B2.rms_current(settings.current[B_AXIS] * 1000.0, settings.hold_current[B_AXIS] / 100.0);
#endif
#ifdef C_TRINAMIC
TRINAMIC_C.microsteps(settings.microsteps[C_AXIS]);
TRINAMIC_C.rms_current(settings.current[C_AXIS] * 1000.0, settings.hold_current[C_AXIS] / 100.0);
#endif
#ifdef C2_TRINAMIC
TRINAMIC_C2.microsteps(settings.microsteps[C_AXIS]);
TRINAMIC_C2.rms_current(settings.current[C_AXIS] * 1000.0, settings.hold_current[C_AXIS] / 100.0);
#endif
}
// Display the response of the attempt to connect to a Trinamic driver
@@ -252,21 +396,56 @@ void trinamic_stepper_enable(bool enable) {
#ifdef X_TRINAMIC
TRINAMIC_X.toff(toff);
#endif
#ifdef X2_TRINAMIC
TRINAMIC_X2.toff(toff);
#endif
#ifdef Y_TRINAMIC
TRINAMIC_Y.toff(toff);
#endif
#ifdef Y2_TRINAMIC
TRINAMIC_Y2.toff(toff);
#endif
#ifdef Z_TRINAMIC
TRINAMIC_Z.toff(toff);
#endif
#ifdef Z2_TRINAMIC
TRINAMIC_Z2.toff(toff);
#endif
#ifdef A_TRINAMIC
TRINAMIC_A.toff(toff);
#endif
#ifdef A2_TRINAMIC
TRINAMIC_A2.toff(toff);
#endif
#ifdef B_TRINAMIC
TRINAMIC_B.toff(toff);
#endif
#ifdef B2_TRINAMIC
TRINAMIC_B2.toff(toff);
#endif
#ifdef C_TRINAMIC
TRINAMIC_C.toff(toff);
#endif
#ifdef C2_TRINAMIC
TRINAMIC_C2.toff(toff);
#endif
}
// returns the next spi index. We cannot preassign to axes because ganged (X2 type axes) might
// need to be inserted into the order of axes.
uint8_t get_next_trinamic_driver_index() {
static uint8_t index = 1; // they start at 1
#ifndef TRINAMIC_DAISY_CHAIN
return -1;
#else
return index++;
#endif
}
#endif

View File

@@ -34,6 +34,8 @@
#ifdef USE_MACHINE_TRINAMIC_INIT
void machine_trinamic_setup();
#endif
uint8_t get_next_trinamic_driver_index();
#endif
#endif // GRBL_TRIAMINIC_h