From 2f35747f294c4b3dc3e6920b34e208f89bd4841d Mon Sep 17 00:00:00 2001 From: Bob Kuhn Date: Wed, 23 Jan 2019 19:06:54 -0600 Subject: [PATCH] L6470 SPI daisy chain support (#12895) --- Marlin/Configuration_adv.h | 91 +- Marlin/src/HAL/shared/HAL_spi_L6470.cpp | 144 ++++ Marlin/src/Marlin.cpp | 56 +- Marlin/src/Marlin.h | 265 ++++++ Marlin/src/config/default/Configuration_adv.h | 91 +- .../3DFabXYZ/Migbot/Configuration_adv.h | 91 +- .../AlephObjects/TAZ4/Configuration_adv.h | 91 +- .../examples/Anet/A2/Configuration_adv.h | 91 +- .../examples/Anet/A2plus/Configuration_adv.h | 91 +- .../examples/Anet/A6/Configuration_adv.h | 91 +- .../examples/Anet/A8/Configuration_adv.h | 91 +- .../config/examples/ArmEd/Configuration_adv.h | 91 +- .../BIBO/TouchX/cyclops/Configuration_adv.h | 91 +- .../BIBO/TouchX/default/Configuration_adv.h | 91 +- .../examples/BQ/Hephestos/Configuration_adv.h | 91 +- .../BQ/Hephestos_2/Configuration_adv.h | 91 +- .../examples/BQ/WITBOX/Configuration_adv.h | 91 +- .../examples/Cartesio/Configuration_adv.h | 91 +- .../Creality/CR-10/Configuration_adv.h | 91 +- .../Creality/CR-10S/Configuration_adv.h | 91 +- .../Creality/CR-10mini/Configuration_adv.h | 91 +- .../Creality/CR-8/Configuration_adv.h | 91 +- .../Creality/Ender-2/Configuration_adv.h | 91 +- .../Creality/Ender-3/Configuration_adv.h | 91 +- .../Creality/Ender-4/Configuration_adv.h | 91 +- .../examples/Einstart-S/Configuration_adv.h | 91 +- .../config/examples/Felix/Configuration_adv.h | 91 +- .../FlashForge/CreatorPro/Configuration_adv.h | 91 +- .../FolgerTech/i3-2020/Configuration_adv.h | 91 +- .../Formbot/Raptor/Configuration_adv.h | 91 +- .../Formbot/T_Rex_2+/Configuration_adv.h | 91 +- .../Formbot/T_Rex_3/Configuration_adv.h | 91 +- .../Geeetech/MeCreator2/Configuration_adv.h | 91 +- .../Prusa i3 Pro C/Configuration_adv.h | 91 +- .../Prusa i3 Pro W/Configuration_adv.h | 91 +- .../Infitary/i3-M508/Configuration_adv.h | 91 +- .../examples/JGAurora/A5/Configuration_adv.h | 91 +- .../examples/MakerParts/Configuration_adv.h | 91 +- .../examples/Malyan/M150/Configuration_adv.h | 91 +- .../examples/Malyan/M200/Configuration_adv.h | 91 +- .../Micromake/C1/enhanced/Configuration_adv.h | 91 +- .../examples/Mks/Robin/Configuration_adv.h | 91 +- .../examples/Mks/Sbase/Configuration_adv.h | 91 +- .../RapideLite/RL200/Configuration_adv.h | 91 +- .../examples/RigidBot/Configuration_adv.h | 91 +- .../config/examples/SCARA/Configuration_adv.h | 91 +- .../examples/Sanguinololu/Configuration_adv.h | 91 +- .../examples/TheBorg/Configuration_adv.h | 91 +- .../examples/TinyBoy2/Configuration_adv.h | 91 +- .../examples/Tronxy/X3A/Configuration_adv.h | 91 +- .../UltiMachine/Archim1/Configuration_adv.h | 91 +- .../UltiMachine/Archim2/Configuration_adv.h | 91 +- .../examples/VORONDesign/Configuration_adv.h | 91 +- .../Velleman/K8200/Configuration_adv.h | 91 +- .../Velleman/K8400/Configuration_adv.h | 91 +- .../WASP/PowerWASP/Configuration_adv.h | 91 +- .../Wanhao/Duplicator 6/Configuration_adv.h | 91 +- .../delta/Anycubic/Kossel/Configuration_adv.h | 91 +- .../FLSUN/auto_calibrate/Configuration_adv.h | 91 +- .../delta/FLSUN/kossel/Configuration_adv.h | 91 +- .../FLSUN/kossel_mini/Configuration_adv.h | 91 +- .../Geeetech/Rostock 301/Configuration_adv.h | 91 +- .../delta/MKS/SBASE/Configuration_adv.h | 91 +- .../Tevo Little Monster/Configuration_adv.h | 91 +- .../delta/generic/Configuration_adv.h | 91 +- .../delta/kossel_mini/Configuration_adv.h | 91 +- .../delta/kossel_xl/Configuration_adv.h | 91 +- .../gCreate/gMax1.5+/Configuration_adv.h | 91 +- .../examples/makibox/Configuration_adv.h | 91 +- .../tvrrug/Round2/Configuration_adv.h | 91 +- .../config/examples/wt150/Configuration_adv.h | 91 +- Marlin/src/core/enum.h | 4 + Marlin/src/core/utility.cpp | 7 + Marlin/src/core/utility.h | 2 + Marlin/src/feature/pause.cpp | 2 +- Marlin/src/gcode/calibrate/G28.cpp | 12 + Marlin/src/gcode/control/M17_M18_M84.cpp | 2 +- Marlin/src/gcode/feature/L6470/M122.cpp | 115 +++ Marlin/src/gcode/feature/L6470/M906.cpp | 259 ++++++ Marlin/src/gcode/feature/L6470/M916-918.cpp | 544 ++++++++++++ Marlin/src/gcode/gcode.cpp | 8 + Marlin/src/gcode/gcode.h | 10 + Marlin/src/gcode/host/M114.cpp | 62 ++ Marlin/src/inc/Conditionals_post.h | 2 +- Marlin/src/libs/L6470/000_l6470_read_me.md | 105 +++ Marlin/src/libs/L6470/L6470_Marlin.cpp | 793 ++++++++++++++++++ Marlin/src/libs/L6470/L6470_Marlin.h | 93 ++ Marlin/src/module/stepper.cpp | 61 +- Marlin/src/module/stepper_indirection.cpp | 281 ++++--- Marlin/src/module/stepper_indirection.h | 236 ++---- Marlin/src/pins/pinsDebug_list.h | 15 + Marlin/src/pins/pins_EINSY_RAMBO.h | 2 +- Marlin/src/pins/pins_EINSY_RETRO.h | 2 +- buildroot/share/tests/LPC1768_tests | 1 + platformio.ini | 2 +- 95 files changed, 7844 insertions(+), 1429 deletions(-) create mode 100644 Marlin/src/HAL/shared/HAL_spi_L6470.cpp create mode 100644 Marlin/src/gcode/feature/L6470/M122.cpp create mode 100644 Marlin/src/gcode/feature/L6470/M906.cpp create mode 100644 Marlin/src/gcode/feature/L6470/M916-918.cpp create mode 100644 Marlin/src/libs/L6470/000_l6470_read_me.md create mode 100644 Marlin/src/libs/L6470/L6470_Marlin.cpp create mode 100644 Marlin/src/libs/L6470/L6470_Marlin.h diff --git a/Marlin/Configuration_adv.h b/Marlin/Configuration_adv.h index 97b435a6b..ed1146681 100644 --- a/Marlin/Configuration_adv.h +++ b/Marlin/Configuration_adv.h @@ -1509,62 +1509,121 @@ /** * L6470 Stepper Driver options * - * The Arduino-L6470 library is required for this stepper driver. + * Arduino-L6470 library (0.7.0 or higher) is required for this stepper driver. * https://github.com/ameyer/Arduino-L6470 + * + * Requires the following to be defined in your pins_YOUR_BOARD file + * L6470_CHAIN_SCK_PIN + * L6470_CHAIN_MISO_PIN + * L6470_CHAIN_MOSI_PIN + * L6470_CHAIN_SS_PIN + * L6470_RESET_CHAIN_PIN (optional) */ #if HAS_DRIVER(L6470) - #define X_MICROSTEPS 16 // number of microsteps - #define X_OVERCURRENT 2000 // maxc current in mA. If the current goes over this value, the driver will switch off - #define X_STALLCURRENT 1500 // current in mA where the driver will detect a stall + #define X_MICROSTEPS 128 // number of microsteps (VALID: 1, 2, 4, 8, 16, 32, 128 & 128) + #define X_OVERCURRENT 2000 // current in mA where the driver will detect an over current (VALID: 375 x (1 - 16) - 6A max - rounds down) + #define X_STALLCURRENT 1500 // current in mA where the driver will detect a stall (VALID: 31.25 * (1-128) - 4A max - rounds down) + #define X_MAX_VOLTAGE 127 // 0-255, max effective voltage seen by stepper + #define X_CHAIN_POS 0 // position in SPI chain, 0 - not in chain, 1- nearest MOSI - #define X2_MICROSTEPS 16 + #define X2_MICROSTEPS 128 #define X2_OVERCURRENT 2000 #define X2_STALLCURRENT 1500 + #define X2_MAX_VOLTAGE 127 + #define X2_CHAIN_POS 0 - #define Y_MICROSTEPS 16 + #define Y_MICROSTEPS 128 #define Y_OVERCURRENT 2000 #define Y_STALLCURRENT 1500 + #define Y_MAX_VOLTAGE 127 + #define Y_CHAIN_POS 0 - #define Y2_MICROSTEPS 16 + #define Y2_MICROSTEPS 128 #define Y2_OVERCURRENT 2000 #define Y2_STALLCURRENT 1500 + #define Y2_MAX_VOLTAGE 127 + #define Y2_CHAIN_POS 0 - #define Z_MICROSTEPS 16 + #define Z_MICROSTEPS 128 #define Z_OVERCURRENT 2000 #define Z_STALLCURRENT 1500 + #define Z_MAX_VOLTAGE 127 + #define Z_CHAIN_POS 0 - #define Z2_MICROSTEPS 16 + #define Z2_MICROSTEPS 128 #define Z2_OVERCURRENT 2000 #define Z2_STALLCURRENT 1500 + #define Z2_MAX_VOLTAGE 127 + #define Z2_CHAIN_POS 0 - #define Z3_MICROSTEPS 16 + #define Z3_MICROSTEPS 128 #define Z3_OVERCURRENT 2000 #define Z3_STALLCURRENT 1500 + #define Z3_MAX_VOLTAGE 127 + #define Z3_CHAIN_POS 0 - #define E0_MICROSTEPS 16 + #define E0_MICROSTEPS 128 #define E0_OVERCURRENT 2000 #define E0_STALLCURRENT 1500 + #define E0_MAX_VOLTAGE 127 + #define E0_CHAIN_POS 0 - #define E1_MICROSTEPS 16 + #define E1_MICROSTEPS 128 #define E1_OVERCURRENT 2000 #define E1_STALLCURRENT 1500 + #define E1_MAX_VOLTAGE 127 + #define E1_CHAIN_POS 0 - #define E2_MICROSTEPS 16 + #define E2_MICROSTEPS 128 #define E2_OVERCURRENT 2000 #define E2_STALLCURRENT 1500 + #define E2_MAX_VOLTAGE 127 + #define E2_CHAIN_POS 0 - #define E3_MICROSTEPS 16 + #define E3_MICROSTEPS 128 #define E3_OVERCURRENT 2000 #define E3_STALLCURRENT 1500 + #define E3_MAX_VOLTAGE 127 + #define E3_CHAIN_POS 0 - #define E4_MICROSTEPS 16 + #define E4_MICROSTEPS 128 #define E4_OVERCURRENT 2000 #define E4_STALLCURRENT 1500 + #define E4_MAX_VOLTAGE 127 + #define E4_CHAIN_POS 0 - #define E5_MICROSTEPS 16 + #define E5_MICROSTEPS 128 #define E5_OVERCURRENT 2000 #define E5_STALLCURRENT 1500 + #define E5_MAX_VOLTAGE 127 + #define E5_CHAIN_POS 0 + + + /** + * Monitor L6470 drivers for error conditions like over temperature and over current. + * In the case of over temperature Marlin can decrease the drive until the error condition clears. + * Other detected conditions can be used to stop the current print. + * Relevant g-codes: + * M906 - I1/2/3/4/5 Set or get motor drive level using axis codes X, Y, Z, E. Report values if no axis codes given. + * I not present or I0 or I1 - X, Y, Z or E0 + * I2 - X2, Y2, Z2 or E1 + * I3 - Z3 or E3 + * I4 - E4 + * I5 - E5 + * M916 - Increase drive level until get thermal warning + * M917 - Find minimum current thresholds + * M918 - Increase speed until max or error + * M122 S0/1 - Report driver parameters + */ + //#define MONITOR_L6470_DRIVER_STATUS + + #if ENABLED(MONITOR_L6470_DRIVER_STATUS) + #define KVAL_HOLD_STEP_DOWN 1 + //#define L6470_STOP_ON_ERROR + #endif + + #define L6470_CHITCHAT // enable display of additional status info #endif // L6470 diff --git a/Marlin/src/HAL/shared/HAL_spi_L6470.cpp b/Marlin/src/HAL/shared/HAL_spi_L6470.cpp new file mode 100644 index 000000000..db79a846a --- /dev/null +++ b/Marlin/src/HAL/shared/HAL_spi_L6470.cpp @@ -0,0 +1,144 @@ +/** + * Marlin 3D Printer Firmware + * Copyright (C) 2016 MarlinFirmware [https://github.com/MarlinFirmware/Marlin] + * + * Based on Sprinter and grbl. + * Copyright (C) 2011 Camiel Gubbels / Erik van der Zalm + * + * This program 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. + * + * This program 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 this program. If not, see . + * + */ + +/** + * Software L6470 SPI functions originally from Arduino Sd2Card Library + * Copyright (C) 2009 by William Greiman + */ + +// -------------------------------------------------------------------------- +// Includes +// -------------------------------------------------------------------------- + +#include "../../inc/MarlinConfig.h" + +#if HAS_DRIVER(L6470) + +#include "Delay.h" + +// -------------------------------------------------------------------------- +// Public Variables +// -------------------------------------------------------------------------- + +// -------------------------------------------------------------------------- +// Public functions +// -------------------------------------------------------------------------- + +#include "../../core/serial.h" +#include "../../libs/L6470/L6470_Marlin.h" + +// -------------------------------------------------------------------------- +// Software L6470 SPI +// -------------------------------------------------------------------------- + +// Make sure GCC optimizes this file. +// Note that this line triggers a bug in GCC which is fixed by casting. +// See the note below. +#pragma GCC optimize (3) + +// run at ~4Mhz +uint8_t L6470_SpiTransfer_Mode_0(uint8_t b) { // using Mode 0 + for (uint8_t bits = 8; bits--;) { + WRITE(L6470_CHAIN_MOSI_PIN, b & 0x80); + b <<= 1; // little setup time + + WRITE(L6470_CHAIN_SCK_PIN, HIGH); + DELAY_NS(125); // 10 cycles @ 84mhz + + b |= (READ(L6470_CHAIN_MISO_PIN) != 0); + + WRITE(L6470_CHAIN_SCK_PIN, LOW); + DELAY_NS(125); // 10 cycles @ 84mhz + } + return b; +} + +uint8_t L6470_SpiTransfer_Mode_3(uint8_t b) { // using Mode 3 + for (uint8_t bits = 8; bits--;) { + WRITE(L6470_CHAIN_SCK_PIN, LOW); + WRITE(L6470_CHAIN_MOSI_PIN, b & 0x80); + + DELAY_NS(125); // 10 cycles @ 84mhz + + WRITE(L6470_CHAIN_SCK_PIN, HIGH); + + b <<= 1; // little setup time + b |= (READ(L6470_CHAIN_MISO_PIN) != 0); + } + + DELAY_NS(125); // 10 cycles @ 84mhz + return b; +} + +/** + * The following are weak-linked and defined as do-nothing + * functions by the L6470-Arduino library. They must be + * defined by the client (Marlin) to provide an SPI interface. + */ + +uint8_t L6470_transfer(uint8_t data, int _SSPin, const uint8_t chain_position) { + uint8_t data_out = 0; + + // first device in chain has data sent last + digitalWrite(_SSPin, LOW); + + for (uint8_t i = L6470::chain[0]; (i >= 1) && !spi_abort; i--) { // stop sending data if spi_abort is active + DISABLE_ISRS(); // disable interrupts during SPI transfer (can't allow partial command to chips) + uint8_t temp = L6470_SpiTransfer_Mode_3(uint8_t(i == chain_position ? data : dSPIN_NOP)); + ENABLE_ISRS(); // enable interrupts + if (i == chain_position) data_out = temp; + } + + digitalWrite(_SSPin, HIGH); + return data_out; +} + +void L6470_transfer(uint8_t L6470_buf[], const uint8_t length) { + // first device in chain has data sent last + + if (spi_active) { // interrupted SPI transfer so need to + WRITE(L6470_CHAIN_SS_PIN, HIGH); // guarantee min high of 650nS + DELAY_US(1); + } + + WRITE(L6470_CHAIN_SS_PIN, LOW); + for (uint8_t i = length; i >= 1; i--) + L6470_SpiTransfer_Mode_3(uint8_t(L6470_buf[i])); + WRITE(L6470_CHAIN_SS_PIN, HIGH); +} + +void L6470_spi_init() { + OUT_WRITE(L6470_CHAIN_SS_PIN, HIGH); + OUT_WRITE(L6470_CHAIN_SCK_PIN, HIGH); + OUT_WRITE(L6470_CHAIN_MOSI_PIN, HIGH); + SET_INPUT(L6470_CHAIN_MISO_PIN); + + #if PIN_EXISTS(L6470_BUSY) + SET_INPUT(L6470_BUSY_PIN); + #endif + + OUT_WRITE(L6470_CHAIN_MOSI_PIN, HIGH); +} + +#pragma GCC reset_options + +#endif // HAS_DRIVER(L6470) diff --git a/Marlin/src/Marlin.cpp b/Marlin/src/Marlin.cpp index 8a5ac05e8..0f5b4bf37 100644 --- a/Marlin/src/Marlin.cpp +++ b/Marlin/src/Marlin.cpp @@ -44,6 +44,8 @@ #include "HAL/shared/Delay.h" +#include "module/stepper_indirection.h" + #ifdef ARDUINO #include #endif @@ -158,6 +160,10 @@ #include "lcd/extensible_ui/ui_api.h" #endif +#if HAS_DRIVER(L6470) + #include "libs/L6470/L6470_Marlin.h" +#endif + bool Running = true; #if ENABLED(TEMPERATURE_UNITS_SUPPORT) @@ -341,28 +347,34 @@ void manage_inactivity(const bool ignore_stepper_queue/*=false*/) { #endif if (stepper_inactive_time) { + static bool already_shutdown_steppers; // = false if (planner.has_blocks_queued()) gcode.previous_move_ms = ms; // reset_stepper_timeout to keep steppers powered else if (MOVE_AWAY_TEST && !ignore_stepper_queue && ELAPSED(ms, gcode.previous_move_ms + stepper_inactive_time)) { - #if ENABLED(DISABLE_INACTIVE_X) - disable_X(); - #endif - #if ENABLED(DISABLE_INACTIVE_Y) - disable_Y(); - #endif - #if ENABLED(DISABLE_INACTIVE_Z) - disable_Z(); - #endif - #if ENABLED(DISABLE_INACTIVE_E) - disable_e_steppers(); - #endif - #if HAS_LCD_MENU && ENABLED(AUTO_BED_LEVELING_UBL) - if (ubl.lcd_map_control) { - ubl.lcd_map_control = false; - ui.defer_status_screen(false); - } - #endif + if (!already_shutdown_steppers) { + already_shutdown_steppers = true; // L6470 SPI will consume 99% of free time without this + #if ENABLED(DISABLE_INACTIVE_X) + disable_X(); + #endif + #if ENABLED(DISABLE_INACTIVE_Y) + disable_Y(); + #endif + #if ENABLED(DISABLE_INACTIVE_Z) + disable_Z(); + #endif + #if ENABLED(DISABLE_INACTIVE_E) + disable_e_steppers(); + #endif + #if HAS_LCD_MENU && ENABLED(AUTO_BED_LEVELING_UBL) + if (ubl.lcd_map_control) { + ubl.lcd_map_control = false; + ui.defer_status_screen(false); + } + #endif + } } + else + already_shutdown_steppers = false; } #if PIN_EXISTS(CHDK) // Check if pin should be set to LOW (after M240 set it HIGH) @@ -516,6 +528,10 @@ void manage_inactivity(const bool ignore_stepper_queue/*=false*/) { monitor_tmc_driver(); #endif + #if ENABLED(MONITOR_L6470_DRIVER_STATUS) + L6470.monitor_driver(); + #endif + // Limit check_axes_activity frequency to 10Hz static millis_t next_check_axes_ms = 0; if (ELAPSED(ms, next_check_axes_ms)) { @@ -680,6 +696,10 @@ void setup() { HAL_init(); #endif + #if HAS_DRIVER(L6470) + L6470.init(); // setup SPI and then init chips + #endif + #if ENABLED(MAX7219_DEBUG) max7219.init(); #endif diff --git a/Marlin/src/Marlin.h b/Marlin/src/Marlin.h index 9b66460c6..b85410a40 100644 --- a/Marlin/src/Marlin.h +++ b/Marlin/src/Marlin.h @@ -31,6 +31,11 @@ #include #include +#if HAS_DRIVER(L6470) + #include "libs/L6470/L6470_Marlin.h" + extern uint8_t axis_known_position; +#endif + void stop(); void idle( @@ -41,6 +46,266 @@ void idle( void manage_inactivity(const bool ignore_stepper_queue=false); +// +// X, Y, Z Stepper enable / disable +// +#if AXIS_DRIVER_TYPE_X(L6470) + extern L6470 stepperX; + #define X_enable NOOP + #define X_disable stepperX.free() +#elif HAS_X_ENABLE + #define X_enable X_ENABLE_WRITE( X_ENABLE_ON) + #define X_disable X_ENABLE_WRITE(!X_ENABLE_ON) +#else + #define X_enable NOOP + #define X_disable NOOP +#endif + +#if AXIS_DRIVER_TYPE_X2(L6470) + extern L6470 stepperX2; + #define X2_enable NOOP + #define X2_disable stepperX2.free() +#elif HAS_X2_ENABLE + #define X2_enable X2_ENABLE_WRITE( X_ENABLE_ON) + #define X2_disable X2_ENABLE_WRITE(!X_ENABLE_ON) +#else + #define X2_enable NOOP + #define X2_disable NOOP +#endif + +#define enable_X() do{ X_enable; X2_enable; }while(0) +#define disable_X() do{ X_disable; X2_disable; CBI(axis_known_position, X_AXIS); }while(0) + +#if AXIS_DRIVER_TYPE_Y(L6470) + extern L6470 stepperY; + #define Y_enable NOOP + #define Y_disable stepperY.free() +#elif HAS_Y_ENABLE + #define Y_enable Y_ENABLE_WRITE( Y_ENABLE_ON) + #define Y_disable Y_ENABLE_WRITE(!Y_ENABLE_ON) +#else + #define Y_enable NOOP + #define Y_disable NOOP +#endif + +#if AXIS_DRIVER_TYPE_Y2(L6470) + extern L6470 stepperY2; + #define Y2_enable NOOP + #define Y2_disable stepperY2.free() +#elif HAS_Y2_ENABLE + #define Y2_enable Y2_ENABLE_WRITE( Y_ENABLE_ON) + #define Y2_disable Y2_ENABLE_WRITE(!Y_ENABLE_ON) +#else + #define Y2_enable NOOP + #define Y2_disable NOOP +#endif + +#define enable_Y() do{ Y_enable; Y2_enable; }while(0) +#define disable_Y() do{ Y_disable; Y2_disable; CBI(axis_known_position, Y_AXIS); }while(0) + +#if AXIS_DRIVER_TYPE_Z(L6470) + extern L6470 stepperZ; + #define Z_enable NOOP + #define Z_disable stepperZ.free() +#elif HAS_Z_ENABLE + #define Z_enable Z_ENABLE_WRITE( Z_ENABLE_ON) + #define Z_disable Z_ENABLE_WRITE(!Z_ENABLE_ON) +#else + #define Z_enable NOOP + #define Z_disable NOOP +#endif + +#if AXIS_DRIVER_TYPE_Z2(L6470) + extern L6470 stepperZ2; + #define Z2_enable NOOP + #define Z2_disable stepperZ2.free() +#elif HAS_Z2_ENABLE + #define Z2_enable Z2_ENABLE_WRITE( Z_ENABLE_ON) + #define Z2_disable Z2_ENABLE_WRITE(!Z_ENABLE_ON) +#else + #define Z2_enable NOOP + #define Z2_disable NOOP +#endif + +#if AXIS_DRIVER_TYPE_Z3(L6470) + extern L6470 stepperZ3; + #define Z3_enable NOOP + #define Z3_disable stepperZ3.free() +#elif HAS_Z3_ENABLE + #define Z3_enable Z3_ENABLE_WRITE( Z_ENABLE_ON) + #define Z3_disable Z3_ENABLE_WRITE(!Z_ENABLE_ON) +#else + #define Z3_enable NOOP + #define Z3_disable NOOP +#endif + +#define enable_Z() do{ Z_enable; Z2_enable; Z3_enable; }while(0) +#define disable_Z() do{ Z_disable; Z2_disable; Z3_disable; CBI(axis_known_position, Z_AXIS); }while(0) + +// end X, Y, Z Stepper enable / disable + +// +// Extruder Stepper enable / disable +// + +// define the individual enables/disables +#if AXIS_DRIVER_TYPE_E0(L6470) + extern L6470 stepperE0; + #define E0_enable NOOP + #define E0_disable do{ stepperE0.free(); CBI(axis_known_position, E_AXIS); }while(0) +#elif HAS_E0_ENABLE + #define E0_enable E0_ENABLE_WRITE( E_ENABLE_ON) + #define E0_disable E0_ENABLE_WRITE(!E_ENABLE_ON) +#else + #define E0_enable NOOP + #define E0_disable NOOP +#endif + +#if AXIS_DRIVER_TYPE_E1(L6470) + extern L6470 stepperE1; + #define E1_enable NOOP + #define E1_disable do{ stepperE1.free(); CBI(axis_known_position, E_AXIS); }while(0) +#elif E_STEPPERS > 1 && HAS_E1_ENABLE + #define E1_enable E1_ENABLE_WRITE( E_ENABLE_ON) + #define E1_disable E1_ENABLE_WRITE(!E_ENABLE_ON) +#else + #define E1_enable NOOP + #define E1_disable NOOP +#endif + +#if AXIS_DRIVER_TYPE_E2(L6470) + extern L6470 stepperE2; + #define E2_enable NOOP + #define E2_disable do{ stepperE2.free(); CBI(axis_known_position, E_AXIS); }while(0) +#elif E_STEPPERS > 2 && HAS_E2_ENABLE + #define E2_enable E2_ENABLE_WRITE( E_ENABLE_ON) + #define E2_disable E2_ENABLE_WRITE(!E_ENABLE_ON) +#else + #define E2_enable NOOP + #define E2_disable NOOP +#endif + +#if AXIS_DRIVER_TYPE_E3(L6470) + extern L6470 stepperE3; + #define E3_enable NOOP + #define E3_disable do{ stepperE3.free(); CBI(axis_known_position, E_AXIS); }while(0) +#elif E_STEPPERS > 3 && HAS_E3_ENABLE + #define E3_enable E3_ENABLE_WRITE( E_ENABLE_ON) + #define E3_disable E3_ENABLE_WRITE(!E_ENABLE_ON) +#else + #define E3_enable NOOP + #define E3_disable NOOP +#endif + +#if AXIS_DRIVER_TYPE_E4(L6470) + extern L6470 stepperE4; + #define E4_enable NOOP + #define E4_disable do{ stepperE4.free(); CBI(axis_known_position, E_AXIS); }while(0) +#elif E_STEPPERS > 4 && HAS_E4_ENABLE + #define E4_enable E4_ENABLE_WRITE( E_ENABLE_ON) + #define E4_disable E4_ENABLE_WRITE(!E_ENABLE_ON) +#else + #define E4_enable NOOP + #define E4_disable NOOP +#endif + +#if AXIS_DRIVER_TYPE_E5(L6470) + extern L6470 stepperE5; + #define E5_enable NOOP + #define E5_disable do{ stepperE5.free(); CBI(axis_known_position, E_AXIS); }while(0) +#elif E_STEPPERS > 5 && HAS_E5_ENABLE + #define E5_enable E5_ENABLE_WRITE( E_ENABLE_ON) + #define E5_disable E5_ENABLE_WRITE(!E_ENABLE_ON) +#else + #define E5_enable NOOP + #define E5_disable NOOP +#endif +// end individual enables/disables + +#if ENABLED(MIXING_EXTRUDER) + + /** + * Mixing steppers synchronize their enable (and direction) together + */ + #if MIXING_STEPPERS > 5 + #define enable_E0() { E0_enable; E1_enable; E2_enable; E3_enable; E4_enable; E5_enable; } + #define disable_E0() { E0_disable; E1_disable; E2_disable; E3_disable; E4_disable; E5_disable; } + #elif MIXING_STEPPERS > 4 + #define enable_E0() { E0_enable; E1_enable; E2_enable; E3_enable; E4_enable; } + #define disable_E0() { E0_disable; E1_disable; E2_disable; E3_disable; E4_disable; } + #elif MIXING_STEPPERS > 3 + #define enable_E0() { E0_enable; E1_enable; E2_enable; E3_enable; } + #define disable_E0() { E0_disable; E1_disable; E2_disable; E3_disable; } + #elif MIXING_STEPPERS > 2 + #define enable_E0() { E0_enable; E1_enable; E2_enable; } + #define disable_E0() { E0_disable; E1_disable; E2_disable; } + #else + #define enable_E0() { E0_enable; E1_enable; } + #define disable_E0() { E0_disable; E1_disable; } + #endif + #define enable_E1() NOOP + #define disable_E1() NOOP + #define enable_E2() NOOP + #define disable_E2() NOOP + #define enable_E3() NOOP + #define disable_E3() NOOP + #define enable_E4() NOOP + #define disable_E4() NOOP + #define enable_E5() NOOP + #define disable_E5() NOOP + +#else // !MIXING_EXTRUDER + + #if HAS_E0_ENABLE + #define enable_E0() E0_enable + #define disable_E0() E0_disable + #else + #define enable_E0() NOOP + #define disable_E0() NOOP + #endif + + #if E_STEPPERS > 1 && HAS_E1_ENABLE + #define enable_E1() E1_enable + #define disable_E1() E1_disable + #else + #define enable_E1() NOOP + #define disable_E1() NOOP + #endif + + #if E_STEPPERS > 2 && HAS_E2_ENABLE + #define enable_E2() E2_enable + #define disable_E2() E2_disable + #else + #define enable_E2() NOOP + #define disable_E2() NOOP + #endif + + #if E_STEPPERS > 3 && HAS_E3_ENABLE + #define enable_E3() E3_enable + #define disable_E3() E3_disable + #else + #define enable_E3() NOOP + #define disable_E3() NOOP + #endif + + #if E_STEPPERS > 4 && HAS_E4_ENABLE + #define enable_E4() E4_enable + #define disable_E4() E4_disable + #else + #define enable_E4() NOOP + #define disable_E4() NOOP + #endif + + #if E_STEPPERS > 5 && HAS_E5_ENABLE + #define enable_E5() E5_enable + #define disable_E5() E5_disable + #else + #define enable_E5() NOOP + #define disable_E5() NOOP + #endif + +#endif // !MIXING_EXTRUDER + #if ENABLED(EXPERIMENTAL_I2CBUS) #include "feature/twibus.h" extern TWIBus i2c; diff --git a/Marlin/src/config/default/Configuration_adv.h b/Marlin/src/config/default/Configuration_adv.h index 97b435a6b..ed1146681 100755 --- a/Marlin/src/config/default/Configuration_adv.h +++ b/Marlin/src/config/default/Configuration_adv.h @@ -1509,62 +1509,121 @@ /** * L6470 Stepper Driver options * - * The Arduino-L6470 library is required for this stepper driver. + * Arduino-L6470 library (0.7.0 or higher) is required for this stepper driver. * https://github.com/ameyer/Arduino-L6470 + * + * Requires the following to be defined in your pins_YOUR_BOARD file + * L6470_CHAIN_SCK_PIN + * L6470_CHAIN_MISO_PIN + * L6470_CHAIN_MOSI_PIN + * L6470_CHAIN_SS_PIN + * L6470_RESET_CHAIN_PIN (optional) */ #if HAS_DRIVER(L6470) - #define X_MICROSTEPS 16 // number of microsteps - #define X_OVERCURRENT 2000 // maxc current in mA. If the current goes over this value, the driver will switch off - #define X_STALLCURRENT 1500 // current in mA where the driver will detect a stall + #define X_MICROSTEPS 128 // number of microsteps (VALID: 1, 2, 4, 8, 16, 32, 128 & 128) + #define X_OVERCURRENT 2000 // current in mA where the driver will detect an over current (VALID: 375 x (1 - 16) - 6A max - rounds down) + #define X_STALLCURRENT 1500 // current in mA where the driver will detect a stall (VALID: 31.25 * (1-128) - 4A max - rounds down) + #define X_MAX_VOLTAGE 127 // 0-255, max effective voltage seen by stepper + #define X_CHAIN_POS 0 // position in SPI chain, 0 - not in chain, 1- nearest MOSI - #define X2_MICROSTEPS 16 + #define X2_MICROSTEPS 128 #define X2_OVERCURRENT 2000 #define X2_STALLCURRENT 1500 + #define X2_MAX_VOLTAGE 127 + #define X2_CHAIN_POS 0 - #define Y_MICROSTEPS 16 + #define Y_MICROSTEPS 128 #define Y_OVERCURRENT 2000 #define Y_STALLCURRENT 1500 + #define Y_MAX_VOLTAGE 127 + #define Y_CHAIN_POS 0 - #define Y2_MICROSTEPS 16 + #define Y2_MICROSTEPS 128 #define Y2_OVERCURRENT 2000 #define Y2_STALLCURRENT 1500 + #define Y2_MAX_VOLTAGE 127 + #define Y2_CHAIN_POS 0 - #define Z_MICROSTEPS 16 + #define Z_MICROSTEPS 128 #define Z_OVERCURRENT 2000 #define Z_STALLCURRENT 1500 + #define Z_MAX_VOLTAGE 127 + #define Z_CHAIN_POS 0 - #define Z2_MICROSTEPS 16 + #define Z2_MICROSTEPS 128 #define Z2_OVERCURRENT 2000 #define Z2_STALLCURRENT 1500 + #define Z2_MAX_VOLTAGE 127 + #define Z2_CHAIN_POS 0 - #define Z3_MICROSTEPS 16 + #define Z3_MICROSTEPS 128 #define Z3_OVERCURRENT 2000 #define Z3_STALLCURRENT 1500 + #define Z3_MAX_VOLTAGE 127 + #define Z3_CHAIN_POS 0 - #define E0_MICROSTEPS 16 + #define E0_MICROSTEPS 128 #define E0_OVERCURRENT 2000 #define E0_STALLCURRENT 1500 + #define E0_MAX_VOLTAGE 127 + #define E0_CHAIN_POS 0 - #define E1_MICROSTEPS 16 + #define E1_MICROSTEPS 128 #define E1_OVERCURRENT 2000 #define E1_STALLCURRENT 1500 + #define E1_MAX_VOLTAGE 127 + #define E1_CHAIN_POS 0 - #define E2_MICROSTEPS 16 + #define E2_MICROSTEPS 128 #define E2_OVERCURRENT 2000 #define E2_STALLCURRENT 1500 + #define E2_MAX_VOLTAGE 127 + #define E2_CHAIN_POS 0 - #define E3_MICROSTEPS 16 + #define E3_MICROSTEPS 128 #define E3_OVERCURRENT 2000 #define E3_STALLCURRENT 1500 + #define E3_MAX_VOLTAGE 127 + #define E3_CHAIN_POS 0 - #define E4_MICROSTEPS 16 + #define E4_MICROSTEPS 128 #define E4_OVERCURRENT 2000 #define E4_STALLCURRENT 1500 + #define E4_MAX_VOLTAGE 127 + #define E4_CHAIN_POS 0 - #define E5_MICROSTEPS 16 + #define E5_MICROSTEPS 128 #define E5_OVERCURRENT 2000 #define E5_STALLCURRENT 1500 + #define E5_MAX_VOLTAGE 127 + #define E5_CHAIN_POS 0 + + + /** + * Monitor L6470 drivers for error conditions like over temperature and over current. + * In the case of over temperature Marlin can decrease the drive until the error condition clears. + * Other detected conditions can be used to stop the current print. + * Relevant g-codes: + * M906 - I1/2/3/4/5 Set or get motor drive level using axis codes X, Y, Z, E. Report values if no axis codes given. + * I not present or I0 or I1 - X, Y, Z or E0 + * I2 - X2, Y2, Z2 or E1 + * I3 - Z3 or E3 + * I4 - E4 + * I5 - E5 + * M916 - Increase drive level until get thermal warning + * M917 - Find minimum current thresholds + * M918 - Increase speed until max or error + * M122 S0/1 - Report driver parameters + */ + //#define MONITOR_L6470_DRIVER_STATUS + + #if ENABLED(MONITOR_L6470_DRIVER_STATUS) + #define KVAL_HOLD_STEP_DOWN 1 + //#define L6470_STOP_ON_ERROR + #endif + + #define L6470_CHITCHAT // enable display of additional status info #endif // L6470 diff --git a/Marlin/src/config/examples/3DFabXYZ/Migbot/Configuration_adv.h b/Marlin/src/config/examples/3DFabXYZ/Migbot/Configuration_adv.h index 0839cbd32..c94d46586 100644 --- a/Marlin/src/config/examples/3DFabXYZ/Migbot/Configuration_adv.h +++ b/Marlin/src/config/examples/3DFabXYZ/Migbot/Configuration_adv.h @@ -1509,62 +1509,121 @@ /** * L6470 Stepper Driver options * - * The Arduino-L6470 library is required for this stepper driver. + * Arduino-L6470 library (0.7.0 or higher) is required for this stepper driver. * https://github.com/ameyer/Arduino-L6470 + * + * Requires the following to be defined in your pins_YOUR_BOARD file + * L6470_CHAIN_SCK_PIN + * L6470_CHAIN_MISO_PIN + * L6470_CHAIN_MOSI_PIN + * L6470_CHAIN_SS_PIN + * L6470_RESET_CHAIN_PIN (optional) */ #if HAS_DRIVER(L6470) - #define X_MICROSTEPS 16 // number of microsteps - #define X_OVERCURRENT 2000 // maxc current in mA. If the current goes over this value, the driver will switch off - #define X_STALLCURRENT 1500 // current in mA where the driver will detect a stall + #define X_MICROSTEPS 128 // number of microsteps (VALID: 1, 2, 4, 8, 16, 32, 128 & 128) + #define X_OVERCURRENT 2000 // current in mA where the driver will detect an over current (VALID: 375 x (1 - 16) - 6A max - rounds down) + #define X_STALLCURRENT 1500 // current in mA where the driver will detect a stall (VALID: 31.25 * (1-128) - 4A max - rounds down) + #define X_MAX_VOLTAGE 127 // 0-255, max effective voltage seen by stepper + #define X_CHAIN_POS 0 // position in SPI chain, 0 - not in chain, 1- nearest MOSI - #define X2_MICROSTEPS 16 + #define X2_MICROSTEPS 128 #define X2_OVERCURRENT 2000 #define X2_STALLCURRENT 1500 + #define X2_MAX_VOLTAGE 127 + #define X2_CHAIN_POS 0 - #define Y_MICROSTEPS 16 + #define Y_MICROSTEPS 128 #define Y_OVERCURRENT 2000 #define Y_STALLCURRENT 1500 + #define Y_MAX_VOLTAGE 127 + #define Y_CHAIN_POS 0 - #define Y2_MICROSTEPS 16 + #define Y2_MICROSTEPS 128 #define Y2_OVERCURRENT 2000 #define Y2_STALLCURRENT 1500 + #define Y2_MAX_VOLTAGE 127 + #define Y2_CHAIN_POS 0 - #define Z_MICROSTEPS 16 + #define Z_MICROSTEPS 128 #define Z_OVERCURRENT 2000 #define Z_STALLCURRENT 1500 + #define Z_MAX_VOLTAGE 127 + #define Z_CHAIN_POS 0 - #define Z2_MICROSTEPS 16 + #define Z2_MICROSTEPS 128 #define Z2_OVERCURRENT 2000 #define Z2_STALLCURRENT 1500 + #define Z2_MAX_VOLTAGE 127 + #define Z2_CHAIN_POS 0 - #define Z3_MICROSTEPS 16 + #define Z3_MICROSTEPS 128 #define Z3_OVERCURRENT 2000 #define Z3_STALLCURRENT 1500 + #define Z3_MAX_VOLTAGE 127 + #define Z3_CHAIN_POS 0 - #define E0_MICROSTEPS 16 + #define E0_MICROSTEPS 128 #define E0_OVERCURRENT 2000 #define E0_STALLCURRENT 1500 + #define E0_MAX_VOLTAGE 127 + #define E0_CHAIN_POS 0 - #define E1_MICROSTEPS 16 + #define E1_MICROSTEPS 128 #define E1_OVERCURRENT 2000 #define E1_STALLCURRENT 1500 + #define E1_MAX_VOLTAGE 127 + #define E1_CHAIN_POS 0 - #define E2_MICROSTEPS 16 + #define E2_MICROSTEPS 128 #define E2_OVERCURRENT 2000 #define E2_STALLCURRENT 1500 + #define E2_MAX_VOLTAGE 127 + #define E2_CHAIN_POS 0 - #define E3_MICROSTEPS 16 + #define E3_MICROSTEPS 128 #define E3_OVERCURRENT 2000 #define E3_STALLCURRENT 1500 + #define E3_MAX_VOLTAGE 127 + #define E3_CHAIN_POS 0 - #define E4_MICROSTEPS 16 + #define E4_MICROSTEPS 128 #define E4_OVERCURRENT 2000 #define E4_STALLCURRENT 1500 + #define E4_MAX_VOLTAGE 127 + #define E4_CHAIN_POS 0 - #define E5_MICROSTEPS 16 + #define E5_MICROSTEPS 128 #define E5_OVERCURRENT 2000 #define E5_STALLCURRENT 1500 + #define E5_MAX_VOLTAGE 127 + #define E5_CHAIN_POS 0 + + + /** + * Monitor L6470 drivers for error conditions like over temperature and over current. + * In the case of over temperature Marlin can decrease the drive until the error condition clears. + * Other detected conditions can be used to stop the current print. + * Relevant g-codes: + * M906 - I1/2/3/4/5 Set or get motor drive level using axis codes X, Y, Z, E. Report values if no axis codes given. + * I not present or I0 or I1 - X, Y, Z or E0 + * I2 - X2, Y2, Z2 or E1 + * I3 - Z3 or E3 + * I4 - E4 + * I5 - E5 + * M916 - Increase drive level until get thermal warning + * M917 - Find minimum current thresholds + * M918 - Increase speed until max or error + * M122 S0/1 - Report driver parameters + */ + //#define MONITOR_L6470_DRIVER_STATUS + + #if ENABLED(MONITOR_L6470_DRIVER_STATUS) + #define KVAL_HOLD_STEP_DOWN 1 + //#define L6470_STOP_ON_ERROR + #endif + + #define L6470_CHITCHAT // enable display of additional status info #endif // L6470 diff --git a/Marlin/src/config/examples/AlephObjects/TAZ4/Configuration_adv.h b/Marlin/src/config/examples/AlephObjects/TAZ4/Configuration_adv.h index 133d455cd..c36a5d286 100644 --- a/Marlin/src/config/examples/AlephObjects/TAZ4/Configuration_adv.h +++ b/Marlin/src/config/examples/AlephObjects/TAZ4/Configuration_adv.h @@ -1508,62 +1508,121 @@ /** * L6470 Stepper Driver options * - * The Arduino-L6470 library is required for this stepper driver. + * Arduino-L6470 library (0.7.0 or higher) is required for this stepper driver. * https://github.com/ameyer/Arduino-L6470 + * + * Requires the following to be defined in your pins_YOUR_BOARD file + * L6470_CHAIN_SCK_PIN + * L6470_CHAIN_MISO_PIN + * L6470_CHAIN_MOSI_PIN + * L6470_CHAIN_SS_PIN + * L6470_RESET_CHAIN_PIN (optional) */ #if HAS_DRIVER(L6470) - #define X_MICROSTEPS 16 // number of microsteps - #define X_OVERCURRENT 2000 // maxc current in mA. If the current goes over this value, the driver will switch off - #define X_STALLCURRENT 1500 // current in mA where the driver will detect a stall + #define X_MICROSTEPS 128 // number of microsteps (VALID: 1, 2, 4, 8, 16, 32, 128 & 128) + #define X_OVERCURRENT 2000 // current in mA where the driver will detect an over current (VALID: 375 x (1 - 16) - 6A max - rounds down) + #define X_STALLCURRENT 1500 // current in mA where the driver will detect a stall (VALID: 31.25 * (1-128) - 4A max - rounds down) + #define X_MAX_VOLTAGE 127 // 0-255, max effective voltage seen by stepper + #define X_CHAIN_POS 0 // position in SPI chain, 0 - not in chain, 1- nearest MOSI - #define X2_MICROSTEPS 16 + #define X2_MICROSTEPS 128 #define X2_OVERCURRENT 2000 #define X2_STALLCURRENT 1500 + #define X2_MAX_VOLTAGE 127 + #define X2_CHAIN_POS 0 - #define Y_MICROSTEPS 16 + #define Y_MICROSTEPS 128 #define Y_OVERCURRENT 2000 #define Y_STALLCURRENT 1500 + #define Y_MAX_VOLTAGE 127 + #define Y_CHAIN_POS 0 - #define Y2_MICROSTEPS 16 + #define Y2_MICROSTEPS 128 #define Y2_OVERCURRENT 2000 #define Y2_STALLCURRENT 1500 + #define Y2_MAX_VOLTAGE 127 + #define Y2_CHAIN_POS 0 - #define Z_MICROSTEPS 16 + #define Z_MICROSTEPS 128 #define Z_OVERCURRENT 2000 #define Z_STALLCURRENT 1500 + #define Z_MAX_VOLTAGE 127 + #define Z_CHAIN_POS 0 - #define Z2_MICROSTEPS 16 + #define Z2_MICROSTEPS 128 #define Z2_OVERCURRENT 2000 #define Z2_STALLCURRENT 1500 + #define Z2_MAX_VOLTAGE 127 + #define Z2_CHAIN_POS 0 - #define Z3_MICROSTEPS 16 + #define Z3_MICROSTEPS 128 #define Z3_OVERCURRENT 2000 #define Z3_STALLCURRENT 1500 + #define Z3_MAX_VOLTAGE 127 + #define Z3_CHAIN_POS 0 - #define E0_MICROSTEPS 16 + #define E0_MICROSTEPS 128 #define E0_OVERCURRENT 2000 #define E0_STALLCURRENT 1500 + #define E0_MAX_VOLTAGE 127 + #define E0_CHAIN_POS 0 - #define E1_MICROSTEPS 16 + #define E1_MICROSTEPS 128 #define E1_OVERCURRENT 2000 #define E1_STALLCURRENT 1500 + #define E1_MAX_VOLTAGE 127 + #define E1_CHAIN_POS 0 - #define E2_MICROSTEPS 16 + #define E2_MICROSTEPS 128 #define E2_OVERCURRENT 2000 #define E2_STALLCURRENT 1500 + #define E2_MAX_VOLTAGE 127 + #define E2_CHAIN_POS 0 - #define E3_MICROSTEPS 16 + #define E3_MICROSTEPS 128 #define E3_OVERCURRENT 2000 #define E3_STALLCURRENT 1500 + #define E3_MAX_VOLTAGE 127 + #define E3_CHAIN_POS 0 - #define E4_MICROSTEPS 16 + #define E4_MICROSTEPS 128 #define E4_OVERCURRENT 2000 #define E4_STALLCURRENT 1500 + #define E4_MAX_VOLTAGE 127 + #define E4_CHAIN_POS 0 - #define E5_MICROSTEPS 16 + #define E5_MICROSTEPS 128 #define E5_OVERCURRENT 2000 #define E5_STALLCURRENT 1500 + #define E5_MAX_VOLTAGE 127 + #define E5_CHAIN_POS 0 + + + /** + * Monitor L6470 drivers for error conditions like over temperature and over current. + * In the case of over temperature Marlin can decrease the drive until the error condition clears. + * Other detected conditions can be used to stop the current print. + * Relevant g-codes: + * M906 - I1/2/3/4/5 Set or get motor drive level using axis codes X, Y, Z, E. Report values if no axis codes given. + * I not present or I0 or I1 - X, Y, Z or E0 + * I2 - X2, Y2, Z2 or E1 + * I3 - Z3 or E3 + * I4 - E4 + * I5 - E5 + * M916 - Increase drive level until get thermal warning + * M917 - Find minimum current thresholds + * M918 - Increase speed until max or error + * M122 S0/1 - Report driver parameters + */ + //#define MONITOR_L6470_DRIVER_STATUS + + #if ENABLED(MONITOR_L6470_DRIVER_STATUS) + #define KVAL_HOLD_STEP_DOWN 1 + //#define L6470_STOP_ON_ERROR + #endif + + #define L6470_CHITCHAT // enable display of additional status info #endif // L6470 diff --git a/Marlin/src/config/examples/Anet/A2/Configuration_adv.h b/Marlin/src/config/examples/Anet/A2/Configuration_adv.h index a79e2ad49..d383eb134 100644 --- a/Marlin/src/config/examples/Anet/A2/Configuration_adv.h +++ b/Marlin/src/config/examples/Anet/A2/Configuration_adv.h @@ -1508,62 +1508,121 @@ /** * L6470 Stepper Driver options * - * The Arduino-L6470 library is required for this stepper driver. + * Arduino-L6470 library (0.7.0 or higher) is required for this stepper driver. * https://github.com/ameyer/Arduino-L6470 + * + * Requires the following to be defined in your pins_YOUR_BOARD file + * L6470_CHAIN_SCK_PIN + * L6470_CHAIN_MISO_PIN + * L6470_CHAIN_MOSI_PIN + * L6470_CHAIN_SS_PIN + * L6470_RESET_CHAIN_PIN (optional) */ #if HAS_DRIVER(L6470) - #define X_MICROSTEPS 16 // number of microsteps - #define X_OVERCURRENT 2000 // maxc current in mA. If the current goes over this value, the driver will switch off - #define X_STALLCURRENT 1500 // current in mA where the driver will detect a stall + #define X_MICROSTEPS 128 // number of microsteps (VALID: 1, 2, 4, 8, 16, 32, 128 & 128) + #define X_OVERCURRENT 2000 // current in mA where the driver will detect an over current (VALID: 375 x (1 - 16) - 6A max - rounds down) + #define X_STALLCURRENT 1500 // current in mA where the driver will detect a stall (VALID: 31.25 * (1-128) - 4A max - rounds down) + #define X_MAX_VOLTAGE 127 // 0-255, max effective voltage seen by stepper + #define X_CHAIN_POS 0 // position in SPI chain, 0 - not in chain, 1- nearest MOSI - #define X2_MICROSTEPS 16 + #define X2_MICROSTEPS 128 #define X2_OVERCURRENT 2000 #define X2_STALLCURRENT 1500 + #define X2_MAX_VOLTAGE 127 + #define X2_CHAIN_POS 0 - #define Y_MICROSTEPS 16 + #define Y_MICROSTEPS 128 #define Y_OVERCURRENT 2000 #define Y_STALLCURRENT 1500 + #define Y_MAX_VOLTAGE 127 + #define Y_CHAIN_POS 0 - #define Y2_MICROSTEPS 16 + #define Y2_MICROSTEPS 128 #define Y2_OVERCURRENT 2000 #define Y2_STALLCURRENT 1500 + #define Y2_MAX_VOLTAGE 127 + #define Y2_CHAIN_POS 0 - #define Z_MICROSTEPS 16 + #define Z_MICROSTEPS 128 #define Z_OVERCURRENT 2000 #define Z_STALLCURRENT 1500 + #define Z_MAX_VOLTAGE 127 + #define Z_CHAIN_POS 0 - #define Z2_MICROSTEPS 16 + #define Z2_MICROSTEPS 128 #define Z2_OVERCURRENT 2000 #define Z2_STALLCURRENT 1500 + #define Z2_MAX_VOLTAGE 127 + #define Z2_CHAIN_POS 0 - #define Z3_MICROSTEPS 16 + #define Z3_MICROSTEPS 128 #define Z3_OVERCURRENT 2000 #define Z3_STALLCURRENT 1500 + #define Z3_MAX_VOLTAGE 127 + #define Z3_CHAIN_POS 0 - #define E0_MICROSTEPS 16 + #define E0_MICROSTEPS 128 #define E0_OVERCURRENT 2000 #define E0_STALLCURRENT 1500 + #define E0_MAX_VOLTAGE 127 + #define E0_CHAIN_POS 0 - #define E1_MICROSTEPS 16 + #define E1_MICROSTEPS 128 #define E1_OVERCURRENT 2000 #define E1_STALLCURRENT 1500 + #define E1_MAX_VOLTAGE 127 + #define E1_CHAIN_POS 0 - #define E2_MICROSTEPS 16 + #define E2_MICROSTEPS 128 #define E2_OVERCURRENT 2000 #define E2_STALLCURRENT 1500 + #define E2_MAX_VOLTAGE 127 + #define E2_CHAIN_POS 0 - #define E3_MICROSTEPS 16 + #define E3_MICROSTEPS 128 #define E3_OVERCURRENT 2000 #define E3_STALLCURRENT 1500 + #define E3_MAX_VOLTAGE 127 + #define E3_CHAIN_POS 0 - #define E4_MICROSTEPS 16 + #define E4_MICROSTEPS 128 #define E4_OVERCURRENT 2000 #define E4_STALLCURRENT 1500 + #define E4_MAX_VOLTAGE 127 + #define E4_CHAIN_POS 0 - #define E5_MICROSTEPS 16 + #define E5_MICROSTEPS 128 #define E5_OVERCURRENT 2000 #define E5_STALLCURRENT 1500 + #define E5_MAX_VOLTAGE 127 + #define E5_CHAIN_POS 0 + + + /** + * Monitor L6470 drivers for error conditions like over temperature and over current. + * In the case of over temperature Marlin can decrease the drive until the error condition clears. + * Other detected conditions can be used to stop the current print. + * Relevant g-codes: + * M906 - I1/2/3/4/5 Set or get motor drive level using axis codes X, Y, Z, E. Report values if no axis codes given. + * I not present or I0 or I1 - X, Y, Z or E0 + * I2 - X2, Y2, Z2 or E1 + * I3 - Z3 or E3 + * I4 - E4 + * I5 - E5 + * M916 - Increase drive level until get thermal warning + * M917 - Find minimum current thresholds + * M918 - Increase speed until max or error + * M122 S0/1 - Report driver parameters + */ + //#define MONITOR_L6470_DRIVER_STATUS + + #if ENABLED(MONITOR_L6470_DRIVER_STATUS) + #define KVAL_HOLD_STEP_DOWN 1 + //#define L6470_STOP_ON_ERROR + #endif + + #define L6470_CHITCHAT // enable display of additional status info #endif // L6470 diff --git a/Marlin/src/config/examples/Anet/A2plus/Configuration_adv.h b/Marlin/src/config/examples/Anet/A2plus/Configuration_adv.h index a79e2ad49..d383eb134 100644 --- a/Marlin/src/config/examples/Anet/A2plus/Configuration_adv.h +++ b/Marlin/src/config/examples/Anet/A2plus/Configuration_adv.h @@ -1508,62 +1508,121 @@ /** * L6470 Stepper Driver options * - * The Arduino-L6470 library is required for this stepper driver. + * Arduino-L6470 library (0.7.0 or higher) is required for this stepper driver. * https://github.com/ameyer/Arduino-L6470 + * + * Requires the following to be defined in your pins_YOUR_BOARD file + * L6470_CHAIN_SCK_PIN + * L6470_CHAIN_MISO_PIN + * L6470_CHAIN_MOSI_PIN + * L6470_CHAIN_SS_PIN + * L6470_RESET_CHAIN_PIN (optional) */ #if HAS_DRIVER(L6470) - #define X_MICROSTEPS 16 // number of microsteps - #define X_OVERCURRENT 2000 // maxc current in mA. If the current goes over this value, the driver will switch off - #define X_STALLCURRENT 1500 // current in mA where the driver will detect a stall + #define X_MICROSTEPS 128 // number of microsteps (VALID: 1, 2, 4, 8, 16, 32, 128 & 128) + #define X_OVERCURRENT 2000 // current in mA where the driver will detect an over current (VALID: 375 x (1 - 16) - 6A max - rounds down) + #define X_STALLCURRENT 1500 // current in mA where the driver will detect a stall (VALID: 31.25 * (1-128) - 4A max - rounds down) + #define X_MAX_VOLTAGE 127 // 0-255, max effective voltage seen by stepper + #define X_CHAIN_POS 0 // position in SPI chain, 0 - not in chain, 1- nearest MOSI - #define X2_MICROSTEPS 16 + #define X2_MICROSTEPS 128 #define X2_OVERCURRENT 2000 #define X2_STALLCURRENT 1500 + #define X2_MAX_VOLTAGE 127 + #define X2_CHAIN_POS 0 - #define Y_MICROSTEPS 16 + #define Y_MICROSTEPS 128 #define Y_OVERCURRENT 2000 #define Y_STALLCURRENT 1500 + #define Y_MAX_VOLTAGE 127 + #define Y_CHAIN_POS 0 - #define Y2_MICROSTEPS 16 + #define Y2_MICROSTEPS 128 #define Y2_OVERCURRENT 2000 #define Y2_STALLCURRENT 1500 + #define Y2_MAX_VOLTAGE 127 + #define Y2_CHAIN_POS 0 - #define Z_MICROSTEPS 16 + #define Z_MICROSTEPS 128 #define Z_OVERCURRENT 2000 #define Z_STALLCURRENT 1500 + #define Z_MAX_VOLTAGE 127 + #define Z_CHAIN_POS 0 - #define Z2_MICROSTEPS 16 + #define Z2_MICROSTEPS 128 #define Z2_OVERCURRENT 2000 #define Z2_STALLCURRENT 1500 + #define Z2_MAX_VOLTAGE 127 + #define Z2_CHAIN_POS 0 - #define Z3_MICROSTEPS 16 + #define Z3_MICROSTEPS 128 #define Z3_OVERCURRENT 2000 #define Z3_STALLCURRENT 1500 + #define Z3_MAX_VOLTAGE 127 + #define Z3_CHAIN_POS 0 - #define E0_MICROSTEPS 16 + #define E0_MICROSTEPS 128 #define E0_OVERCURRENT 2000 #define E0_STALLCURRENT 1500 + #define E0_MAX_VOLTAGE 127 + #define E0_CHAIN_POS 0 - #define E1_MICROSTEPS 16 + #define E1_MICROSTEPS 128 #define E1_OVERCURRENT 2000 #define E1_STALLCURRENT 1500 + #define E1_MAX_VOLTAGE 127 + #define E1_CHAIN_POS 0 - #define E2_MICROSTEPS 16 + #define E2_MICROSTEPS 128 #define E2_OVERCURRENT 2000 #define E2_STALLCURRENT 1500 + #define E2_MAX_VOLTAGE 127 + #define E2_CHAIN_POS 0 - #define E3_MICROSTEPS 16 + #define E3_MICROSTEPS 128 #define E3_OVERCURRENT 2000 #define E3_STALLCURRENT 1500 + #define E3_MAX_VOLTAGE 127 + #define E3_CHAIN_POS 0 - #define E4_MICROSTEPS 16 + #define E4_MICROSTEPS 128 #define E4_OVERCURRENT 2000 #define E4_STALLCURRENT 1500 + #define E4_MAX_VOLTAGE 127 + #define E4_CHAIN_POS 0 - #define E5_MICROSTEPS 16 + #define E5_MICROSTEPS 128 #define E5_OVERCURRENT 2000 #define E5_STALLCURRENT 1500 + #define E5_MAX_VOLTAGE 127 + #define E5_CHAIN_POS 0 + + + /** + * Monitor L6470 drivers for error conditions like over temperature and over current. + * In the case of over temperature Marlin can decrease the drive until the error condition clears. + * Other detected conditions can be used to stop the current print. + * Relevant g-codes: + * M906 - I1/2/3/4/5 Set or get motor drive level using axis codes X, Y, Z, E. Report values if no axis codes given. + * I not present or I0 or I1 - X, Y, Z or E0 + * I2 - X2, Y2, Z2 or E1 + * I3 - Z3 or E3 + * I4 - E4 + * I5 - E5 + * M916 - Increase drive level until get thermal warning + * M917 - Find minimum current thresholds + * M918 - Increase speed until max or error + * M122 S0/1 - Report driver parameters + */ + //#define MONITOR_L6470_DRIVER_STATUS + + #if ENABLED(MONITOR_L6470_DRIVER_STATUS) + #define KVAL_HOLD_STEP_DOWN 1 + //#define L6470_STOP_ON_ERROR + #endif + + #define L6470_CHITCHAT // enable display of additional status info #endif // L6470 diff --git a/Marlin/src/config/examples/Anet/A6/Configuration_adv.h b/Marlin/src/config/examples/Anet/A6/Configuration_adv.h index a71d0db12..8db87019e 100644 --- a/Marlin/src/config/examples/Anet/A6/Configuration_adv.h +++ b/Marlin/src/config/examples/Anet/A6/Configuration_adv.h @@ -1507,62 +1507,121 @@ /** * L6470 Stepper Driver options * - * The Arduino-L6470 library is required for this stepper driver. + * Arduino-L6470 library (0.7.0 or higher) is required for this stepper driver. * https://github.com/ameyer/Arduino-L6470 + * + * Requires the following to be defined in your pins_YOUR_BOARD file + * L6470_CHAIN_SCK_PIN + * L6470_CHAIN_MISO_PIN + * L6470_CHAIN_MOSI_PIN + * L6470_CHAIN_SS_PIN + * L6470_RESET_CHAIN_PIN (optional) */ #if HAS_DRIVER(L6470) - #define X_MICROSTEPS 16 // number of microsteps - #define X_OVERCURRENT 2000 // maxc current in mA. If the current goes over this value, the driver will switch off - #define X_STALLCURRENT 1500 // current in mA where the driver will detect a stall + #define X_MICROSTEPS 128 // number of microsteps (VALID: 1, 2, 4, 8, 16, 32, 128 & 128) + #define X_OVERCURRENT 2000 // current in mA where the driver will detect an over current (VALID: 375 x (1 - 16) - 6A max - rounds down) + #define X_STALLCURRENT 1500 // current in mA where the driver will detect a stall (VALID: 31.25 * (1-128) - 4A max - rounds down) + #define X_MAX_VOLTAGE 127 // 0-255, max effective voltage seen by stepper + #define X_CHAIN_POS 0 // position in SPI chain, 0 - not in chain, 1- nearest MOSI - #define X2_MICROSTEPS 16 + #define X2_MICROSTEPS 128 #define X2_OVERCURRENT 2000 #define X2_STALLCURRENT 1500 + #define X2_MAX_VOLTAGE 127 + #define X2_CHAIN_POS 0 - #define Y_MICROSTEPS 16 + #define Y_MICROSTEPS 128 #define Y_OVERCURRENT 2000 #define Y_STALLCURRENT 1500 + #define Y_MAX_VOLTAGE 127 + #define Y_CHAIN_POS 0 - #define Y2_MICROSTEPS 16 + #define Y2_MICROSTEPS 128 #define Y2_OVERCURRENT 2000 #define Y2_STALLCURRENT 1500 + #define Y2_MAX_VOLTAGE 127 + #define Y2_CHAIN_POS 0 - #define Z_MICROSTEPS 16 + #define Z_MICROSTEPS 128 #define Z_OVERCURRENT 2000 #define Z_STALLCURRENT 1500 + #define Z_MAX_VOLTAGE 127 + #define Z_CHAIN_POS 0 - #define Z2_MICROSTEPS 16 + #define Z2_MICROSTEPS 128 #define Z2_OVERCURRENT 2000 #define Z2_STALLCURRENT 1500 + #define Z2_MAX_VOLTAGE 127 + #define Z2_CHAIN_POS 0 - #define Z3_MICROSTEPS 16 + #define Z3_MICROSTEPS 128 #define Z3_OVERCURRENT 2000 #define Z3_STALLCURRENT 1500 + #define Z3_MAX_VOLTAGE 127 + #define Z3_CHAIN_POS 0 - #define E0_MICROSTEPS 16 + #define E0_MICROSTEPS 128 #define E0_OVERCURRENT 2000 #define E0_STALLCURRENT 1500 + #define E0_MAX_VOLTAGE 127 + #define E0_CHAIN_POS 0 - #define E1_MICROSTEPS 16 + #define E1_MICROSTEPS 128 #define E1_OVERCURRENT 2000 #define E1_STALLCURRENT 1500 + #define E1_MAX_VOLTAGE 127 + #define E1_CHAIN_POS 0 - #define E2_MICROSTEPS 16 + #define E2_MICROSTEPS 128 #define E2_OVERCURRENT 2000 #define E2_STALLCURRENT 1500 + #define E2_MAX_VOLTAGE 127 + #define E2_CHAIN_POS 0 - #define E3_MICROSTEPS 16 + #define E3_MICROSTEPS 128 #define E3_OVERCURRENT 2000 #define E3_STALLCURRENT 1500 + #define E3_MAX_VOLTAGE 127 + #define E3_CHAIN_POS 0 - #define E4_MICROSTEPS 16 + #define E4_MICROSTEPS 128 #define E4_OVERCURRENT 2000 #define E4_STALLCURRENT 1500 + #define E4_MAX_VOLTAGE 127 + #define E4_CHAIN_POS 0 - #define E5_MICROSTEPS 16 + #define E5_MICROSTEPS 128 #define E5_OVERCURRENT 2000 #define E5_STALLCURRENT 1500 + #define E5_MAX_VOLTAGE 127 + #define E5_CHAIN_POS 0 + + + /** + * Monitor L6470 drivers for error conditions like over temperature and over current. + * In the case of over temperature Marlin can decrease the drive until the error condition clears. + * Other detected conditions can be used to stop the current print. + * Relevant g-codes: + * M906 - I1/2/3/4/5 Set or get motor drive level using axis codes X, Y, Z, E. Report values if no axis codes given. + * I not present or I0 or I1 - X, Y, Z or E0 + * I2 - X2, Y2, Z2 or E1 + * I3 - Z3 or E3 + * I4 - E4 + * I5 - E5 + * M916 - Increase drive level until get thermal warning + * M917 - Find minimum current thresholds + * M918 - Increase speed until max or error + * M122 S0/1 - Report driver parameters + */ + //#define MONITOR_L6470_DRIVER_STATUS + + #if ENABLED(MONITOR_L6470_DRIVER_STATUS) + #define KVAL_HOLD_STEP_DOWN 1 + //#define L6470_STOP_ON_ERROR + #endif + + #define L6470_CHITCHAT // enable display of additional status info #endif // L6470 diff --git a/Marlin/src/config/examples/Anet/A8/Configuration_adv.h b/Marlin/src/config/examples/Anet/A8/Configuration_adv.h index c7b6e0b9b..74bdf35e2 100644 --- a/Marlin/src/config/examples/Anet/A8/Configuration_adv.h +++ b/Marlin/src/config/examples/Anet/A8/Configuration_adv.h @@ -1508,62 +1508,121 @@ /** * L6470 Stepper Driver options * - * The Arduino-L6470 library is required for this stepper driver. + * Arduino-L6470 library (0.7.0 or higher) is required for this stepper driver. * https://github.com/ameyer/Arduino-L6470 + * + * Requires the following to be defined in your pins_YOUR_BOARD file + * L6470_CHAIN_SCK_PIN + * L6470_CHAIN_MISO_PIN + * L6470_CHAIN_MOSI_PIN + * L6470_CHAIN_SS_PIN + * L6470_RESET_CHAIN_PIN (optional) */ #if HAS_DRIVER(L6470) - #define X_MICROSTEPS 16 // number of microsteps - #define X_OVERCURRENT 2000 // maxc current in mA. If the current goes over this value, the driver will switch off - #define X_STALLCURRENT 1500 // current in mA where the driver will detect a stall + #define X_MICROSTEPS 128 // number of microsteps (VALID: 1, 2, 4, 8, 16, 32, 128 & 128) + #define X_OVERCURRENT 2000 // current in mA where the driver will detect an over current (VALID: 375 x (1 - 16) - 6A max - rounds down) + #define X_STALLCURRENT 1500 // current in mA where the driver will detect a stall (VALID: 31.25 * (1-128) - 4A max - rounds down) + #define X_MAX_VOLTAGE 127 // 0-255, max effective voltage seen by stepper + #define X_CHAIN_POS 0 // position in SPI chain, 0 - not in chain, 1- nearest MOSI - #define X2_MICROSTEPS 16 + #define X2_MICROSTEPS 128 #define X2_OVERCURRENT 2000 #define X2_STALLCURRENT 1500 + #define X2_MAX_VOLTAGE 127 + #define X2_CHAIN_POS 0 - #define Y_MICROSTEPS 16 + #define Y_MICROSTEPS 128 #define Y_OVERCURRENT 2000 #define Y_STALLCURRENT 1500 + #define Y_MAX_VOLTAGE 127 + #define Y_CHAIN_POS 0 - #define Y2_MICROSTEPS 16 + #define Y2_MICROSTEPS 128 #define Y2_OVERCURRENT 2000 #define Y2_STALLCURRENT 1500 + #define Y2_MAX_VOLTAGE 127 + #define Y2_CHAIN_POS 0 - #define Z_MICROSTEPS 16 + #define Z_MICROSTEPS 128 #define Z_OVERCURRENT 2000 #define Z_STALLCURRENT 1500 + #define Z_MAX_VOLTAGE 127 + #define Z_CHAIN_POS 0 - #define Z2_MICROSTEPS 16 + #define Z2_MICROSTEPS 128 #define Z2_OVERCURRENT 2000 #define Z2_STALLCURRENT 1500 + #define Z2_MAX_VOLTAGE 127 + #define Z2_CHAIN_POS 0 - #define Z3_MICROSTEPS 16 + #define Z3_MICROSTEPS 128 #define Z3_OVERCURRENT 2000 #define Z3_STALLCURRENT 1500 + #define Z3_MAX_VOLTAGE 127 + #define Z3_CHAIN_POS 0 - #define E0_MICROSTEPS 16 + #define E0_MICROSTEPS 128 #define E0_OVERCURRENT 2000 #define E0_STALLCURRENT 1500 + #define E0_MAX_VOLTAGE 127 + #define E0_CHAIN_POS 0 - #define E1_MICROSTEPS 16 + #define E1_MICROSTEPS 128 #define E1_OVERCURRENT 2000 #define E1_STALLCURRENT 1500 + #define E1_MAX_VOLTAGE 127 + #define E1_CHAIN_POS 0 - #define E2_MICROSTEPS 16 + #define E2_MICROSTEPS 128 #define E2_OVERCURRENT 2000 #define E2_STALLCURRENT 1500 + #define E2_MAX_VOLTAGE 127 + #define E2_CHAIN_POS 0 - #define E3_MICROSTEPS 16 + #define E3_MICROSTEPS 128 #define E3_OVERCURRENT 2000 #define E3_STALLCURRENT 1500 + #define E3_MAX_VOLTAGE 127 + #define E3_CHAIN_POS 0 - #define E4_MICROSTEPS 16 + #define E4_MICROSTEPS 128 #define E4_OVERCURRENT 2000 #define E4_STALLCURRENT 1500 + #define E4_MAX_VOLTAGE 127 + #define E4_CHAIN_POS 0 - #define E5_MICROSTEPS 16 + #define E5_MICROSTEPS 128 #define E5_OVERCURRENT 2000 #define E5_STALLCURRENT 1500 + #define E5_MAX_VOLTAGE 127 + #define E5_CHAIN_POS 0 + + + /** + * Monitor L6470 drivers for error conditions like over temperature and over current. + * In the case of over temperature Marlin can decrease the drive until the error condition clears. + * Other detected conditions can be used to stop the current print. + * Relevant g-codes: + * M906 - I1/2/3/4/5 Set or get motor drive level using axis codes X, Y, Z, E. Report values if no axis codes given. + * I not present or I0 or I1 - X, Y, Z or E0 + * I2 - X2, Y2, Z2 or E1 + * I3 - Z3 or E3 + * I4 - E4 + * I5 - E5 + * M916 - Increase drive level until get thermal warning + * M917 - Find minimum current thresholds + * M918 - Increase speed until max or error + * M122 S0/1 - Report driver parameters + */ + //#define MONITOR_L6470_DRIVER_STATUS + + #if ENABLED(MONITOR_L6470_DRIVER_STATUS) + #define KVAL_HOLD_STEP_DOWN 1 + //#define L6470_STOP_ON_ERROR + #endif + + #define L6470_CHITCHAT // enable display of additional status info #endif // L6470 diff --git a/Marlin/src/config/examples/ArmEd/Configuration_adv.h b/Marlin/src/config/examples/ArmEd/Configuration_adv.h index 8982e5234..87c941812 100644 --- a/Marlin/src/config/examples/ArmEd/Configuration_adv.h +++ b/Marlin/src/config/examples/ArmEd/Configuration_adv.h @@ -1482,62 +1482,121 @@ /** * L6470 Stepper Driver options * - * The Arduino-L6470 library is required for this stepper driver. + * Arduino-L6470 library (0.7.0 or higher) is required for this stepper driver. * https://github.com/ameyer/Arduino-L6470 + * + * Requires the following to be defined in your pins_YOUR_BOARD file + * L6470_CHAIN_SCK_PIN + * L6470_CHAIN_MISO_PIN + * L6470_CHAIN_MOSI_PIN + * L6470_CHAIN_SS_PIN + * L6470_RESET_CHAIN_PIN (optional) */ #if HAS_DRIVER(L6470) - #define X_MICROSTEPS 16 // number of microsteps - #define X_OVERCURRENT 2000 // maxc current in mA. If the current goes over this value, the driver will switch off - #define X_STALLCURRENT 1500 // current in mA where the driver will detect a stall + #define X_MICROSTEPS 128 // number of microsteps (VALID: 1, 2, 4, 8, 16, 32, 128 & 128) + #define X_OVERCURRENT 2000 // current in mA where the driver will detect an over current (VALID: 375 x (1 - 16) - 6A max - rounds down) + #define X_STALLCURRENT 1500 // current in mA where the driver will detect a stall (VALID: 31.25 * (1-128) - 4A max - rounds down) + #define X_MAX_VOLTAGE 127 // 0-255, max effective voltage seen by stepper + #define X_CHAIN_POS 0 // position in SPI chain, 0 - not in chain, 1- nearest MOSI - #define X2_MICROSTEPS 16 + #define X2_MICROSTEPS 128 #define X2_OVERCURRENT 2000 #define X2_STALLCURRENT 1500 + #define X2_MAX_VOLTAGE 127 + #define X2_CHAIN_POS 0 - #define Y_MICROSTEPS 16 + #define Y_MICROSTEPS 128 #define Y_OVERCURRENT 2000 #define Y_STALLCURRENT 1500 + #define Y_MAX_VOLTAGE 127 + #define Y_CHAIN_POS 0 - #define Y2_MICROSTEPS 16 + #define Y2_MICROSTEPS 128 #define Y2_OVERCURRENT 2000 #define Y2_STALLCURRENT 1500 + #define Y2_MAX_VOLTAGE 127 + #define Y2_CHAIN_POS 0 - #define Z_MICROSTEPS 16 + #define Z_MICROSTEPS 128 #define Z_OVERCURRENT 2000 #define Z_STALLCURRENT 1500 + #define Z_MAX_VOLTAGE 127 + #define Z_CHAIN_POS 0 - #define Z2_MICROSTEPS 16 + #define Z2_MICROSTEPS 128 #define Z2_OVERCURRENT 2000 #define Z2_STALLCURRENT 1500 + #define Z2_MAX_VOLTAGE 127 + #define Z2_CHAIN_POS 0 - #define Z3_MICROSTEPS 16 + #define Z3_MICROSTEPS 128 #define Z3_OVERCURRENT 2000 #define Z3_STALLCURRENT 1500 + #define Z3_MAX_VOLTAGE 127 + #define Z3_CHAIN_POS 0 - #define E0_MICROSTEPS 16 + #define E0_MICROSTEPS 128 #define E0_OVERCURRENT 2000 #define E0_STALLCURRENT 1500 + #define E0_MAX_VOLTAGE 127 + #define E0_CHAIN_POS 0 - #define E1_MICROSTEPS 16 + #define E1_MICROSTEPS 128 #define E1_OVERCURRENT 2000 #define E1_STALLCURRENT 1500 + #define E1_MAX_VOLTAGE 127 + #define E1_CHAIN_POS 0 - #define E2_MICROSTEPS 16 + #define E2_MICROSTEPS 128 #define E2_OVERCURRENT 2000 #define E2_STALLCURRENT 1500 + #define E2_MAX_VOLTAGE 127 + #define E2_CHAIN_POS 0 - #define E3_MICROSTEPS 16 + #define E3_MICROSTEPS 128 #define E3_OVERCURRENT 2000 #define E3_STALLCURRENT 1500 + #define E3_MAX_VOLTAGE 127 + #define E3_CHAIN_POS 0 - #define E4_MICROSTEPS 16 + #define E4_MICROSTEPS 128 #define E4_OVERCURRENT 2000 #define E4_STALLCURRENT 1500 + #define E4_MAX_VOLTAGE 127 + #define E4_CHAIN_POS 0 - #define E5_MICROSTEPS 16 + #define E5_MICROSTEPS 128 #define E5_OVERCURRENT 2000 #define E5_STALLCURRENT 1500 + #define E5_MAX_VOLTAGE 127 + #define E5_CHAIN_POS 0 + + + /** + * Monitor L6470 drivers for error conditions like over temperature and over current. + * In the case of over temperature Marlin can decrease the drive until the error condition clears. + * Other detected conditions can be used to stop the current print. + * Relevant g-codes: + * M906 - I1/2/3/4/5 Set or get motor drive level using axis codes X, Y, Z, E. Report values if no axis codes given. + * I not present or I0 or I1 - X, Y, Z or E0 + * I2 - X2, Y2, Z2 or E1 + * I3 - Z3 or E3 + * I4 - E4 + * I5 - E5 + * M916 - Increase drive level until get thermal warning + * M917 - Find minimum current thresholds + * M918 - Increase speed until max or error + * M122 S0/1 - Report driver parameters + */ + //#define MONITOR_L6470_DRIVER_STATUS + + #if ENABLED(MONITOR_L6470_DRIVER_STATUS) + #define KVAL_HOLD_STEP_DOWN 1 + //#define L6470_STOP_ON_ERROR + #endif + + #define L6470_CHITCHAT // enable display of additional status info #endif // L6470 diff --git a/Marlin/src/config/examples/BIBO/TouchX/cyclops/Configuration_adv.h b/Marlin/src/config/examples/BIBO/TouchX/cyclops/Configuration_adv.h index 44309302a..b0c0eec41 100644 --- a/Marlin/src/config/examples/BIBO/TouchX/cyclops/Configuration_adv.h +++ b/Marlin/src/config/examples/BIBO/TouchX/cyclops/Configuration_adv.h @@ -1507,62 +1507,121 @@ /** * L6470 Stepper Driver options * - * The Arduino-L6470 library is required for this stepper driver. + * Arduino-L6470 library (0.7.0 or higher) is required for this stepper driver. * https://github.com/ameyer/Arduino-L6470 + * + * Requires the following to be defined in your pins_YOUR_BOARD file + * L6470_CHAIN_SCK_PIN + * L6470_CHAIN_MISO_PIN + * L6470_CHAIN_MOSI_PIN + * L6470_CHAIN_SS_PIN + * L6470_RESET_CHAIN_PIN (optional) */ #if HAS_DRIVER(L6470) - #define X_MICROSTEPS 16 // number of microsteps - #define X_OVERCURRENT 2000 // maxc current in mA. If the current goes over this value, the driver will switch off - #define X_STALLCURRENT 1500 // current in mA where the driver will detect a stall + #define X_MICROSTEPS 128 // number of microsteps (VALID: 1, 2, 4, 8, 16, 32, 128 & 128) + #define X_OVERCURRENT 2000 // current in mA where the driver will detect an over current (VALID: 375 x (1 - 16) - 6A max - rounds down) + #define X_STALLCURRENT 1500 // current in mA where the driver will detect a stall (VALID: 31.25 * (1-128) - 4A max - rounds down) + #define X_MAX_VOLTAGE 127 // 0-255, max effective voltage seen by stepper + #define X_CHAIN_POS 0 // position in SPI chain, 0 - not in chain, 1- nearest MOSI - #define X2_MICROSTEPS 16 + #define X2_MICROSTEPS 128 #define X2_OVERCURRENT 2000 #define X2_STALLCURRENT 1500 + #define X2_MAX_VOLTAGE 127 + #define X2_CHAIN_POS 0 - #define Y_MICROSTEPS 16 + #define Y_MICROSTEPS 128 #define Y_OVERCURRENT 2000 #define Y_STALLCURRENT 1500 + #define Y_MAX_VOLTAGE 127 + #define Y_CHAIN_POS 0 - #define Y2_MICROSTEPS 16 + #define Y2_MICROSTEPS 128 #define Y2_OVERCURRENT 2000 #define Y2_STALLCURRENT 1500 + #define Y2_MAX_VOLTAGE 127 + #define Y2_CHAIN_POS 0 - #define Z_MICROSTEPS 16 + #define Z_MICROSTEPS 128 #define Z_OVERCURRENT 2000 #define Z_STALLCURRENT 1500 + #define Z_MAX_VOLTAGE 127 + #define Z_CHAIN_POS 0 - #define Z2_MICROSTEPS 16 + #define Z2_MICROSTEPS 128 #define Z2_OVERCURRENT 2000 #define Z2_STALLCURRENT 1500 + #define Z2_MAX_VOLTAGE 127 + #define Z2_CHAIN_POS 0 - #define Z3_MICROSTEPS 16 + #define Z3_MICROSTEPS 128 #define Z3_OVERCURRENT 2000 #define Z3_STALLCURRENT 1500 + #define Z3_MAX_VOLTAGE 127 + #define Z3_CHAIN_POS 0 - #define E0_MICROSTEPS 16 + #define E0_MICROSTEPS 128 #define E0_OVERCURRENT 2000 #define E0_STALLCURRENT 1500 + #define E0_MAX_VOLTAGE 127 + #define E0_CHAIN_POS 0 - #define E1_MICROSTEPS 16 + #define E1_MICROSTEPS 128 #define E1_OVERCURRENT 2000 #define E1_STALLCURRENT 1500 + #define E1_MAX_VOLTAGE 127 + #define E1_CHAIN_POS 0 - #define E2_MICROSTEPS 16 + #define E2_MICROSTEPS 128 #define E2_OVERCURRENT 2000 #define E2_STALLCURRENT 1500 + #define E2_MAX_VOLTAGE 127 + #define E2_CHAIN_POS 0 - #define E3_MICROSTEPS 16 + #define E3_MICROSTEPS 128 #define E3_OVERCURRENT 2000 #define E3_STALLCURRENT 1500 + #define E3_MAX_VOLTAGE 127 + #define E3_CHAIN_POS 0 - #define E4_MICROSTEPS 16 + #define E4_MICROSTEPS 128 #define E4_OVERCURRENT 2000 #define E4_STALLCURRENT 1500 + #define E4_MAX_VOLTAGE 127 + #define E4_CHAIN_POS 0 - #define E5_MICROSTEPS 16 + #define E5_MICROSTEPS 128 #define E5_OVERCURRENT 2000 #define E5_STALLCURRENT 1500 + #define E5_MAX_VOLTAGE 127 + #define E5_CHAIN_POS 0 + + + /** + * Monitor L6470 drivers for error conditions like over temperature and over current. + * In the case of over temperature Marlin can decrease the drive until the error condition clears. + * Other detected conditions can be used to stop the current print. + * Relevant g-codes: + * M906 - I1/2/3/4/5 Set or get motor drive level using axis codes X, Y, Z, E. Report values if no axis codes given. + * I not present or I0 or I1 - X, Y, Z or E0 + * I2 - X2, Y2, Z2 or E1 + * I3 - Z3 or E3 + * I4 - E4 + * I5 - E5 + * M916 - Increase drive level until get thermal warning + * M917 - Find minimum current thresholds + * M918 - Increase speed until max or error + * M122 S0/1 - Report driver parameters + */ + //#define MONITOR_L6470_DRIVER_STATUS + + #if ENABLED(MONITOR_L6470_DRIVER_STATUS) + #define KVAL_HOLD_STEP_DOWN 1 + //#define L6470_STOP_ON_ERROR + #endif + + #define L6470_CHITCHAT // enable display of additional status info #endif // L6470 diff --git a/Marlin/src/config/examples/BIBO/TouchX/default/Configuration_adv.h b/Marlin/src/config/examples/BIBO/TouchX/default/Configuration_adv.h index 6dcb37a5e..6ccce86b6 100644 --- a/Marlin/src/config/examples/BIBO/TouchX/default/Configuration_adv.h +++ b/Marlin/src/config/examples/BIBO/TouchX/default/Configuration_adv.h @@ -1508,62 +1508,121 @@ /** * L6470 Stepper Driver options * - * The Arduino-L6470 library is required for this stepper driver. + * Arduino-L6470 library (0.7.0 or higher) is required for this stepper driver. * https://github.com/ameyer/Arduino-L6470 + * + * Requires the following to be defined in your pins_YOUR_BOARD file + * L6470_CHAIN_SCK_PIN + * L6470_CHAIN_MISO_PIN + * L6470_CHAIN_MOSI_PIN + * L6470_CHAIN_SS_PIN + * L6470_RESET_CHAIN_PIN (optional) */ #if HAS_DRIVER(L6470) - #define X_MICROSTEPS 16 // number of microsteps - #define X_OVERCURRENT 2000 // maxc current in mA. If the current goes over this value, the driver will switch off - #define X_STALLCURRENT 1500 // current in mA where the driver will detect a stall + #define X_MICROSTEPS 128 // number of microsteps (VALID: 1, 2, 4, 8, 16, 32, 128 & 128) + #define X_OVERCURRENT 2000 // current in mA where the driver will detect an over current (VALID: 375 x (1 - 16) - 6A max - rounds down) + #define X_STALLCURRENT 1500 // current in mA where the driver will detect a stall (VALID: 31.25 * (1-128) - 4A max - rounds down) + #define X_MAX_VOLTAGE 127 // 0-255, max effective voltage seen by stepper + #define X_CHAIN_POS 0 // position in SPI chain, 0 - not in chain, 1- nearest MOSI - #define X2_MICROSTEPS 16 + #define X2_MICROSTEPS 128 #define X2_OVERCURRENT 2000 #define X2_STALLCURRENT 1500 + #define X2_MAX_VOLTAGE 127 + #define X2_CHAIN_POS 0 - #define Y_MICROSTEPS 16 + #define Y_MICROSTEPS 128 #define Y_OVERCURRENT 2000 #define Y_STALLCURRENT 1500 + #define Y_MAX_VOLTAGE 127 + #define Y_CHAIN_POS 0 - #define Y2_MICROSTEPS 16 + #define Y2_MICROSTEPS 128 #define Y2_OVERCURRENT 2000 #define Y2_STALLCURRENT 1500 + #define Y2_MAX_VOLTAGE 127 + #define Y2_CHAIN_POS 0 - #define Z_MICROSTEPS 16 + #define Z_MICROSTEPS 128 #define Z_OVERCURRENT 2000 #define Z_STALLCURRENT 1500 + #define Z_MAX_VOLTAGE 127 + #define Z_CHAIN_POS 0 - #define Z2_MICROSTEPS 16 + #define Z2_MICROSTEPS 128 #define Z2_OVERCURRENT 2000 #define Z2_STALLCURRENT 1500 + #define Z2_MAX_VOLTAGE 127 + #define Z2_CHAIN_POS 0 - #define Z3_MICROSTEPS 16 + #define Z3_MICROSTEPS 128 #define Z3_OVERCURRENT 2000 #define Z3_STALLCURRENT 1500 + #define Z3_MAX_VOLTAGE 127 + #define Z3_CHAIN_POS 0 - #define E0_MICROSTEPS 16 + #define E0_MICROSTEPS 128 #define E0_OVERCURRENT 2000 #define E0_STALLCURRENT 1500 + #define E0_MAX_VOLTAGE 127 + #define E0_CHAIN_POS 0 - #define E1_MICROSTEPS 16 + #define E1_MICROSTEPS 128 #define E1_OVERCURRENT 2000 #define E1_STALLCURRENT 1500 + #define E1_MAX_VOLTAGE 127 + #define E1_CHAIN_POS 0 - #define E2_MICROSTEPS 16 + #define E2_MICROSTEPS 128 #define E2_OVERCURRENT 2000 #define E2_STALLCURRENT 1500 + #define E2_MAX_VOLTAGE 127 + #define E2_CHAIN_POS 0 - #define E3_MICROSTEPS 16 + #define E3_MICROSTEPS 128 #define E3_OVERCURRENT 2000 #define E3_STALLCURRENT 1500 + #define E3_MAX_VOLTAGE 127 + #define E3_CHAIN_POS 0 - #define E4_MICROSTEPS 16 + #define E4_MICROSTEPS 128 #define E4_OVERCURRENT 2000 #define E4_STALLCURRENT 1500 + #define E4_MAX_VOLTAGE 127 + #define E4_CHAIN_POS 0 - #define E5_MICROSTEPS 16 + #define E5_MICROSTEPS 128 #define E5_OVERCURRENT 2000 #define E5_STALLCURRENT 1500 + #define E5_MAX_VOLTAGE 127 + #define E5_CHAIN_POS 0 + + + /** + * Monitor L6470 drivers for error conditions like over temperature and over current. + * In the case of over temperature Marlin can decrease the drive until the error condition clears. + * Other detected conditions can be used to stop the current print. + * Relevant g-codes: + * M906 - I1/2/3/4/5 Set or get motor drive level using axis codes X, Y, Z, E. Report values if no axis codes given. + * I not present or I0 or I1 - X, Y, Z or E0 + * I2 - X2, Y2, Z2 or E1 + * I3 - Z3 or E3 + * I4 - E4 + * I5 - E5 + * M916 - Increase drive level until get thermal warning + * M917 - Find minimum current thresholds + * M918 - Increase speed until max or error + * M122 S0/1 - Report driver parameters + */ + //#define MONITOR_L6470_DRIVER_STATUS + + #if ENABLED(MONITOR_L6470_DRIVER_STATUS) + #define KVAL_HOLD_STEP_DOWN 1 + //#define L6470_STOP_ON_ERROR + #endif + + #define L6470_CHITCHAT // enable display of additional status info #endif // L6470 diff --git a/Marlin/src/config/examples/BQ/Hephestos/Configuration_adv.h b/Marlin/src/config/examples/BQ/Hephestos/Configuration_adv.h index df6b1a554..a771c69df 100644 --- a/Marlin/src/config/examples/BQ/Hephestos/Configuration_adv.h +++ b/Marlin/src/config/examples/BQ/Hephestos/Configuration_adv.h @@ -1508,62 +1508,121 @@ /** * L6470 Stepper Driver options * - * The Arduino-L6470 library is required for this stepper driver. + * Arduino-L6470 library (0.7.0 or higher) is required for this stepper driver. * https://github.com/ameyer/Arduino-L6470 + * + * Requires the following to be defined in your pins_YOUR_BOARD file + * L6470_CHAIN_SCK_PIN + * L6470_CHAIN_MISO_PIN + * L6470_CHAIN_MOSI_PIN + * L6470_CHAIN_SS_PIN + * L6470_RESET_CHAIN_PIN (optional) */ #if HAS_DRIVER(L6470) - #define X_MICROSTEPS 16 // number of microsteps - #define X_OVERCURRENT 2000 // maxc current in mA. If the current goes over this value, the driver will switch off - #define X_STALLCURRENT 1500 // current in mA where the driver will detect a stall + #define X_MICROSTEPS 128 // number of microsteps (VALID: 1, 2, 4, 8, 16, 32, 128 & 128) + #define X_OVERCURRENT 2000 // current in mA where the driver will detect an over current (VALID: 375 x (1 - 16) - 6A max - rounds down) + #define X_STALLCURRENT 1500 // current in mA where the driver will detect a stall (VALID: 31.25 * (1-128) - 4A max - rounds down) + #define X_MAX_VOLTAGE 127 // 0-255, max effective voltage seen by stepper + #define X_CHAIN_POS 0 // position in SPI chain, 0 - not in chain, 1- nearest MOSI - #define X2_MICROSTEPS 16 + #define X2_MICROSTEPS 128 #define X2_OVERCURRENT 2000 #define X2_STALLCURRENT 1500 + #define X2_MAX_VOLTAGE 127 + #define X2_CHAIN_POS 0 - #define Y_MICROSTEPS 16 + #define Y_MICROSTEPS 128 #define Y_OVERCURRENT 2000 #define Y_STALLCURRENT 1500 + #define Y_MAX_VOLTAGE 127 + #define Y_CHAIN_POS 0 - #define Y2_MICROSTEPS 16 + #define Y2_MICROSTEPS 128 #define Y2_OVERCURRENT 2000 #define Y2_STALLCURRENT 1500 + #define Y2_MAX_VOLTAGE 127 + #define Y2_CHAIN_POS 0 - #define Z_MICROSTEPS 16 + #define Z_MICROSTEPS 128 #define Z_OVERCURRENT 2000 #define Z_STALLCURRENT 1500 + #define Z_MAX_VOLTAGE 127 + #define Z_CHAIN_POS 0 - #define Z2_MICROSTEPS 16 + #define Z2_MICROSTEPS 128 #define Z2_OVERCURRENT 2000 #define Z2_STALLCURRENT 1500 + #define Z2_MAX_VOLTAGE 127 + #define Z2_CHAIN_POS 0 - #define Z3_MICROSTEPS 16 + #define Z3_MICROSTEPS 128 #define Z3_OVERCURRENT 2000 #define Z3_STALLCURRENT 1500 + #define Z3_MAX_VOLTAGE 127 + #define Z3_CHAIN_POS 0 - #define E0_MICROSTEPS 16 + #define E0_MICROSTEPS 128 #define E0_OVERCURRENT 2000 #define E0_STALLCURRENT 1500 + #define E0_MAX_VOLTAGE 127 + #define E0_CHAIN_POS 0 - #define E1_MICROSTEPS 16 + #define E1_MICROSTEPS 128 #define E1_OVERCURRENT 2000 #define E1_STALLCURRENT 1500 + #define E1_MAX_VOLTAGE 127 + #define E1_CHAIN_POS 0 - #define E2_MICROSTEPS 16 + #define E2_MICROSTEPS 128 #define E2_OVERCURRENT 2000 #define E2_STALLCURRENT 1500 + #define E2_MAX_VOLTAGE 127 + #define E2_CHAIN_POS 0 - #define E3_MICROSTEPS 16 + #define E3_MICROSTEPS 128 #define E3_OVERCURRENT 2000 #define E3_STALLCURRENT 1500 + #define E3_MAX_VOLTAGE 127 + #define E3_CHAIN_POS 0 - #define E4_MICROSTEPS 16 + #define E4_MICROSTEPS 128 #define E4_OVERCURRENT 2000 #define E4_STALLCURRENT 1500 + #define E4_MAX_VOLTAGE 127 + #define E4_CHAIN_POS 0 - #define E5_MICROSTEPS 16 + #define E5_MICROSTEPS 128 #define E5_OVERCURRENT 2000 #define E5_STALLCURRENT 1500 + #define E5_MAX_VOLTAGE 127 + #define E5_CHAIN_POS 0 + + + /** + * Monitor L6470 drivers for error conditions like over temperature and over current. + * In the case of over temperature Marlin can decrease the drive until the error condition clears. + * Other detected conditions can be used to stop the current print. + * Relevant g-codes: + * M906 - I1/2/3/4/5 Set or get motor drive level using axis codes X, Y, Z, E. Report values if no axis codes given. + * I not present or I0 or I1 - X, Y, Z or E0 + * I2 - X2, Y2, Z2 or E1 + * I3 - Z3 or E3 + * I4 - E4 + * I5 - E5 + * M916 - Increase drive level until get thermal warning + * M917 - Find minimum current thresholds + * M918 - Increase speed until max or error + * M122 S0/1 - Report driver parameters + */ + //#define MONITOR_L6470_DRIVER_STATUS + + #if ENABLED(MONITOR_L6470_DRIVER_STATUS) + #define KVAL_HOLD_STEP_DOWN 1 + //#define L6470_STOP_ON_ERROR + #endif + + #define L6470_CHITCHAT // enable display of additional status info #endif // L6470 diff --git a/Marlin/src/config/examples/BQ/Hephestos_2/Configuration_adv.h b/Marlin/src/config/examples/BQ/Hephestos_2/Configuration_adv.h index ff49e6b69..4525324f5 100644 --- a/Marlin/src/config/examples/BQ/Hephestos_2/Configuration_adv.h +++ b/Marlin/src/config/examples/BQ/Hephestos_2/Configuration_adv.h @@ -1516,62 +1516,121 @@ /** * L6470 Stepper Driver options * - * The Arduino-L6470 library is required for this stepper driver. + * Arduino-L6470 library (0.7.0 or higher) is required for this stepper driver. * https://github.com/ameyer/Arduino-L6470 + * + * Requires the following to be defined in your pins_YOUR_BOARD file + * L6470_CHAIN_SCK_PIN + * L6470_CHAIN_MISO_PIN + * L6470_CHAIN_MOSI_PIN + * L6470_CHAIN_SS_PIN + * L6470_RESET_CHAIN_PIN (optional) */ #if HAS_DRIVER(L6470) - #define X_MICROSTEPS 16 // number of microsteps - #define X_OVERCURRENT 2000 // maxc current in mA. If the current goes over this value, the driver will switch off - #define X_STALLCURRENT 1500 // current in mA where the driver will detect a stall + #define X_MICROSTEPS 128 // number of microsteps (VALID: 1, 2, 4, 8, 16, 32, 128 & 128) + #define X_OVERCURRENT 2000 // current in mA where the driver will detect an over current (VALID: 375 x (1 - 16) - 6A max - rounds down) + #define X_STALLCURRENT 1500 // current in mA where the driver will detect a stall (VALID: 31.25 * (1-128) - 4A max - rounds down) + #define X_MAX_VOLTAGE 127 // 0-255, max effective voltage seen by stepper + #define X_CHAIN_POS 0 // position in SPI chain, 0 - not in chain, 1- nearest MOSI - #define X2_MICROSTEPS 16 + #define X2_MICROSTEPS 128 #define X2_OVERCURRENT 2000 #define X2_STALLCURRENT 1500 + #define X2_MAX_VOLTAGE 127 + #define X2_CHAIN_POS 0 - #define Y_MICROSTEPS 16 + #define Y_MICROSTEPS 128 #define Y_OVERCURRENT 2000 #define Y_STALLCURRENT 1500 + #define Y_MAX_VOLTAGE 127 + #define Y_CHAIN_POS 0 - #define Y2_MICROSTEPS 16 + #define Y2_MICROSTEPS 128 #define Y2_OVERCURRENT 2000 #define Y2_STALLCURRENT 1500 + #define Y2_MAX_VOLTAGE 127 + #define Y2_CHAIN_POS 0 - #define Z_MICROSTEPS 16 + #define Z_MICROSTEPS 128 #define Z_OVERCURRENT 2000 #define Z_STALLCURRENT 1500 + #define Z_MAX_VOLTAGE 127 + #define Z_CHAIN_POS 0 - #define Z2_MICROSTEPS 16 + #define Z2_MICROSTEPS 128 #define Z2_OVERCURRENT 2000 #define Z2_STALLCURRENT 1500 + #define Z2_MAX_VOLTAGE 127 + #define Z2_CHAIN_POS 0 - #define Z3_MICROSTEPS 16 + #define Z3_MICROSTEPS 128 #define Z3_OVERCURRENT 2000 #define Z3_STALLCURRENT 1500 + #define Z3_MAX_VOLTAGE 127 + #define Z3_CHAIN_POS 0 - #define E0_MICROSTEPS 16 + #define E0_MICROSTEPS 128 #define E0_OVERCURRENT 2000 #define E0_STALLCURRENT 1500 + #define E0_MAX_VOLTAGE 127 + #define E0_CHAIN_POS 0 - #define E1_MICROSTEPS 16 + #define E1_MICROSTEPS 128 #define E1_OVERCURRENT 2000 #define E1_STALLCURRENT 1500 + #define E1_MAX_VOLTAGE 127 + #define E1_CHAIN_POS 0 - #define E2_MICROSTEPS 16 + #define E2_MICROSTEPS 128 #define E2_OVERCURRENT 2000 #define E2_STALLCURRENT 1500 + #define E2_MAX_VOLTAGE 127 + #define E2_CHAIN_POS 0 - #define E3_MICROSTEPS 16 + #define E3_MICROSTEPS 128 #define E3_OVERCURRENT 2000 #define E3_STALLCURRENT 1500 + #define E3_MAX_VOLTAGE 127 + #define E3_CHAIN_POS 0 - #define E4_MICROSTEPS 16 + #define E4_MICROSTEPS 128 #define E4_OVERCURRENT 2000 #define E4_STALLCURRENT 1500 + #define E4_MAX_VOLTAGE 127 + #define E4_CHAIN_POS 0 - #define E5_MICROSTEPS 16 + #define E5_MICROSTEPS 128 #define E5_OVERCURRENT 2000 #define E5_STALLCURRENT 1500 + #define E5_MAX_VOLTAGE 127 + #define E5_CHAIN_POS 0 + + + /** + * Monitor L6470 drivers for error conditions like over temperature and over current. + * In the case of over temperature Marlin can decrease the drive until the error condition clears. + * Other detected conditions can be used to stop the current print. + * Relevant g-codes: + * M906 - I1/2/3/4/5 Set or get motor drive level using axis codes X, Y, Z, E. Report values if no axis codes given. + * I not present or I0 or I1 - X, Y, Z or E0 + * I2 - X2, Y2, Z2 or E1 + * I3 - Z3 or E3 + * I4 - E4 + * I5 - E5 + * M916 - Increase drive level until get thermal warning + * M917 - Find minimum current thresholds + * M918 - Increase speed until max or error + * M122 S0/1 - Report driver parameters + */ + //#define MONITOR_L6470_DRIVER_STATUS + + #if ENABLED(MONITOR_L6470_DRIVER_STATUS) + #define KVAL_HOLD_STEP_DOWN 1 + //#define L6470_STOP_ON_ERROR + #endif + + #define L6470_CHITCHAT // enable display of additional status info #endif // L6470 diff --git a/Marlin/src/config/examples/BQ/WITBOX/Configuration_adv.h b/Marlin/src/config/examples/BQ/WITBOX/Configuration_adv.h index df6b1a554..a771c69df 100644 --- a/Marlin/src/config/examples/BQ/WITBOX/Configuration_adv.h +++ b/Marlin/src/config/examples/BQ/WITBOX/Configuration_adv.h @@ -1508,62 +1508,121 @@ /** * L6470 Stepper Driver options * - * The Arduino-L6470 library is required for this stepper driver. + * Arduino-L6470 library (0.7.0 or higher) is required for this stepper driver. * https://github.com/ameyer/Arduino-L6470 + * + * Requires the following to be defined in your pins_YOUR_BOARD file + * L6470_CHAIN_SCK_PIN + * L6470_CHAIN_MISO_PIN + * L6470_CHAIN_MOSI_PIN + * L6470_CHAIN_SS_PIN + * L6470_RESET_CHAIN_PIN (optional) */ #if HAS_DRIVER(L6470) - #define X_MICROSTEPS 16 // number of microsteps - #define X_OVERCURRENT 2000 // maxc current in mA. If the current goes over this value, the driver will switch off - #define X_STALLCURRENT 1500 // current in mA where the driver will detect a stall + #define X_MICROSTEPS 128 // number of microsteps (VALID: 1, 2, 4, 8, 16, 32, 128 & 128) + #define X_OVERCURRENT 2000 // current in mA where the driver will detect an over current (VALID: 375 x (1 - 16) - 6A max - rounds down) + #define X_STALLCURRENT 1500 // current in mA where the driver will detect a stall (VALID: 31.25 * (1-128) - 4A max - rounds down) + #define X_MAX_VOLTAGE 127 // 0-255, max effective voltage seen by stepper + #define X_CHAIN_POS 0 // position in SPI chain, 0 - not in chain, 1- nearest MOSI - #define X2_MICROSTEPS 16 + #define X2_MICROSTEPS 128 #define X2_OVERCURRENT 2000 #define X2_STALLCURRENT 1500 + #define X2_MAX_VOLTAGE 127 + #define X2_CHAIN_POS 0 - #define Y_MICROSTEPS 16 + #define Y_MICROSTEPS 128 #define Y_OVERCURRENT 2000 #define Y_STALLCURRENT 1500 + #define Y_MAX_VOLTAGE 127 + #define Y_CHAIN_POS 0 - #define Y2_MICROSTEPS 16 + #define Y2_MICROSTEPS 128 #define Y2_OVERCURRENT 2000 #define Y2_STALLCURRENT 1500 + #define Y2_MAX_VOLTAGE 127 + #define Y2_CHAIN_POS 0 - #define Z_MICROSTEPS 16 + #define Z_MICROSTEPS 128 #define Z_OVERCURRENT 2000 #define Z_STALLCURRENT 1500 + #define Z_MAX_VOLTAGE 127 + #define Z_CHAIN_POS 0 - #define Z2_MICROSTEPS 16 + #define Z2_MICROSTEPS 128 #define Z2_OVERCURRENT 2000 #define Z2_STALLCURRENT 1500 + #define Z2_MAX_VOLTAGE 127 + #define Z2_CHAIN_POS 0 - #define Z3_MICROSTEPS 16 + #define Z3_MICROSTEPS 128 #define Z3_OVERCURRENT 2000 #define Z3_STALLCURRENT 1500 + #define Z3_MAX_VOLTAGE 127 + #define Z3_CHAIN_POS 0 - #define E0_MICROSTEPS 16 + #define E0_MICROSTEPS 128 #define E0_OVERCURRENT 2000 #define E0_STALLCURRENT 1500 + #define E0_MAX_VOLTAGE 127 + #define E0_CHAIN_POS 0 - #define E1_MICROSTEPS 16 + #define E1_MICROSTEPS 128 #define E1_OVERCURRENT 2000 #define E1_STALLCURRENT 1500 + #define E1_MAX_VOLTAGE 127 + #define E1_CHAIN_POS 0 - #define E2_MICROSTEPS 16 + #define E2_MICROSTEPS 128 #define E2_OVERCURRENT 2000 #define E2_STALLCURRENT 1500 + #define E2_MAX_VOLTAGE 127 + #define E2_CHAIN_POS 0 - #define E3_MICROSTEPS 16 + #define E3_MICROSTEPS 128 #define E3_OVERCURRENT 2000 #define E3_STALLCURRENT 1500 + #define E3_MAX_VOLTAGE 127 + #define E3_CHAIN_POS 0 - #define E4_MICROSTEPS 16 + #define E4_MICROSTEPS 128 #define E4_OVERCURRENT 2000 #define E4_STALLCURRENT 1500 + #define E4_MAX_VOLTAGE 127 + #define E4_CHAIN_POS 0 - #define E5_MICROSTEPS 16 + #define E5_MICROSTEPS 128 #define E5_OVERCURRENT 2000 #define E5_STALLCURRENT 1500 + #define E5_MAX_VOLTAGE 127 + #define E5_CHAIN_POS 0 + + + /** + * Monitor L6470 drivers for error conditions like over temperature and over current. + * In the case of over temperature Marlin can decrease the drive until the error condition clears. + * Other detected conditions can be used to stop the current print. + * Relevant g-codes: + * M906 - I1/2/3/4/5 Set or get motor drive level using axis codes X, Y, Z, E. Report values if no axis codes given. + * I not present or I0 or I1 - X, Y, Z or E0 + * I2 - X2, Y2, Z2 or E1 + * I3 - Z3 or E3 + * I4 - E4 + * I5 - E5 + * M916 - Increase drive level until get thermal warning + * M917 - Find minimum current thresholds + * M918 - Increase speed until max or error + * M122 S0/1 - Report driver parameters + */ + //#define MONITOR_L6470_DRIVER_STATUS + + #if ENABLED(MONITOR_L6470_DRIVER_STATUS) + #define KVAL_HOLD_STEP_DOWN 1 + //#define L6470_STOP_ON_ERROR + #endif + + #define L6470_CHITCHAT // enable display of additional status info #endif // L6470 diff --git a/Marlin/src/config/examples/Cartesio/Configuration_adv.h b/Marlin/src/config/examples/Cartesio/Configuration_adv.h index 6e2f94707..b0326bd21 100644 --- a/Marlin/src/config/examples/Cartesio/Configuration_adv.h +++ b/Marlin/src/config/examples/Cartesio/Configuration_adv.h @@ -1508,62 +1508,121 @@ /** * L6470 Stepper Driver options * - * The Arduino-L6470 library is required for this stepper driver. + * Arduino-L6470 library (0.7.0 or higher) is required for this stepper driver. * https://github.com/ameyer/Arduino-L6470 + * + * Requires the following to be defined in your pins_YOUR_BOARD file + * L6470_CHAIN_SCK_PIN + * L6470_CHAIN_MISO_PIN + * L6470_CHAIN_MOSI_PIN + * L6470_CHAIN_SS_PIN + * L6470_RESET_CHAIN_PIN (optional) */ #if HAS_DRIVER(L6470) - #define X_MICROSTEPS 16 // number of microsteps - #define X_OVERCURRENT 2000 // maxc current in mA. If the current goes over this value, the driver will switch off - #define X_STALLCURRENT 1500 // current in mA where the driver will detect a stall + #define X_MICROSTEPS 128 // number of microsteps (VALID: 1, 2, 4, 8, 16, 32, 128 & 128) + #define X_OVERCURRENT 2000 // current in mA where the driver will detect an over current (VALID: 375 x (1 - 16) - 6A max - rounds down) + #define X_STALLCURRENT 1500 // current in mA where the driver will detect a stall (VALID: 31.25 * (1-128) - 4A max - rounds down) + #define X_MAX_VOLTAGE 127 // 0-255, max effective voltage seen by stepper + #define X_CHAIN_POS 0 // position in SPI chain, 0 - not in chain, 1- nearest MOSI - #define X2_MICROSTEPS 16 + #define X2_MICROSTEPS 128 #define X2_OVERCURRENT 2000 #define X2_STALLCURRENT 1500 + #define X2_MAX_VOLTAGE 127 + #define X2_CHAIN_POS 0 - #define Y_MICROSTEPS 16 + #define Y_MICROSTEPS 128 #define Y_OVERCURRENT 2000 #define Y_STALLCURRENT 1500 + #define Y_MAX_VOLTAGE 127 + #define Y_CHAIN_POS 0 - #define Y2_MICROSTEPS 16 + #define Y2_MICROSTEPS 128 #define Y2_OVERCURRENT 2000 #define Y2_STALLCURRENT 1500 + #define Y2_MAX_VOLTAGE 127 + #define Y2_CHAIN_POS 0 - #define Z_MICROSTEPS 16 + #define Z_MICROSTEPS 128 #define Z_OVERCURRENT 2000 #define Z_STALLCURRENT 1500 + #define Z_MAX_VOLTAGE 127 + #define Z_CHAIN_POS 0 - #define Z2_MICROSTEPS 16 + #define Z2_MICROSTEPS 128 #define Z2_OVERCURRENT 2000 #define Z2_STALLCURRENT 1500 + #define Z2_MAX_VOLTAGE 127 + #define Z2_CHAIN_POS 0 - #define Z3_MICROSTEPS 16 + #define Z3_MICROSTEPS 128 #define Z3_OVERCURRENT 2000 #define Z3_STALLCURRENT 1500 + #define Z3_MAX_VOLTAGE 127 + #define Z3_CHAIN_POS 0 - #define E0_MICROSTEPS 16 + #define E0_MICROSTEPS 128 #define E0_OVERCURRENT 2000 #define E0_STALLCURRENT 1500 + #define E0_MAX_VOLTAGE 127 + #define E0_CHAIN_POS 0 - #define E1_MICROSTEPS 16 + #define E1_MICROSTEPS 128 #define E1_OVERCURRENT 2000 #define E1_STALLCURRENT 1500 + #define E1_MAX_VOLTAGE 127 + #define E1_CHAIN_POS 0 - #define E2_MICROSTEPS 16 + #define E2_MICROSTEPS 128 #define E2_OVERCURRENT 2000 #define E2_STALLCURRENT 1500 + #define E2_MAX_VOLTAGE 127 + #define E2_CHAIN_POS 0 - #define E3_MICROSTEPS 16 + #define E3_MICROSTEPS 128 #define E3_OVERCURRENT 2000 #define E3_STALLCURRENT 1500 + #define E3_MAX_VOLTAGE 127 + #define E3_CHAIN_POS 0 - #define E4_MICROSTEPS 16 + #define E4_MICROSTEPS 128 #define E4_OVERCURRENT 2000 #define E4_STALLCURRENT 1500 + #define E4_MAX_VOLTAGE 127 + #define E4_CHAIN_POS 0 - #define E5_MICROSTEPS 16 + #define E5_MICROSTEPS 128 #define E5_OVERCURRENT 2000 #define E5_STALLCURRENT 1500 + #define E5_MAX_VOLTAGE 127 + #define E5_CHAIN_POS 0 + + + /** + * Monitor L6470 drivers for error conditions like over temperature and over current. + * In the case of over temperature Marlin can decrease the drive until the error condition clears. + * Other detected conditions can be used to stop the current print. + * Relevant g-codes: + * M906 - I1/2/3/4/5 Set or get motor drive level using axis codes X, Y, Z, E. Report values if no axis codes given. + * I not present or I0 or I1 - X, Y, Z or E0 + * I2 - X2, Y2, Z2 or E1 + * I3 - Z3 or E3 + * I4 - E4 + * I5 - E5 + * M916 - Increase drive level until get thermal warning + * M917 - Find minimum current thresholds + * M918 - Increase speed until max or error + * M122 S0/1 - Report driver parameters + */ + //#define MONITOR_L6470_DRIVER_STATUS + + #if ENABLED(MONITOR_L6470_DRIVER_STATUS) + #define KVAL_HOLD_STEP_DOWN 1 + //#define L6470_STOP_ON_ERROR + #endif + + #define L6470_CHITCHAT // enable display of additional status info #endif // L6470 diff --git a/Marlin/src/config/examples/Creality/CR-10/Configuration_adv.h b/Marlin/src/config/examples/Creality/CR-10/Configuration_adv.h index a36748d56..2a28290c9 100755 --- a/Marlin/src/config/examples/Creality/CR-10/Configuration_adv.h +++ b/Marlin/src/config/examples/Creality/CR-10/Configuration_adv.h @@ -1508,62 +1508,121 @@ /** * L6470 Stepper Driver options * - * The Arduino-L6470 library is required for this stepper driver. + * Arduino-L6470 library (0.7.0 or higher) is required for this stepper driver. * https://github.com/ameyer/Arduino-L6470 + * + * Requires the following to be defined in your pins_YOUR_BOARD file + * L6470_CHAIN_SCK_PIN + * L6470_CHAIN_MISO_PIN + * L6470_CHAIN_MOSI_PIN + * L6470_CHAIN_SS_PIN + * L6470_RESET_CHAIN_PIN (optional) */ #if HAS_DRIVER(L6470) - #define X_MICROSTEPS 16 // number of microsteps - #define X_OVERCURRENT 2000 // maxc current in mA. If the current goes over this value, the driver will switch off - #define X_STALLCURRENT 1500 // current in mA where the driver will detect a stall + #define X_MICROSTEPS 128 // number of microsteps (VALID: 1, 2, 4, 8, 16, 32, 128 & 128) + #define X_OVERCURRENT 2000 // current in mA where the driver will detect an over current (VALID: 375 x (1 - 16) - 6A max - rounds down) + #define X_STALLCURRENT 1500 // current in mA where the driver will detect a stall (VALID: 31.25 * (1-128) - 4A max - rounds down) + #define X_MAX_VOLTAGE 127 // 0-255, max effective voltage seen by stepper + #define X_CHAIN_POS 0 // position in SPI chain, 0 - not in chain, 1- nearest MOSI - #define X2_MICROSTEPS 16 + #define X2_MICROSTEPS 128 #define X2_OVERCURRENT 2000 #define X2_STALLCURRENT 1500 + #define X2_MAX_VOLTAGE 127 + #define X2_CHAIN_POS 0 - #define Y_MICROSTEPS 16 + #define Y_MICROSTEPS 128 #define Y_OVERCURRENT 2000 #define Y_STALLCURRENT 1500 + #define Y_MAX_VOLTAGE 127 + #define Y_CHAIN_POS 0 - #define Y2_MICROSTEPS 16 + #define Y2_MICROSTEPS 128 #define Y2_OVERCURRENT 2000 #define Y2_STALLCURRENT 1500 + #define Y2_MAX_VOLTAGE 127 + #define Y2_CHAIN_POS 0 - #define Z_MICROSTEPS 16 + #define Z_MICROSTEPS 128 #define Z_OVERCURRENT 2000 #define Z_STALLCURRENT 1500 + #define Z_MAX_VOLTAGE 127 + #define Z_CHAIN_POS 0 - #define Z2_MICROSTEPS 16 + #define Z2_MICROSTEPS 128 #define Z2_OVERCURRENT 2000 #define Z2_STALLCURRENT 1500 + #define Z2_MAX_VOLTAGE 127 + #define Z2_CHAIN_POS 0 - #define Z3_MICROSTEPS 16 + #define Z3_MICROSTEPS 128 #define Z3_OVERCURRENT 2000 #define Z3_STALLCURRENT 1500 + #define Z3_MAX_VOLTAGE 127 + #define Z3_CHAIN_POS 0 - #define E0_MICROSTEPS 16 + #define E0_MICROSTEPS 128 #define E0_OVERCURRENT 2000 #define E0_STALLCURRENT 1500 + #define E0_MAX_VOLTAGE 127 + #define E0_CHAIN_POS 0 - #define E1_MICROSTEPS 16 + #define E1_MICROSTEPS 128 #define E1_OVERCURRENT 2000 #define E1_STALLCURRENT 1500 + #define E1_MAX_VOLTAGE 127 + #define E1_CHAIN_POS 0 - #define E2_MICROSTEPS 16 + #define E2_MICROSTEPS 128 #define E2_OVERCURRENT 2000 #define E2_STALLCURRENT 1500 + #define E2_MAX_VOLTAGE 127 + #define E2_CHAIN_POS 0 - #define E3_MICROSTEPS 16 + #define E3_MICROSTEPS 128 #define E3_OVERCURRENT 2000 #define E3_STALLCURRENT 1500 + #define E3_MAX_VOLTAGE 127 + #define E3_CHAIN_POS 0 - #define E4_MICROSTEPS 16 + #define E4_MICROSTEPS 128 #define E4_OVERCURRENT 2000 #define E4_STALLCURRENT 1500 + #define E4_MAX_VOLTAGE 127 + #define E4_CHAIN_POS 0 - #define E5_MICROSTEPS 16 + #define E5_MICROSTEPS 128 #define E5_OVERCURRENT 2000 #define E5_STALLCURRENT 1500 + #define E5_MAX_VOLTAGE 127 + #define E5_CHAIN_POS 0 + + + /** + * Monitor L6470 drivers for error conditions like over temperature and over current. + * In the case of over temperature Marlin can decrease the drive until the error condition clears. + * Other detected conditions can be used to stop the current print. + * Relevant g-codes: + * M906 - I1/2/3/4/5 Set or get motor drive level using axis codes X, Y, Z, E. Report values if no axis codes given. + * I not present or I0 or I1 - X, Y, Z or E0 + * I2 - X2, Y2, Z2 or E1 + * I3 - Z3 or E3 + * I4 - E4 + * I5 - E5 + * M916 - Increase drive level until get thermal warning + * M917 - Find minimum current thresholds + * M918 - Increase speed until max or error + * M122 S0/1 - Report driver parameters + */ + //#define MONITOR_L6470_DRIVER_STATUS + + #if ENABLED(MONITOR_L6470_DRIVER_STATUS) + #define KVAL_HOLD_STEP_DOWN 1 + //#define L6470_STOP_ON_ERROR + #endif + + #define L6470_CHITCHAT // enable display of additional status info #endif // L6470 diff --git a/Marlin/src/config/examples/Creality/CR-10S/Configuration_adv.h b/Marlin/src/config/examples/Creality/CR-10S/Configuration_adv.h index e2e7a7c59..27f9107e1 100644 --- a/Marlin/src/config/examples/Creality/CR-10S/Configuration_adv.h +++ b/Marlin/src/config/examples/Creality/CR-10S/Configuration_adv.h @@ -1508,62 +1508,121 @@ /** * L6470 Stepper Driver options * - * The Arduino-L6470 library is required for this stepper driver. + * Arduino-L6470 library (0.7.0 or higher) is required for this stepper driver. * https://github.com/ameyer/Arduino-L6470 + * + * Requires the following to be defined in your pins_YOUR_BOARD file + * L6470_CHAIN_SCK_PIN + * L6470_CHAIN_MISO_PIN + * L6470_CHAIN_MOSI_PIN + * L6470_CHAIN_SS_PIN + * L6470_RESET_CHAIN_PIN (optional) */ #if HAS_DRIVER(L6470) - #define X_MICROSTEPS 16 // number of microsteps - #define X_OVERCURRENT 2000 // maxc current in mA. If the current goes over this value, the driver will switch off - #define X_STALLCURRENT 1500 // current in mA where the driver will detect a stall + #define X_MICROSTEPS 128 // number of microsteps (VALID: 1, 2, 4, 8, 16, 32, 128 & 128) + #define X_OVERCURRENT 2000 // current in mA where the driver will detect an over current (VALID: 375 x (1 - 16) - 6A max - rounds down) + #define X_STALLCURRENT 1500 // current in mA where the driver will detect a stall (VALID: 31.25 * (1-128) - 4A max - rounds down) + #define X_MAX_VOLTAGE 127 // 0-255, max effective voltage seen by stepper + #define X_CHAIN_POS 0 // position in SPI chain, 0 - not in chain, 1- nearest MOSI - #define X2_MICROSTEPS 16 + #define X2_MICROSTEPS 128 #define X2_OVERCURRENT 2000 #define X2_STALLCURRENT 1500 + #define X2_MAX_VOLTAGE 127 + #define X2_CHAIN_POS 0 - #define Y_MICROSTEPS 16 + #define Y_MICROSTEPS 128 #define Y_OVERCURRENT 2000 #define Y_STALLCURRENT 1500 + #define Y_MAX_VOLTAGE 127 + #define Y_CHAIN_POS 0 - #define Y2_MICROSTEPS 16 + #define Y2_MICROSTEPS 128 #define Y2_OVERCURRENT 2000 #define Y2_STALLCURRENT 1500 + #define Y2_MAX_VOLTAGE 127 + #define Y2_CHAIN_POS 0 - #define Z_MICROSTEPS 16 + #define Z_MICROSTEPS 128 #define Z_OVERCURRENT 2000 #define Z_STALLCURRENT 1500 + #define Z_MAX_VOLTAGE 127 + #define Z_CHAIN_POS 0 - #define Z2_MICROSTEPS 16 + #define Z2_MICROSTEPS 128 #define Z2_OVERCURRENT 2000 #define Z2_STALLCURRENT 1500 + #define Z2_MAX_VOLTAGE 127 + #define Z2_CHAIN_POS 0 - #define Z3_MICROSTEPS 16 + #define Z3_MICROSTEPS 128 #define Z3_OVERCURRENT 2000 #define Z3_STALLCURRENT 1500 + #define Z3_MAX_VOLTAGE 127 + #define Z3_CHAIN_POS 0 - #define E0_MICROSTEPS 16 + #define E0_MICROSTEPS 128 #define E0_OVERCURRENT 2000 #define E0_STALLCURRENT 1500 + #define E0_MAX_VOLTAGE 127 + #define E0_CHAIN_POS 0 - #define E1_MICROSTEPS 16 + #define E1_MICROSTEPS 128 #define E1_OVERCURRENT 2000 #define E1_STALLCURRENT 1500 + #define E1_MAX_VOLTAGE 127 + #define E1_CHAIN_POS 0 - #define E2_MICROSTEPS 16 + #define E2_MICROSTEPS 128 #define E2_OVERCURRENT 2000 #define E2_STALLCURRENT 1500 + #define E2_MAX_VOLTAGE 127 + #define E2_CHAIN_POS 0 - #define E3_MICROSTEPS 16 + #define E3_MICROSTEPS 128 #define E3_OVERCURRENT 2000 #define E3_STALLCURRENT 1500 + #define E3_MAX_VOLTAGE 127 + #define E3_CHAIN_POS 0 - #define E4_MICROSTEPS 16 + #define E4_MICROSTEPS 128 #define E4_OVERCURRENT 2000 #define E4_STALLCURRENT 1500 + #define E4_MAX_VOLTAGE 127 + #define E4_CHAIN_POS 0 - #define E5_MICROSTEPS 16 + #define E5_MICROSTEPS 128 #define E5_OVERCURRENT 2000 #define E5_STALLCURRENT 1500 + #define E5_MAX_VOLTAGE 127 + #define E5_CHAIN_POS 0 + + + /** + * Monitor L6470 drivers for error conditions like over temperature and over current. + * In the case of over temperature Marlin can decrease the drive until the error condition clears. + * Other detected conditions can be used to stop the current print. + * Relevant g-codes: + * M906 - I1/2/3/4/5 Set or get motor drive level using axis codes X, Y, Z, E. Report values if no axis codes given. + * I not present or I0 or I1 - X, Y, Z or E0 + * I2 - X2, Y2, Z2 or E1 + * I3 - Z3 or E3 + * I4 - E4 + * I5 - E5 + * M916 - Increase drive level until get thermal warning + * M917 - Find minimum current thresholds + * M918 - Increase speed until max or error + * M122 S0/1 - Report driver parameters + */ + //#define MONITOR_L6470_DRIVER_STATUS + + #if ENABLED(MONITOR_L6470_DRIVER_STATUS) + #define KVAL_HOLD_STEP_DOWN 1 + //#define L6470_STOP_ON_ERROR + #endif + + #define L6470_CHITCHAT // enable display of additional status info #endif // L6470 diff --git a/Marlin/src/config/examples/Creality/CR-10mini/Configuration_adv.h b/Marlin/src/config/examples/Creality/CR-10mini/Configuration_adv.h index cba5302d4..ac710686a 100644 --- a/Marlin/src/config/examples/Creality/CR-10mini/Configuration_adv.h +++ b/Marlin/src/config/examples/Creality/CR-10mini/Configuration_adv.h @@ -1508,62 +1508,121 @@ /** * L6470 Stepper Driver options * - * The Arduino-L6470 library is required for this stepper driver. + * Arduino-L6470 library (0.7.0 or higher) is required for this stepper driver. * https://github.com/ameyer/Arduino-L6470 + * + * Requires the following to be defined in your pins_YOUR_BOARD file + * L6470_CHAIN_SCK_PIN + * L6470_CHAIN_MISO_PIN + * L6470_CHAIN_MOSI_PIN + * L6470_CHAIN_SS_PIN + * L6470_RESET_CHAIN_PIN (optional) */ #if HAS_DRIVER(L6470) - #define X_MICROSTEPS 16 // number of microsteps - #define X_OVERCURRENT 2000 // maxc current in mA. If the current goes over this value, the driver will switch off - #define X_STALLCURRENT 1500 // current in mA where the driver will detect a stall + #define X_MICROSTEPS 128 // number of microsteps (VALID: 1, 2, 4, 8, 16, 32, 128 & 128) + #define X_OVERCURRENT 2000 // current in mA where the driver will detect an over current (VALID: 375 x (1 - 16) - 6A max - rounds down) + #define X_STALLCURRENT 1500 // current in mA where the driver will detect a stall (VALID: 31.25 * (1-128) - 4A max - rounds down) + #define X_MAX_VOLTAGE 127 // 0-255, max effective voltage seen by stepper + #define X_CHAIN_POS 0 // position in SPI chain, 0 - not in chain, 1- nearest MOSI - #define X2_MICROSTEPS 16 + #define X2_MICROSTEPS 128 #define X2_OVERCURRENT 2000 #define X2_STALLCURRENT 1500 + #define X2_MAX_VOLTAGE 127 + #define X2_CHAIN_POS 0 - #define Y_MICROSTEPS 16 + #define Y_MICROSTEPS 128 #define Y_OVERCURRENT 2000 #define Y_STALLCURRENT 1500 + #define Y_MAX_VOLTAGE 127 + #define Y_CHAIN_POS 0 - #define Y2_MICROSTEPS 16 + #define Y2_MICROSTEPS 128 #define Y2_OVERCURRENT 2000 #define Y2_STALLCURRENT 1500 + #define Y2_MAX_VOLTAGE 127 + #define Y2_CHAIN_POS 0 - #define Z_MICROSTEPS 16 + #define Z_MICROSTEPS 128 #define Z_OVERCURRENT 2000 #define Z_STALLCURRENT 1500 + #define Z_MAX_VOLTAGE 127 + #define Z_CHAIN_POS 0 - #define Z2_MICROSTEPS 16 + #define Z2_MICROSTEPS 128 #define Z2_OVERCURRENT 2000 #define Z2_STALLCURRENT 1500 + #define Z2_MAX_VOLTAGE 127 + #define Z2_CHAIN_POS 0 - #define Z3_MICROSTEPS 16 + #define Z3_MICROSTEPS 128 #define Z3_OVERCURRENT 2000 #define Z3_STALLCURRENT 1500 + #define Z3_MAX_VOLTAGE 127 + #define Z3_CHAIN_POS 0 - #define E0_MICROSTEPS 16 + #define E0_MICROSTEPS 128 #define E0_OVERCURRENT 2000 #define E0_STALLCURRENT 1500 + #define E0_MAX_VOLTAGE 127 + #define E0_CHAIN_POS 0 - #define E1_MICROSTEPS 16 + #define E1_MICROSTEPS 128 #define E1_OVERCURRENT 2000 #define E1_STALLCURRENT 1500 + #define E1_MAX_VOLTAGE 127 + #define E1_CHAIN_POS 0 - #define E2_MICROSTEPS 16 + #define E2_MICROSTEPS 128 #define E2_OVERCURRENT 2000 #define E2_STALLCURRENT 1500 + #define E2_MAX_VOLTAGE 127 + #define E2_CHAIN_POS 0 - #define E3_MICROSTEPS 16 + #define E3_MICROSTEPS 128 #define E3_OVERCURRENT 2000 #define E3_STALLCURRENT 1500 + #define E3_MAX_VOLTAGE 127 + #define E3_CHAIN_POS 0 - #define E4_MICROSTEPS 16 + #define E4_MICROSTEPS 128 #define E4_OVERCURRENT 2000 #define E4_STALLCURRENT 1500 + #define E4_MAX_VOLTAGE 127 + #define E4_CHAIN_POS 0 - #define E5_MICROSTEPS 16 + #define E5_MICROSTEPS 128 #define E5_OVERCURRENT 2000 #define E5_STALLCURRENT 1500 + #define E5_MAX_VOLTAGE 127 + #define E5_CHAIN_POS 0 + + + /** + * Monitor L6470 drivers for error conditions like over temperature and over current. + * In the case of over temperature Marlin can decrease the drive until the error condition clears. + * Other detected conditions can be used to stop the current print. + * Relevant g-codes: + * M906 - I1/2/3/4/5 Set or get motor drive level using axis codes X, Y, Z, E. Report values if no axis codes given. + * I not present or I0 or I1 - X, Y, Z or E0 + * I2 - X2, Y2, Z2 or E1 + * I3 - Z3 or E3 + * I4 - E4 + * I5 - E5 + * M916 - Increase drive level until get thermal warning + * M917 - Find minimum current thresholds + * M918 - Increase speed until max or error + * M122 S0/1 - Report driver parameters + */ + //#define MONITOR_L6470_DRIVER_STATUS + + #if ENABLED(MONITOR_L6470_DRIVER_STATUS) + #define KVAL_HOLD_STEP_DOWN 1 + //#define L6470_STOP_ON_ERROR + #endif + + #define L6470_CHITCHAT // enable display of additional status info #endif // L6470 diff --git a/Marlin/src/config/examples/Creality/CR-8/Configuration_adv.h b/Marlin/src/config/examples/Creality/CR-8/Configuration_adv.h index 76cdb32ce..c4368a808 100644 --- a/Marlin/src/config/examples/Creality/CR-8/Configuration_adv.h +++ b/Marlin/src/config/examples/Creality/CR-8/Configuration_adv.h @@ -1508,62 +1508,121 @@ /** * L6470 Stepper Driver options * - * The Arduino-L6470 library is required for this stepper driver. + * Arduino-L6470 library (0.7.0 or higher) is required for this stepper driver. * https://github.com/ameyer/Arduino-L6470 + * + * Requires the following to be defined in your pins_YOUR_BOARD file + * L6470_CHAIN_SCK_PIN + * L6470_CHAIN_MISO_PIN + * L6470_CHAIN_MOSI_PIN + * L6470_CHAIN_SS_PIN + * L6470_RESET_CHAIN_PIN (optional) */ #if HAS_DRIVER(L6470) - #define X_MICROSTEPS 16 // number of microsteps - #define X_OVERCURRENT 2000 // maxc current in mA. If the current goes over this value, the driver will switch off - #define X_STALLCURRENT 1500 // current in mA where the driver will detect a stall + #define X_MICROSTEPS 128 // number of microsteps (VALID: 1, 2, 4, 8, 16, 32, 128 & 128) + #define X_OVERCURRENT 2000 // current in mA where the driver will detect an over current (VALID: 375 x (1 - 16) - 6A max - rounds down) + #define X_STALLCURRENT 1500 // current in mA where the driver will detect a stall (VALID: 31.25 * (1-128) - 4A max - rounds down) + #define X_MAX_VOLTAGE 127 // 0-255, max effective voltage seen by stepper + #define X_CHAIN_POS 0 // position in SPI chain, 0 - not in chain, 1- nearest MOSI - #define X2_MICROSTEPS 16 + #define X2_MICROSTEPS 128 #define X2_OVERCURRENT 2000 #define X2_STALLCURRENT 1500 + #define X2_MAX_VOLTAGE 127 + #define X2_CHAIN_POS 0 - #define Y_MICROSTEPS 16 + #define Y_MICROSTEPS 128 #define Y_OVERCURRENT 2000 #define Y_STALLCURRENT 1500 + #define Y_MAX_VOLTAGE 127 + #define Y_CHAIN_POS 0 - #define Y2_MICROSTEPS 16 + #define Y2_MICROSTEPS 128 #define Y2_OVERCURRENT 2000 #define Y2_STALLCURRENT 1500 + #define Y2_MAX_VOLTAGE 127 + #define Y2_CHAIN_POS 0 - #define Z_MICROSTEPS 16 + #define Z_MICROSTEPS 128 #define Z_OVERCURRENT 2000 #define Z_STALLCURRENT 1500 + #define Z_MAX_VOLTAGE 127 + #define Z_CHAIN_POS 0 - #define Z2_MICROSTEPS 16 + #define Z2_MICROSTEPS 128 #define Z2_OVERCURRENT 2000 #define Z2_STALLCURRENT 1500 + #define Z2_MAX_VOLTAGE 127 + #define Z2_CHAIN_POS 0 - #define Z3_MICROSTEPS 16 + #define Z3_MICROSTEPS 128 #define Z3_OVERCURRENT 2000 #define Z3_STALLCURRENT 1500 + #define Z3_MAX_VOLTAGE 127 + #define Z3_CHAIN_POS 0 - #define E0_MICROSTEPS 16 + #define E0_MICROSTEPS 128 #define E0_OVERCURRENT 2000 #define E0_STALLCURRENT 1500 + #define E0_MAX_VOLTAGE 127 + #define E0_CHAIN_POS 0 - #define E1_MICROSTEPS 16 + #define E1_MICROSTEPS 128 #define E1_OVERCURRENT 2000 #define E1_STALLCURRENT 1500 + #define E1_MAX_VOLTAGE 127 + #define E1_CHAIN_POS 0 - #define E2_MICROSTEPS 16 + #define E2_MICROSTEPS 128 #define E2_OVERCURRENT 2000 #define E2_STALLCURRENT 1500 + #define E2_MAX_VOLTAGE 127 + #define E2_CHAIN_POS 0 - #define E3_MICROSTEPS 16 + #define E3_MICROSTEPS 128 #define E3_OVERCURRENT 2000 #define E3_STALLCURRENT 1500 + #define E3_MAX_VOLTAGE 127 + #define E3_CHAIN_POS 0 - #define E4_MICROSTEPS 16 + #define E4_MICROSTEPS 128 #define E4_OVERCURRENT 2000 #define E4_STALLCURRENT 1500 + #define E4_MAX_VOLTAGE 127 + #define E4_CHAIN_POS 0 - #define E5_MICROSTEPS 16 + #define E5_MICROSTEPS 128 #define E5_OVERCURRENT 2000 #define E5_STALLCURRENT 1500 + #define E5_MAX_VOLTAGE 127 + #define E5_CHAIN_POS 0 + + + /** + * Monitor L6470 drivers for error conditions like over temperature and over current. + * In the case of over temperature Marlin can decrease the drive until the error condition clears. + * Other detected conditions can be used to stop the current print. + * Relevant g-codes: + * M906 - I1/2/3/4/5 Set or get motor drive level using axis codes X, Y, Z, E. Report values if no axis codes given. + * I not present or I0 or I1 - X, Y, Z or E0 + * I2 - X2, Y2, Z2 or E1 + * I3 - Z3 or E3 + * I4 - E4 + * I5 - E5 + * M916 - Increase drive level until get thermal warning + * M917 - Find minimum current thresholds + * M918 - Increase speed until max or error + * M122 S0/1 - Report driver parameters + */ + //#define MONITOR_L6470_DRIVER_STATUS + + #if ENABLED(MONITOR_L6470_DRIVER_STATUS) + #define KVAL_HOLD_STEP_DOWN 1 + //#define L6470_STOP_ON_ERROR + #endif + + #define L6470_CHITCHAT // enable display of additional status info #endif // L6470 diff --git a/Marlin/src/config/examples/Creality/Ender-2/Configuration_adv.h b/Marlin/src/config/examples/Creality/Ender-2/Configuration_adv.h index d66ee5ee9..612dbf111 100644 --- a/Marlin/src/config/examples/Creality/Ender-2/Configuration_adv.h +++ b/Marlin/src/config/examples/Creality/Ender-2/Configuration_adv.h @@ -1508,62 +1508,121 @@ /** * L6470 Stepper Driver options * - * The Arduino-L6470 library is required for this stepper driver. + * Arduino-L6470 library (0.7.0 or higher) is required for this stepper driver. * https://github.com/ameyer/Arduino-L6470 + * + * Requires the following to be defined in your pins_YOUR_BOARD file + * L6470_CHAIN_SCK_PIN + * L6470_CHAIN_MISO_PIN + * L6470_CHAIN_MOSI_PIN + * L6470_CHAIN_SS_PIN + * L6470_RESET_CHAIN_PIN (optional) */ #if HAS_DRIVER(L6470) - #define X_MICROSTEPS 16 // number of microsteps - #define X_OVERCURRENT 2000 // maxc current in mA. If the current goes over this value, the driver will switch off - #define X_STALLCURRENT 1500 // current in mA where the driver will detect a stall + #define X_MICROSTEPS 128 // number of microsteps (VALID: 1, 2, 4, 8, 16, 32, 128 & 128) + #define X_OVERCURRENT 2000 // current in mA where the driver will detect an over current (VALID: 375 x (1 - 16) - 6A max - rounds down) + #define X_STALLCURRENT 1500 // current in mA where the driver will detect a stall (VALID: 31.25 * (1-128) - 4A max - rounds down) + #define X_MAX_VOLTAGE 127 // 0-255, max effective voltage seen by stepper + #define X_CHAIN_POS 0 // position in SPI chain, 0 - not in chain, 1- nearest MOSI - #define X2_MICROSTEPS 16 + #define X2_MICROSTEPS 128 #define X2_OVERCURRENT 2000 #define X2_STALLCURRENT 1500 + #define X2_MAX_VOLTAGE 127 + #define X2_CHAIN_POS 0 - #define Y_MICROSTEPS 16 + #define Y_MICROSTEPS 128 #define Y_OVERCURRENT 2000 #define Y_STALLCURRENT 1500 + #define Y_MAX_VOLTAGE 127 + #define Y_CHAIN_POS 0 - #define Y2_MICROSTEPS 16 + #define Y2_MICROSTEPS 128 #define Y2_OVERCURRENT 2000 #define Y2_STALLCURRENT 1500 + #define Y2_MAX_VOLTAGE 127 + #define Y2_CHAIN_POS 0 - #define Z_MICROSTEPS 16 + #define Z_MICROSTEPS 128 #define Z_OVERCURRENT 2000 #define Z_STALLCURRENT 1500 + #define Z_MAX_VOLTAGE 127 + #define Z_CHAIN_POS 0 - #define Z2_MICROSTEPS 16 + #define Z2_MICROSTEPS 128 #define Z2_OVERCURRENT 2000 #define Z2_STALLCURRENT 1500 + #define Z2_MAX_VOLTAGE 127 + #define Z2_CHAIN_POS 0 - #define Z3_MICROSTEPS 16 + #define Z3_MICROSTEPS 128 #define Z3_OVERCURRENT 2000 #define Z3_STALLCURRENT 1500 + #define Z3_MAX_VOLTAGE 127 + #define Z3_CHAIN_POS 0 - #define E0_MICROSTEPS 16 + #define E0_MICROSTEPS 128 #define E0_OVERCURRENT 2000 #define E0_STALLCURRENT 1500 + #define E0_MAX_VOLTAGE 127 + #define E0_CHAIN_POS 0 - #define E1_MICROSTEPS 16 + #define E1_MICROSTEPS 128 #define E1_OVERCURRENT 2000 #define E1_STALLCURRENT 1500 + #define E1_MAX_VOLTAGE 127 + #define E1_CHAIN_POS 0 - #define E2_MICROSTEPS 16 + #define E2_MICROSTEPS 128 #define E2_OVERCURRENT 2000 #define E2_STALLCURRENT 1500 + #define E2_MAX_VOLTAGE 127 + #define E2_CHAIN_POS 0 - #define E3_MICROSTEPS 16 + #define E3_MICROSTEPS 128 #define E3_OVERCURRENT 2000 #define E3_STALLCURRENT 1500 + #define E3_MAX_VOLTAGE 127 + #define E3_CHAIN_POS 0 - #define E4_MICROSTEPS 16 + #define E4_MICROSTEPS 128 #define E4_OVERCURRENT 2000 #define E4_STALLCURRENT 1500 + #define E4_MAX_VOLTAGE 127 + #define E4_CHAIN_POS 0 - #define E5_MICROSTEPS 16 + #define E5_MICROSTEPS 128 #define E5_OVERCURRENT 2000 #define E5_STALLCURRENT 1500 + #define E5_MAX_VOLTAGE 127 + #define E5_CHAIN_POS 0 + + + /** + * Monitor L6470 drivers for error conditions like over temperature and over current. + * In the case of over temperature Marlin can decrease the drive until the error condition clears. + * Other detected conditions can be used to stop the current print. + * Relevant g-codes: + * M906 - I1/2/3/4/5 Set or get motor drive level using axis codes X, Y, Z, E. Report values if no axis codes given. + * I not present or I0 or I1 - X, Y, Z or E0 + * I2 - X2, Y2, Z2 or E1 + * I3 - Z3 or E3 + * I4 - E4 + * I5 - E5 + * M916 - Increase drive level until get thermal warning + * M917 - Find minimum current thresholds + * M918 - Increase speed until max or error + * M122 S0/1 - Report driver parameters + */ + //#define MONITOR_L6470_DRIVER_STATUS + + #if ENABLED(MONITOR_L6470_DRIVER_STATUS) + #define KVAL_HOLD_STEP_DOWN 1 + //#define L6470_STOP_ON_ERROR + #endif + + #define L6470_CHITCHAT // enable display of additional status info #endif // L6470 diff --git a/Marlin/src/config/examples/Creality/Ender-3/Configuration_adv.h b/Marlin/src/config/examples/Creality/Ender-3/Configuration_adv.h index 25e38925a..30cb4a6f9 100644 --- a/Marlin/src/config/examples/Creality/Ender-3/Configuration_adv.h +++ b/Marlin/src/config/examples/Creality/Ender-3/Configuration_adv.h @@ -1508,62 +1508,121 @@ /** * L6470 Stepper Driver options * - * The Arduino-L6470 library is required for this stepper driver. + * Arduino-L6470 library (0.7.0 or higher) is required for this stepper driver. * https://github.com/ameyer/Arduino-L6470 + * + * Requires the following to be defined in your pins_YOUR_BOARD file + * L6470_CHAIN_SCK_PIN + * L6470_CHAIN_MISO_PIN + * L6470_CHAIN_MOSI_PIN + * L6470_CHAIN_SS_PIN + * L6470_RESET_CHAIN_PIN (optional) */ #if HAS_DRIVER(L6470) - #define X_MICROSTEPS 16 // number of microsteps - #define X_OVERCURRENT 2000 // maxc current in mA. If the current goes over this value, the driver will switch off - #define X_STALLCURRENT 1500 // current in mA where the driver will detect a stall + #define X_MICROSTEPS 128 // number of microsteps (VALID: 1, 2, 4, 8, 16, 32, 128 & 128) + #define X_OVERCURRENT 2000 // current in mA where the driver will detect an over current (VALID: 375 x (1 - 16) - 6A max - rounds down) + #define X_STALLCURRENT 1500 // current in mA where the driver will detect a stall (VALID: 31.25 * (1-128) - 4A max - rounds down) + #define X_MAX_VOLTAGE 127 // 0-255, max effective voltage seen by stepper + #define X_CHAIN_POS 0 // position in SPI chain, 0 - not in chain, 1- nearest MOSI - #define X2_MICROSTEPS 16 + #define X2_MICROSTEPS 128 #define X2_OVERCURRENT 2000 #define X2_STALLCURRENT 1500 + #define X2_MAX_VOLTAGE 127 + #define X2_CHAIN_POS 0 - #define Y_MICROSTEPS 16 + #define Y_MICROSTEPS 128 #define Y_OVERCURRENT 2000 #define Y_STALLCURRENT 1500 + #define Y_MAX_VOLTAGE 127 + #define Y_CHAIN_POS 0 - #define Y2_MICROSTEPS 16 + #define Y2_MICROSTEPS 128 #define Y2_OVERCURRENT 2000 #define Y2_STALLCURRENT 1500 + #define Y2_MAX_VOLTAGE 127 + #define Y2_CHAIN_POS 0 - #define Z_MICROSTEPS 16 + #define Z_MICROSTEPS 128 #define Z_OVERCURRENT 2000 #define Z_STALLCURRENT 1500 + #define Z_MAX_VOLTAGE 127 + #define Z_CHAIN_POS 0 - #define Z2_MICROSTEPS 16 + #define Z2_MICROSTEPS 128 #define Z2_OVERCURRENT 2000 #define Z2_STALLCURRENT 1500 + #define Z2_MAX_VOLTAGE 127 + #define Z2_CHAIN_POS 0 - #define Z3_MICROSTEPS 16 + #define Z3_MICROSTEPS 128 #define Z3_OVERCURRENT 2000 #define Z3_STALLCURRENT 1500 + #define Z3_MAX_VOLTAGE 127 + #define Z3_CHAIN_POS 0 - #define E0_MICROSTEPS 16 + #define E0_MICROSTEPS 128 #define E0_OVERCURRENT 2000 #define E0_STALLCURRENT 1500 + #define E0_MAX_VOLTAGE 127 + #define E0_CHAIN_POS 0 - #define E1_MICROSTEPS 16 + #define E1_MICROSTEPS 128 #define E1_OVERCURRENT 2000 #define E1_STALLCURRENT 1500 + #define E1_MAX_VOLTAGE 127 + #define E1_CHAIN_POS 0 - #define E2_MICROSTEPS 16 + #define E2_MICROSTEPS 128 #define E2_OVERCURRENT 2000 #define E2_STALLCURRENT 1500 + #define E2_MAX_VOLTAGE 127 + #define E2_CHAIN_POS 0 - #define E3_MICROSTEPS 16 + #define E3_MICROSTEPS 128 #define E3_OVERCURRENT 2000 #define E3_STALLCURRENT 1500 + #define E3_MAX_VOLTAGE 127 + #define E3_CHAIN_POS 0 - #define E4_MICROSTEPS 16 + #define E4_MICROSTEPS 128 #define E4_OVERCURRENT 2000 #define E4_STALLCURRENT 1500 + #define E4_MAX_VOLTAGE 127 + #define E4_CHAIN_POS 0 - #define E5_MICROSTEPS 16 + #define E5_MICROSTEPS 128 #define E5_OVERCURRENT 2000 #define E5_STALLCURRENT 1500 + #define E5_MAX_VOLTAGE 127 + #define E5_CHAIN_POS 0 + + + /** + * Monitor L6470 drivers for error conditions like over temperature and over current. + * In the case of over temperature Marlin can decrease the drive until the error condition clears. + * Other detected conditions can be used to stop the current print. + * Relevant g-codes: + * M906 - I1/2/3/4/5 Set or get motor drive level using axis codes X, Y, Z, E. Report values if no axis codes given. + * I not present or I0 or I1 - X, Y, Z or E0 + * I2 - X2, Y2, Z2 or E1 + * I3 - Z3 or E3 + * I4 - E4 + * I5 - E5 + * M916 - Increase drive level until get thermal warning + * M917 - Find minimum current thresholds + * M918 - Increase speed until max or error + * M122 S0/1 - Report driver parameters + */ + //#define MONITOR_L6470_DRIVER_STATUS + + #if ENABLED(MONITOR_L6470_DRIVER_STATUS) + #define KVAL_HOLD_STEP_DOWN 1 + //#define L6470_STOP_ON_ERROR + #endif + + #define L6470_CHITCHAT // enable display of additional status info #endif // L6470 diff --git a/Marlin/src/config/examples/Creality/Ender-4/Configuration_adv.h b/Marlin/src/config/examples/Creality/Ender-4/Configuration_adv.h index 781874628..1c613a174 100644 --- a/Marlin/src/config/examples/Creality/Ender-4/Configuration_adv.h +++ b/Marlin/src/config/examples/Creality/Ender-4/Configuration_adv.h @@ -1508,62 +1508,121 @@ /** * L6470 Stepper Driver options * - * The Arduino-L6470 library is required for this stepper driver. + * Arduino-L6470 library (0.7.0 or higher) is required for this stepper driver. * https://github.com/ameyer/Arduino-L6470 + * + * Requires the following to be defined in your pins_YOUR_BOARD file + * L6470_CHAIN_SCK_PIN + * L6470_CHAIN_MISO_PIN + * L6470_CHAIN_MOSI_PIN + * L6470_CHAIN_SS_PIN + * L6470_RESET_CHAIN_PIN (optional) */ #if HAS_DRIVER(L6470) - #define X_MICROSTEPS 16 // number of microsteps - #define X_OVERCURRENT 2000 // maxc current in mA. If the current goes over this value, the driver will switch off - #define X_STALLCURRENT 1500 // current in mA where the driver will detect a stall + #define X_MICROSTEPS 128 // number of microsteps (VALID: 1, 2, 4, 8, 16, 32, 128 & 128) + #define X_OVERCURRENT 2000 // current in mA where the driver will detect an over current (VALID: 375 x (1 - 16) - 6A max - rounds down) + #define X_STALLCURRENT 1500 // current in mA where the driver will detect a stall (VALID: 31.25 * (1-128) - 4A max - rounds down) + #define X_MAX_VOLTAGE 127 // 0-255, max effective voltage seen by stepper + #define X_CHAIN_POS 0 // position in SPI chain, 0 - not in chain, 1- nearest MOSI - #define X2_MICROSTEPS 16 + #define X2_MICROSTEPS 128 #define X2_OVERCURRENT 2000 #define X2_STALLCURRENT 1500 + #define X2_MAX_VOLTAGE 127 + #define X2_CHAIN_POS 0 - #define Y_MICROSTEPS 16 + #define Y_MICROSTEPS 128 #define Y_OVERCURRENT 2000 #define Y_STALLCURRENT 1500 + #define Y_MAX_VOLTAGE 127 + #define Y_CHAIN_POS 0 - #define Y2_MICROSTEPS 16 + #define Y2_MICROSTEPS 128 #define Y2_OVERCURRENT 2000 #define Y2_STALLCURRENT 1500 + #define Y2_MAX_VOLTAGE 127 + #define Y2_CHAIN_POS 0 - #define Z_MICROSTEPS 16 + #define Z_MICROSTEPS 128 #define Z_OVERCURRENT 2000 #define Z_STALLCURRENT 1500 + #define Z_MAX_VOLTAGE 127 + #define Z_CHAIN_POS 0 - #define Z2_MICROSTEPS 16 + #define Z2_MICROSTEPS 128 #define Z2_OVERCURRENT 2000 #define Z2_STALLCURRENT 1500 + #define Z2_MAX_VOLTAGE 127 + #define Z2_CHAIN_POS 0 - #define Z3_MICROSTEPS 16 + #define Z3_MICROSTEPS 128 #define Z3_OVERCURRENT 2000 #define Z3_STALLCURRENT 1500 + #define Z3_MAX_VOLTAGE 127 + #define Z3_CHAIN_POS 0 - #define E0_MICROSTEPS 16 + #define E0_MICROSTEPS 128 #define E0_OVERCURRENT 2000 #define E0_STALLCURRENT 1500 + #define E0_MAX_VOLTAGE 127 + #define E0_CHAIN_POS 0 - #define E1_MICROSTEPS 16 + #define E1_MICROSTEPS 128 #define E1_OVERCURRENT 2000 #define E1_STALLCURRENT 1500 + #define E1_MAX_VOLTAGE 127 + #define E1_CHAIN_POS 0 - #define E2_MICROSTEPS 16 + #define E2_MICROSTEPS 128 #define E2_OVERCURRENT 2000 #define E2_STALLCURRENT 1500 + #define E2_MAX_VOLTAGE 127 + #define E2_CHAIN_POS 0 - #define E3_MICROSTEPS 16 + #define E3_MICROSTEPS 128 #define E3_OVERCURRENT 2000 #define E3_STALLCURRENT 1500 + #define E3_MAX_VOLTAGE 127 + #define E3_CHAIN_POS 0 - #define E4_MICROSTEPS 16 + #define E4_MICROSTEPS 128 #define E4_OVERCURRENT 2000 #define E4_STALLCURRENT 1500 + #define E4_MAX_VOLTAGE 127 + #define E4_CHAIN_POS 0 - #define E5_MICROSTEPS 16 + #define E5_MICROSTEPS 128 #define E5_OVERCURRENT 2000 #define E5_STALLCURRENT 1500 + #define E5_MAX_VOLTAGE 127 + #define E5_CHAIN_POS 0 + + + /** + * Monitor L6470 drivers for error conditions like over temperature and over current. + * In the case of over temperature Marlin can decrease the drive until the error condition clears. + * Other detected conditions can be used to stop the current print. + * Relevant g-codes: + * M906 - I1/2/3/4/5 Set or get motor drive level using axis codes X, Y, Z, E. Report values if no axis codes given. + * I not present or I0 or I1 - X, Y, Z or E0 + * I2 - X2, Y2, Z2 or E1 + * I3 - Z3 or E3 + * I4 - E4 + * I5 - E5 + * M916 - Increase drive level until get thermal warning + * M917 - Find minimum current thresholds + * M918 - Increase speed until max or error + * M122 S0/1 - Report driver parameters + */ + //#define MONITOR_L6470_DRIVER_STATUS + + #if ENABLED(MONITOR_L6470_DRIVER_STATUS) + #define KVAL_HOLD_STEP_DOWN 1 + //#define L6470_STOP_ON_ERROR + #endif + + #define L6470_CHITCHAT // enable display of additional status info #endif // L6470 diff --git a/Marlin/src/config/examples/Einstart-S/Configuration_adv.h b/Marlin/src/config/examples/Einstart-S/Configuration_adv.h index c404f3346..7ff7ef6a7 100644 --- a/Marlin/src/config/examples/Einstart-S/Configuration_adv.h +++ b/Marlin/src/config/examples/Einstart-S/Configuration_adv.h @@ -1508,62 +1508,121 @@ /** * L6470 Stepper Driver options * - * The Arduino-L6470 library is required for this stepper driver. + * Arduino-L6470 library (0.7.0 or higher) is required for this stepper driver. * https://github.com/ameyer/Arduino-L6470 + * + * Requires the following to be defined in your pins_YOUR_BOARD file + * L6470_CHAIN_SCK_PIN + * L6470_CHAIN_MISO_PIN + * L6470_CHAIN_MOSI_PIN + * L6470_CHAIN_SS_PIN + * L6470_RESET_CHAIN_PIN (optional) */ #if HAS_DRIVER(L6470) - #define X_MICROSTEPS 16 // number of microsteps - #define X_OVERCURRENT 2000 // maxc current in mA. If the current goes over this value, the driver will switch off - #define X_STALLCURRENT 1500 // current in mA where the driver will detect a stall + #define X_MICROSTEPS 128 // number of microsteps (VALID: 1, 2, 4, 8, 16, 32, 128 & 128) + #define X_OVERCURRENT 2000 // current in mA where the driver will detect an over current (VALID: 375 x (1 - 16) - 6A max - rounds down) + #define X_STALLCURRENT 1500 // current in mA where the driver will detect a stall (VALID: 31.25 * (1-128) - 4A max - rounds down) + #define X_MAX_VOLTAGE 127 // 0-255, max effective voltage seen by stepper + #define X_CHAIN_POS 0 // position in SPI chain, 0 - not in chain, 1- nearest MOSI - #define X2_MICROSTEPS 16 + #define X2_MICROSTEPS 128 #define X2_OVERCURRENT 2000 #define X2_STALLCURRENT 1500 + #define X2_MAX_VOLTAGE 127 + #define X2_CHAIN_POS 0 - #define Y_MICROSTEPS 16 + #define Y_MICROSTEPS 128 #define Y_OVERCURRENT 2000 #define Y_STALLCURRENT 1500 + #define Y_MAX_VOLTAGE 127 + #define Y_CHAIN_POS 0 - #define Y2_MICROSTEPS 16 + #define Y2_MICROSTEPS 128 #define Y2_OVERCURRENT 2000 #define Y2_STALLCURRENT 1500 + #define Y2_MAX_VOLTAGE 127 + #define Y2_CHAIN_POS 0 - #define Z_MICROSTEPS 16 + #define Z_MICROSTEPS 128 #define Z_OVERCURRENT 2000 #define Z_STALLCURRENT 1500 + #define Z_MAX_VOLTAGE 127 + #define Z_CHAIN_POS 0 - #define Z2_MICROSTEPS 16 + #define Z2_MICROSTEPS 128 #define Z2_OVERCURRENT 2000 #define Z2_STALLCURRENT 1500 + #define Z2_MAX_VOLTAGE 127 + #define Z2_CHAIN_POS 0 - #define Z3_MICROSTEPS 16 + #define Z3_MICROSTEPS 128 #define Z3_OVERCURRENT 2000 #define Z3_STALLCURRENT 1500 + #define Z3_MAX_VOLTAGE 127 + #define Z3_CHAIN_POS 0 - #define E0_MICROSTEPS 16 + #define E0_MICROSTEPS 128 #define E0_OVERCURRENT 2000 #define E0_STALLCURRENT 1500 + #define E0_MAX_VOLTAGE 127 + #define E0_CHAIN_POS 0 - #define E1_MICROSTEPS 16 + #define E1_MICROSTEPS 128 #define E1_OVERCURRENT 2000 #define E1_STALLCURRENT 1500 + #define E1_MAX_VOLTAGE 127 + #define E1_CHAIN_POS 0 - #define E2_MICROSTEPS 16 + #define E2_MICROSTEPS 128 #define E2_OVERCURRENT 2000 #define E2_STALLCURRENT 1500 + #define E2_MAX_VOLTAGE 127 + #define E2_CHAIN_POS 0 - #define E3_MICROSTEPS 16 + #define E3_MICROSTEPS 128 #define E3_OVERCURRENT 2000 #define E3_STALLCURRENT 1500 + #define E3_MAX_VOLTAGE 127 + #define E3_CHAIN_POS 0 - #define E4_MICROSTEPS 16 + #define E4_MICROSTEPS 128 #define E4_OVERCURRENT 2000 #define E4_STALLCURRENT 1500 + #define E4_MAX_VOLTAGE 127 + #define E4_CHAIN_POS 0 - #define E5_MICROSTEPS 16 + #define E5_MICROSTEPS 128 #define E5_OVERCURRENT 2000 #define E5_STALLCURRENT 1500 + #define E5_MAX_VOLTAGE 127 + #define E5_CHAIN_POS 0 + + + /** + * Monitor L6470 drivers for error conditions like over temperature and over current. + * In the case of over temperature Marlin can decrease the drive until the error condition clears. + * Other detected conditions can be used to stop the current print. + * Relevant g-codes: + * M906 - I1/2/3/4/5 Set or get motor drive level using axis codes X, Y, Z, E. Report values if no axis codes given. + * I not present or I0 or I1 - X, Y, Z or E0 + * I2 - X2, Y2, Z2 or E1 + * I3 - Z3 or E3 + * I4 - E4 + * I5 - E5 + * M916 - Increase drive level until get thermal warning + * M917 - Find minimum current thresholds + * M918 - Increase speed until max or error + * M122 S0/1 - Report driver parameters + */ + //#define MONITOR_L6470_DRIVER_STATUS + + #if ENABLED(MONITOR_L6470_DRIVER_STATUS) + #define KVAL_HOLD_STEP_DOWN 1 + //#define L6470_STOP_ON_ERROR + #endif + + #define L6470_CHITCHAT // enable display of additional status info #endif // L6470 diff --git a/Marlin/src/config/examples/Felix/Configuration_adv.h b/Marlin/src/config/examples/Felix/Configuration_adv.h index dd70b81fe..82687ebef 100644 --- a/Marlin/src/config/examples/Felix/Configuration_adv.h +++ b/Marlin/src/config/examples/Felix/Configuration_adv.h @@ -1508,62 +1508,121 @@ /** * L6470 Stepper Driver options * - * The Arduino-L6470 library is required for this stepper driver. + * Arduino-L6470 library (0.7.0 or higher) is required for this stepper driver. * https://github.com/ameyer/Arduino-L6470 + * + * Requires the following to be defined in your pins_YOUR_BOARD file + * L6470_CHAIN_SCK_PIN + * L6470_CHAIN_MISO_PIN + * L6470_CHAIN_MOSI_PIN + * L6470_CHAIN_SS_PIN + * L6470_RESET_CHAIN_PIN (optional) */ #if HAS_DRIVER(L6470) - #define X_MICROSTEPS 16 // number of microsteps - #define X_OVERCURRENT 2000 // maxc current in mA. If the current goes over this value, the driver will switch off - #define X_STALLCURRENT 1500 // current in mA where the driver will detect a stall + #define X_MICROSTEPS 128 // number of microsteps (VALID: 1, 2, 4, 8, 16, 32, 128 & 128) + #define X_OVERCURRENT 2000 // current in mA where the driver will detect an over current (VALID: 375 x (1 - 16) - 6A max - rounds down) + #define X_STALLCURRENT 1500 // current in mA where the driver will detect a stall (VALID: 31.25 * (1-128) - 4A max - rounds down) + #define X_MAX_VOLTAGE 127 // 0-255, max effective voltage seen by stepper + #define X_CHAIN_POS 0 // position in SPI chain, 0 - not in chain, 1- nearest MOSI - #define X2_MICROSTEPS 16 + #define X2_MICROSTEPS 128 #define X2_OVERCURRENT 2000 #define X2_STALLCURRENT 1500 + #define X2_MAX_VOLTAGE 127 + #define X2_CHAIN_POS 0 - #define Y_MICROSTEPS 16 + #define Y_MICROSTEPS 128 #define Y_OVERCURRENT 2000 #define Y_STALLCURRENT 1500 + #define Y_MAX_VOLTAGE 127 + #define Y_CHAIN_POS 0 - #define Y2_MICROSTEPS 16 + #define Y2_MICROSTEPS 128 #define Y2_OVERCURRENT 2000 #define Y2_STALLCURRENT 1500 + #define Y2_MAX_VOLTAGE 127 + #define Y2_CHAIN_POS 0 - #define Z_MICROSTEPS 16 + #define Z_MICROSTEPS 128 #define Z_OVERCURRENT 2000 #define Z_STALLCURRENT 1500 + #define Z_MAX_VOLTAGE 127 + #define Z_CHAIN_POS 0 - #define Z2_MICROSTEPS 16 + #define Z2_MICROSTEPS 128 #define Z2_OVERCURRENT 2000 #define Z2_STALLCURRENT 1500 + #define Z2_MAX_VOLTAGE 127 + #define Z2_CHAIN_POS 0 - #define Z3_MICROSTEPS 16 + #define Z3_MICROSTEPS 128 #define Z3_OVERCURRENT 2000 #define Z3_STALLCURRENT 1500 + #define Z3_MAX_VOLTAGE 127 + #define Z3_CHAIN_POS 0 - #define E0_MICROSTEPS 16 + #define E0_MICROSTEPS 128 #define E0_OVERCURRENT 2000 #define E0_STALLCURRENT 1500 + #define E0_MAX_VOLTAGE 127 + #define E0_CHAIN_POS 0 - #define E1_MICROSTEPS 16 + #define E1_MICROSTEPS 128 #define E1_OVERCURRENT 2000 #define E1_STALLCURRENT 1500 + #define E1_MAX_VOLTAGE 127 + #define E1_CHAIN_POS 0 - #define E2_MICROSTEPS 16 + #define E2_MICROSTEPS 128 #define E2_OVERCURRENT 2000 #define E2_STALLCURRENT 1500 + #define E2_MAX_VOLTAGE 127 + #define E2_CHAIN_POS 0 - #define E3_MICROSTEPS 16 + #define E3_MICROSTEPS 128 #define E3_OVERCURRENT 2000 #define E3_STALLCURRENT 1500 + #define E3_MAX_VOLTAGE 127 + #define E3_CHAIN_POS 0 - #define E4_MICROSTEPS 16 + #define E4_MICROSTEPS 128 #define E4_OVERCURRENT 2000 #define E4_STALLCURRENT 1500 + #define E4_MAX_VOLTAGE 127 + #define E4_CHAIN_POS 0 - #define E5_MICROSTEPS 16 + #define E5_MICROSTEPS 128 #define E5_OVERCURRENT 2000 #define E5_STALLCURRENT 1500 + #define E5_MAX_VOLTAGE 127 + #define E5_CHAIN_POS 0 + + + /** + * Monitor L6470 drivers for error conditions like over temperature and over current. + * In the case of over temperature Marlin can decrease the drive until the error condition clears. + * Other detected conditions can be used to stop the current print. + * Relevant g-codes: + * M906 - I1/2/3/4/5 Set or get motor drive level using axis codes X, Y, Z, E. Report values if no axis codes given. + * I not present or I0 or I1 - X, Y, Z or E0 + * I2 - X2, Y2, Z2 or E1 + * I3 - Z3 or E3 + * I4 - E4 + * I5 - E5 + * M916 - Increase drive level until get thermal warning + * M917 - Find minimum current thresholds + * M918 - Increase speed until max or error + * M122 S0/1 - Report driver parameters + */ + //#define MONITOR_L6470_DRIVER_STATUS + + #if ENABLED(MONITOR_L6470_DRIVER_STATUS) + #define KVAL_HOLD_STEP_DOWN 1 + //#define L6470_STOP_ON_ERROR + #endif + + #define L6470_CHITCHAT // enable display of additional status info #endif // L6470 diff --git a/Marlin/src/config/examples/FlashForge/CreatorPro/Configuration_adv.h b/Marlin/src/config/examples/FlashForge/CreatorPro/Configuration_adv.h index 3b96628f7..82f1ba2b5 100644 --- a/Marlin/src/config/examples/FlashForge/CreatorPro/Configuration_adv.h +++ b/Marlin/src/config/examples/FlashForge/CreatorPro/Configuration_adv.h @@ -1507,62 +1507,121 @@ /** * L6470 Stepper Driver options * - * The Arduino-L6470 library is required for this stepper driver. + * Arduino-L6470 library (0.7.0 or higher) is required for this stepper driver. * https://github.com/ameyer/Arduino-L6470 + * + * Requires the following to be defined in your pins_YOUR_BOARD file + * L6470_CHAIN_SCK_PIN + * L6470_CHAIN_MISO_PIN + * L6470_CHAIN_MOSI_PIN + * L6470_CHAIN_SS_PIN + * L6470_RESET_CHAIN_PIN (optional) */ #if HAS_DRIVER(L6470) - #define X_MICROSTEPS 16 // number of microsteps - #define X_OVERCURRENT 2000 // maxc current in mA. If the current goes over this value, the driver will switch off - #define X_STALLCURRENT 1500 // current in mA where the driver will detect a stall + #define X_MICROSTEPS 128 // number of microsteps (VALID: 1, 2, 4, 8, 16, 32, 128 & 128) + #define X_OVERCURRENT 2000 // current in mA where the driver will detect an over current (VALID: 375 x (1 - 16) - 6A max - rounds down) + #define X_STALLCURRENT 1500 // current in mA where the driver will detect a stall (VALID: 31.25 * (1-128) - 4A max - rounds down) + #define X_MAX_VOLTAGE 127 // 0-255, max effective voltage seen by stepper + #define X_CHAIN_POS 0 // position in SPI chain, 0 - not in chain, 1- nearest MOSI - #define X2_MICROSTEPS 16 + #define X2_MICROSTEPS 128 #define X2_OVERCURRENT 2000 #define X2_STALLCURRENT 1500 + #define X2_MAX_VOLTAGE 127 + #define X2_CHAIN_POS 0 - #define Y_MICROSTEPS 16 + #define Y_MICROSTEPS 128 #define Y_OVERCURRENT 2000 #define Y_STALLCURRENT 1500 + #define Y_MAX_VOLTAGE 127 + #define Y_CHAIN_POS 0 - #define Y2_MICROSTEPS 16 + #define Y2_MICROSTEPS 128 #define Y2_OVERCURRENT 2000 #define Y2_STALLCURRENT 1500 + #define Y2_MAX_VOLTAGE 127 + #define Y2_CHAIN_POS 0 - #define Z_MICROSTEPS 16 + #define Z_MICROSTEPS 128 #define Z_OVERCURRENT 2000 #define Z_STALLCURRENT 1500 + #define Z_MAX_VOLTAGE 127 + #define Z_CHAIN_POS 0 - #define Z2_MICROSTEPS 16 + #define Z2_MICROSTEPS 128 #define Z2_OVERCURRENT 2000 #define Z2_STALLCURRENT 1500 + #define Z2_MAX_VOLTAGE 127 + #define Z2_CHAIN_POS 0 - #define Z3_MICROSTEPS 16 + #define Z3_MICROSTEPS 128 #define Z3_OVERCURRENT 2000 #define Z3_STALLCURRENT 1500 + #define Z3_MAX_VOLTAGE 127 + #define Z3_CHAIN_POS 0 - #define E0_MICROSTEPS 16 + #define E0_MICROSTEPS 128 #define E0_OVERCURRENT 2000 #define E0_STALLCURRENT 1500 + #define E0_MAX_VOLTAGE 127 + #define E0_CHAIN_POS 0 - #define E1_MICROSTEPS 16 + #define E1_MICROSTEPS 128 #define E1_OVERCURRENT 2000 #define E1_STALLCURRENT 1500 + #define E1_MAX_VOLTAGE 127 + #define E1_CHAIN_POS 0 - #define E2_MICROSTEPS 16 + #define E2_MICROSTEPS 128 #define E2_OVERCURRENT 2000 #define E2_STALLCURRENT 1500 + #define E2_MAX_VOLTAGE 127 + #define E2_CHAIN_POS 0 - #define E3_MICROSTEPS 16 + #define E3_MICROSTEPS 128 #define E3_OVERCURRENT 2000 #define E3_STALLCURRENT 1500 + #define E3_MAX_VOLTAGE 127 + #define E3_CHAIN_POS 0 - #define E4_MICROSTEPS 16 + #define E4_MICROSTEPS 128 #define E4_OVERCURRENT 2000 #define E4_STALLCURRENT 1500 + #define E4_MAX_VOLTAGE 127 + #define E4_CHAIN_POS 0 - #define E5_MICROSTEPS 16 + #define E5_MICROSTEPS 128 #define E5_OVERCURRENT 2000 #define E5_STALLCURRENT 1500 + #define E5_MAX_VOLTAGE 127 + #define E5_CHAIN_POS 0 + + + /** + * Monitor L6470 drivers for error conditions like over temperature and over current. + * In the case of over temperature Marlin can decrease the drive until the error condition clears. + * Other detected conditions can be used to stop the current print. + * Relevant g-codes: + * M906 - I1/2/3/4/5 Set or get motor drive level using axis codes X, Y, Z, E. Report values if no axis codes given. + * I not present or I0 or I1 - X, Y, Z or E0 + * I2 - X2, Y2, Z2 or E1 + * I3 - Z3 or E3 + * I4 - E4 + * I5 - E5 + * M916 - Increase drive level until get thermal warning + * M917 - Find minimum current thresholds + * M918 - Increase speed until max or error + * M122 S0/1 - Report driver parameters + */ + //#define MONITOR_L6470_DRIVER_STATUS + + #if ENABLED(MONITOR_L6470_DRIVER_STATUS) + #define KVAL_HOLD_STEP_DOWN 1 + //#define L6470_STOP_ON_ERROR + #endif + + #define L6470_CHITCHAT // enable display of additional status info #endif // L6470 diff --git a/Marlin/src/config/examples/FolgerTech/i3-2020/Configuration_adv.h b/Marlin/src/config/examples/FolgerTech/i3-2020/Configuration_adv.h index 4859887f2..ce619c7a9 100644 --- a/Marlin/src/config/examples/FolgerTech/i3-2020/Configuration_adv.h +++ b/Marlin/src/config/examples/FolgerTech/i3-2020/Configuration_adv.h @@ -1508,62 +1508,121 @@ /** * L6470 Stepper Driver options * - * The Arduino-L6470 library is required for this stepper driver. + * Arduino-L6470 library (0.7.0 or higher) is required for this stepper driver. * https://github.com/ameyer/Arduino-L6470 + * + * Requires the following to be defined in your pins_YOUR_BOARD file + * L6470_CHAIN_SCK_PIN + * L6470_CHAIN_MISO_PIN + * L6470_CHAIN_MOSI_PIN + * L6470_CHAIN_SS_PIN + * L6470_RESET_CHAIN_PIN (optional) */ #if HAS_DRIVER(L6470) - #define X_MICROSTEPS 16 // number of microsteps - #define X_OVERCURRENT 2000 // maxc current in mA. If the current goes over this value, the driver will switch off - #define X_STALLCURRENT 1500 // current in mA where the driver will detect a stall + #define X_MICROSTEPS 128 // number of microsteps (VALID: 1, 2, 4, 8, 16, 32, 128 & 128) + #define X_OVERCURRENT 2000 // current in mA where the driver will detect an over current (VALID: 375 x (1 - 16) - 6A max - rounds down) + #define X_STALLCURRENT 1500 // current in mA where the driver will detect a stall (VALID: 31.25 * (1-128) - 4A max - rounds down) + #define X_MAX_VOLTAGE 127 // 0-255, max effective voltage seen by stepper + #define X_CHAIN_POS 0 // position in SPI chain, 0 - not in chain, 1- nearest MOSI - #define X2_MICROSTEPS 16 + #define X2_MICROSTEPS 128 #define X2_OVERCURRENT 2000 #define X2_STALLCURRENT 1500 + #define X2_MAX_VOLTAGE 127 + #define X2_CHAIN_POS 0 - #define Y_MICROSTEPS 16 + #define Y_MICROSTEPS 128 #define Y_OVERCURRENT 2000 #define Y_STALLCURRENT 1500 + #define Y_MAX_VOLTAGE 127 + #define Y_CHAIN_POS 0 - #define Y2_MICROSTEPS 16 + #define Y2_MICROSTEPS 128 #define Y2_OVERCURRENT 2000 #define Y2_STALLCURRENT 1500 + #define Y2_MAX_VOLTAGE 127 + #define Y2_CHAIN_POS 0 - #define Z_MICROSTEPS 16 + #define Z_MICROSTEPS 128 #define Z_OVERCURRENT 2000 #define Z_STALLCURRENT 1500 + #define Z_MAX_VOLTAGE 127 + #define Z_CHAIN_POS 0 - #define Z2_MICROSTEPS 16 + #define Z2_MICROSTEPS 128 #define Z2_OVERCURRENT 2000 #define Z2_STALLCURRENT 1500 + #define Z2_MAX_VOLTAGE 127 + #define Z2_CHAIN_POS 0 - #define Z3_MICROSTEPS 16 + #define Z3_MICROSTEPS 128 #define Z3_OVERCURRENT 2000 #define Z3_STALLCURRENT 1500 + #define Z3_MAX_VOLTAGE 127 + #define Z3_CHAIN_POS 0 - #define E0_MICROSTEPS 16 + #define E0_MICROSTEPS 128 #define E0_OVERCURRENT 2000 #define E0_STALLCURRENT 1500 + #define E0_MAX_VOLTAGE 127 + #define E0_CHAIN_POS 0 - #define E1_MICROSTEPS 16 + #define E1_MICROSTEPS 128 #define E1_OVERCURRENT 2000 #define E1_STALLCURRENT 1500 + #define E1_MAX_VOLTAGE 127 + #define E1_CHAIN_POS 0 - #define E2_MICROSTEPS 16 + #define E2_MICROSTEPS 128 #define E2_OVERCURRENT 2000 #define E2_STALLCURRENT 1500 + #define E2_MAX_VOLTAGE 127 + #define E2_CHAIN_POS 0 - #define E3_MICROSTEPS 16 + #define E3_MICROSTEPS 128 #define E3_OVERCURRENT 2000 #define E3_STALLCURRENT 1500 + #define E3_MAX_VOLTAGE 127 + #define E3_CHAIN_POS 0 - #define E4_MICROSTEPS 16 + #define E4_MICROSTEPS 128 #define E4_OVERCURRENT 2000 #define E4_STALLCURRENT 1500 + #define E4_MAX_VOLTAGE 127 + #define E4_CHAIN_POS 0 - #define E5_MICROSTEPS 16 + #define E5_MICROSTEPS 128 #define E5_OVERCURRENT 2000 #define E5_STALLCURRENT 1500 + #define E5_MAX_VOLTAGE 127 + #define E5_CHAIN_POS 0 + + + /** + * Monitor L6470 drivers for error conditions like over temperature and over current. + * In the case of over temperature Marlin can decrease the drive until the error condition clears. + * Other detected conditions can be used to stop the current print. + * Relevant g-codes: + * M906 - I1/2/3/4/5 Set or get motor drive level using axis codes X, Y, Z, E. Report values if no axis codes given. + * I not present or I0 or I1 - X, Y, Z or E0 + * I2 - X2, Y2, Z2 or E1 + * I3 - Z3 or E3 + * I4 - E4 + * I5 - E5 + * M916 - Increase drive level until get thermal warning + * M917 - Find minimum current thresholds + * M918 - Increase speed until max or error + * M122 S0/1 - Report driver parameters + */ + //#define MONITOR_L6470_DRIVER_STATUS + + #if ENABLED(MONITOR_L6470_DRIVER_STATUS) + #define KVAL_HOLD_STEP_DOWN 1 + //#define L6470_STOP_ON_ERROR + #endif + + #define L6470_CHITCHAT // enable display of additional status info #endif // L6470 diff --git a/Marlin/src/config/examples/Formbot/Raptor/Configuration_adv.h b/Marlin/src/config/examples/Formbot/Raptor/Configuration_adv.h index 39265b811..e923f4085 100644 --- a/Marlin/src/config/examples/Formbot/Raptor/Configuration_adv.h +++ b/Marlin/src/config/examples/Formbot/Raptor/Configuration_adv.h @@ -1510,62 +1510,121 @@ /** * L6470 Stepper Driver options * - * The Arduino-L6470 library is required for this stepper driver. + * Arduino-L6470 library (0.7.0 or higher) is required for this stepper driver. * https://github.com/ameyer/Arduino-L6470 + * + * Requires the following to be defined in your pins_YOUR_BOARD file + * L6470_CHAIN_SCK_PIN + * L6470_CHAIN_MISO_PIN + * L6470_CHAIN_MOSI_PIN + * L6470_CHAIN_SS_PIN + * L6470_RESET_CHAIN_PIN (optional) */ #if HAS_DRIVER(L6470) - #define X_MICROSTEPS 16 // number of microsteps - #define X_OVERCURRENT 2000 // maxc current in mA. If the current goes over this value, the driver will switch off - #define X_STALLCURRENT 1500 // current in mA where the driver will detect a stall + #define X_MICROSTEPS 128 // number of microsteps (VALID: 1, 2, 4, 8, 16, 32, 128 & 128) + #define X_OVERCURRENT 2000 // current in mA where the driver will detect an over current (VALID: 375 x (1 - 16) - 6A max - rounds down) + #define X_STALLCURRENT 1500 // current in mA where the driver will detect a stall (VALID: 31.25 * (1-128) - 4A max - rounds down) + #define X_MAX_VOLTAGE 127 // 0-255, max effective voltage seen by stepper + #define X_CHAIN_POS 0 // position in SPI chain, 0 - not in chain, 1- nearest MOSI - #define X2_MICROSTEPS 16 + #define X2_MICROSTEPS 128 #define X2_OVERCURRENT 2000 #define X2_STALLCURRENT 1500 + #define X2_MAX_VOLTAGE 127 + #define X2_CHAIN_POS 0 - #define Y_MICROSTEPS 16 + #define Y_MICROSTEPS 128 #define Y_OVERCURRENT 2000 #define Y_STALLCURRENT 1500 + #define Y_MAX_VOLTAGE 127 + #define Y_CHAIN_POS 0 - #define Y2_MICROSTEPS 16 + #define Y2_MICROSTEPS 128 #define Y2_OVERCURRENT 2000 #define Y2_STALLCURRENT 1500 + #define Y2_MAX_VOLTAGE 127 + #define Y2_CHAIN_POS 0 - #define Z_MICROSTEPS 16 + #define Z_MICROSTEPS 128 #define Z_OVERCURRENT 2000 #define Z_STALLCURRENT 1500 + #define Z_MAX_VOLTAGE 127 + #define Z_CHAIN_POS 0 - #define Z2_MICROSTEPS 16 + #define Z2_MICROSTEPS 128 #define Z2_OVERCURRENT 2000 #define Z2_STALLCURRENT 1500 + #define Z2_MAX_VOLTAGE 127 + #define Z2_CHAIN_POS 0 - #define Z3_MICROSTEPS 16 + #define Z3_MICROSTEPS 128 #define Z3_OVERCURRENT 2000 #define Z3_STALLCURRENT 1500 + #define Z3_MAX_VOLTAGE 127 + #define Z3_CHAIN_POS 0 - #define E0_MICROSTEPS 16 + #define E0_MICROSTEPS 128 #define E0_OVERCURRENT 2000 #define E0_STALLCURRENT 1500 + #define E0_MAX_VOLTAGE 127 + #define E0_CHAIN_POS 0 - #define E1_MICROSTEPS 16 + #define E1_MICROSTEPS 128 #define E1_OVERCURRENT 2000 #define E1_STALLCURRENT 1500 + #define E1_MAX_VOLTAGE 127 + #define E1_CHAIN_POS 0 - #define E2_MICROSTEPS 16 + #define E2_MICROSTEPS 128 #define E2_OVERCURRENT 2000 #define E2_STALLCURRENT 1500 + #define E2_MAX_VOLTAGE 127 + #define E2_CHAIN_POS 0 - #define E3_MICROSTEPS 16 + #define E3_MICROSTEPS 128 #define E3_OVERCURRENT 2000 #define E3_STALLCURRENT 1500 + #define E3_MAX_VOLTAGE 127 + #define E3_CHAIN_POS 0 - #define E4_MICROSTEPS 16 + #define E4_MICROSTEPS 128 #define E4_OVERCURRENT 2000 #define E4_STALLCURRENT 1500 + #define E4_MAX_VOLTAGE 127 + #define E4_CHAIN_POS 0 - #define E5_MICROSTEPS 16 + #define E5_MICROSTEPS 128 #define E5_OVERCURRENT 2000 #define E5_STALLCURRENT 1500 + #define E5_MAX_VOLTAGE 127 + #define E5_CHAIN_POS 0 + + + /** + * Monitor L6470 drivers for error conditions like over temperature and over current. + * In the case of over temperature Marlin can decrease the drive until the error condition clears. + * Other detected conditions can be used to stop the current print. + * Relevant g-codes: + * M906 - I1/2/3/4/5 Set or get motor drive level using axis codes X, Y, Z, E. Report values if no axis codes given. + * I not present or I0 or I1 - X, Y, Z or E0 + * I2 - X2, Y2, Z2 or E1 + * I3 - Z3 or E3 + * I4 - E4 + * I5 - E5 + * M916 - Increase drive level until get thermal warning + * M917 - Find minimum current thresholds + * M918 - Increase speed until max or error + * M122 S0/1 - Report driver parameters + */ + //#define MONITOR_L6470_DRIVER_STATUS + + #if ENABLED(MONITOR_L6470_DRIVER_STATUS) + #define KVAL_HOLD_STEP_DOWN 1 + //#define L6470_STOP_ON_ERROR + #endif + + #define L6470_CHITCHAT // enable display of additional status info #endif // L6470 diff --git a/Marlin/src/config/examples/Formbot/T_Rex_2+/Configuration_adv.h b/Marlin/src/config/examples/Formbot/T_Rex_2+/Configuration_adv.h index 27a7992f7..df89649e0 100644 --- a/Marlin/src/config/examples/Formbot/T_Rex_2+/Configuration_adv.h +++ b/Marlin/src/config/examples/Formbot/T_Rex_2+/Configuration_adv.h @@ -1513,62 +1513,121 @@ /** * L6470 Stepper Driver options * - * The Arduino-L6470 library is required for this stepper driver. + * Arduino-L6470 library (0.7.0 or higher) is required for this stepper driver. * https://github.com/ameyer/Arduino-L6470 + * + * Requires the following to be defined in your pins_YOUR_BOARD file + * L6470_CHAIN_SCK_PIN + * L6470_CHAIN_MISO_PIN + * L6470_CHAIN_MOSI_PIN + * L6470_CHAIN_SS_PIN + * L6470_RESET_CHAIN_PIN (optional) */ #if HAS_DRIVER(L6470) - #define X_MICROSTEPS 16 // number of microsteps - #define X_OVERCURRENT 2000 // maxc current in mA. If the current goes over this value, the driver will switch off - #define X_STALLCURRENT 1500 // current in mA where the driver will detect a stall + #define X_MICROSTEPS 128 // number of microsteps (VALID: 1, 2, 4, 8, 16, 32, 128 & 128) + #define X_OVERCURRENT 2000 // current in mA where the driver will detect an over current (VALID: 375 x (1 - 16) - 6A max - rounds down) + #define X_STALLCURRENT 1500 // current in mA where the driver will detect a stall (VALID: 31.25 * (1-128) - 4A max - rounds down) + #define X_MAX_VOLTAGE 127 // 0-255, max effective voltage seen by stepper + #define X_CHAIN_POS 0 // position in SPI chain, 0 - not in chain, 1- nearest MOSI - #define X2_MICROSTEPS 16 + #define X2_MICROSTEPS 128 #define X2_OVERCURRENT 2000 #define X2_STALLCURRENT 1500 + #define X2_MAX_VOLTAGE 127 + #define X2_CHAIN_POS 0 - #define Y_MICROSTEPS 16 + #define Y_MICROSTEPS 128 #define Y_OVERCURRENT 2000 #define Y_STALLCURRENT 1500 + #define Y_MAX_VOLTAGE 127 + #define Y_CHAIN_POS 0 - #define Y2_MICROSTEPS 16 + #define Y2_MICROSTEPS 128 #define Y2_OVERCURRENT 2000 #define Y2_STALLCURRENT 1500 + #define Y2_MAX_VOLTAGE 127 + #define Y2_CHAIN_POS 0 - #define Z_MICROSTEPS 16 + #define Z_MICROSTEPS 128 #define Z_OVERCURRENT 2000 #define Z_STALLCURRENT 1500 + #define Z_MAX_VOLTAGE 127 + #define Z_CHAIN_POS 0 - #define Z2_MICROSTEPS 16 + #define Z2_MICROSTEPS 128 #define Z2_OVERCURRENT 2000 #define Z2_STALLCURRENT 1500 + #define Z2_MAX_VOLTAGE 127 + #define Z2_CHAIN_POS 0 - #define Z3_MICROSTEPS 16 + #define Z3_MICROSTEPS 128 #define Z3_OVERCURRENT 2000 #define Z3_STALLCURRENT 1500 + #define Z3_MAX_VOLTAGE 127 + #define Z3_CHAIN_POS 0 - #define E0_MICROSTEPS 16 + #define E0_MICROSTEPS 128 #define E0_OVERCURRENT 2000 #define E0_STALLCURRENT 1500 + #define E0_MAX_VOLTAGE 127 + #define E0_CHAIN_POS 0 - #define E1_MICROSTEPS 16 + #define E1_MICROSTEPS 128 #define E1_OVERCURRENT 2000 #define E1_STALLCURRENT 1500 + #define E1_MAX_VOLTAGE 127 + #define E1_CHAIN_POS 0 - #define E2_MICROSTEPS 16 + #define E2_MICROSTEPS 128 #define E2_OVERCURRENT 2000 #define E2_STALLCURRENT 1500 + #define E2_MAX_VOLTAGE 127 + #define E2_CHAIN_POS 0 - #define E3_MICROSTEPS 16 + #define E3_MICROSTEPS 128 #define E3_OVERCURRENT 2000 #define E3_STALLCURRENT 1500 + #define E3_MAX_VOLTAGE 127 + #define E3_CHAIN_POS 0 - #define E4_MICROSTEPS 16 + #define E4_MICROSTEPS 128 #define E4_OVERCURRENT 2000 #define E4_STALLCURRENT 1500 + #define E4_MAX_VOLTAGE 127 + #define E4_CHAIN_POS 0 - #define E5_MICROSTEPS 16 + #define E5_MICROSTEPS 128 #define E5_OVERCURRENT 2000 #define E5_STALLCURRENT 1500 + #define E5_MAX_VOLTAGE 127 + #define E5_CHAIN_POS 0 + + + /** + * Monitor L6470 drivers for error conditions like over temperature and over current. + * In the case of over temperature Marlin can decrease the drive until the error condition clears. + * Other detected conditions can be used to stop the current print. + * Relevant g-codes: + * M906 - I1/2/3/4/5 Set or get motor drive level using axis codes X, Y, Z, E. Report values if no axis codes given. + * I not present or I0 or I1 - X, Y, Z or E0 + * I2 - X2, Y2, Z2 or E1 + * I3 - Z3 or E3 + * I4 - E4 + * I5 - E5 + * M916 - Increase drive level until get thermal warning + * M917 - Find minimum current thresholds + * M918 - Increase speed until max or error + * M122 S0/1 - Report driver parameters + */ + //#define MONITOR_L6470_DRIVER_STATUS + + #if ENABLED(MONITOR_L6470_DRIVER_STATUS) + #define KVAL_HOLD_STEP_DOWN 1 + //#define L6470_STOP_ON_ERROR + #endif + + #define L6470_CHITCHAT // enable display of additional status info #endif // L6470 diff --git a/Marlin/src/config/examples/Formbot/T_Rex_3/Configuration_adv.h b/Marlin/src/config/examples/Formbot/T_Rex_3/Configuration_adv.h index 98c2776cd..d49d74e7c 100644 --- a/Marlin/src/config/examples/Formbot/T_Rex_3/Configuration_adv.h +++ b/Marlin/src/config/examples/Formbot/T_Rex_3/Configuration_adv.h @@ -1513,62 +1513,121 @@ /** * L6470 Stepper Driver options * - * The Arduino-L6470 library is required for this stepper driver. + * Arduino-L6470 library (0.7.0 or higher) is required for this stepper driver. * https://github.com/ameyer/Arduino-L6470 + * + * Requires the following to be defined in your pins_YOUR_BOARD file + * L6470_CHAIN_SCK_PIN + * L6470_CHAIN_MISO_PIN + * L6470_CHAIN_MOSI_PIN + * L6470_CHAIN_SS_PIN + * L6470_RESET_CHAIN_PIN (optional) */ #if HAS_DRIVER(L6470) - #define X_MICROSTEPS 16 // number of microsteps - #define X_OVERCURRENT 2000 // maxc current in mA. If the current goes over this value, the driver will switch off - #define X_STALLCURRENT 1500 // current in mA where the driver will detect a stall + #define X_MICROSTEPS 128 // number of microsteps (VALID: 1, 2, 4, 8, 16, 32, 128 & 128) + #define X_OVERCURRENT 2000 // current in mA where the driver will detect an over current (VALID: 375 x (1 - 16) - 6A max - rounds down) + #define X_STALLCURRENT 1500 // current in mA where the driver will detect a stall (VALID: 31.25 * (1-128) - 4A max - rounds down) + #define X_MAX_VOLTAGE 127 // 0-255, max effective voltage seen by stepper + #define X_CHAIN_POS 0 // position in SPI chain, 0 - not in chain, 1- nearest MOSI - #define X2_MICROSTEPS 16 + #define X2_MICROSTEPS 128 #define X2_OVERCURRENT 2000 #define X2_STALLCURRENT 1500 + #define X2_MAX_VOLTAGE 127 + #define X2_CHAIN_POS 0 - #define Y_MICROSTEPS 16 + #define Y_MICROSTEPS 128 #define Y_OVERCURRENT 2000 #define Y_STALLCURRENT 1500 + #define Y_MAX_VOLTAGE 127 + #define Y_CHAIN_POS 0 - #define Y2_MICROSTEPS 16 + #define Y2_MICROSTEPS 128 #define Y2_OVERCURRENT 2000 #define Y2_STALLCURRENT 1500 + #define Y2_MAX_VOLTAGE 127 + #define Y2_CHAIN_POS 0 - #define Z_MICROSTEPS 16 + #define Z_MICROSTEPS 128 #define Z_OVERCURRENT 2000 #define Z_STALLCURRENT 1500 + #define Z_MAX_VOLTAGE 127 + #define Z_CHAIN_POS 0 - #define Z2_MICROSTEPS 16 + #define Z2_MICROSTEPS 128 #define Z2_OVERCURRENT 2000 #define Z2_STALLCURRENT 1500 + #define Z2_MAX_VOLTAGE 127 + #define Z2_CHAIN_POS 0 - #define Z3_MICROSTEPS 16 + #define Z3_MICROSTEPS 128 #define Z3_OVERCURRENT 2000 #define Z3_STALLCURRENT 1500 + #define Z3_MAX_VOLTAGE 127 + #define Z3_CHAIN_POS 0 - #define E0_MICROSTEPS 16 + #define E0_MICROSTEPS 128 #define E0_OVERCURRENT 2000 #define E0_STALLCURRENT 1500 + #define E0_MAX_VOLTAGE 127 + #define E0_CHAIN_POS 0 - #define E1_MICROSTEPS 16 + #define E1_MICROSTEPS 128 #define E1_OVERCURRENT 2000 #define E1_STALLCURRENT 1500 + #define E1_MAX_VOLTAGE 127 + #define E1_CHAIN_POS 0 - #define E2_MICROSTEPS 16 + #define E2_MICROSTEPS 128 #define E2_OVERCURRENT 2000 #define E2_STALLCURRENT 1500 + #define E2_MAX_VOLTAGE 127 + #define E2_CHAIN_POS 0 - #define E3_MICROSTEPS 16 + #define E3_MICROSTEPS 128 #define E3_OVERCURRENT 2000 #define E3_STALLCURRENT 1500 + #define E3_MAX_VOLTAGE 127 + #define E3_CHAIN_POS 0 - #define E4_MICROSTEPS 16 + #define E4_MICROSTEPS 128 #define E4_OVERCURRENT 2000 #define E4_STALLCURRENT 1500 + #define E4_MAX_VOLTAGE 127 + #define E4_CHAIN_POS 0 - #define E5_MICROSTEPS 16 + #define E5_MICROSTEPS 128 #define E5_OVERCURRENT 2000 #define E5_STALLCURRENT 1500 + #define E5_MAX_VOLTAGE 127 + #define E5_CHAIN_POS 0 + + + /** + * Monitor L6470 drivers for error conditions like over temperature and over current. + * In the case of over temperature Marlin can decrease the drive until the error condition clears. + * Other detected conditions can be used to stop the current print. + * Relevant g-codes: + * M906 - I1/2/3/4/5 Set or get motor drive level using axis codes X, Y, Z, E. Report values if no axis codes given. + * I not present or I0 or I1 - X, Y, Z or E0 + * I2 - X2, Y2, Z2 or E1 + * I3 - Z3 or E3 + * I4 - E4 + * I5 - E5 + * M916 - Increase drive level until get thermal warning + * M917 - Find minimum current thresholds + * M918 - Increase speed until max or error + * M122 S0/1 - Report driver parameters + */ + //#define MONITOR_L6470_DRIVER_STATUS + + #if ENABLED(MONITOR_L6470_DRIVER_STATUS) + #define KVAL_HOLD_STEP_DOWN 1 + //#define L6470_STOP_ON_ERROR + #endif + + #define L6470_CHITCHAT // enable display of additional status info #endif // L6470 diff --git a/Marlin/src/config/examples/Geeetech/MeCreator2/Configuration_adv.h b/Marlin/src/config/examples/Geeetech/MeCreator2/Configuration_adv.h index f9720e68c..49fd426e8 100644 --- a/Marlin/src/config/examples/Geeetech/MeCreator2/Configuration_adv.h +++ b/Marlin/src/config/examples/Geeetech/MeCreator2/Configuration_adv.h @@ -1509,62 +1509,121 @@ /** * L6470 Stepper Driver options * - * The Arduino-L6470 library is required for this stepper driver. + * Arduino-L6470 library (0.7.0 or higher) is required for this stepper driver. * https://github.com/ameyer/Arduino-L6470 + * + * Requires the following to be defined in your pins_YOUR_BOARD file + * L6470_CHAIN_SCK_PIN + * L6470_CHAIN_MISO_PIN + * L6470_CHAIN_MOSI_PIN + * L6470_CHAIN_SS_PIN + * L6470_RESET_CHAIN_PIN (optional) */ #if HAS_DRIVER(L6470) - #define X_MICROSTEPS 16 // number of microsteps - #define X_OVERCURRENT 2000 // maxc current in mA. If the current goes over this value, the driver will switch off - #define X_STALLCURRENT 1500 // current in mA where the driver will detect a stall + #define X_MICROSTEPS 128 // number of microsteps (VALID: 1, 2, 4, 8, 16, 32, 128 & 128) + #define X_OVERCURRENT 2000 // current in mA where the driver will detect an over current (VALID: 375 x (1 - 16) - 6A max - rounds down) + #define X_STALLCURRENT 1500 // current in mA where the driver will detect a stall (VALID: 31.25 * (1-128) - 4A max - rounds down) + #define X_MAX_VOLTAGE 127 // 0-255, max effective voltage seen by stepper + #define X_CHAIN_POS 0 // position in SPI chain, 0 - not in chain, 1- nearest MOSI - #define X2_MICROSTEPS 16 + #define X2_MICROSTEPS 128 #define X2_OVERCURRENT 2000 #define X2_STALLCURRENT 1500 + #define X2_MAX_VOLTAGE 127 + #define X2_CHAIN_POS 0 - #define Y_MICROSTEPS 16 + #define Y_MICROSTEPS 128 #define Y_OVERCURRENT 2000 #define Y_STALLCURRENT 1500 + #define Y_MAX_VOLTAGE 127 + #define Y_CHAIN_POS 0 - #define Y2_MICROSTEPS 16 + #define Y2_MICROSTEPS 128 #define Y2_OVERCURRENT 2000 #define Y2_STALLCURRENT 1500 + #define Y2_MAX_VOLTAGE 127 + #define Y2_CHAIN_POS 0 - #define Z_MICROSTEPS 16 + #define Z_MICROSTEPS 128 #define Z_OVERCURRENT 2000 #define Z_STALLCURRENT 1500 + #define Z_MAX_VOLTAGE 127 + #define Z_CHAIN_POS 0 - #define Z2_MICROSTEPS 16 + #define Z2_MICROSTEPS 128 #define Z2_OVERCURRENT 2000 #define Z2_STALLCURRENT 1500 + #define Z2_MAX_VOLTAGE 127 + #define Z2_CHAIN_POS 0 - #define Z3_MICROSTEPS 16 + #define Z3_MICROSTEPS 128 #define Z3_OVERCURRENT 2000 #define Z3_STALLCURRENT 1500 + #define Z3_MAX_VOLTAGE 127 + #define Z3_CHAIN_POS 0 - #define E0_MICROSTEPS 16 + #define E0_MICROSTEPS 128 #define E0_OVERCURRENT 2000 #define E0_STALLCURRENT 1500 + #define E0_MAX_VOLTAGE 127 + #define E0_CHAIN_POS 0 - #define E1_MICROSTEPS 16 + #define E1_MICROSTEPS 128 #define E1_OVERCURRENT 2000 #define E1_STALLCURRENT 1500 + #define E1_MAX_VOLTAGE 127 + #define E1_CHAIN_POS 0 - #define E2_MICROSTEPS 16 + #define E2_MICROSTEPS 128 #define E2_OVERCURRENT 2000 #define E2_STALLCURRENT 1500 + #define E2_MAX_VOLTAGE 127 + #define E2_CHAIN_POS 0 - #define E3_MICROSTEPS 16 + #define E3_MICROSTEPS 128 #define E3_OVERCURRENT 2000 #define E3_STALLCURRENT 1500 + #define E3_MAX_VOLTAGE 127 + #define E3_CHAIN_POS 0 - #define E4_MICROSTEPS 16 + #define E4_MICROSTEPS 128 #define E4_OVERCURRENT 2000 #define E4_STALLCURRENT 1500 + #define E4_MAX_VOLTAGE 127 + #define E4_CHAIN_POS 0 - #define E5_MICROSTEPS 16 + #define E5_MICROSTEPS 128 #define E5_OVERCURRENT 2000 #define E5_STALLCURRENT 1500 + #define E5_MAX_VOLTAGE 127 + #define E5_CHAIN_POS 0 + + + /** + * Monitor L6470 drivers for error conditions like over temperature and over current. + * In the case of over temperature Marlin can decrease the drive until the error condition clears. + * Other detected conditions can be used to stop the current print. + * Relevant g-codes: + * M906 - I1/2/3/4/5 Set or get motor drive level using axis codes X, Y, Z, E. Report values if no axis codes given. + * I not present or I0 or I1 - X, Y, Z or E0 + * I2 - X2, Y2, Z2 or E1 + * I3 - Z3 or E3 + * I4 - E4 + * I5 - E5 + * M916 - Increase drive level until get thermal warning + * M917 - Find minimum current thresholds + * M918 - Increase speed until max or error + * M122 S0/1 - Report driver parameters + */ + //#define MONITOR_L6470_DRIVER_STATUS + + #if ENABLED(MONITOR_L6470_DRIVER_STATUS) + #define KVAL_HOLD_STEP_DOWN 1 + //#define L6470_STOP_ON_ERROR + #endif + + #define L6470_CHITCHAT // enable display of additional status info #endif // L6470 diff --git a/Marlin/src/config/examples/Geeetech/Prusa i3 Pro C/Configuration_adv.h b/Marlin/src/config/examples/Geeetech/Prusa i3 Pro C/Configuration_adv.h index 5e61cbde7..8c77f69e7 100644 --- a/Marlin/src/config/examples/Geeetech/Prusa i3 Pro C/Configuration_adv.h +++ b/Marlin/src/config/examples/Geeetech/Prusa i3 Pro C/Configuration_adv.h @@ -1508,62 +1508,121 @@ /** * L6470 Stepper Driver options * - * The Arduino-L6470 library is required for this stepper driver. + * Arduino-L6470 library (0.7.0 or higher) is required for this stepper driver. * https://github.com/ameyer/Arduino-L6470 + * + * Requires the following to be defined in your pins_YOUR_BOARD file + * L6470_CHAIN_SCK_PIN + * L6470_CHAIN_MISO_PIN + * L6470_CHAIN_MOSI_PIN + * L6470_CHAIN_SS_PIN + * L6470_RESET_CHAIN_PIN (optional) */ #if HAS_DRIVER(L6470) - #define X_MICROSTEPS 16 // number of microsteps - #define X_OVERCURRENT 2000 // maxc current in mA. If the current goes over this value, the driver will switch off - #define X_STALLCURRENT 1500 // current in mA where the driver will detect a stall + #define X_MICROSTEPS 128 // number of microsteps (VALID: 1, 2, 4, 8, 16, 32, 128 & 128) + #define X_OVERCURRENT 2000 // current in mA where the driver will detect an over current (VALID: 375 x (1 - 16) - 6A max - rounds down) + #define X_STALLCURRENT 1500 // current in mA where the driver will detect a stall (VALID: 31.25 * (1-128) - 4A max - rounds down) + #define X_MAX_VOLTAGE 127 // 0-255, max effective voltage seen by stepper + #define X_CHAIN_POS 0 // position in SPI chain, 0 - not in chain, 1- nearest MOSI - #define X2_MICROSTEPS 16 + #define X2_MICROSTEPS 128 #define X2_OVERCURRENT 2000 #define X2_STALLCURRENT 1500 + #define X2_MAX_VOLTAGE 127 + #define X2_CHAIN_POS 0 - #define Y_MICROSTEPS 16 + #define Y_MICROSTEPS 128 #define Y_OVERCURRENT 2000 #define Y_STALLCURRENT 1500 + #define Y_MAX_VOLTAGE 127 + #define Y_CHAIN_POS 0 - #define Y2_MICROSTEPS 16 + #define Y2_MICROSTEPS 128 #define Y2_OVERCURRENT 2000 #define Y2_STALLCURRENT 1500 + #define Y2_MAX_VOLTAGE 127 + #define Y2_CHAIN_POS 0 - #define Z_MICROSTEPS 16 + #define Z_MICROSTEPS 128 #define Z_OVERCURRENT 2000 #define Z_STALLCURRENT 1500 + #define Z_MAX_VOLTAGE 127 + #define Z_CHAIN_POS 0 - #define Z2_MICROSTEPS 16 + #define Z2_MICROSTEPS 128 #define Z2_OVERCURRENT 2000 #define Z2_STALLCURRENT 1500 + #define Z2_MAX_VOLTAGE 127 + #define Z2_CHAIN_POS 0 - #define Z3_MICROSTEPS 16 + #define Z3_MICROSTEPS 128 #define Z3_OVERCURRENT 2000 #define Z3_STALLCURRENT 1500 + #define Z3_MAX_VOLTAGE 127 + #define Z3_CHAIN_POS 0 - #define E0_MICROSTEPS 16 + #define E0_MICROSTEPS 128 #define E0_OVERCURRENT 2000 #define E0_STALLCURRENT 1500 + #define E0_MAX_VOLTAGE 127 + #define E0_CHAIN_POS 0 - #define E1_MICROSTEPS 16 + #define E1_MICROSTEPS 128 #define E1_OVERCURRENT 2000 #define E1_STALLCURRENT 1500 + #define E1_MAX_VOLTAGE 127 + #define E1_CHAIN_POS 0 - #define E2_MICROSTEPS 16 + #define E2_MICROSTEPS 128 #define E2_OVERCURRENT 2000 #define E2_STALLCURRENT 1500 + #define E2_MAX_VOLTAGE 127 + #define E2_CHAIN_POS 0 - #define E3_MICROSTEPS 16 + #define E3_MICROSTEPS 128 #define E3_OVERCURRENT 2000 #define E3_STALLCURRENT 1500 + #define E3_MAX_VOLTAGE 127 + #define E3_CHAIN_POS 0 - #define E4_MICROSTEPS 16 + #define E4_MICROSTEPS 128 #define E4_OVERCURRENT 2000 #define E4_STALLCURRENT 1500 + #define E4_MAX_VOLTAGE 127 + #define E4_CHAIN_POS 0 - #define E5_MICROSTEPS 16 + #define E5_MICROSTEPS 128 #define E5_OVERCURRENT 2000 #define E5_STALLCURRENT 1500 + #define E5_MAX_VOLTAGE 127 + #define E5_CHAIN_POS 0 + + + /** + * Monitor L6470 drivers for error conditions like over temperature and over current. + * In the case of over temperature Marlin can decrease the drive until the error condition clears. + * Other detected conditions can be used to stop the current print. + * Relevant g-codes: + * M906 - I1/2/3/4/5 Set or get motor drive level using axis codes X, Y, Z, E. Report values if no axis codes given. + * I not present or I0 or I1 - X, Y, Z or E0 + * I2 - X2, Y2, Z2 or E1 + * I3 - Z3 or E3 + * I4 - E4 + * I5 - E5 + * M916 - Increase drive level until get thermal warning + * M917 - Find minimum current thresholds + * M918 - Increase speed until max or error + * M122 S0/1 - Report driver parameters + */ + //#define MONITOR_L6470_DRIVER_STATUS + + #if ENABLED(MONITOR_L6470_DRIVER_STATUS) + #define KVAL_HOLD_STEP_DOWN 1 + //#define L6470_STOP_ON_ERROR + #endif + + #define L6470_CHITCHAT // enable display of additional status info #endif // L6470 diff --git a/Marlin/src/config/examples/Geeetech/Prusa i3 Pro W/Configuration_adv.h b/Marlin/src/config/examples/Geeetech/Prusa i3 Pro W/Configuration_adv.h index 5e61cbde7..8c77f69e7 100644 --- a/Marlin/src/config/examples/Geeetech/Prusa i3 Pro W/Configuration_adv.h +++ b/Marlin/src/config/examples/Geeetech/Prusa i3 Pro W/Configuration_adv.h @@ -1508,62 +1508,121 @@ /** * L6470 Stepper Driver options * - * The Arduino-L6470 library is required for this stepper driver. + * Arduino-L6470 library (0.7.0 or higher) is required for this stepper driver. * https://github.com/ameyer/Arduino-L6470 + * + * Requires the following to be defined in your pins_YOUR_BOARD file + * L6470_CHAIN_SCK_PIN + * L6470_CHAIN_MISO_PIN + * L6470_CHAIN_MOSI_PIN + * L6470_CHAIN_SS_PIN + * L6470_RESET_CHAIN_PIN (optional) */ #if HAS_DRIVER(L6470) - #define X_MICROSTEPS 16 // number of microsteps - #define X_OVERCURRENT 2000 // maxc current in mA. If the current goes over this value, the driver will switch off - #define X_STALLCURRENT 1500 // current in mA where the driver will detect a stall + #define X_MICROSTEPS 128 // number of microsteps (VALID: 1, 2, 4, 8, 16, 32, 128 & 128) + #define X_OVERCURRENT 2000 // current in mA where the driver will detect an over current (VALID: 375 x (1 - 16) - 6A max - rounds down) + #define X_STALLCURRENT 1500 // current in mA where the driver will detect a stall (VALID: 31.25 * (1-128) - 4A max - rounds down) + #define X_MAX_VOLTAGE 127 // 0-255, max effective voltage seen by stepper + #define X_CHAIN_POS 0 // position in SPI chain, 0 - not in chain, 1- nearest MOSI - #define X2_MICROSTEPS 16 + #define X2_MICROSTEPS 128 #define X2_OVERCURRENT 2000 #define X2_STALLCURRENT 1500 + #define X2_MAX_VOLTAGE 127 + #define X2_CHAIN_POS 0 - #define Y_MICROSTEPS 16 + #define Y_MICROSTEPS 128 #define Y_OVERCURRENT 2000 #define Y_STALLCURRENT 1500 + #define Y_MAX_VOLTAGE 127 + #define Y_CHAIN_POS 0 - #define Y2_MICROSTEPS 16 + #define Y2_MICROSTEPS 128 #define Y2_OVERCURRENT 2000 #define Y2_STALLCURRENT 1500 + #define Y2_MAX_VOLTAGE 127 + #define Y2_CHAIN_POS 0 - #define Z_MICROSTEPS 16 + #define Z_MICROSTEPS 128 #define Z_OVERCURRENT 2000 #define Z_STALLCURRENT 1500 + #define Z_MAX_VOLTAGE 127 + #define Z_CHAIN_POS 0 - #define Z2_MICROSTEPS 16 + #define Z2_MICROSTEPS 128 #define Z2_OVERCURRENT 2000 #define Z2_STALLCURRENT 1500 + #define Z2_MAX_VOLTAGE 127 + #define Z2_CHAIN_POS 0 - #define Z3_MICROSTEPS 16 + #define Z3_MICROSTEPS 128 #define Z3_OVERCURRENT 2000 #define Z3_STALLCURRENT 1500 + #define Z3_MAX_VOLTAGE 127 + #define Z3_CHAIN_POS 0 - #define E0_MICROSTEPS 16 + #define E0_MICROSTEPS 128 #define E0_OVERCURRENT 2000 #define E0_STALLCURRENT 1500 + #define E0_MAX_VOLTAGE 127 + #define E0_CHAIN_POS 0 - #define E1_MICROSTEPS 16 + #define E1_MICROSTEPS 128 #define E1_OVERCURRENT 2000 #define E1_STALLCURRENT 1500 + #define E1_MAX_VOLTAGE 127 + #define E1_CHAIN_POS 0 - #define E2_MICROSTEPS 16 + #define E2_MICROSTEPS 128 #define E2_OVERCURRENT 2000 #define E2_STALLCURRENT 1500 + #define E2_MAX_VOLTAGE 127 + #define E2_CHAIN_POS 0 - #define E3_MICROSTEPS 16 + #define E3_MICROSTEPS 128 #define E3_OVERCURRENT 2000 #define E3_STALLCURRENT 1500 + #define E3_MAX_VOLTAGE 127 + #define E3_CHAIN_POS 0 - #define E4_MICROSTEPS 16 + #define E4_MICROSTEPS 128 #define E4_OVERCURRENT 2000 #define E4_STALLCURRENT 1500 + #define E4_MAX_VOLTAGE 127 + #define E4_CHAIN_POS 0 - #define E5_MICROSTEPS 16 + #define E5_MICROSTEPS 128 #define E5_OVERCURRENT 2000 #define E5_STALLCURRENT 1500 + #define E5_MAX_VOLTAGE 127 + #define E5_CHAIN_POS 0 + + + /** + * Monitor L6470 drivers for error conditions like over temperature and over current. + * In the case of over temperature Marlin can decrease the drive until the error condition clears. + * Other detected conditions can be used to stop the current print. + * Relevant g-codes: + * M906 - I1/2/3/4/5 Set or get motor drive level using axis codes X, Y, Z, E. Report values if no axis codes given. + * I not present or I0 or I1 - X, Y, Z or E0 + * I2 - X2, Y2, Z2 or E1 + * I3 - Z3 or E3 + * I4 - E4 + * I5 - E5 + * M916 - Increase drive level until get thermal warning + * M917 - Find minimum current thresholds + * M918 - Increase speed until max or error + * M122 S0/1 - Report driver parameters + */ + //#define MONITOR_L6470_DRIVER_STATUS + + #if ENABLED(MONITOR_L6470_DRIVER_STATUS) + #define KVAL_HOLD_STEP_DOWN 1 + //#define L6470_STOP_ON_ERROR + #endif + + #define L6470_CHITCHAT // enable display of additional status info #endif // L6470 diff --git a/Marlin/src/config/examples/Infitary/i3-M508/Configuration_adv.h b/Marlin/src/config/examples/Infitary/i3-M508/Configuration_adv.h index 144fdc422..4e02acc80 100644 --- a/Marlin/src/config/examples/Infitary/i3-M508/Configuration_adv.h +++ b/Marlin/src/config/examples/Infitary/i3-M508/Configuration_adv.h @@ -1508,62 +1508,121 @@ /** * L6470 Stepper Driver options * - * The Arduino-L6470 library is required for this stepper driver. + * Arduino-L6470 library (0.7.0 or higher) is required for this stepper driver. * https://github.com/ameyer/Arduino-L6470 + * + * Requires the following to be defined in your pins_YOUR_BOARD file + * L6470_CHAIN_SCK_PIN + * L6470_CHAIN_MISO_PIN + * L6470_CHAIN_MOSI_PIN + * L6470_CHAIN_SS_PIN + * L6470_RESET_CHAIN_PIN (optional) */ #if HAS_DRIVER(L6470) - #define X_MICROSTEPS 16 // number of microsteps - #define X_OVERCURRENT 2000 // maxc current in mA. If the current goes over this value, the driver will switch off - #define X_STALLCURRENT 1500 // current in mA where the driver will detect a stall + #define X_MICROSTEPS 128 // number of microsteps (VALID: 1, 2, 4, 8, 16, 32, 128 & 128) + #define X_OVERCURRENT 2000 // current in mA where the driver will detect an over current (VALID: 375 x (1 - 16) - 6A max - rounds down) + #define X_STALLCURRENT 1500 // current in mA where the driver will detect a stall (VALID: 31.25 * (1-128) - 4A max - rounds down) + #define X_MAX_VOLTAGE 127 // 0-255, max effective voltage seen by stepper + #define X_CHAIN_POS 0 // position in SPI chain, 0 - not in chain, 1- nearest MOSI - #define X2_MICROSTEPS 16 + #define X2_MICROSTEPS 128 #define X2_OVERCURRENT 2000 #define X2_STALLCURRENT 1500 + #define X2_MAX_VOLTAGE 127 + #define X2_CHAIN_POS 0 - #define Y_MICROSTEPS 16 + #define Y_MICROSTEPS 128 #define Y_OVERCURRENT 2000 #define Y_STALLCURRENT 1500 + #define Y_MAX_VOLTAGE 127 + #define Y_CHAIN_POS 0 - #define Y2_MICROSTEPS 16 + #define Y2_MICROSTEPS 128 #define Y2_OVERCURRENT 2000 #define Y2_STALLCURRENT 1500 + #define Y2_MAX_VOLTAGE 127 + #define Y2_CHAIN_POS 0 - #define Z_MICROSTEPS 16 + #define Z_MICROSTEPS 128 #define Z_OVERCURRENT 2000 #define Z_STALLCURRENT 1500 + #define Z_MAX_VOLTAGE 127 + #define Z_CHAIN_POS 0 - #define Z2_MICROSTEPS 16 + #define Z2_MICROSTEPS 128 #define Z2_OVERCURRENT 2000 #define Z2_STALLCURRENT 1500 + #define Z2_MAX_VOLTAGE 127 + #define Z2_CHAIN_POS 0 - #define Z3_MICROSTEPS 16 + #define Z3_MICROSTEPS 128 #define Z3_OVERCURRENT 2000 #define Z3_STALLCURRENT 1500 + #define Z3_MAX_VOLTAGE 127 + #define Z3_CHAIN_POS 0 - #define E0_MICROSTEPS 16 + #define E0_MICROSTEPS 128 #define E0_OVERCURRENT 2000 #define E0_STALLCURRENT 1500 + #define E0_MAX_VOLTAGE 127 + #define E0_CHAIN_POS 0 - #define E1_MICROSTEPS 16 + #define E1_MICROSTEPS 128 #define E1_OVERCURRENT 2000 #define E1_STALLCURRENT 1500 + #define E1_MAX_VOLTAGE 127 + #define E1_CHAIN_POS 0 - #define E2_MICROSTEPS 16 + #define E2_MICROSTEPS 128 #define E2_OVERCURRENT 2000 #define E2_STALLCURRENT 1500 + #define E2_MAX_VOLTAGE 127 + #define E2_CHAIN_POS 0 - #define E3_MICROSTEPS 16 + #define E3_MICROSTEPS 128 #define E3_OVERCURRENT 2000 #define E3_STALLCURRENT 1500 + #define E3_MAX_VOLTAGE 127 + #define E3_CHAIN_POS 0 - #define E4_MICROSTEPS 16 + #define E4_MICROSTEPS 128 #define E4_OVERCURRENT 2000 #define E4_STALLCURRENT 1500 + #define E4_MAX_VOLTAGE 127 + #define E4_CHAIN_POS 0 - #define E5_MICROSTEPS 16 + #define E5_MICROSTEPS 128 #define E5_OVERCURRENT 2000 #define E5_STALLCURRENT 1500 + #define E5_MAX_VOLTAGE 127 + #define E5_CHAIN_POS 0 + + + /** + * Monitor L6470 drivers for error conditions like over temperature and over current. + * In the case of over temperature Marlin can decrease the drive until the error condition clears. + * Other detected conditions can be used to stop the current print. + * Relevant g-codes: + * M906 - I1/2/3/4/5 Set or get motor drive level using axis codes X, Y, Z, E. Report values if no axis codes given. + * I not present or I0 or I1 - X, Y, Z or E0 + * I2 - X2, Y2, Z2 or E1 + * I3 - Z3 or E3 + * I4 - E4 + * I5 - E5 + * M916 - Increase drive level until get thermal warning + * M917 - Find minimum current thresholds + * M918 - Increase speed until max or error + * M122 S0/1 - Report driver parameters + */ + //#define MONITOR_L6470_DRIVER_STATUS + + #if ENABLED(MONITOR_L6470_DRIVER_STATUS) + #define KVAL_HOLD_STEP_DOWN 1 + //#define L6470_STOP_ON_ERROR + #endif + + #define L6470_CHITCHAT // enable display of additional status info #endif // L6470 diff --git a/Marlin/src/config/examples/JGAurora/A5/Configuration_adv.h b/Marlin/src/config/examples/JGAurora/A5/Configuration_adv.h index 1fbf47e7c..6dc754193 100644 --- a/Marlin/src/config/examples/JGAurora/A5/Configuration_adv.h +++ b/Marlin/src/config/examples/JGAurora/A5/Configuration_adv.h @@ -1508,62 +1508,121 @@ /** * L6470 Stepper Driver options * - * The Arduino-L6470 library is required for this stepper driver. + * Arduino-L6470 library (0.7.0 or higher) is required for this stepper driver. * https://github.com/ameyer/Arduino-L6470 + * + * Requires the following to be defined in your pins_YOUR_BOARD file + * L6470_CHAIN_SCK_PIN + * L6470_CHAIN_MISO_PIN + * L6470_CHAIN_MOSI_PIN + * L6470_CHAIN_SS_PIN + * L6470_RESET_CHAIN_PIN (optional) */ #if HAS_DRIVER(L6470) - #define X_MICROSTEPS 16 // number of microsteps - #define X_OVERCURRENT 2000 // maxc current in mA. If the current goes over this value, the driver will switch off - #define X_STALLCURRENT 1500 // current in mA where the driver will detect a stall + #define X_MICROSTEPS 128 // number of microsteps (VALID: 1, 2, 4, 8, 16, 32, 128 & 128) + #define X_OVERCURRENT 2000 // current in mA where the driver will detect an over current (VALID: 375 x (1 - 16) - 6A max - rounds down) + #define X_STALLCURRENT 1500 // current in mA where the driver will detect a stall (VALID: 31.25 * (1-128) - 4A max - rounds down) + #define X_MAX_VOLTAGE 127 // 0-255, max effective voltage seen by stepper + #define X_CHAIN_POS 0 // position in SPI chain, 0 - not in chain, 1- nearest MOSI - #define X2_MICROSTEPS 16 + #define X2_MICROSTEPS 128 #define X2_OVERCURRENT 2000 #define X2_STALLCURRENT 1500 + #define X2_MAX_VOLTAGE 127 + #define X2_CHAIN_POS 0 - #define Y_MICROSTEPS 16 + #define Y_MICROSTEPS 128 #define Y_OVERCURRENT 2000 #define Y_STALLCURRENT 1500 + #define Y_MAX_VOLTAGE 127 + #define Y_CHAIN_POS 0 - #define Y2_MICROSTEPS 16 + #define Y2_MICROSTEPS 128 #define Y2_OVERCURRENT 2000 #define Y2_STALLCURRENT 1500 + #define Y2_MAX_VOLTAGE 127 + #define Y2_CHAIN_POS 0 - #define Z_MICROSTEPS 16 + #define Z_MICROSTEPS 128 #define Z_OVERCURRENT 2000 #define Z_STALLCURRENT 1500 + #define Z_MAX_VOLTAGE 127 + #define Z_CHAIN_POS 0 - #define Z2_MICROSTEPS 16 + #define Z2_MICROSTEPS 128 #define Z2_OVERCURRENT 2000 #define Z2_STALLCURRENT 1500 + #define Z2_MAX_VOLTAGE 127 + #define Z2_CHAIN_POS 0 - #define Z3_MICROSTEPS 16 + #define Z3_MICROSTEPS 128 #define Z3_OVERCURRENT 2000 #define Z3_STALLCURRENT 1500 + #define Z3_MAX_VOLTAGE 127 + #define Z3_CHAIN_POS 0 - #define E0_MICROSTEPS 16 + #define E0_MICROSTEPS 128 #define E0_OVERCURRENT 2000 #define E0_STALLCURRENT 1500 + #define E0_MAX_VOLTAGE 127 + #define E0_CHAIN_POS 0 - #define E1_MICROSTEPS 16 + #define E1_MICROSTEPS 128 #define E1_OVERCURRENT 2000 #define E1_STALLCURRENT 1500 + #define E1_MAX_VOLTAGE 127 + #define E1_CHAIN_POS 0 - #define E2_MICROSTEPS 16 + #define E2_MICROSTEPS 128 #define E2_OVERCURRENT 2000 #define E2_STALLCURRENT 1500 + #define E2_MAX_VOLTAGE 127 + #define E2_CHAIN_POS 0 - #define E3_MICROSTEPS 16 + #define E3_MICROSTEPS 128 #define E3_OVERCURRENT 2000 #define E3_STALLCURRENT 1500 + #define E3_MAX_VOLTAGE 127 + #define E3_CHAIN_POS 0 - #define E4_MICROSTEPS 16 + #define E4_MICROSTEPS 128 #define E4_OVERCURRENT 2000 #define E4_STALLCURRENT 1500 + #define E4_MAX_VOLTAGE 127 + #define E4_CHAIN_POS 0 - #define E5_MICROSTEPS 16 + #define E5_MICROSTEPS 128 #define E5_OVERCURRENT 2000 #define E5_STALLCURRENT 1500 + #define E5_MAX_VOLTAGE 127 + #define E5_CHAIN_POS 0 + + + /** + * Monitor L6470 drivers for error conditions like over temperature and over current. + * In the case of over temperature Marlin can decrease the drive until the error condition clears. + * Other detected conditions can be used to stop the current print. + * Relevant g-codes: + * M906 - I1/2/3/4/5 Set or get motor drive level using axis codes X, Y, Z, E. Report values if no axis codes given. + * I not present or I0 or I1 - X, Y, Z or E0 + * I2 - X2, Y2, Z2 or E1 + * I3 - Z3 or E3 + * I4 - E4 + * I5 - E5 + * M916 - Increase drive level until get thermal warning + * M917 - Find minimum current thresholds + * M918 - Increase speed until max or error + * M122 S0/1 - Report driver parameters + */ + //#define MONITOR_L6470_DRIVER_STATUS + + #if ENABLED(MONITOR_L6470_DRIVER_STATUS) + #define KVAL_HOLD_STEP_DOWN 1 + //#define L6470_STOP_ON_ERROR + #endif + + #define L6470_CHITCHAT // enable display of additional status info #endif // L6470 diff --git a/Marlin/src/config/examples/MakerParts/Configuration_adv.h b/Marlin/src/config/examples/MakerParts/Configuration_adv.h index 1fa08c553..ea95224d4 100644 --- a/Marlin/src/config/examples/MakerParts/Configuration_adv.h +++ b/Marlin/src/config/examples/MakerParts/Configuration_adv.h @@ -1508,62 +1508,121 @@ /** * L6470 Stepper Driver options * - * The Arduino-L6470 library is required for this stepper driver. + * Arduino-L6470 library (0.7.0 or higher) is required for this stepper driver. * https://github.com/ameyer/Arduino-L6470 + * + * Requires the following to be defined in your pins_YOUR_BOARD file + * L6470_CHAIN_SCK_PIN + * L6470_CHAIN_MISO_PIN + * L6470_CHAIN_MOSI_PIN + * L6470_CHAIN_SS_PIN + * L6470_RESET_CHAIN_PIN (optional) */ #if HAS_DRIVER(L6470) - #define X_MICROSTEPS 16 // number of microsteps - #define X_OVERCURRENT 2000 // maxc current in mA. If the current goes over this value, the driver will switch off - #define X_STALLCURRENT 1500 // current in mA where the driver will detect a stall + #define X_MICROSTEPS 128 // number of microsteps (VALID: 1, 2, 4, 8, 16, 32, 128 & 128) + #define X_OVERCURRENT 2000 // current in mA where the driver will detect an over current (VALID: 375 x (1 - 16) - 6A max - rounds down) + #define X_STALLCURRENT 1500 // current in mA where the driver will detect a stall (VALID: 31.25 * (1-128) - 4A max - rounds down) + #define X_MAX_VOLTAGE 127 // 0-255, max effective voltage seen by stepper + #define X_CHAIN_POS 0 // position in SPI chain, 0 - not in chain, 1- nearest MOSI - #define X2_MICROSTEPS 16 + #define X2_MICROSTEPS 128 #define X2_OVERCURRENT 2000 #define X2_STALLCURRENT 1500 + #define X2_MAX_VOLTAGE 127 + #define X2_CHAIN_POS 0 - #define Y_MICROSTEPS 16 + #define Y_MICROSTEPS 128 #define Y_OVERCURRENT 2000 #define Y_STALLCURRENT 1500 + #define Y_MAX_VOLTAGE 127 + #define Y_CHAIN_POS 0 - #define Y2_MICROSTEPS 16 + #define Y2_MICROSTEPS 128 #define Y2_OVERCURRENT 2000 #define Y2_STALLCURRENT 1500 + #define Y2_MAX_VOLTAGE 127 + #define Y2_CHAIN_POS 0 - #define Z_MICROSTEPS 16 + #define Z_MICROSTEPS 128 #define Z_OVERCURRENT 2000 #define Z_STALLCURRENT 1500 + #define Z_MAX_VOLTAGE 127 + #define Z_CHAIN_POS 0 - #define Z2_MICROSTEPS 16 + #define Z2_MICROSTEPS 128 #define Z2_OVERCURRENT 2000 #define Z2_STALLCURRENT 1500 + #define Z2_MAX_VOLTAGE 127 + #define Z2_CHAIN_POS 0 - #define Z3_MICROSTEPS 16 + #define Z3_MICROSTEPS 128 #define Z3_OVERCURRENT 2000 #define Z3_STALLCURRENT 1500 + #define Z3_MAX_VOLTAGE 127 + #define Z3_CHAIN_POS 0 - #define E0_MICROSTEPS 16 + #define E0_MICROSTEPS 128 #define E0_OVERCURRENT 2000 #define E0_STALLCURRENT 1500 + #define E0_MAX_VOLTAGE 127 + #define E0_CHAIN_POS 0 - #define E1_MICROSTEPS 16 + #define E1_MICROSTEPS 128 #define E1_OVERCURRENT 2000 #define E1_STALLCURRENT 1500 + #define E1_MAX_VOLTAGE 127 + #define E1_CHAIN_POS 0 - #define E2_MICROSTEPS 16 + #define E2_MICROSTEPS 128 #define E2_OVERCURRENT 2000 #define E2_STALLCURRENT 1500 + #define E2_MAX_VOLTAGE 127 + #define E2_CHAIN_POS 0 - #define E3_MICROSTEPS 16 + #define E3_MICROSTEPS 128 #define E3_OVERCURRENT 2000 #define E3_STALLCURRENT 1500 + #define E3_MAX_VOLTAGE 127 + #define E3_CHAIN_POS 0 - #define E4_MICROSTEPS 16 + #define E4_MICROSTEPS 128 #define E4_OVERCURRENT 2000 #define E4_STALLCURRENT 1500 + #define E4_MAX_VOLTAGE 127 + #define E4_CHAIN_POS 0 - #define E5_MICROSTEPS 16 + #define E5_MICROSTEPS 128 #define E5_OVERCURRENT 2000 #define E5_STALLCURRENT 1500 + #define E5_MAX_VOLTAGE 127 + #define E5_CHAIN_POS 0 + + + /** + * Monitor L6470 drivers for error conditions like over temperature and over current. + * In the case of over temperature Marlin can decrease the drive until the error condition clears. + * Other detected conditions can be used to stop the current print. + * Relevant g-codes: + * M906 - I1/2/3/4/5 Set or get motor drive level using axis codes X, Y, Z, E. Report values if no axis codes given. + * I not present or I0 or I1 - X, Y, Z or E0 + * I2 - X2, Y2, Z2 or E1 + * I3 - Z3 or E3 + * I4 - E4 + * I5 - E5 + * M916 - Increase drive level until get thermal warning + * M917 - Find minimum current thresholds + * M918 - Increase speed until max or error + * M122 S0/1 - Report driver parameters + */ + //#define MONITOR_L6470_DRIVER_STATUS + + #if ENABLED(MONITOR_L6470_DRIVER_STATUS) + #define KVAL_HOLD_STEP_DOWN 1 + //#define L6470_STOP_ON_ERROR + #endif + + #define L6470_CHITCHAT // enable display of additional status info #endif // L6470 diff --git a/Marlin/src/config/examples/Malyan/M150/Configuration_adv.h b/Marlin/src/config/examples/Malyan/M150/Configuration_adv.h index 42a4fec08..4b5288473 100644 --- a/Marlin/src/config/examples/Malyan/M150/Configuration_adv.h +++ b/Marlin/src/config/examples/Malyan/M150/Configuration_adv.h @@ -1508,62 +1508,121 @@ /** * L6470 Stepper Driver options * - * The Arduino-L6470 library is required for this stepper driver. + * Arduino-L6470 library (0.7.0 or higher) is required for this stepper driver. * https://github.com/ameyer/Arduino-L6470 + * + * Requires the following to be defined in your pins_YOUR_BOARD file + * L6470_CHAIN_SCK_PIN + * L6470_CHAIN_MISO_PIN + * L6470_CHAIN_MOSI_PIN + * L6470_CHAIN_SS_PIN + * L6470_RESET_CHAIN_PIN (optional) */ #if HAS_DRIVER(L6470) - #define X_MICROSTEPS 16 // number of microsteps - #define X_OVERCURRENT 2000 // maxc current in mA. If the current goes over this value, the driver will switch off - #define X_STALLCURRENT 1500 // current in mA where the driver will detect a stall + #define X_MICROSTEPS 128 // number of microsteps (VALID: 1, 2, 4, 8, 16, 32, 128 & 128) + #define X_OVERCURRENT 2000 // current in mA where the driver will detect an over current (VALID: 375 x (1 - 16) - 6A max - rounds down) + #define X_STALLCURRENT 1500 // current in mA where the driver will detect a stall (VALID: 31.25 * (1-128) - 4A max - rounds down) + #define X_MAX_VOLTAGE 127 // 0-255, max effective voltage seen by stepper + #define X_CHAIN_POS 0 // position in SPI chain, 0 - not in chain, 1- nearest MOSI - #define X2_MICROSTEPS 16 + #define X2_MICROSTEPS 128 #define X2_OVERCURRENT 2000 #define X2_STALLCURRENT 1500 + #define X2_MAX_VOLTAGE 127 + #define X2_CHAIN_POS 0 - #define Y_MICROSTEPS 16 + #define Y_MICROSTEPS 128 #define Y_OVERCURRENT 2000 #define Y_STALLCURRENT 1500 + #define Y_MAX_VOLTAGE 127 + #define Y_CHAIN_POS 0 - #define Y2_MICROSTEPS 16 + #define Y2_MICROSTEPS 128 #define Y2_OVERCURRENT 2000 #define Y2_STALLCURRENT 1500 + #define Y2_MAX_VOLTAGE 127 + #define Y2_CHAIN_POS 0 - #define Z_MICROSTEPS 16 + #define Z_MICROSTEPS 128 #define Z_OVERCURRENT 2000 #define Z_STALLCURRENT 1500 + #define Z_MAX_VOLTAGE 127 + #define Z_CHAIN_POS 0 - #define Z2_MICROSTEPS 16 + #define Z2_MICROSTEPS 128 #define Z2_OVERCURRENT 2000 #define Z2_STALLCURRENT 1500 + #define Z2_MAX_VOLTAGE 127 + #define Z2_CHAIN_POS 0 - #define Z3_MICROSTEPS 16 + #define Z3_MICROSTEPS 128 #define Z3_OVERCURRENT 2000 #define Z3_STALLCURRENT 1500 + #define Z3_MAX_VOLTAGE 127 + #define Z3_CHAIN_POS 0 - #define E0_MICROSTEPS 16 + #define E0_MICROSTEPS 128 #define E0_OVERCURRENT 2000 #define E0_STALLCURRENT 1500 + #define E0_MAX_VOLTAGE 127 + #define E0_CHAIN_POS 0 - #define E1_MICROSTEPS 16 + #define E1_MICROSTEPS 128 #define E1_OVERCURRENT 2000 #define E1_STALLCURRENT 1500 + #define E1_MAX_VOLTAGE 127 + #define E1_CHAIN_POS 0 - #define E2_MICROSTEPS 16 + #define E2_MICROSTEPS 128 #define E2_OVERCURRENT 2000 #define E2_STALLCURRENT 1500 + #define E2_MAX_VOLTAGE 127 + #define E2_CHAIN_POS 0 - #define E3_MICROSTEPS 16 + #define E3_MICROSTEPS 128 #define E3_OVERCURRENT 2000 #define E3_STALLCURRENT 1500 + #define E3_MAX_VOLTAGE 127 + #define E3_CHAIN_POS 0 - #define E4_MICROSTEPS 16 + #define E4_MICROSTEPS 128 #define E4_OVERCURRENT 2000 #define E4_STALLCURRENT 1500 + #define E4_MAX_VOLTAGE 127 + #define E4_CHAIN_POS 0 - #define E5_MICROSTEPS 16 + #define E5_MICROSTEPS 128 #define E5_OVERCURRENT 2000 #define E5_STALLCURRENT 1500 + #define E5_MAX_VOLTAGE 127 + #define E5_CHAIN_POS 0 + + + /** + * Monitor L6470 drivers for error conditions like over temperature and over current. + * In the case of over temperature Marlin can decrease the drive until the error condition clears. + * Other detected conditions can be used to stop the current print. + * Relevant g-codes: + * M906 - I1/2/3/4/5 Set or get motor drive level using axis codes X, Y, Z, E. Report values if no axis codes given. + * I not present or I0 or I1 - X, Y, Z or E0 + * I2 - X2, Y2, Z2 or E1 + * I3 - Z3 or E3 + * I4 - E4 + * I5 - E5 + * M916 - Increase drive level until get thermal warning + * M917 - Find minimum current thresholds + * M918 - Increase speed until max or error + * M122 S0/1 - Report driver parameters + */ + //#define MONITOR_L6470_DRIVER_STATUS + + #if ENABLED(MONITOR_L6470_DRIVER_STATUS) + #define KVAL_HOLD_STEP_DOWN 1 + //#define L6470_STOP_ON_ERROR + #endif + + #define L6470_CHITCHAT // enable display of additional status info #endif // L6470 diff --git a/Marlin/src/config/examples/Malyan/M200/Configuration_adv.h b/Marlin/src/config/examples/Malyan/M200/Configuration_adv.h index 38b17bc2d..fa2a9e8ba 100644 --- a/Marlin/src/config/examples/Malyan/M200/Configuration_adv.h +++ b/Marlin/src/config/examples/Malyan/M200/Configuration_adv.h @@ -1508,62 +1508,121 @@ /** * L6470 Stepper Driver options * - * The Arduino-L6470 library is required for this stepper driver. + * Arduino-L6470 library (0.7.0 or higher) is required for this stepper driver. * https://github.com/ameyer/Arduino-L6470 + * + * Requires the following to be defined in your pins_YOUR_BOARD file + * L6470_CHAIN_SCK_PIN + * L6470_CHAIN_MISO_PIN + * L6470_CHAIN_MOSI_PIN + * L6470_CHAIN_SS_PIN + * L6470_RESET_CHAIN_PIN (optional) */ #if HAS_DRIVER(L6470) - #define X_MICROSTEPS 16 // number of microsteps - #define X_OVERCURRENT 2000 // maxc current in mA. If the current goes over this value, the driver will switch off - #define X_STALLCURRENT 1500 // current in mA where the driver will detect a stall + #define X_MICROSTEPS 128 // number of microsteps (VALID: 1, 2, 4, 8, 16, 32, 128 & 128) + #define X_OVERCURRENT 2000 // current in mA where the driver will detect an over current (VALID: 375 x (1 - 16) - 6A max - rounds down) + #define X_STALLCURRENT 1500 // current in mA where the driver will detect a stall (VALID: 31.25 * (1-128) - 4A max - rounds down) + #define X_MAX_VOLTAGE 127 // 0-255, max effective voltage seen by stepper + #define X_CHAIN_POS 0 // position in SPI chain, 0 - not in chain, 1- nearest MOSI - #define X2_MICROSTEPS 16 + #define X2_MICROSTEPS 128 #define X2_OVERCURRENT 2000 #define X2_STALLCURRENT 1500 + #define X2_MAX_VOLTAGE 127 + #define X2_CHAIN_POS 0 - #define Y_MICROSTEPS 16 + #define Y_MICROSTEPS 128 #define Y_OVERCURRENT 2000 #define Y_STALLCURRENT 1500 + #define Y_MAX_VOLTAGE 127 + #define Y_CHAIN_POS 0 - #define Y2_MICROSTEPS 16 + #define Y2_MICROSTEPS 128 #define Y2_OVERCURRENT 2000 #define Y2_STALLCURRENT 1500 + #define Y2_MAX_VOLTAGE 127 + #define Y2_CHAIN_POS 0 - #define Z_MICROSTEPS 16 + #define Z_MICROSTEPS 128 #define Z_OVERCURRENT 2000 #define Z_STALLCURRENT 1500 + #define Z_MAX_VOLTAGE 127 + #define Z_CHAIN_POS 0 - #define Z2_MICROSTEPS 16 + #define Z2_MICROSTEPS 128 #define Z2_OVERCURRENT 2000 #define Z2_STALLCURRENT 1500 + #define Z2_MAX_VOLTAGE 127 + #define Z2_CHAIN_POS 0 - #define Z3_MICROSTEPS 16 + #define Z3_MICROSTEPS 128 #define Z3_OVERCURRENT 2000 #define Z3_STALLCURRENT 1500 + #define Z3_MAX_VOLTAGE 127 + #define Z3_CHAIN_POS 0 - #define E0_MICROSTEPS 16 + #define E0_MICROSTEPS 128 #define E0_OVERCURRENT 2000 #define E0_STALLCURRENT 1500 + #define E0_MAX_VOLTAGE 127 + #define E0_CHAIN_POS 0 - #define E1_MICROSTEPS 16 + #define E1_MICROSTEPS 128 #define E1_OVERCURRENT 2000 #define E1_STALLCURRENT 1500 + #define E1_MAX_VOLTAGE 127 + #define E1_CHAIN_POS 0 - #define E2_MICROSTEPS 16 + #define E2_MICROSTEPS 128 #define E2_OVERCURRENT 2000 #define E2_STALLCURRENT 1500 + #define E2_MAX_VOLTAGE 127 + #define E2_CHAIN_POS 0 - #define E3_MICROSTEPS 16 + #define E3_MICROSTEPS 128 #define E3_OVERCURRENT 2000 #define E3_STALLCURRENT 1500 + #define E3_MAX_VOLTAGE 127 + #define E3_CHAIN_POS 0 - #define E4_MICROSTEPS 16 + #define E4_MICROSTEPS 128 #define E4_OVERCURRENT 2000 #define E4_STALLCURRENT 1500 + #define E4_MAX_VOLTAGE 127 + #define E4_CHAIN_POS 0 - #define E5_MICROSTEPS 16 + #define E5_MICROSTEPS 128 #define E5_OVERCURRENT 2000 #define E5_STALLCURRENT 1500 + #define E5_MAX_VOLTAGE 127 + #define E5_CHAIN_POS 0 + + + /** + * Monitor L6470 drivers for error conditions like over temperature and over current. + * In the case of over temperature Marlin can decrease the drive until the error condition clears. + * Other detected conditions can be used to stop the current print. + * Relevant g-codes: + * M906 - I1/2/3/4/5 Set or get motor drive level using axis codes X, Y, Z, E. Report values if no axis codes given. + * I not present or I0 or I1 - X, Y, Z or E0 + * I2 - X2, Y2, Z2 or E1 + * I3 - Z3 or E3 + * I4 - E4 + * I5 - E5 + * M916 - Increase drive level until get thermal warning + * M917 - Find minimum current thresholds + * M918 - Increase speed until max or error + * M122 S0/1 - Report driver parameters + */ + //#define MONITOR_L6470_DRIVER_STATUS + + #if ENABLED(MONITOR_L6470_DRIVER_STATUS) + #define KVAL_HOLD_STEP_DOWN 1 + //#define L6470_STOP_ON_ERROR + #endif + + #define L6470_CHITCHAT // enable display of additional status info #endif // L6470 diff --git a/Marlin/src/config/examples/Micromake/C1/enhanced/Configuration_adv.h b/Marlin/src/config/examples/Micromake/C1/enhanced/Configuration_adv.h index 1d99b8f2b..091666a92 100644 --- a/Marlin/src/config/examples/Micromake/C1/enhanced/Configuration_adv.h +++ b/Marlin/src/config/examples/Micromake/C1/enhanced/Configuration_adv.h @@ -1508,62 +1508,121 @@ /** * L6470 Stepper Driver options * - * The Arduino-L6470 library is required for this stepper driver. + * Arduino-L6470 library (0.7.0 or higher) is required for this stepper driver. * https://github.com/ameyer/Arduino-L6470 + * + * Requires the following to be defined in your pins_YOUR_BOARD file + * L6470_CHAIN_SCK_PIN + * L6470_CHAIN_MISO_PIN + * L6470_CHAIN_MOSI_PIN + * L6470_CHAIN_SS_PIN + * L6470_RESET_CHAIN_PIN (optional) */ #if HAS_DRIVER(L6470) - #define X_MICROSTEPS 16 // number of microsteps - #define X_OVERCURRENT 2000 // maxc current in mA. If the current goes over this value, the driver will switch off - #define X_STALLCURRENT 1500 // current in mA where the driver will detect a stall + #define X_MICROSTEPS 128 // number of microsteps (VALID: 1, 2, 4, 8, 16, 32, 128 & 128) + #define X_OVERCURRENT 2000 // current in mA where the driver will detect an over current (VALID: 375 x (1 - 16) - 6A max - rounds down) + #define X_STALLCURRENT 1500 // current in mA where the driver will detect a stall (VALID: 31.25 * (1-128) - 4A max - rounds down) + #define X_MAX_VOLTAGE 127 // 0-255, max effective voltage seen by stepper + #define X_CHAIN_POS 0 // position in SPI chain, 0 - not in chain, 1- nearest MOSI - #define X2_MICROSTEPS 16 + #define X2_MICROSTEPS 128 #define X2_OVERCURRENT 2000 #define X2_STALLCURRENT 1500 + #define X2_MAX_VOLTAGE 127 + #define X2_CHAIN_POS 0 - #define Y_MICROSTEPS 16 + #define Y_MICROSTEPS 128 #define Y_OVERCURRENT 2000 #define Y_STALLCURRENT 1500 + #define Y_MAX_VOLTAGE 127 + #define Y_CHAIN_POS 0 - #define Y2_MICROSTEPS 16 + #define Y2_MICROSTEPS 128 #define Y2_OVERCURRENT 2000 #define Y2_STALLCURRENT 1500 + #define Y2_MAX_VOLTAGE 127 + #define Y2_CHAIN_POS 0 - #define Z_MICROSTEPS 16 + #define Z_MICROSTEPS 128 #define Z_OVERCURRENT 2000 #define Z_STALLCURRENT 1500 + #define Z_MAX_VOLTAGE 127 + #define Z_CHAIN_POS 0 - #define Z2_MICROSTEPS 16 + #define Z2_MICROSTEPS 128 #define Z2_OVERCURRENT 2000 #define Z2_STALLCURRENT 1500 + #define Z2_MAX_VOLTAGE 127 + #define Z2_CHAIN_POS 0 - #define Z3_MICROSTEPS 16 + #define Z3_MICROSTEPS 128 #define Z3_OVERCURRENT 2000 #define Z3_STALLCURRENT 1500 + #define Z3_MAX_VOLTAGE 127 + #define Z3_CHAIN_POS 0 - #define E0_MICROSTEPS 16 + #define E0_MICROSTEPS 128 #define E0_OVERCURRENT 2000 #define E0_STALLCURRENT 1500 + #define E0_MAX_VOLTAGE 127 + #define E0_CHAIN_POS 0 - #define E1_MICROSTEPS 16 + #define E1_MICROSTEPS 128 #define E1_OVERCURRENT 2000 #define E1_STALLCURRENT 1500 + #define E1_MAX_VOLTAGE 127 + #define E1_CHAIN_POS 0 - #define E2_MICROSTEPS 16 + #define E2_MICROSTEPS 128 #define E2_OVERCURRENT 2000 #define E2_STALLCURRENT 1500 + #define E2_MAX_VOLTAGE 127 + #define E2_CHAIN_POS 0 - #define E3_MICROSTEPS 16 + #define E3_MICROSTEPS 128 #define E3_OVERCURRENT 2000 #define E3_STALLCURRENT 1500 + #define E3_MAX_VOLTAGE 127 + #define E3_CHAIN_POS 0 - #define E4_MICROSTEPS 16 + #define E4_MICROSTEPS 128 #define E4_OVERCURRENT 2000 #define E4_STALLCURRENT 1500 + #define E4_MAX_VOLTAGE 127 + #define E4_CHAIN_POS 0 - #define E5_MICROSTEPS 16 + #define E5_MICROSTEPS 128 #define E5_OVERCURRENT 2000 #define E5_STALLCURRENT 1500 + #define E5_MAX_VOLTAGE 127 + #define E5_CHAIN_POS 0 + + + /** + * Monitor L6470 drivers for error conditions like over temperature and over current. + * In the case of over temperature Marlin can decrease the drive until the error condition clears. + * Other detected conditions can be used to stop the current print. + * Relevant g-codes: + * M906 - I1/2/3/4/5 Set or get motor drive level using axis codes X, Y, Z, E. Report values if no axis codes given. + * I not present or I0 or I1 - X, Y, Z or E0 + * I2 - X2, Y2, Z2 or E1 + * I3 - Z3 or E3 + * I4 - E4 + * I5 - E5 + * M916 - Increase drive level until get thermal warning + * M917 - Find minimum current thresholds + * M918 - Increase speed until max or error + * M122 S0/1 - Report driver parameters + */ + //#define MONITOR_L6470_DRIVER_STATUS + + #if ENABLED(MONITOR_L6470_DRIVER_STATUS) + #define KVAL_HOLD_STEP_DOWN 1 + //#define L6470_STOP_ON_ERROR + #endif + + #define L6470_CHITCHAT // enable display of additional status info #endif // L6470 diff --git a/Marlin/src/config/examples/Mks/Robin/Configuration_adv.h b/Marlin/src/config/examples/Mks/Robin/Configuration_adv.h index d002babfa..30b8a66fa 100644 --- a/Marlin/src/config/examples/Mks/Robin/Configuration_adv.h +++ b/Marlin/src/config/examples/Mks/Robin/Configuration_adv.h @@ -1509,62 +1509,121 @@ /** * L6470 Stepper Driver options * - * The Arduino-L6470 library is required for this stepper driver. + * Arduino-L6470 library (0.7.0 or higher) is required for this stepper driver. * https://github.com/ameyer/Arduino-L6470 + * + * Requires the following to be defined in your pins_YOUR_BOARD file + * L6470_CHAIN_SCK_PIN + * L6470_CHAIN_MISO_PIN + * L6470_CHAIN_MOSI_PIN + * L6470_CHAIN_SS_PIN + * L6470_RESET_CHAIN_PIN (optional) */ #if HAS_DRIVER(L6470) - #define X_MICROSTEPS 16 // number of microsteps - #define X_OVERCURRENT 2000 // maxc current in mA. If the current goes over this value, the driver will switch off - #define X_STALLCURRENT 1500 // current in mA where the driver will detect a stall + #define X_MICROSTEPS 128 // number of microsteps (VALID: 1, 2, 4, 8, 16, 32, 128 & 128) + #define X_OVERCURRENT 2000 // current in mA where the driver will detect an over current (VALID: 375 x (1 - 16) - 6A max - rounds down) + #define X_STALLCURRENT 1500 // current in mA where the driver will detect a stall (VALID: 31.25 * (1-128) - 4A max - rounds down) + #define X_MAX_VOLTAGE 127 // 0-255, max effective voltage seen by stepper + #define X_CHAIN_POS 0 // position in SPI chain, 0 - not in chain, 1- nearest MOSI - #define X2_MICROSTEPS 16 + #define X2_MICROSTEPS 128 #define X2_OVERCURRENT 2000 #define X2_STALLCURRENT 1500 + #define X2_MAX_VOLTAGE 127 + #define X2_CHAIN_POS 0 - #define Y_MICROSTEPS 16 + #define Y_MICROSTEPS 128 #define Y_OVERCURRENT 2000 #define Y_STALLCURRENT 1500 + #define Y_MAX_VOLTAGE 127 + #define Y_CHAIN_POS 0 - #define Y2_MICROSTEPS 16 + #define Y2_MICROSTEPS 128 #define Y2_OVERCURRENT 2000 #define Y2_STALLCURRENT 1500 + #define Y2_MAX_VOLTAGE 127 + #define Y2_CHAIN_POS 0 - #define Z_MICROSTEPS 16 + #define Z_MICROSTEPS 128 #define Z_OVERCURRENT 2000 #define Z_STALLCURRENT 1500 + #define Z_MAX_VOLTAGE 127 + #define Z_CHAIN_POS 0 - #define Z2_MICROSTEPS 16 + #define Z2_MICROSTEPS 128 #define Z2_OVERCURRENT 2000 #define Z2_STALLCURRENT 1500 + #define Z2_MAX_VOLTAGE 127 + #define Z2_CHAIN_POS 0 - #define Z3_MICROSTEPS 16 + #define Z3_MICROSTEPS 128 #define Z3_OVERCURRENT 2000 #define Z3_STALLCURRENT 1500 + #define Z3_MAX_VOLTAGE 127 + #define Z3_CHAIN_POS 0 - #define E0_MICROSTEPS 16 + #define E0_MICROSTEPS 128 #define E0_OVERCURRENT 2000 #define E0_STALLCURRENT 1500 + #define E0_MAX_VOLTAGE 127 + #define E0_CHAIN_POS 0 - #define E1_MICROSTEPS 16 + #define E1_MICROSTEPS 128 #define E1_OVERCURRENT 2000 #define E1_STALLCURRENT 1500 + #define E1_MAX_VOLTAGE 127 + #define E1_CHAIN_POS 0 - #define E2_MICROSTEPS 16 + #define E2_MICROSTEPS 128 #define E2_OVERCURRENT 2000 #define E2_STALLCURRENT 1500 + #define E2_MAX_VOLTAGE 127 + #define E2_CHAIN_POS 0 - #define E3_MICROSTEPS 16 + #define E3_MICROSTEPS 128 #define E3_OVERCURRENT 2000 #define E3_STALLCURRENT 1500 + #define E3_MAX_VOLTAGE 127 + #define E3_CHAIN_POS 0 - #define E4_MICROSTEPS 16 + #define E4_MICROSTEPS 128 #define E4_OVERCURRENT 2000 #define E4_STALLCURRENT 1500 + #define E4_MAX_VOLTAGE 127 + #define E4_CHAIN_POS 0 - #define E5_MICROSTEPS 16 + #define E5_MICROSTEPS 128 #define E5_OVERCURRENT 2000 #define E5_STALLCURRENT 1500 + #define E5_MAX_VOLTAGE 127 + #define E5_CHAIN_POS 0 + + + /** + * Monitor L6470 drivers for error conditions like over temperature and over current. + * In the case of over temperature Marlin can decrease the drive until the error condition clears. + * Other detected conditions can be used to stop the current print. + * Relevant g-codes: + * M906 - I1/2/3/4/5 Set or get motor drive level using axis codes X, Y, Z, E. Report values if no axis codes given. + * I not present or I0 or I1 - X, Y, Z or E0 + * I2 - X2, Y2, Z2 or E1 + * I3 - Z3 or E3 + * I4 - E4 + * I5 - E5 + * M916 - Increase drive level until get thermal warning + * M917 - Find minimum current thresholds + * M918 - Increase speed until max or error + * M122 S0/1 - Report driver parameters + */ + //#define MONITOR_L6470_DRIVER_STATUS + + #if ENABLED(MONITOR_L6470_DRIVER_STATUS) + #define KVAL_HOLD_STEP_DOWN 1 + //#define L6470_STOP_ON_ERROR + #endif + + #define L6470_CHITCHAT // enable display of additional status info #endif // L6470 diff --git a/Marlin/src/config/examples/Mks/Sbase/Configuration_adv.h b/Marlin/src/config/examples/Mks/Sbase/Configuration_adv.h index 807e71ee1..cdcebda72 100644 --- a/Marlin/src/config/examples/Mks/Sbase/Configuration_adv.h +++ b/Marlin/src/config/examples/Mks/Sbase/Configuration_adv.h @@ -1516,62 +1516,121 @@ /** * L6470 Stepper Driver options * - * The Arduino-L6470 library is required for this stepper driver. + * Arduino-L6470 library (0.7.0 or higher) is required for this stepper driver. * https://github.com/ameyer/Arduino-L6470 + * + * Requires the following to be defined in your pins_YOUR_BOARD file + * L6470_CHAIN_SCK_PIN + * L6470_CHAIN_MISO_PIN + * L6470_CHAIN_MOSI_PIN + * L6470_CHAIN_SS_PIN + * L6470_RESET_CHAIN_PIN (optional) */ #if HAS_DRIVER(L6470) - #define X_MICROSTEPS 16 // number of microsteps - #define X_OVERCURRENT 2000 // maxc current in mA. If the current goes over this value, the driver will switch off - #define X_STALLCURRENT 1500 // current in mA where the driver will detect a stall + #define X_MICROSTEPS 128 // number of microsteps (VALID: 1, 2, 4, 8, 16, 32, 128 & 128) + #define X_OVERCURRENT 2000 // current in mA where the driver will detect an over current (VALID: 375 x (1 - 16) - 6A max - rounds down) + #define X_STALLCURRENT 1500 // current in mA where the driver will detect a stall (VALID: 31.25 * (1-128) - 4A max - rounds down) + #define X_MAX_VOLTAGE 127 // 0-255, max effective voltage seen by stepper + #define X_CHAIN_POS 0 // position in SPI chain, 0 - not in chain, 1- nearest MOSI - #define X2_MICROSTEPS 16 + #define X2_MICROSTEPS 128 #define X2_OVERCURRENT 2000 #define X2_STALLCURRENT 1500 + #define X2_MAX_VOLTAGE 127 + #define X2_CHAIN_POS 0 - #define Y_MICROSTEPS 16 + #define Y_MICROSTEPS 128 #define Y_OVERCURRENT 2000 #define Y_STALLCURRENT 1500 + #define Y_MAX_VOLTAGE 127 + #define Y_CHAIN_POS 0 - #define Y2_MICROSTEPS 16 + #define Y2_MICROSTEPS 128 #define Y2_OVERCURRENT 2000 #define Y2_STALLCURRENT 1500 + #define Y2_MAX_VOLTAGE 127 + #define Y2_CHAIN_POS 0 - #define Z_MICROSTEPS 16 + #define Z_MICROSTEPS 128 #define Z_OVERCURRENT 2000 #define Z_STALLCURRENT 1500 + #define Z_MAX_VOLTAGE 127 + #define Z_CHAIN_POS 0 - #define Z2_MICROSTEPS 16 + #define Z2_MICROSTEPS 128 #define Z2_OVERCURRENT 2000 #define Z2_STALLCURRENT 1500 + #define Z2_MAX_VOLTAGE 127 + #define Z2_CHAIN_POS 0 - #define Z3_MICROSTEPS 16 + #define Z3_MICROSTEPS 128 #define Z3_OVERCURRENT 2000 #define Z3_STALLCURRENT 1500 + #define Z3_MAX_VOLTAGE 127 + #define Z3_CHAIN_POS 0 - #define E0_MICROSTEPS 16 + #define E0_MICROSTEPS 128 #define E0_OVERCURRENT 2000 #define E0_STALLCURRENT 1500 + #define E0_MAX_VOLTAGE 127 + #define E0_CHAIN_POS 0 - #define E1_MICROSTEPS 16 + #define E1_MICROSTEPS 128 #define E1_OVERCURRENT 2000 #define E1_STALLCURRENT 1500 + #define E1_MAX_VOLTAGE 127 + #define E1_CHAIN_POS 0 - #define E2_MICROSTEPS 16 + #define E2_MICROSTEPS 128 #define E2_OVERCURRENT 2000 #define E2_STALLCURRENT 1500 + #define E2_MAX_VOLTAGE 127 + #define E2_CHAIN_POS 0 - #define E3_MICROSTEPS 16 + #define E3_MICROSTEPS 128 #define E3_OVERCURRENT 2000 #define E3_STALLCURRENT 1500 + #define E3_MAX_VOLTAGE 127 + #define E3_CHAIN_POS 0 - #define E4_MICROSTEPS 16 + #define E4_MICROSTEPS 128 #define E4_OVERCURRENT 2000 #define E4_STALLCURRENT 1500 + #define E4_MAX_VOLTAGE 127 + #define E4_CHAIN_POS 0 - #define E5_MICROSTEPS 16 + #define E5_MICROSTEPS 128 #define E5_OVERCURRENT 2000 #define E5_STALLCURRENT 1500 + #define E5_MAX_VOLTAGE 127 + #define E5_CHAIN_POS 0 + + + /** + * Monitor L6470 drivers for error conditions like over temperature and over current. + * In the case of over temperature Marlin can decrease the drive until the error condition clears. + * Other detected conditions can be used to stop the current print. + * Relevant g-codes: + * M906 - I1/2/3/4/5 Set or get motor drive level using axis codes X, Y, Z, E. Report values if no axis codes given. + * I not present or I0 or I1 - X, Y, Z or E0 + * I2 - X2, Y2, Z2 or E1 + * I3 - Z3 or E3 + * I4 - E4 + * I5 - E5 + * M916 - Increase drive level until get thermal warning + * M917 - Find minimum current thresholds + * M918 - Increase speed until max or error + * M122 S0/1 - Report driver parameters + */ + //#define MONITOR_L6470_DRIVER_STATUS + + #if ENABLED(MONITOR_L6470_DRIVER_STATUS) + #define KVAL_HOLD_STEP_DOWN 1 + //#define L6470_STOP_ON_ERROR + #endif + + #define L6470_CHITCHAT // enable display of additional status info #endif // L6470 diff --git a/Marlin/src/config/examples/RapideLite/RL200/Configuration_adv.h b/Marlin/src/config/examples/RapideLite/RL200/Configuration_adv.h index a14004c86..b1a162450 100644 --- a/Marlin/src/config/examples/RapideLite/RL200/Configuration_adv.h +++ b/Marlin/src/config/examples/RapideLite/RL200/Configuration_adv.h @@ -1509,62 +1509,121 @@ /** * L6470 Stepper Driver options * - * The Arduino-L6470 library is required for this stepper driver. + * Arduino-L6470 library (0.7.0 or higher) is required for this stepper driver. * https://github.com/ameyer/Arduino-L6470 + * + * Requires the following to be defined in your pins_YOUR_BOARD file + * L6470_CHAIN_SCK_PIN + * L6470_CHAIN_MISO_PIN + * L6470_CHAIN_MOSI_PIN + * L6470_CHAIN_SS_PIN + * L6470_RESET_CHAIN_PIN (optional) */ #if HAS_DRIVER(L6470) - #define X_MICROSTEPS 16 // number of microsteps - #define X_OVERCURRENT 2000 // maxc current in mA. If the current goes over this value, the driver will switch off - #define X_STALLCURRENT 1500 // current in mA where the driver will detect a stall + #define X_MICROSTEPS 128 // number of microsteps (VALID: 1, 2, 4, 8, 16, 32, 128 & 128) + #define X_OVERCURRENT 2000 // current in mA where the driver will detect an over current (VALID: 375 x (1 - 16) - 6A max - rounds down) + #define X_STALLCURRENT 1500 // current in mA where the driver will detect a stall (VALID: 31.25 * (1-128) - 4A max - rounds down) + #define X_MAX_VOLTAGE 127 // 0-255, max effective voltage seen by stepper + #define X_CHAIN_POS 0 // position in SPI chain, 0 - not in chain, 1- nearest MOSI - #define X2_MICROSTEPS 16 + #define X2_MICROSTEPS 128 #define X2_OVERCURRENT 2000 #define X2_STALLCURRENT 1500 + #define X2_MAX_VOLTAGE 127 + #define X2_CHAIN_POS 0 - #define Y_MICROSTEPS 16 + #define Y_MICROSTEPS 128 #define Y_OVERCURRENT 2000 #define Y_STALLCURRENT 1500 + #define Y_MAX_VOLTAGE 127 + #define Y_CHAIN_POS 0 - #define Y2_MICROSTEPS 16 + #define Y2_MICROSTEPS 128 #define Y2_OVERCURRENT 2000 #define Y2_STALLCURRENT 1500 + #define Y2_MAX_VOLTAGE 127 + #define Y2_CHAIN_POS 0 - #define Z_MICROSTEPS 16 + #define Z_MICROSTEPS 128 #define Z_OVERCURRENT 2000 #define Z_STALLCURRENT 1500 + #define Z_MAX_VOLTAGE 127 + #define Z_CHAIN_POS 0 - #define Z2_MICROSTEPS 16 + #define Z2_MICROSTEPS 128 #define Z2_OVERCURRENT 2000 #define Z2_STALLCURRENT 1500 + #define Z2_MAX_VOLTAGE 127 + #define Z2_CHAIN_POS 0 - #define Z3_MICROSTEPS 16 + #define Z3_MICROSTEPS 128 #define Z3_OVERCURRENT 2000 #define Z3_STALLCURRENT 1500 + #define Z3_MAX_VOLTAGE 127 + #define Z3_CHAIN_POS 0 - #define E0_MICROSTEPS 16 + #define E0_MICROSTEPS 128 #define E0_OVERCURRENT 2000 #define E0_STALLCURRENT 1500 + #define E0_MAX_VOLTAGE 127 + #define E0_CHAIN_POS 0 - #define E1_MICROSTEPS 16 + #define E1_MICROSTEPS 128 #define E1_OVERCURRENT 2000 #define E1_STALLCURRENT 1500 + #define E1_MAX_VOLTAGE 127 + #define E1_CHAIN_POS 0 - #define E2_MICROSTEPS 16 + #define E2_MICROSTEPS 128 #define E2_OVERCURRENT 2000 #define E2_STALLCURRENT 1500 + #define E2_MAX_VOLTAGE 127 + #define E2_CHAIN_POS 0 - #define E3_MICROSTEPS 16 + #define E3_MICROSTEPS 128 #define E3_OVERCURRENT 2000 #define E3_STALLCURRENT 1500 + #define E3_MAX_VOLTAGE 127 + #define E3_CHAIN_POS 0 - #define E4_MICROSTEPS 16 + #define E4_MICROSTEPS 128 #define E4_OVERCURRENT 2000 #define E4_STALLCURRENT 1500 + #define E4_MAX_VOLTAGE 127 + #define E4_CHAIN_POS 0 - #define E5_MICROSTEPS 16 + #define E5_MICROSTEPS 128 #define E5_OVERCURRENT 2000 #define E5_STALLCURRENT 1500 + #define E5_MAX_VOLTAGE 127 + #define E5_CHAIN_POS 0 + + + /** + * Monitor L6470 drivers for error conditions like over temperature and over current. + * In the case of over temperature Marlin can decrease the drive until the error condition clears. + * Other detected conditions can be used to stop the current print. + * Relevant g-codes: + * M906 - I1/2/3/4/5 Set or get motor drive level using axis codes X, Y, Z, E. Report values if no axis codes given. + * I not present or I0 or I1 - X, Y, Z or E0 + * I2 - X2, Y2, Z2 or E1 + * I3 - Z3 or E3 + * I4 - E4 + * I5 - E5 + * M916 - Increase drive level until get thermal warning + * M917 - Find minimum current thresholds + * M918 - Increase speed until max or error + * M122 S0/1 - Report driver parameters + */ + //#define MONITOR_L6470_DRIVER_STATUS + + #if ENABLED(MONITOR_L6470_DRIVER_STATUS) + #define KVAL_HOLD_STEP_DOWN 1 + //#define L6470_STOP_ON_ERROR + #endif + + #define L6470_CHITCHAT // enable display of additional status info #endif // L6470 diff --git a/Marlin/src/config/examples/RigidBot/Configuration_adv.h b/Marlin/src/config/examples/RigidBot/Configuration_adv.h index 2ff106928..9f032c730 100644 --- a/Marlin/src/config/examples/RigidBot/Configuration_adv.h +++ b/Marlin/src/config/examples/RigidBot/Configuration_adv.h @@ -1508,62 +1508,121 @@ /** * L6470 Stepper Driver options * - * The Arduino-L6470 library is required for this stepper driver. + * Arduino-L6470 library (0.7.0 or higher) is required for this stepper driver. * https://github.com/ameyer/Arduino-L6470 + * + * Requires the following to be defined in your pins_YOUR_BOARD file + * L6470_CHAIN_SCK_PIN + * L6470_CHAIN_MISO_PIN + * L6470_CHAIN_MOSI_PIN + * L6470_CHAIN_SS_PIN + * L6470_RESET_CHAIN_PIN (optional) */ #if HAS_DRIVER(L6470) - #define X_MICROSTEPS 16 // number of microsteps - #define X_OVERCURRENT 2000 // maxc current in mA. If the current goes over this value, the driver will switch off - #define X_STALLCURRENT 1500 // current in mA where the driver will detect a stall + #define X_MICROSTEPS 128 // number of microsteps (VALID: 1, 2, 4, 8, 16, 32, 128 & 128) + #define X_OVERCURRENT 2000 // current in mA where the driver will detect an over current (VALID: 375 x (1 - 16) - 6A max - rounds down) + #define X_STALLCURRENT 1500 // current in mA where the driver will detect a stall (VALID: 31.25 * (1-128) - 4A max - rounds down) + #define X_MAX_VOLTAGE 127 // 0-255, max effective voltage seen by stepper + #define X_CHAIN_POS 0 // position in SPI chain, 0 - not in chain, 1- nearest MOSI - #define X2_MICROSTEPS 16 + #define X2_MICROSTEPS 128 #define X2_OVERCURRENT 2000 #define X2_STALLCURRENT 1500 + #define X2_MAX_VOLTAGE 127 + #define X2_CHAIN_POS 0 - #define Y_MICROSTEPS 16 + #define Y_MICROSTEPS 128 #define Y_OVERCURRENT 2000 #define Y_STALLCURRENT 1500 + #define Y_MAX_VOLTAGE 127 + #define Y_CHAIN_POS 0 - #define Y2_MICROSTEPS 16 + #define Y2_MICROSTEPS 128 #define Y2_OVERCURRENT 2000 #define Y2_STALLCURRENT 1500 + #define Y2_MAX_VOLTAGE 127 + #define Y2_CHAIN_POS 0 - #define Z_MICROSTEPS 16 + #define Z_MICROSTEPS 128 #define Z_OVERCURRENT 2000 #define Z_STALLCURRENT 1500 + #define Z_MAX_VOLTAGE 127 + #define Z_CHAIN_POS 0 - #define Z2_MICROSTEPS 16 + #define Z2_MICROSTEPS 128 #define Z2_OVERCURRENT 2000 #define Z2_STALLCURRENT 1500 + #define Z2_MAX_VOLTAGE 127 + #define Z2_CHAIN_POS 0 - #define Z3_MICROSTEPS 16 + #define Z3_MICROSTEPS 128 #define Z3_OVERCURRENT 2000 #define Z3_STALLCURRENT 1500 + #define Z3_MAX_VOLTAGE 127 + #define Z3_CHAIN_POS 0 - #define E0_MICROSTEPS 16 + #define E0_MICROSTEPS 128 #define E0_OVERCURRENT 2000 #define E0_STALLCURRENT 1500 + #define E0_MAX_VOLTAGE 127 + #define E0_CHAIN_POS 0 - #define E1_MICROSTEPS 16 + #define E1_MICROSTEPS 128 #define E1_OVERCURRENT 2000 #define E1_STALLCURRENT 1500 + #define E1_MAX_VOLTAGE 127 + #define E1_CHAIN_POS 0 - #define E2_MICROSTEPS 16 + #define E2_MICROSTEPS 128 #define E2_OVERCURRENT 2000 #define E2_STALLCURRENT 1500 + #define E2_MAX_VOLTAGE 127 + #define E2_CHAIN_POS 0 - #define E3_MICROSTEPS 16 + #define E3_MICROSTEPS 128 #define E3_OVERCURRENT 2000 #define E3_STALLCURRENT 1500 + #define E3_MAX_VOLTAGE 127 + #define E3_CHAIN_POS 0 - #define E4_MICROSTEPS 16 + #define E4_MICROSTEPS 128 #define E4_OVERCURRENT 2000 #define E4_STALLCURRENT 1500 + #define E4_MAX_VOLTAGE 127 + #define E4_CHAIN_POS 0 - #define E5_MICROSTEPS 16 + #define E5_MICROSTEPS 128 #define E5_OVERCURRENT 2000 #define E5_STALLCURRENT 1500 + #define E5_MAX_VOLTAGE 127 + #define E5_CHAIN_POS 0 + + + /** + * Monitor L6470 drivers for error conditions like over temperature and over current. + * In the case of over temperature Marlin can decrease the drive until the error condition clears. + * Other detected conditions can be used to stop the current print. + * Relevant g-codes: + * M906 - I1/2/3/4/5 Set or get motor drive level using axis codes X, Y, Z, E. Report values if no axis codes given. + * I not present or I0 or I1 - X, Y, Z or E0 + * I2 - X2, Y2, Z2 or E1 + * I3 - Z3 or E3 + * I4 - E4 + * I5 - E5 + * M916 - Increase drive level until get thermal warning + * M917 - Find minimum current thresholds + * M918 - Increase speed until max or error + * M122 S0/1 - Report driver parameters + */ + //#define MONITOR_L6470_DRIVER_STATUS + + #if ENABLED(MONITOR_L6470_DRIVER_STATUS) + #define KVAL_HOLD_STEP_DOWN 1 + //#define L6470_STOP_ON_ERROR + #endif + + #define L6470_CHITCHAT // enable display of additional status info #endif // L6470 diff --git a/Marlin/src/config/examples/SCARA/Configuration_adv.h b/Marlin/src/config/examples/SCARA/Configuration_adv.h index 7cfab9dc6..0660a7978 100644 --- a/Marlin/src/config/examples/SCARA/Configuration_adv.h +++ b/Marlin/src/config/examples/SCARA/Configuration_adv.h @@ -1508,62 +1508,121 @@ /** * L6470 Stepper Driver options * - * The Arduino-L6470 library is required for this stepper driver. + * Arduino-L6470 library (0.7.0 or higher) is required for this stepper driver. * https://github.com/ameyer/Arduino-L6470 + * + * Requires the following to be defined in your pins_YOUR_BOARD file + * L6470_CHAIN_SCK_PIN + * L6470_CHAIN_MISO_PIN + * L6470_CHAIN_MOSI_PIN + * L6470_CHAIN_SS_PIN + * L6470_RESET_CHAIN_PIN (optional) */ #if HAS_DRIVER(L6470) - #define X_MICROSTEPS 16 // number of microsteps - #define X_OVERCURRENT 2000 // maxc current in mA. If the current goes over this value, the driver will switch off - #define X_STALLCURRENT 1500 // current in mA where the driver will detect a stall + #define X_MICROSTEPS 128 // number of microsteps (VALID: 1, 2, 4, 8, 16, 32, 128 & 128) + #define X_OVERCURRENT 2000 // current in mA where the driver will detect an over current (VALID: 375 x (1 - 16) - 6A max - rounds down) + #define X_STALLCURRENT 1500 // current in mA where the driver will detect a stall (VALID: 31.25 * (1-128) - 4A max - rounds down) + #define X_MAX_VOLTAGE 127 // 0-255, max effective voltage seen by stepper + #define X_CHAIN_POS 0 // position in SPI chain, 0 - not in chain, 1- nearest MOSI - #define X2_MICROSTEPS 16 + #define X2_MICROSTEPS 128 #define X2_OVERCURRENT 2000 #define X2_STALLCURRENT 1500 + #define X2_MAX_VOLTAGE 127 + #define X2_CHAIN_POS 0 - #define Y_MICROSTEPS 16 + #define Y_MICROSTEPS 128 #define Y_OVERCURRENT 2000 #define Y_STALLCURRENT 1500 + #define Y_MAX_VOLTAGE 127 + #define Y_CHAIN_POS 0 - #define Y2_MICROSTEPS 16 + #define Y2_MICROSTEPS 128 #define Y2_OVERCURRENT 2000 #define Y2_STALLCURRENT 1500 + #define Y2_MAX_VOLTAGE 127 + #define Y2_CHAIN_POS 0 - #define Z_MICROSTEPS 16 + #define Z_MICROSTEPS 128 #define Z_OVERCURRENT 2000 #define Z_STALLCURRENT 1500 + #define Z_MAX_VOLTAGE 127 + #define Z_CHAIN_POS 0 - #define Z2_MICROSTEPS 16 + #define Z2_MICROSTEPS 128 #define Z2_OVERCURRENT 2000 #define Z2_STALLCURRENT 1500 + #define Z2_MAX_VOLTAGE 127 + #define Z2_CHAIN_POS 0 - #define Z3_MICROSTEPS 16 + #define Z3_MICROSTEPS 128 #define Z3_OVERCURRENT 2000 #define Z3_STALLCURRENT 1500 + #define Z3_MAX_VOLTAGE 127 + #define Z3_CHAIN_POS 0 - #define E0_MICROSTEPS 16 + #define E0_MICROSTEPS 128 #define E0_OVERCURRENT 2000 #define E0_STALLCURRENT 1500 + #define E0_MAX_VOLTAGE 127 + #define E0_CHAIN_POS 0 - #define E1_MICROSTEPS 16 + #define E1_MICROSTEPS 128 #define E1_OVERCURRENT 2000 #define E1_STALLCURRENT 1500 + #define E1_MAX_VOLTAGE 127 + #define E1_CHAIN_POS 0 - #define E2_MICROSTEPS 16 + #define E2_MICROSTEPS 128 #define E2_OVERCURRENT 2000 #define E2_STALLCURRENT 1500 + #define E2_MAX_VOLTAGE 127 + #define E2_CHAIN_POS 0 - #define E3_MICROSTEPS 16 + #define E3_MICROSTEPS 128 #define E3_OVERCURRENT 2000 #define E3_STALLCURRENT 1500 + #define E3_MAX_VOLTAGE 127 + #define E3_CHAIN_POS 0 - #define E4_MICROSTEPS 16 + #define E4_MICROSTEPS 128 #define E4_OVERCURRENT 2000 #define E4_STALLCURRENT 1500 + #define E4_MAX_VOLTAGE 127 + #define E4_CHAIN_POS 0 - #define E5_MICROSTEPS 16 + #define E5_MICROSTEPS 128 #define E5_OVERCURRENT 2000 #define E5_STALLCURRENT 1500 + #define E5_MAX_VOLTAGE 127 + #define E5_CHAIN_POS 0 + + + /** + * Monitor L6470 drivers for error conditions like over temperature and over current. + * In the case of over temperature Marlin can decrease the drive until the error condition clears. + * Other detected conditions can be used to stop the current print. + * Relevant g-codes: + * M906 - I1/2/3/4/5 Set or get motor drive level using axis codes X, Y, Z, E. Report values if no axis codes given. + * I not present or I0 or I1 - X, Y, Z or E0 + * I2 - X2, Y2, Z2 or E1 + * I3 - Z3 or E3 + * I4 - E4 + * I5 - E5 + * M916 - Increase drive level until get thermal warning + * M917 - Find minimum current thresholds + * M918 - Increase speed until max or error + * M122 S0/1 - Report driver parameters + */ + //#define MONITOR_L6470_DRIVER_STATUS + + #if ENABLED(MONITOR_L6470_DRIVER_STATUS) + #define KVAL_HOLD_STEP_DOWN 1 + //#define L6470_STOP_ON_ERROR + #endif + + #define L6470_CHITCHAT // enable display of additional status info #endif // L6470 diff --git a/Marlin/src/config/examples/Sanguinololu/Configuration_adv.h b/Marlin/src/config/examples/Sanguinololu/Configuration_adv.h index 70f00a3d3..fcad89b2b 100644 --- a/Marlin/src/config/examples/Sanguinololu/Configuration_adv.h +++ b/Marlin/src/config/examples/Sanguinololu/Configuration_adv.h @@ -1508,62 +1508,121 @@ /** * L6470 Stepper Driver options * - * The Arduino-L6470 library is required for this stepper driver. + * Arduino-L6470 library (0.7.0 or higher) is required for this stepper driver. * https://github.com/ameyer/Arduino-L6470 + * + * Requires the following to be defined in your pins_YOUR_BOARD file + * L6470_CHAIN_SCK_PIN + * L6470_CHAIN_MISO_PIN + * L6470_CHAIN_MOSI_PIN + * L6470_CHAIN_SS_PIN + * L6470_RESET_CHAIN_PIN (optional) */ #if HAS_DRIVER(L6470) - #define X_MICROSTEPS 16 // number of microsteps - #define X_OVERCURRENT 2000 // maxc current in mA. If the current goes over this value, the driver will switch off - #define X_STALLCURRENT 1500 // current in mA where the driver will detect a stall + #define X_MICROSTEPS 128 // number of microsteps (VALID: 1, 2, 4, 8, 16, 32, 128 & 128) + #define X_OVERCURRENT 2000 // current in mA where the driver will detect an over current (VALID: 375 x (1 - 16) - 6A max - rounds down) + #define X_STALLCURRENT 1500 // current in mA where the driver will detect a stall (VALID: 31.25 * (1-128) - 4A max - rounds down) + #define X_MAX_VOLTAGE 127 // 0-255, max effective voltage seen by stepper + #define X_CHAIN_POS 0 // position in SPI chain, 0 - not in chain, 1- nearest MOSI - #define X2_MICROSTEPS 16 + #define X2_MICROSTEPS 128 #define X2_OVERCURRENT 2000 #define X2_STALLCURRENT 1500 + #define X2_MAX_VOLTAGE 127 + #define X2_CHAIN_POS 0 - #define Y_MICROSTEPS 16 + #define Y_MICROSTEPS 128 #define Y_OVERCURRENT 2000 #define Y_STALLCURRENT 1500 + #define Y_MAX_VOLTAGE 127 + #define Y_CHAIN_POS 0 - #define Y2_MICROSTEPS 16 + #define Y2_MICROSTEPS 128 #define Y2_OVERCURRENT 2000 #define Y2_STALLCURRENT 1500 + #define Y2_MAX_VOLTAGE 127 + #define Y2_CHAIN_POS 0 - #define Z_MICROSTEPS 16 + #define Z_MICROSTEPS 128 #define Z_OVERCURRENT 2000 #define Z_STALLCURRENT 1500 + #define Z_MAX_VOLTAGE 127 + #define Z_CHAIN_POS 0 - #define Z2_MICROSTEPS 16 + #define Z2_MICROSTEPS 128 #define Z2_OVERCURRENT 2000 #define Z2_STALLCURRENT 1500 + #define Z2_MAX_VOLTAGE 127 + #define Z2_CHAIN_POS 0 - #define Z3_MICROSTEPS 16 + #define Z3_MICROSTEPS 128 #define Z3_OVERCURRENT 2000 #define Z3_STALLCURRENT 1500 + #define Z3_MAX_VOLTAGE 127 + #define Z3_CHAIN_POS 0 - #define E0_MICROSTEPS 16 + #define E0_MICROSTEPS 128 #define E0_OVERCURRENT 2000 #define E0_STALLCURRENT 1500 + #define E0_MAX_VOLTAGE 127 + #define E0_CHAIN_POS 0 - #define E1_MICROSTEPS 16 + #define E1_MICROSTEPS 128 #define E1_OVERCURRENT 2000 #define E1_STALLCURRENT 1500 + #define E1_MAX_VOLTAGE 127 + #define E1_CHAIN_POS 0 - #define E2_MICROSTEPS 16 + #define E2_MICROSTEPS 128 #define E2_OVERCURRENT 2000 #define E2_STALLCURRENT 1500 + #define E2_MAX_VOLTAGE 127 + #define E2_CHAIN_POS 0 - #define E3_MICROSTEPS 16 + #define E3_MICROSTEPS 128 #define E3_OVERCURRENT 2000 #define E3_STALLCURRENT 1500 + #define E3_MAX_VOLTAGE 127 + #define E3_CHAIN_POS 0 - #define E4_MICROSTEPS 16 + #define E4_MICROSTEPS 128 #define E4_OVERCURRENT 2000 #define E4_STALLCURRENT 1500 + #define E4_MAX_VOLTAGE 127 + #define E4_CHAIN_POS 0 - #define E5_MICROSTEPS 16 + #define E5_MICROSTEPS 128 #define E5_OVERCURRENT 2000 #define E5_STALLCURRENT 1500 + #define E5_MAX_VOLTAGE 127 + #define E5_CHAIN_POS 0 + + + /** + * Monitor L6470 drivers for error conditions like over temperature and over current. + * In the case of over temperature Marlin can decrease the drive until the error condition clears. + * Other detected conditions can be used to stop the current print. + * Relevant g-codes: + * M906 - I1/2/3/4/5 Set or get motor drive level using axis codes X, Y, Z, E. Report values if no axis codes given. + * I not present or I0 or I1 - X, Y, Z or E0 + * I2 - X2, Y2, Z2 or E1 + * I3 - Z3 or E3 + * I4 - E4 + * I5 - E5 + * M916 - Increase drive level until get thermal warning + * M917 - Find minimum current thresholds + * M918 - Increase speed until max or error + * M122 S0/1 - Report driver parameters + */ + //#define MONITOR_L6470_DRIVER_STATUS + + #if ENABLED(MONITOR_L6470_DRIVER_STATUS) + #define KVAL_HOLD_STEP_DOWN 1 + //#define L6470_STOP_ON_ERROR + #endif + + #define L6470_CHITCHAT // enable display of additional status info #endif // L6470 diff --git a/Marlin/src/config/examples/TheBorg/Configuration_adv.h b/Marlin/src/config/examples/TheBorg/Configuration_adv.h index d83cdecd8..66d947e85 100644 --- a/Marlin/src/config/examples/TheBorg/Configuration_adv.h +++ b/Marlin/src/config/examples/TheBorg/Configuration_adv.h @@ -1508,62 +1508,121 @@ /** * L6470 Stepper Driver options * - * The Arduino-L6470 library is required for this stepper driver. + * Arduino-L6470 library (0.7.0 or higher) is required for this stepper driver. * https://github.com/ameyer/Arduino-L6470 + * + * Requires the following to be defined in your pins_YOUR_BOARD file + * L6470_CHAIN_SCK_PIN + * L6470_CHAIN_MISO_PIN + * L6470_CHAIN_MOSI_PIN + * L6470_CHAIN_SS_PIN + * L6470_RESET_CHAIN_PIN (optional) */ #if HAS_DRIVER(L6470) - #define X_MICROSTEPS 16 // number of microsteps - #define X_OVERCURRENT 2000 // maxc current in mA. If the current goes over this value, the driver will switch off - #define X_STALLCURRENT 1500 // current in mA where the driver will detect a stall + #define X_MICROSTEPS 128 // number of microsteps (VALID: 1, 2, 4, 8, 16, 32, 128 & 128) + #define X_OVERCURRENT 2000 // current in mA where the driver will detect an over current (VALID: 375 x (1 - 16) - 6A max - rounds down) + #define X_STALLCURRENT 1500 // current in mA where the driver will detect a stall (VALID: 31.25 * (1-128) - 4A max - rounds down) + #define X_MAX_VOLTAGE 127 // 0-255, max effective voltage seen by stepper + #define X_CHAIN_POS 0 // position in SPI chain, 0 - not in chain, 1- nearest MOSI - #define X2_MICROSTEPS 16 + #define X2_MICROSTEPS 128 #define X2_OVERCURRENT 2000 #define X2_STALLCURRENT 1500 + #define X2_MAX_VOLTAGE 127 + #define X2_CHAIN_POS 0 - #define Y_MICROSTEPS 16 + #define Y_MICROSTEPS 128 #define Y_OVERCURRENT 2000 #define Y_STALLCURRENT 1500 + #define Y_MAX_VOLTAGE 127 + #define Y_CHAIN_POS 0 - #define Y2_MICROSTEPS 16 + #define Y2_MICROSTEPS 128 #define Y2_OVERCURRENT 2000 #define Y2_STALLCURRENT 1500 + #define Y2_MAX_VOLTAGE 127 + #define Y2_CHAIN_POS 0 - #define Z_MICROSTEPS 16 + #define Z_MICROSTEPS 128 #define Z_OVERCURRENT 2000 #define Z_STALLCURRENT 1500 + #define Z_MAX_VOLTAGE 127 + #define Z_CHAIN_POS 0 - #define Z2_MICROSTEPS 16 + #define Z2_MICROSTEPS 128 #define Z2_OVERCURRENT 2000 #define Z2_STALLCURRENT 1500 + #define Z2_MAX_VOLTAGE 127 + #define Z2_CHAIN_POS 0 - #define Z3_MICROSTEPS 16 + #define Z3_MICROSTEPS 128 #define Z3_OVERCURRENT 2000 #define Z3_STALLCURRENT 1500 + #define Z3_MAX_VOLTAGE 127 + #define Z3_CHAIN_POS 0 - #define E0_MICROSTEPS 16 + #define E0_MICROSTEPS 128 #define E0_OVERCURRENT 2000 #define E0_STALLCURRENT 1500 + #define E0_MAX_VOLTAGE 127 + #define E0_CHAIN_POS 0 - #define E1_MICROSTEPS 16 + #define E1_MICROSTEPS 128 #define E1_OVERCURRENT 2000 #define E1_STALLCURRENT 1500 + #define E1_MAX_VOLTAGE 127 + #define E1_CHAIN_POS 0 - #define E2_MICROSTEPS 16 + #define E2_MICROSTEPS 128 #define E2_OVERCURRENT 2000 #define E2_STALLCURRENT 1500 + #define E2_MAX_VOLTAGE 127 + #define E2_CHAIN_POS 0 - #define E3_MICROSTEPS 16 + #define E3_MICROSTEPS 128 #define E3_OVERCURRENT 2000 #define E3_STALLCURRENT 1500 + #define E3_MAX_VOLTAGE 127 + #define E3_CHAIN_POS 0 - #define E4_MICROSTEPS 16 + #define E4_MICROSTEPS 128 #define E4_OVERCURRENT 2000 #define E4_STALLCURRENT 1500 + #define E4_MAX_VOLTAGE 127 + #define E4_CHAIN_POS 0 - #define E5_MICROSTEPS 16 + #define E5_MICROSTEPS 128 #define E5_OVERCURRENT 2000 #define E5_STALLCURRENT 1500 + #define E5_MAX_VOLTAGE 127 + #define E5_CHAIN_POS 0 + + + /** + * Monitor L6470 drivers for error conditions like over temperature and over current. + * In the case of over temperature Marlin can decrease the drive until the error condition clears. + * Other detected conditions can be used to stop the current print. + * Relevant g-codes: + * M906 - I1/2/3/4/5 Set or get motor drive level using axis codes X, Y, Z, E. Report values if no axis codes given. + * I not present or I0 or I1 - X, Y, Z or E0 + * I2 - X2, Y2, Z2 or E1 + * I3 - Z3 or E3 + * I4 - E4 + * I5 - E5 + * M916 - Increase drive level until get thermal warning + * M917 - Find minimum current thresholds + * M918 - Increase speed until max or error + * M122 S0/1 - Report driver parameters + */ + //#define MONITOR_L6470_DRIVER_STATUS + + #if ENABLED(MONITOR_L6470_DRIVER_STATUS) + #define KVAL_HOLD_STEP_DOWN 1 + //#define L6470_STOP_ON_ERROR + #endif + + #define L6470_CHITCHAT // enable display of additional status info #endif // L6470 diff --git a/Marlin/src/config/examples/TinyBoy2/Configuration_adv.h b/Marlin/src/config/examples/TinyBoy2/Configuration_adv.h index cc49baf42..029c04fb6 100644 --- a/Marlin/src/config/examples/TinyBoy2/Configuration_adv.h +++ b/Marlin/src/config/examples/TinyBoy2/Configuration_adv.h @@ -1508,62 +1508,121 @@ /** * L6470 Stepper Driver options * - * The Arduino-L6470 library is required for this stepper driver. + * Arduino-L6470 library (0.7.0 or higher) is required for this stepper driver. * https://github.com/ameyer/Arduino-L6470 + * + * Requires the following to be defined in your pins_YOUR_BOARD file + * L6470_CHAIN_SCK_PIN + * L6470_CHAIN_MISO_PIN + * L6470_CHAIN_MOSI_PIN + * L6470_CHAIN_SS_PIN + * L6470_RESET_CHAIN_PIN (optional) */ #if HAS_DRIVER(L6470) - #define X_MICROSTEPS 16 // number of microsteps - #define X_OVERCURRENT 2000 // maxc current in mA. If the current goes over this value, the driver will switch off - #define X_STALLCURRENT 1500 // current in mA where the driver will detect a stall + #define X_MICROSTEPS 128 // number of microsteps (VALID: 1, 2, 4, 8, 16, 32, 128 & 128) + #define X_OVERCURRENT 2000 // current in mA where the driver will detect an over current (VALID: 375 x (1 - 16) - 6A max - rounds down) + #define X_STALLCURRENT 1500 // current in mA where the driver will detect a stall (VALID: 31.25 * (1-128) - 4A max - rounds down) + #define X_MAX_VOLTAGE 127 // 0-255, max effective voltage seen by stepper + #define X_CHAIN_POS 0 // position in SPI chain, 0 - not in chain, 1- nearest MOSI - #define X2_MICROSTEPS 16 + #define X2_MICROSTEPS 128 #define X2_OVERCURRENT 2000 #define X2_STALLCURRENT 1500 + #define X2_MAX_VOLTAGE 127 + #define X2_CHAIN_POS 0 - #define Y_MICROSTEPS 16 + #define Y_MICROSTEPS 128 #define Y_OVERCURRENT 2000 #define Y_STALLCURRENT 1500 + #define Y_MAX_VOLTAGE 127 + #define Y_CHAIN_POS 0 - #define Y2_MICROSTEPS 16 + #define Y2_MICROSTEPS 128 #define Y2_OVERCURRENT 2000 #define Y2_STALLCURRENT 1500 + #define Y2_MAX_VOLTAGE 127 + #define Y2_CHAIN_POS 0 - #define Z_MICROSTEPS 16 + #define Z_MICROSTEPS 128 #define Z_OVERCURRENT 2000 #define Z_STALLCURRENT 1500 + #define Z_MAX_VOLTAGE 127 + #define Z_CHAIN_POS 0 - #define Z2_MICROSTEPS 16 + #define Z2_MICROSTEPS 128 #define Z2_OVERCURRENT 2000 #define Z2_STALLCURRENT 1500 + #define Z2_MAX_VOLTAGE 127 + #define Z2_CHAIN_POS 0 - #define Z3_MICROSTEPS 16 + #define Z3_MICROSTEPS 128 #define Z3_OVERCURRENT 2000 #define Z3_STALLCURRENT 1500 + #define Z3_MAX_VOLTAGE 127 + #define Z3_CHAIN_POS 0 - #define E0_MICROSTEPS 16 + #define E0_MICROSTEPS 128 #define E0_OVERCURRENT 2000 #define E0_STALLCURRENT 1500 + #define E0_MAX_VOLTAGE 127 + #define E0_CHAIN_POS 0 - #define E1_MICROSTEPS 16 + #define E1_MICROSTEPS 128 #define E1_OVERCURRENT 2000 #define E1_STALLCURRENT 1500 + #define E1_MAX_VOLTAGE 127 + #define E1_CHAIN_POS 0 - #define E2_MICROSTEPS 16 + #define E2_MICROSTEPS 128 #define E2_OVERCURRENT 2000 #define E2_STALLCURRENT 1500 + #define E2_MAX_VOLTAGE 127 + #define E2_CHAIN_POS 0 - #define E3_MICROSTEPS 16 + #define E3_MICROSTEPS 128 #define E3_OVERCURRENT 2000 #define E3_STALLCURRENT 1500 + #define E3_MAX_VOLTAGE 127 + #define E3_CHAIN_POS 0 - #define E4_MICROSTEPS 16 + #define E4_MICROSTEPS 128 #define E4_OVERCURRENT 2000 #define E4_STALLCURRENT 1500 + #define E4_MAX_VOLTAGE 127 + #define E4_CHAIN_POS 0 - #define E5_MICROSTEPS 16 + #define E5_MICROSTEPS 128 #define E5_OVERCURRENT 2000 #define E5_STALLCURRENT 1500 + #define E5_MAX_VOLTAGE 127 + #define E5_CHAIN_POS 0 + + + /** + * Monitor L6470 drivers for error conditions like over temperature and over current. + * In the case of over temperature Marlin can decrease the drive until the error condition clears. + * Other detected conditions can be used to stop the current print. + * Relevant g-codes: + * M906 - I1/2/3/4/5 Set or get motor drive level using axis codes X, Y, Z, E. Report values if no axis codes given. + * I not present or I0 or I1 - X, Y, Z or E0 + * I2 - X2, Y2, Z2 or E1 + * I3 - Z3 or E3 + * I4 - E4 + * I5 - E5 + * M916 - Increase drive level until get thermal warning + * M917 - Find minimum current thresholds + * M918 - Increase speed until max or error + * M122 S0/1 - Report driver parameters + */ + //#define MONITOR_L6470_DRIVER_STATUS + + #if ENABLED(MONITOR_L6470_DRIVER_STATUS) + #define KVAL_HOLD_STEP_DOWN 1 + //#define L6470_STOP_ON_ERROR + #endif + + #define L6470_CHITCHAT // enable display of additional status info #endif // L6470 diff --git a/Marlin/src/config/examples/Tronxy/X3A/Configuration_adv.h b/Marlin/src/config/examples/Tronxy/X3A/Configuration_adv.h index 693d195fa..ee093cd6c 100644 --- a/Marlin/src/config/examples/Tronxy/X3A/Configuration_adv.h +++ b/Marlin/src/config/examples/Tronxy/X3A/Configuration_adv.h @@ -1508,62 +1508,121 @@ /** * L6470 Stepper Driver options * - * The Arduino-L6470 library is required for this stepper driver. + * Arduino-L6470 library (0.7.0 or higher) is required for this stepper driver. * https://github.com/ameyer/Arduino-L6470 + * + * Requires the following to be defined in your pins_YOUR_BOARD file + * L6470_CHAIN_SCK_PIN + * L6470_CHAIN_MISO_PIN + * L6470_CHAIN_MOSI_PIN + * L6470_CHAIN_SS_PIN + * L6470_RESET_CHAIN_PIN (optional) */ #if HAS_DRIVER(L6470) - #define X_MICROSTEPS 16 // number of microsteps - #define X_OVERCURRENT 2000 // maxc current in mA. If the current goes over this value, the driver will switch off - #define X_STALLCURRENT 1500 // current in mA where the driver will detect a stall + #define X_MICROSTEPS 128 // number of microsteps (VALID: 1, 2, 4, 8, 16, 32, 128 & 128) + #define X_OVERCURRENT 2000 // current in mA where the driver will detect an over current (VALID: 375 x (1 - 16) - 6A max - rounds down) + #define X_STALLCURRENT 1500 // current in mA where the driver will detect a stall (VALID: 31.25 * (1-128) - 4A max - rounds down) + #define X_MAX_VOLTAGE 127 // 0-255, max effective voltage seen by stepper + #define X_CHAIN_POS 0 // position in SPI chain, 0 - not in chain, 1- nearest MOSI - #define X2_MICROSTEPS 16 + #define X2_MICROSTEPS 128 #define X2_OVERCURRENT 2000 #define X2_STALLCURRENT 1500 + #define X2_MAX_VOLTAGE 127 + #define X2_CHAIN_POS 0 - #define Y_MICROSTEPS 16 + #define Y_MICROSTEPS 128 #define Y_OVERCURRENT 2000 #define Y_STALLCURRENT 1500 + #define Y_MAX_VOLTAGE 127 + #define Y_CHAIN_POS 0 - #define Y2_MICROSTEPS 16 + #define Y2_MICROSTEPS 128 #define Y2_OVERCURRENT 2000 #define Y2_STALLCURRENT 1500 + #define Y2_MAX_VOLTAGE 127 + #define Y2_CHAIN_POS 0 - #define Z_MICROSTEPS 16 + #define Z_MICROSTEPS 128 #define Z_OVERCURRENT 2000 #define Z_STALLCURRENT 1500 + #define Z_MAX_VOLTAGE 127 + #define Z_CHAIN_POS 0 - #define Z2_MICROSTEPS 16 + #define Z2_MICROSTEPS 128 #define Z2_OVERCURRENT 2000 #define Z2_STALLCURRENT 1500 + #define Z2_MAX_VOLTAGE 127 + #define Z2_CHAIN_POS 0 - #define Z3_MICROSTEPS 16 + #define Z3_MICROSTEPS 128 #define Z3_OVERCURRENT 2000 #define Z3_STALLCURRENT 1500 + #define Z3_MAX_VOLTAGE 127 + #define Z3_CHAIN_POS 0 - #define E0_MICROSTEPS 16 + #define E0_MICROSTEPS 128 #define E0_OVERCURRENT 2000 #define E0_STALLCURRENT 1500 + #define E0_MAX_VOLTAGE 127 + #define E0_CHAIN_POS 0 - #define E1_MICROSTEPS 16 + #define E1_MICROSTEPS 128 #define E1_OVERCURRENT 2000 #define E1_STALLCURRENT 1500 + #define E1_MAX_VOLTAGE 127 + #define E1_CHAIN_POS 0 - #define E2_MICROSTEPS 16 + #define E2_MICROSTEPS 128 #define E2_OVERCURRENT 2000 #define E2_STALLCURRENT 1500 + #define E2_MAX_VOLTAGE 127 + #define E2_CHAIN_POS 0 - #define E3_MICROSTEPS 16 + #define E3_MICROSTEPS 128 #define E3_OVERCURRENT 2000 #define E3_STALLCURRENT 1500 + #define E3_MAX_VOLTAGE 127 + #define E3_CHAIN_POS 0 - #define E4_MICROSTEPS 16 + #define E4_MICROSTEPS 128 #define E4_OVERCURRENT 2000 #define E4_STALLCURRENT 1500 + #define E4_MAX_VOLTAGE 127 + #define E4_CHAIN_POS 0 - #define E5_MICROSTEPS 16 + #define E5_MICROSTEPS 128 #define E5_OVERCURRENT 2000 #define E5_STALLCURRENT 1500 + #define E5_MAX_VOLTAGE 127 + #define E5_CHAIN_POS 0 + + + /** + * Monitor L6470 drivers for error conditions like over temperature and over current. + * In the case of over temperature Marlin can decrease the drive until the error condition clears. + * Other detected conditions can be used to stop the current print. + * Relevant g-codes: + * M906 - I1/2/3/4/5 Set or get motor drive level using axis codes X, Y, Z, E. Report values if no axis codes given. + * I not present or I0 or I1 - X, Y, Z or E0 + * I2 - X2, Y2, Z2 or E1 + * I3 - Z3 or E3 + * I4 - E4 + * I5 - E5 + * M916 - Increase drive level until get thermal warning + * M917 - Find minimum current thresholds + * M918 - Increase speed until max or error + * M122 S0/1 - Report driver parameters + */ + //#define MONITOR_L6470_DRIVER_STATUS + + #if ENABLED(MONITOR_L6470_DRIVER_STATUS) + #define KVAL_HOLD_STEP_DOWN 1 + //#define L6470_STOP_ON_ERROR + #endif + + #define L6470_CHITCHAT // enable display of additional status info #endif // L6470 diff --git a/Marlin/src/config/examples/UltiMachine/Archim1/Configuration_adv.h b/Marlin/src/config/examples/UltiMachine/Archim1/Configuration_adv.h index b0d0621cc..35d47d75f 100644 --- a/Marlin/src/config/examples/UltiMachine/Archim1/Configuration_adv.h +++ b/Marlin/src/config/examples/UltiMachine/Archim1/Configuration_adv.h @@ -1509,62 +1509,121 @@ /** * L6470 Stepper Driver options * - * The Arduino-L6470 library is required for this stepper driver. + * Arduino-L6470 library (0.7.0 or higher) is required for this stepper driver. * https://github.com/ameyer/Arduino-L6470 + * + * Requires the following to be defined in your pins_YOUR_BOARD file + * L6470_CHAIN_SCK_PIN + * L6470_CHAIN_MISO_PIN + * L6470_CHAIN_MOSI_PIN + * L6470_CHAIN_SS_PIN + * L6470_RESET_CHAIN_PIN (optional) */ #if HAS_DRIVER(L6470) - #define X_MICROSTEPS 16 // number of microsteps - #define X_OVERCURRENT 2000 // maxc current in mA. If the current goes over this value, the driver will switch off - #define X_STALLCURRENT 1500 // current in mA where the driver will detect a stall + #define X_MICROSTEPS 128 // number of microsteps (VALID: 1, 2, 4, 8, 16, 32, 128 & 128) + #define X_OVERCURRENT 2000 // current in mA where the driver will detect an over current (VALID: 375 x (1 - 16) - 6A max - rounds down) + #define X_STALLCURRENT 1500 // current in mA where the driver will detect a stall (VALID: 31.25 * (1-128) - 4A max - rounds down) + #define X_MAX_VOLTAGE 127 // 0-255, max effective voltage seen by stepper + #define X_CHAIN_POS 0 // position in SPI chain, 0 - not in chain, 1- nearest MOSI - #define X2_MICROSTEPS 16 + #define X2_MICROSTEPS 128 #define X2_OVERCURRENT 2000 #define X2_STALLCURRENT 1500 + #define X2_MAX_VOLTAGE 127 + #define X2_CHAIN_POS 0 - #define Y_MICROSTEPS 16 + #define Y_MICROSTEPS 128 #define Y_OVERCURRENT 2000 #define Y_STALLCURRENT 1500 + #define Y_MAX_VOLTAGE 127 + #define Y_CHAIN_POS 0 - #define Y2_MICROSTEPS 16 + #define Y2_MICROSTEPS 128 #define Y2_OVERCURRENT 2000 #define Y2_STALLCURRENT 1500 + #define Y2_MAX_VOLTAGE 127 + #define Y2_CHAIN_POS 0 - #define Z_MICROSTEPS 16 + #define Z_MICROSTEPS 128 #define Z_OVERCURRENT 2000 #define Z_STALLCURRENT 1500 + #define Z_MAX_VOLTAGE 127 + #define Z_CHAIN_POS 0 - #define Z2_MICROSTEPS 16 + #define Z2_MICROSTEPS 128 #define Z2_OVERCURRENT 2000 #define Z2_STALLCURRENT 1500 + #define Z2_MAX_VOLTAGE 127 + #define Z2_CHAIN_POS 0 - #define Z3_MICROSTEPS 16 + #define Z3_MICROSTEPS 128 #define Z3_OVERCURRENT 2000 #define Z3_STALLCURRENT 1500 + #define Z3_MAX_VOLTAGE 127 + #define Z3_CHAIN_POS 0 - #define E0_MICROSTEPS 16 + #define E0_MICROSTEPS 128 #define E0_OVERCURRENT 2000 #define E0_STALLCURRENT 1500 + #define E0_MAX_VOLTAGE 127 + #define E0_CHAIN_POS 0 - #define E1_MICROSTEPS 16 + #define E1_MICROSTEPS 128 #define E1_OVERCURRENT 2000 #define E1_STALLCURRENT 1500 + #define E1_MAX_VOLTAGE 127 + #define E1_CHAIN_POS 0 - #define E2_MICROSTEPS 16 + #define E2_MICROSTEPS 128 #define E2_OVERCURRENT 2000 #define E2_STALLCURRENT 1500 + #define E2_MAX_VOLTAGE 127 + #define E2_CHAIN_POS 0 - #define E3_MICROSTEPS 16 + #define E3_MICROSTEPS 128 #define E3_OVERCURRENT 2000 #define E3_STALLCURRENT 1500 + #define E3_MAX_VOLTAGE 127 + #define E3_CHAIN_POS 0 - #define E4_MICROSTEPS 16 + #define E4_MICROSTEPS 128 #define E4_OVERCURRENT 2000 #define E4_STALLCURRENT 1500 + #define E4_MAX_VOLTAGE 127 + #define E4_CHAIN_POS 0 - #define E5_MICROSTEPS 16 + #define E5_MICROSTEPS 128 #define E5_OVERCURRENT 2000 #define E5_STALLCURRENT 1500 + #define E5_MAX_VOLTAGE 127 + #define E5_CHAIN_POS 0 + + + /** + * Monitor L6470 drivers for error conditions like over temperature and over current. + * In the case of over temperature Marlin can decrease the drive until the error condition clears. + * Other detected conditions can be used to stop the current print. + * Relevant g-codes: + * M906 - I1/2/3/4/5 Set or get motor drive level using axis codes X, Y, Z, E. Report values if no axis codes given. + * I not present or I0 or I1 - X, Y, Z or E0 + * I2 - X2, Y2, Z2 or E1 + * I3 - Z3 or E3 + * I4 - E4 + * I5 - E5 + * M916 - Increase drive level until get thermal warning + * M917 - Find minimum current thresholds + * M918 - Increase speed until max or error + * M122 S0/1 - Report driver parameters + */ + //#define MONITOR_L6470_DRIVER_STATUS + + #if ENABLED(MONITOR_L6470_DRIVER_STATUS) + #define KVAL_HOLD_STEP_DOWN 1 + //#define L6470_STOP_ON_ERROR + #endif + + #define L6470_CHITCHAT // enable display of additional status info #endif // L6470 diff --git a/Marlin/src/config/examples/UltiMachine/Archim2/Configuration_adv.h b/Marlin/src/config/examples/UltiMachine/Archim2/Configuration_adv.h index 8240d213c..c06c77179 100644 --- a/Marlin/src/config/examples/UltiMachine/Archim2/Configuration_adv.h +++ b/Marlin/src/config/examples/UltiMachine/Archim2/Configuration_adv.h @@ -1508,62 +1508,121 @@ /** * L6470 Stepper Driver options * - * The Arduino-L6470 library is required for this stepper driver. + * Arduino-L6470 library (0.7.0 or higher) is required for this stepper driver. * https://github.com/ameyer/Arduino-L6470 + * + * Requires the following to be defined in your pins_YOUR_BOARD file + * L6470_CHAIN_SCK_PIN + * L6470_CHAIN_MISO_PIN + * L6470_CHAIN_MOSI_PIN + * L6470_CHAIN_SS_PIN + * L6470_RESET_CHAIN_PIN (optional) */ #if HAS_DRIVER(L6470) - #define X_MICROSTEPS 16 // number of microsteps - #define X_OVERCURRENT 2000 // maxc current in mA. If the current goes over this value, the driver will switch off - #define X_STALLCURRENT 1500 // current in mA where the driver will detect a stall + #define X_MICROSTEPS 128 // number of microsteps (VALID: 1, 2, 4, 8, 16, 32, 128 & 128) + #define X_OVERCURRENT 2000 // current in mA where the driver will detect an over current (VALID: 375 x (1 - 16) - 6A max - rounds down) + #define X_STALLCURRENT 1500 // current in mA where the driver will detect a stall (VALID: 31.25 * (1-128) - 4A max - rounds down) + #define X_MAX_VOLTAGE 127 // 0-255, max effective voltage seen by stepper + #define X_CHAIN_POS 0 // position in SPI chain, 0 - not in chain, 1- nearest MOSI - #define X2_MICROSTEPS 16 + #define X2_MICROSTEPS 128 #define X2_OVERCURRENT 2000 #define X2_STALLCURRENT 1500 + #define X2_MAX_VOLTAGE 127 + #define X2_CHAIN_POS 0 - #define Y_MICROSTEPS 16 + #define Y_MICROSTEPS 128 #define Y_OVERCURRENT 2000 #define Y_STALLCURRENT 1500 + #define Y_MAX_VOLTAGE 127 + #define Y_CHAIN_POS 0 - #define Y2_MICROSTEPS 16 + #define Y2_MICROSTEPS 128 #define Y2_OVERCURRENT 2000 #define Y2_STALLCURRENT 1500 + #define Y2_MAX_VOLTAGE 127 + #define Y2_CHAIN_POS 0 - #define Z_MICROSTEPS 16 + #define Z_MICROSTEPS 128 #define Z_OVERCURRENT 2000 #define Z_STALLCURRENT 1500 + #define Z_MAX_VOLTAGE 127 + #define Z_CHAIN_POS 0 - #define Z2_MICROSTEPS 16 + #define Z2_MICROSTEPS 128 #define Z2_OVERCURRENT 2000 #define Z2_STALLCURRENT 1500 + #define Z2_MAX_VOLTAGE 127 + #define Z2_CHAIN_POS 0 - #define Z3_MICROSTEPS 16 + #define Z3_MICROSTEPS 128 #define Z3_OVERCURRENT 2000 #define Z3_STALLCURRENT 1500 + #define Z3_MAX_VOLTAGE 127 + #define Z3_CHAIN_POS 0 - #define E0_MICROSTEPS 16 + #define E0_MICROSTEPS 128 #define E0_OVERCURRENT 2000 #define E0_STALLCURRENT 1500 + #define E0_MAX_VOLTAGE 127 + #define E0_CHAIN_POS 0 - #define E1_MICROSTEPS 16 + #define E1_MICROSTEPS 128 #define E1_OVERCURRENT 2000 #define E1_STALLCURRENT 1500 + #define E1_MAX_VOLTAGE 127 + #define E1_CHAIN_POS 0 - #define E2_MICROSTEPS 16 + #define E2_MICROSTEPS 128 #define E2_OVERCURRENT 2000 #define E2_STALLCURRENT 1500 + #define E2_MAX_VOLTAGE 127 + #define E2_CHAIN_POS 0 - #define E3_MICROSTEPS 16 + #define E3_MICROSTEPS 128 #define E3_OVERCURRENT 2000 #define E3_STALLCURRENT 1500 + #define E3_MAX_VOLTAGE 127 + #define E3_CHAIN_POS 0 - #define E4_MICROSTEPS 16 + #define E4_MICROSTEPS 128 #define E4_OVERCURRENT 2000 #define E4_STALLCURRENT 1500 + #define E4_MAX_VOLTAGE 127 + #define E4_CHAIN_POS 0 - #define E5_MICROSTEPS 16 + #define E5_MICROSTEPS 128 #define E5_OVERCURRENT 2000 #define E5_STALLCURRENT 1500 + #define E5_MAX_VOLTAGE 127 + #define E5_CHAIN_POS 0 + + + /** + * Monitor L6470 drivers for error conditions like over temperature and over current. + * In the case of over temperature Marlin can decrease the drive until the error condition clears. + * Other detected conditions can be used to stop the current print. + * Relevant g-codes: + * M906 - I1/2/3/4/5 Set or get motor drive level using axis codes X, Y, Z, E. Report values if no axis codes given. + * I not present or I0 or I1 - X, Y, Z or E0 + * I2 - X2, Y2, Z2 or E1 + * I3 - Z3 or E3 + * I4 - E4 + * I5 - E5 + * M916 - Increase drive level until get thermal warning + * M917 - Find minimum current thresholds + * M918 - Increase speed until max or error + * M122 S0/1 - Report driver parameters + */ + //#define MONITOR_L6470_DRIVER_STATUS + + #if ENABLED(MONITOR_L6470_DRIVER_STATUS) + #define KVAL_HOLD_STEP_DOWN 1 + //#define L6470_STOP_ON_ERROR + #endif + + #define L6470_CHITCHAT // enable display of additional status info #endif // L6470 diff --git a/Marlin/src/config/examples/VORONDesign/Configuration_adv.h b/Marlin/src/config/examples/VORONDesign/Configuration_adv.h index 8631b05f9..7f6abd1d8 100644 --- a/Marlin/src/config/examples/VORONDesign/Configuration_adv.h +++ b/Marlin/src/config/examples/VORONDesign/Configuration_adv.h @@ -1509,62 +1509,121 @@ /** * L6470 Stepper Driver options * - * The Arduino-L6470 library is required for this stepper driver. + * Arduino-L6470 library (0.7.0 or higher) is required for this stepper driver. * https://github.com/ameyer/Arduino-L6470 + * + * Requires the following to be defined in your pins_YOUR_BOARD file + * L6470_CHAIN_SCK_PIN + * L6470_CHAIN_MISO_PIN + * L6470_CHAIN_MOSI_PIN + * L6470_CHAIN_SS_PIN + * L6470_RESET_CHAIN_PIN (optional) */ #if HAS_DRIVER(L6470) - #define X_MICROSTEPS 16 // number of microsteps - #define X_OVERCURRENT 2000 // maxc current in mA. If the current goes over this value, the driver will switch off - #define X_STALLCURRENT 1500 // current in mA where the driver will detect a stall + #define X_MICROSTEPS 128 // number of microsteps (VALID: 1, 2, 4, 8, 16, 32, 128 & 128) + #define X_OVERCURRENT 2000 // current in mA where the driver will detect an over current (VALID: 375 x (1 - 16) - 6A max - rounds down) + #define X_STALLCURRENT 1500 // current in mA where the driver will detect a stall (VALID: 31.25 * (1-128) - 4A max - rounds down) + #define X_MAX_VOLTAGE 127 // 0-255, max effective voltage seen by stepper + #define X_CHAIN_POS 0 // position in SPI chain, 0 - not in chain, 1- nearest MOSI - #define X2_MICROSTEPS 16 + #define X2_MICROSTEPS 128 #define X2_OVERCURRENT 2000 #define X2_STALLCURRENT 1500 + #define X2_MAX_VOLTAGE 127 + #define X2_CHAIN_POS 0 - #define Y_MICROSTEPS 16 + #define Y_MICROSTEPS 128 #define Y_OVERCURRENT 2000 #define Y_STALLCURRENT 1500 + #define Y_MAX_VOLTAGE 127 + #define Y_CHAIN_POS 0 - #define Y2_MICROSTEPS 16 + #define Y2_MICROSTEPS 128 #define Y2_OVERCURRENT 2000 #define Y2_STALLCURRENT 1500 + #define Y2_MAX_VOLTAGE 127 + #define Y2_CHAIN_POS 0 - #define Z_MICROSTEPS 16 + #define Z_MICROSTEPS 128 #define Z_OVERCURRENT 2000 #define Z_STALLCURRENT 1500 + #define Z_MAX_VOLTAGE 127 + #define Z_CHAIN_POS 0 - #define Z2_MICROSTEPS 16 + #define Z2_MICROSTEPS 128 #define Z2_OVERCURRENT 2000 #define Z2_STALLCURRENT 1500 + #define Z2_MAX_VOLTAGE 127 + #define Z2_CHAIN_POS 0 - #define Z3_MICROSTEPS 16 + #define Z3_MICROSTEPS 128 #define Z3_OVERCURRENT 2000 #define Z3_STALLCURRENT 1500 + #define Z3_MAX_VOLTAGE 127 + #define Z3_CHAIN_POS 0 - #define E0_MICROSTEPS 16 + #define E0_MICROSTEPS 128 #define E0_OVERCURRENT 2000 #define E0_STALLCURRENT 1500 + #define E0_MAX_VOLTAGE 127 + #define E0_CHAIN_POS 0 - #define E1_MICROSTEPS 16 + #define E1_MICROSTEPS 128 #define E1_OVERCURRENT 2000 #define E1_STALLCURRENT 1500 + #define E1_MAX_VOLTAGE 127 + #define E1_CHAIN_POS 0 - #define E2_MICROSTEPS 16 + #define E2_MICROSTEPS 128 #define E2_OVERCURRENT 2000 #define E2_STALLCURRENT 1500 + #define E2_MAX_VOLTAGE 127 + #define E2_CHAIN_POS 0 - #define E3_MICROSTEPS 16 + #define E3_MICROSTEPS 128 #define E3_OVERCURRENT 2000 #define E3_STALLCURRENT 1500 + #define E3_MAX_VOLTAGE 127 + #define E3_CHAIN_POS 0 - #define E4_MICROSTEPS 16 + #define E4_MICROSTEPS 128 #define E4_OVERCURRENT 2000 #define E4_STALLCURRENT 1500 + #define E4_MAX_VOLTAGE 127 + #define E4_CHAIN_POS 0 - #define E5_MICROSTEPS 16 + #define E5_MICROSTEPS 128 #define E5_OVERCURRENT 2000 #define E5_STALLCURRENT 1500 + #define E5_MAX_VOLTAGE 127 + #define E5_CHAIN_POS 0 + + + /** + * Monitor L6470 drivers for error conditions like over temperature and over current. + * In the case of over temperature Marlin can decrease the drive until the error condition clears. + * Other detected conditions can be used to stop the current print. + * Relevant g-codes: + * M906 - I1/2/3/4/5 Set or get motor drive level using axis codes X, Y, Z, E. Report values if no axis codes given. + * I not present or I0 or I1 - X, Y, Z or E0 + * I2 - X2, Y2, Z2 or E1 + * I3 - Z3 or E3 + * I4 - E4 + * I5 - E5 + * M916 - Increase drive level until get thermal warning + * M917 - Find minimum current thresholds + * M918 - Increase speed until max or error + * M122 S0/1 - Report driver parameters + */ + //#define MONITOR_L6470_DRIVER_STATUS + + #if ENABLED(MONITOR_L6470_DRIVER_STATUS) + #define KVAL_HOLD_STEP_DOWN 1 + //#define L6470_STOP_ON_ERROR + #endif + + #define L6470_CHITCHAT // enable display of additional status info #endif // L6470 diff --git a/Marlin/src/config/examples/Velleman/K8200/Configuration_adv.h b/Marlin/src/config/examples/Velleman/K8200/Configuration_adv.h index 34ab61f9d..5cb29ea7f 100644 --- a/Marlin/src/config/examples/Velleman/K8200/Configuration_adv.h +++ b/Marlin/src/config/examples/Velleman/K8200/Configuration_adv.h @@ -1521,62 +1521,121 @@ /** * L6470 Stepper Driver options * - * The Arduino-L6470 library is required for this stepper driver. + * Arduino-L6470 library (0.7.0 or higher) is required for this stepper driver. * https://github.com/ameyer/Arduino-L6470 + * + * Requires the following to be defined in your pins_YOUR_BOARD file + * L6470_CHAIN_SCK_PIN + * L6470_CHAIN_MISO_PIN + * L6470_CHAIN_MOSI_PIN + * L6470_CHAIN_SS_PIN + * L6470_RESET_CHAIN_PIN (optional) */ #if HAS_DRIVER(L6470) - #define X_MICROSTEPS 16 // number of microsteps - #define X_OVERCURRENT 2000 // maxc current in mA. If the current goes over this value, the driver will switch off - #define X_STALLCURRENT 1500 // current in mA where the driver will detect a stall + #define X_MICROSTEPS 128 // number of microsteps (VALID: 1, 2, 4, 8, 16, 32, 128 & 128) + #define X_OVERCURRENT 2000 // current in mA where the driver will detect an over current (VALID: 375 x (1 - 16) - 6A max - rounds down) + #define X_STALLCURRENT 1500 // current in mA where the driver will detect a stall (VALID: 31.25 * (1-128) - 4A max - rounds down) + #define X_MAX_VOLTAGE 127 // 0-255, max effective voltage seen by stepper + #define X_CHAIN_POS 0 // position in SPI chain, 0 - not in chain, 1- nearest MOSI - #define X2_MICROSTEPS 16 + #define X2_MICROSTEPS 128 #define X2_OVERCURRENT 2000 #define X2_STALLCURRENT 1500 + #define X2_MAX_VOLTAGE 127 + #define X2_CHAIN_POS 0 - #define Y_MICROSTEPS 16 + #define Y_MICROSTEPS 128 #define Y_OVERCURRENT 2000 #define Y_STALLCURRENT 1500 + #define Y_MAX_VOLTAGE 127 + #define Y_CHAIN_POS 0 - #define Y2_MICROSTEPS 16 + #define Y2_MICROSTEPS 128 #define Y2_OVERCURRENT 2000 #define Y2_STALLCURRENT 1500 + #define Y2_MAX_VOLTAGE 127 + #define Y2_CHAIN_POS 0 - #define Z_MICROSTEPS 16 + #define Z_MICROSTEPS 128 #define Z_OVERCURRENT 2000 #define Z_STALLCURRENT 1500 + #define Z_MAX_VOLTAGE 127 + #define Z_CHAIN_POS 0 - #define Z2_MICROSTEPS 16 + #define Z2_MICROSTEPS 128 #define Z2_OVERCURRENT 2000 #define Z2_STALLCURRENT 1500 + #define Z2_MAX_VOLTAGE 127 + #define Z2_CHAIN_POS 0 - #define Z3_MICROSTEPS 16 + #define Z3_MICROSTEPS 128 #define Z3_OVERCURRENT 2000 #define Z3_STALLCURRENT 1500 + #define Z3_MAX_VOLTAGE 127 + #define Z3_CHAIN_POS 0 - #define E0_MICROSTEPS 16 + #define E0_MICROSTEPS 128 #define E0_OVERCURRENT 2000 #define E0_STALLCURRENT 1500 + #define E0_MAX_VOLTAGE 127 + #define E0_CHAIN_POS 0 - #define E1_MICROSTEPS 16 + #define E1_MICROSTEPS 128 #define E1_OVERCURRENT 2000 #define E1_STALLCURRENT 1500 + #define E1_MAX_VOLTAGE 127 + #define E1_CHAIN_POS 0 - #define E2_MICROSTEPS 16 + #define E2_MICROSTEPS 128 #define E2_OVERCURRENT 2000 #define E2_STALLCURRENT 1500 + #define E2_MAX_VOLTAGE 127 + #define E2_CHAIN_POS 0 - #define E3_MICROSTEPS 16 + #define E3_MICROSTEPS 128 #define E3_OVERCURRENT 2000 #define E3_STALLCURRENT 1500 + #define E3_MAX_VOLTAGE 127 + #define E3_CHAIN_POS 0 - #define E4_MICROSTEPS 16 + #define E4_MICROSTEPS 128 #define E4_OVERCURRENT 2000 #define E4_STALLCURRENT 1500 + #define E4_MAX_VOLTAGE 127 + #define E4_CHAIN_POS 0 - #define E5_MICROSTEPS 16 + #define E5_MICROSTEPS 128 #define E5_OVERCURRENT 2000 #define E5_STALLCURRENT 1500 + #define E5_MAX_VOLTAGE 127 + #define E5_CHAIN_POS 0 + + + /** + * Monitor L6470 drivers for error conditions like over temperature and over current. + * In the case of over temperature Marlin can decrease the drive until the error condition clears. + * Other detected conditions can be used to stop the current print. + * Relevant g-codes: + * M906 - I1/2/3/4/5 Set or get motor drive level using axis codes X, Y, Z, E. Report values if no axis codes given. + * I not present or I0 or I1 - X, Y, Z or E0 + * I2 - X2, Y2, Z2 or E1 + * I3 - Z3 or E3 + * I4 - E4 + * I5 - E5 + * M916 - Increase drive level until get thermal warning + * M917 - Find minimum current thresholds + * M918 - Increase speed until max or error + * M122 S0/1 - Report driver parameters + */ + //#define MONITOR_L6470_DRIVER_STATUS + + #if ENABLED(MONITOR_L6470_DRIVER_STATUS) + #define KVAL_HOLD_STEP_DOWN 1 + //#define L6470_STOP_ON_ERROR + #endif + + #define L6470_CHITCHAT // enable display of additional status info #endif // L6470 diff --git a/Marlin/src/config/examples/Velleman/K8400/Configuration_adv.h b/Marlin/src/config/examples/Velleman/K8400/Configuration_adv.h index d31a5dfba..c8c198afd 100644 --- a/Marlin/src/config/examples/Velleman/K8400/Configuration_adv.h +++ b/Marlin/src/config/examples/Velleman/K8400/Configuration_adv.h @@ -1508,62 +1508,121 @@ /** * L6470 Stepper Driver options * - * The Arduino-L6470 library is required for this stepper driver. + * Arduino-L6470 library (0.7.0 or higher) is required for this stepper driver. * https://github.com/ameyer/Arduino-L6470 + * + * Requires the following to be defined in your pins_YOUR_BOARD file + * L6470_CHAIN_SCK_PIN + * L6470_CHAIN_MISO_PIN + * L6470_CHAIN_MOSI_PIN + * L6470_CHAIN_SS_PIN + * L6470_RESET_CHAIN_PIN (optional) */ #if HAS_DRIVER(L6470) - #define X_MICROSTEPS 16 // number of microsteps - #define X_OVERCURRENT 2000 // maxc current in mA. If the current goes over this value, the driver will switch off - #define X_STALLCURRENT 1500 // current in mA where the driver will detect a stall + #define X_MICROSTEPS 128 // number of microsteps (VALID: 1, 2, 4, 8, 16, 32, 128 & 128) + #define X_OVERCURRENT 2000 // current in mA where the driver will detect an over current (VALID: 375 x (1 - 16) - 6A max - rounds down) + #define X_STALLCURRENT 1500 // current in mA where the driver will detect a stall (VALID: 31.25 * (1-128) - 4A max - rounds down) + #define X_MAX_VOLTAGE 127 // 0-255, max effective voltage seen by stepper + #define X_CHAIN_POS 0 // position in SPI chain, 0 - not in chain, 1- nearest MOSI - #define X2_MICROSTEPS 16 + #define X2_MICROSTEPS 128 #define X2_OVERCURRENT 2000 #define X2_STALLCURRENT 1500 + #define X2_MAX_VOLTAGE 127 + #define X2_CHAIN_POS 0 - #define Y_MICROSTEPS 16 + #define Y_MICROSTEPS 128 #define Y_OVERCURRENT 2000 #define Y_STALLCURRENT 1500 + #define Y_MAX_VOLTAGE 127 + #define Y_CHAIN_POS 0 - #define Y2_MICROSTEPS 16 + #define Y2_MICROSTEPS 128 #define Y2_OVERCURRENT 2000 #define Y2_STALLCURRENT 1500 + #define Y2_MAX_VOLTAGE 127 + #define Y2_CHAIN_POS 0 - #define Z_MICROSTEPS 16 + #define Z_MICROSTEPS 128 #define Z_OVERCURRENT 2000 #define Z_STALLCURRENT 1500 + #define Z_MAX_VOLTAGE 127 + #define Z_CHAIN_POS 0 - #define Z2_MICROSTEPS 16 + #define Z2_MICROSTEPS 128 #define Z2_OVERCURRENT 2000 #define Z2_STALLCURRENT 1500 + #define Z2_MAX_VOLTAGE 127 + #define Z2_CHAIN_POS 0 - #define Z3_MICROSTEPS 16 + #define Z3_MICROSTEPS 128 #define Z3_OVERCURRENT 2000 #define Z3_STALLCURRENT 1500 + #define Z3_MAX_VOLTAGE 127 + #define Z3_CHAIN_POS 0 - #define E0_MICROSTEPS 16 + #define E0_MICROSTEPS 128 #define E0_OVERCURRENT 2000 #define E0_STALLCURRENT 1500 + #define E0_MAX_VOLTAGE 127 + #define E0_CHAIN_POS 0 - #define E1_MICROSTEPS 16 + #define E1_MICROSTEPS 128 #define E1_OVERCURRENT 2000 #define E1_STALLCURRENT 1500 + #define E1_MAX_VOLTAGE 127 + #define E1_CHAIN_POS 0 - #define E2_MICROSTEPS 16 + #define E2_MICROSTEPS 128 #define E2_OVERCURRENT 2000 #define E2_STALLCURRENT 1500 + #define E2_MAX_VOLTAGE 127 + #define E2_CHAIN_POS 0 - #define E3_MICROSTEPS 16 + #define E3_MICROSTEPS 128 #define E3_OVERCURRENT 2000 #define E3_STALLCURRENT 1500 + #define E3_MAX_VOLTAGE 127 + #define E3_CHAIN_POS 0 - #define E4_MICROSTEPS 16 + #define E4_MICROSTEPS 128 #define E4_OVERCURRENT 2000 #define E4_STALLCURRENT 1500 + #define E4_MAX_VOLTAGE 127 + #define E4_CHAIN_POS 0 - #define E5_MICROSTEPS 16 + #define E5_MICROSTEPS 128 #define E5_OVERCURRENT 2000 #define E5_STALLCURRENT 1500 + #define E5_MAX_VOLTAGE 127 + #define E5_CHAIN_POS 0 + + + /** + * Monitor L6470 drivers for error conditions like over temperature and over current. + * In the case of over temperature Marlin can decrease the drive until the error condition clears. + * Other detected conditions can be used to stop the current print. + * Relevant g-codes: + * M906 - I1/2/3/4/5 Set or get motor drive level using axis codes X, Y, Z, E. Report values if no axis codes given. + * I not present or I0 or I1 - X, Y, Z or E0 + * I2 - X2, Y2, Z2 or E1 + * I3 - Z3 or E3 + * I4 - E4 + * I5 - E5 + * M916 - Increase drive level until get thermal warning + * M917 - Find minimum current thresholds + * M918 - Increase speed until max or error + * M122 S0/1 - Report driver parameters + */ + //#define MONITOR_L6470_DRIVER_STATUS + + #if ENABLED(MONITOR_L6470_DRIVER_STATUS) + #define KVAL_HOLD_STEP_DOWN 1 + //#define L6470_STOP_ON_ERROR + #endif + + #define L6470_CHITCHAT // enable display of additional status info #endif // L6470 diff --git a/Marlin/src/config/examples/WASP/PowerWASP/Configuration_adv.h b/Marlin/src/config/examples/WASP/PowerWASP/Configuration_adv.h index 0fff75443..11f7da59d 100644 --- a/Marlin/src/config/examples/WASP/PowerWASP/Configuration_adv.h +++ b/Marlin/src/config/examples/WASP/PowerWASP/Configuration_adv.h @@ -1509,62 +1509,121 @@ /** * L6470 Stepper Driver options * - * The Arduino-L6470 library is required for this stepper driver. + * Arduino-L6470 library (0.7.0 or higher) is required for this stepper driver. * https://github.com/ameyer/Arduino-L6470 + * + * Requires the following to be defined in your pins_YOUR_BOARD file + * L6470_CHAIN_SCK_PIN + * L6470_CHAIN_MISO_PIN + * L6470_CHAIN_MOSI_PIN + * L6470_CHAIN_SS_PIN + * L6470_RESET_CHAIN_PIN (optional) */ #if HAS_DRIVER(L6470) - #define X_MICROSTEPS 16 // number of microsteps - #define X_OVERCURRENT 2000 // maxc current in mA. If the current goes over this value, the driver will switch off - #define X_STALLCURRENT 1500 // current in mA where the driver will detect a stall + #define X_MICROSTEPS 128 // number of microsteps (VALID: 1, 2, 4, 8, 16, 32, 128 & 128) + #define X_OVERCURRENT 2000 // current in mA where the driver will detect an over current (VALID: 375 x (1 - 16) - 6A max - rounds down) + #define X_STALLCURRENT 1500 // current in mA where the driver will detect a stall (VALID: 31.25 * (1-128) - 4A max - rounds down) + #define X_MAX_VOLTAGE 127 // 0-255, max effective voltage seen by stepper + #define X_CHAIN_POS 0 // position in SPI chain, 0 - not in chain, 1- nearest MOSI - #define X2_MICROSTEPS 16 + #define X2_MICROSTEPS 128 #define X2_OVERCURRENT 2000 #define X2_STALLCURRENT 1500 + #define X2_MAX_VOLTAGE 127 + #define X2_CHAIN_POS 0 - #define Y_MICROSTEPS 16 + #define Y_MICROSTEPS 128 #define Y_OVERCURRENT 2000 #define Y_STALLCURRENT 1500 + #define Y_MAX_VOLTAGE 127 + #define Y_CHAIN_POS 0 - #define Y2_MICROSTEPS 16 + #define Y2_MICROSTEPS 128 #define Y2_OVERCURRENT 2000 #define Y2_STALLCURRENT 1500 + #define Y2_MAX_VOLTAGE 127 + #define Y2_CHAIN_POS 0 - #define Z_MICROSTEPS 16 + #define Z_MICROSTEPS 128 #define Z_OVERCURRENT 2000 #define Z_STALLCURRENT 1500 + #define Z_MAX_VOLTAGE 127 + #define Z_CHAIN_POS 0 - #define Z2_MICROSTEPS 16 + #define Z2_MICROSTEPS 128 #define Z2_OVERCURRENT 2000 #define Z2_STALLCURRENT 1500 + #define Z2_MAX_VOLTAGE 127 + #define Z2_CHAIN_POS 0 - #define Z3_MICROSTEPS 16 + #define Z3_MICROSTEPS 128 #define Z3_OVERCURRENT 2000 #define Z3_STALLCURRENT 1500 + #define Z3_MAX_VOLTAGE 127 + #define Z3_CHAIN_POS 0 - #define E0_MICROSTEPS 16 + #define E0_MICROSTEPS 128 #define E0_OVERCURRENT 2000 #define E0_STALLCURRENT 1500 + #define E0_MAX_VOLTAGE 127 + #define E0_CHAIN_POS 0 - #define E1_MICROSTEPS 16 + #define E1_MICROSTEPS 128 #define E1_OVERCURRENT 2000 #define E1_STALLCURRENT 1500 + #define E1_MAX_VOLTAGE 127 + #define E1_CHAIN_POS 0 - #define E2_MICROSTEPS 16 + #define E2_MICROSTEPS 128 #define E2_OVERCURRENT 2000 #define E2_STALLCURRENT 1500 + #define E2_MAX_VOLTAGE 127 + #define E2_CHAIN_POS 0 - #define E3_MICROSTEPS 16 + #define E3_MICROSTEPS 128 #define E3_OVERCURRENT 2000 #define E3_STALLCURRENT 1500 + #define E3_MAX_VOLTAGE 127 + #define E3_CHAIN_POS 0 - #define E4_MICROSTEPS 16 + #define E4_MICROSTEPS 128 #define E4_OVERCURRENT 2000 #define E4_STALLCURRENT 1500 + #define E4_MAX_VOLTAGE 127 + #define E4_CHAIN_POS 0 - #define E5_MICROSTEPS 16 + #define E5_MICROSTEPS 128 #define E5_OVERCURRENT 2000 #define E5_STALLCURRENT 1500 + #define E5_MAX_VOLTAGE 127 + #define E5_CHAIN_POS 0 + + + /** + * Monitor L6470 drivers for error conditions like over temperature and over current. + * In the case of over temperature Marlin can decrease the drive until the error condition clears. + * Other detected conditions can be used to stop the current print. + * Relevant g-codes: + * M906 - I1/2/3/4/5 Set or get motor drive level using axis codes X, Y, Z, E. Report values if no axis codes given. + * I not present or I0 or I1 - X, Y, Z or E0 + * I2 - X2, Y2, Z2 or E1 + * I3 - Z3 or E3 + * I4 - E4 + * I5 - E5 + * M916 - Increase drive level until get thermal warning + * M917 - Find minimum current thresholds + * M918 - Increase speed until max or error + * M122 S0/1 - Report driver parameters + */ + //#define MONITOR_L6470_DRIVER_STATUS + + #if ENABLED(MONITOR_L6470_DRIVER_STATUS) + #define KVAL_HOLD_STEP_DOWN 1 + //#define L6470_STOP_ON_ERROR + #endif + + #define L6470_CHITCHAT // enable display of additional status info #endif // L6470 diff --git a/Marlin/src/config/examples/Wanhao/Duplicator 6/Configuration_adv.h b/Marlin/src/config/examples/Wanhao/Duplicator 6/Configuration_adv.h index 8e0bf023d..e68a2487c 100644 --- a/Marlin/src/config/examples/Wanhao/Duplicator 6/Configuration_adv.h +++ b/Marlin/src/config/examples/Wanhao/Duplicator 6/Configuration_adv.h @@ -1510,62 +1510,121 @@ /** * L6470 Stepper Driver options * - * The Arduino-L6470 library is required for this stepper driver. + * Arduino-L6470 library (0.7.0 or higher) is required for this stepper driver. * https://github.com/ameyer/Arduino-L6470 + * + * Requires the following to be defined in your pins_YOUR_BOARD file + * L6470_CHAIN_SCK_PIN + * L6470_CHAIN_MISO_PIN + * L6470_CHAIN_MOSI_PIN + * L6470_CHAIN_SS_PIN + * L6470_RESET_CHAIN_PIN (optional) */ #if HAS_DRIVER(L6470) - #define X_MICROSTEPS 16 // number of microsteps - #define X_OVERCURRENT 2000 // maxc current in mA. If the current goes over this value, the driver will switch off - #define X_STALLCURRENT 1500 // current in mA where the driver will detect a stall + #define X_MICROSTEPS 128 // number of microsteps (VALID: 1, 2, 4, 8, 16, 32, 128 & 128) + #define X_OVERCURRENT 2000 // current in mA where the driver will detect an over current (VALID: 375 x (1 - 16) - 6A max - rounds down) + #define X_STALLCURRENT 1500 // current in mA where the driver will detect a stall (VALID: 31.25 * (1-128) - 4A max - rounds down) + #define X_MAX_VOLTAGE 127 // 0-255, max effective voltage seen by stepper + #define X_CHAIN_POS 0 // position in SPI chain, 0 - not in chain, 1- nearest MOSI - #define X2_MICROSTEPS 16 + #define X2_MICROSTEPS 128 #define X2_OVERCURRENT 2000 #define X2_STALLCURRENT 1500 + #define X2_MAX_VOLTAGE 127 + #define X2_CHAIN_POS 0 - #define Y_MICROSTEPS 16 + #define Y_MICROSTEPS 128 #define Y_OVERCURRENT 2000 #define Y_STALLCURRENT 1500 + #define Y_MAX_VOLTAGE 127 + #define Y_CHAIN_POS 0 - #define Y2_MICROSTEPS 16 + #define Y2_MICROSTEPS 128 #define Y2_OVERCURRENT 2000 #define Y2_STALLCURRENT 1500 + #define Y2_MAX_VOLTAGE 127 + #define Y2_CHAIN_POS 0 - #define Z_MICROSTEPS 16 + #define Z_MICROSTEPS 128 #define Z_OVERCURRENT 2000 #define Z_STALLCURRENT 1500 + #define Z_MAX_VOLTAGE 127 + #define Z_CHAIN_POS 0 - #define Z2_MICROSTEPS 16 + #define Z2_MICROSTEPS 128 #define Z2_OVERCURRENT 2000 #define Z2_STALLCURRENT 1500 + #define Z2_MAX_VOLTAGE 127 + #define Z2_CHAIN_POS 0 - #define Z3_MICROSTEPS 16 + #define Z3_MICROSTEPS 128 #define Z3_OVERCURRENT 2000 #define Z3_STALLCURRENT 1500 + #define Z3_MAX_VOLTAGE 127 + #define Z3_CHAIN_POS 0 - #define E0_MICROSTEPS 16 + #define E0_MICROSTEPS 128 #define E0_OVERCURRENT 2000 #define E0_STALLCURRENT 1500 + #define E0_MAX_VOLTAGE 127 + #define E0_CHAIN_POS 0 - #define E1_MICROSTEPS 16 + #define E1_MICROSTEPS 128 #define E1_OVERCURRENT 2000 #define E1_STALLCURRENT 1500 + #define E1_MAX_VOLTAGE 127 + #define E1_CHAIN_POS 0 - #define E2_MICROSTEPS 16 + #define E2_MICROSTEPS 128 #define E2_OVERCURRENT 2000 #define E2_STALLCURRENT 1500 + #define E2_MAX_VOLTAGE 127 + #define E2_CHAIN_POS 0 - #define E3_MICROSTEPS 16 + #define E3_MICROSTEPS 128 #define E3_OVERCURRENT 2000 #define E3_STALLCURRENT 1500 + #define E3_MAX_VOLTAGE 127 + #define E3_CHAIN_POS 0 - #define E4_MICROSTEPS 16 + #define E4_MICROSTEPS 128 #define E4_OVERCURRENT 2000 #define E4_STALLCURRENT 1500 + #define E4_MAX_VOLTAGE 127 + #define E4_CHAIN_POS 0 - #define E5_MICROSTEPS 16 + #define E5_MICROSTEPS 128 #define E5_OVERCURRENT 2000 #define E5_STALLCURRENT 1500 + #define E5_MAX_VOLTAGE 127 + #define E5_CHAIN_POS 0 + + + /** + * Monitor L6470 drivers for error conditions like over temperature and over current. + * In the case of over temperature Marlin can decrease the drive until the error condition clears. + * Other detected conditions can be used to stop the current print. + * Relevant g-codes: + * M906 - I1/2/3/4/5 Set or get motor drive level using axis codes X, Y, Z, E. Report values if no axis codes given. + * I not present or I0 or I1 - X, Y, Z or E0 + * I2 - X2, Y2, Z2 or E1 + * I3 - Z3 or E3 + * I4 - E4 + * I5 - E5 + * M916 - Increase drive level until get thermal warning + * M917 - Find minimum current thresholds + * M918 - Increase speed until max or error + * M122 S0/1 - Report driver parameters + */ + //#define MONITOR_L6470_DRIVER_STATUS + + #if ENABLED(MONITOR_L6470_DRIVER_STATUS) + #define KVAL_HOLD_STEP_DOWN 1 + //#define L6470_STOP_ON_ERROR + #endif + + #define L6470_CHITCHAT // enable display of additional status info #endif // L6470 diff --git a/Marlin/src/config/examples/delta/Anycubic/Kossel/Configuration_adv.h b/Marlin/src/config/examples/delta/Anycubic/Kossel/Configuration_adv.h index e760a4258..f008f76d7 100644 --- a/Marlin/src/config/examples/delta/Anycubic/Kossel/Configuration_adv.h +++ b/Marlin/src/config/examples/delta/Anycubic/Kossel/Configuration_adv.h @@ -1510,62 +1510,121 @@ /** * L6470 Stepper Driver options * - * The Arduino-L6470 library is required for this stepper driver. + * Arduino-L6470 library (0.7.0 or higher) is required for this stepper driver. * https://github.com/ameyer/Arduino-L6470 + * + * Requires the following to be defined in your pins_YOUR_BOARD file + * L6470_CHAIN_SCK_PIN + * L6470_CHAIN_MISO_PIN + * L6470_CHAIN_MOSI_PIN + * L6470_CHAIN_SS_PIN + * L6470_RESET_CHAIN_PIN (optional) */ #if HAS_DRIVER(L6470) - #define X_MICROSTEPS 16 // number of microsteps - #define X_OVERCURRENT 2000 // maxc current in mA. If the current goes over this value, the driver will switch off - #define X_STALLCURRENT 1500 // current in mA where the driver will detect a stall + #define X_MICROSTEPS 128 // number of microsteps (VALID: 1, 2, 4, 8, 16, 32, 128 & 128) + #define X_OVERCURRENT 2000 // current in mA where the driver will detect an over current (VALID: 375 x (1 - 16) - 6A max - rounds down) + #define X_STALLCURRENT 1500 // current in mA where the driver will detect a stall (VALID: 31.25 * (1-128) - 4A max - rounds down) + #define X_MAX_VOLTAGE 127 // 0-255, max effective voltage seen by stepper + #define X_CHAIN_POS 0 // position in SPI chain, 0 - not in chain, 1- nearest MOSI - #define X2_MICROSTEPS 16 + #define X2_MICROSTEPS 128 #define X2_OVERCURRENT 2000 #define X2_STALLCURRENT 1500 + #define X2_MAX_VOLTAGE 127 + #define X2_CHAIN_POS 0 - #define Y_MICROSTEPS 16 + #define Y_MICROSTEPS 128 #define Y_OVERCURRENT 2000 #define Y_STALLCURRENT 1500 + #define Y_MAX_VOLTAGE 127 + #define Y_CHAIN_POS 0 - #define Y2_MICROSTEPS 16 + #define Y2_MICROSTEPS 128 #define Y2_OVERCURRENT 2000 #define Y2_STALLCURRENT 1500 + #define Y2_MAX_VOLTAGE 127 + #define Y2_CHAIN_POS 0 - #define Z_MICROSTEPS 16 + #define Z_MICROSTEPS 128 #define Z_OVERCURRENT 2000 #define Z_STALLCURRENT 1500 + #define Z_MAX_VOLTAGE 127 + #define Z_CHAIN_POS 0 - #define Z2_MICROSTEPS 16 + #define Z2_MICROSTEPS 128 #define Z2_OVERCURRENT 2000 #define Z2_STALLCURRENT 1500 + #define Z2_MAX_VOLTAGE 127 + #define Z2_CHAIN_POS 0 - #define Z3_MICROSTEPS 16 + #define Z3_MICROSTEPS 128 #define Z3_OVERCURRENT 2000 #define Z3_STALLCURRENT 1500 + #define Z3_MAX_VOLTAGE 127 + #define Z3_CHAIN_POS 0 - #define E0_MICROSTEPS 16 + #define E0_MICROSTEPS 128 #define E0_OVERCURRENT 2000 #define E0_STALLCURRENT 1500 + #define E0_MAX_VOLTAGE 127 + #define E0_CHAIN_POS 0 - #define E1_MICROSTEPS 16 + #define E1_MICROSTEPS 128 #define E1_OVERCURRENT 2000 #define E1_STALLCURRENT 1500 + #define E1_MAX_VOLTAGE 127 + #define E1_CHAIN_POS 0 - #define E2_MICROSTEPS 16 + #define E2_MICROSTEPS 128 #define E2_OVERCURRENT 2000 #define E2_STALLCURRENT 1500 + #define E2_MAX_VOLTAGE 127 + #define E2_CHAIN_POS 0 - #define E3_MICROSTEPS 16 + #define E3_MICROSTEPS 128 #define E3_OVERCURRENT 2000 #define E3_STALLCURRENT 1500 + #define E3_MAX_VOLTAGE 127 + #define E3_CHAIN_POS 0 - #define E4_MICROSTEPS 16 + #define E4_MICROSTEPS 128 #define E4_OVERCURRENT 2000 #define E4_STALLCURRENT 1500 + #define E4_MAX_VOLTAGE 127 + #define E4_CHAIN_POS 0 - #define E5_MICROSTEPS 16 + #define E5_MICROSTEPS 128 #define E5_OVERCURRENT 2000 #define E5_STALLCURRENT 1500 + #define E5_MAX_VOLTAGE 127 + #define E5_CHAIN_POS 0 + + + /** + * Monitor L6470 drivers for error conditions like over temperature and over current. + * In the case of over temperature Marlin can decrease the drive until the error condition clears. + * Other detected conditions can be used to stop the current print. + * Relevant g-codes: + * M906 - I1/2/3/4/5 Set or get motor drive level using axis codes X, Y, Z, E. Report values if no axis codes given. + * I not present or I0 or I1 - X, Y, Z or E0 + * I2 - X2, Y2, Z2 or E1 + * I3 - Z3 or E3 + * I4 - E4 + * I5 - E5 + * M916 - Increase drive level until get thermal warning + * M917 - Find minimum current thresholds + * M918 - Increase speed until max or error + * M122 S0/1 - Report driver parameters + */ + //#define MONITOR_L6470_DRIVER_STATUS + + #if ENABLED(MONITOR_L6470_DRIVER_STATUS) + #define KVAL_HOLD_STEP_DOWN 1 + //#define L6470_STOP_ON_ERROR + #endif + + #define L6470_CHITCHAT // enable display of additional status info #endif // L6470 diff --git a/Marlin/src/config/examples/delta/FLSUN/auto_calibrate/Configuration_adv.h b/Marlin/src/config/examples/delta/FLSUN/auto_calibrate/Configuration_adv.h index df9e3d07b..14bcdbe8d 100644 --- a/Marlin/src/config/examples/delta/FLSUN/auto_calibrate/Configuration_adv.h +++ b/Marlin/src/config/examples/delta/FLSUN/auto_calibrate/Configuration_adv.h @@ -1510,62 +1510,121 @@ /** * L6470 Stepper Driver options * - * The Arduino-L6470 library is required for this stepper driver. + * Arduino-L6470 library (0.7.0 or higher) is required for this stepper driver. * https://github.com/ameyer/Arduino-L6470 + * + * Requires the following to be defined in your pins_YOUR_BOARD file + * L6470_CHAIN_SCK_PIN + * L6470_CHAIN_MISO_PIN + * L6470_CHAIN_MOSI_PIN + * L6470_CHAIN_SS_PIN + * L6470_RESET_CHAIN_PIN (optional) */ #if HAS_DRIVER(L6470) - #define X_MICROSTEPS 16 // number of microsteps - #define X_OVERCURRENT 2000 // maxc current in mA. If the current goes over this value, the driver will switch off - #define X_STALLCURRENT 1500 // current in mA where the driver will detect a stall + #define X_MICROSTEPS 128 // number of microsteps (VALID: 1, 2, 4, 8, 16, 32, 128 & 128) + #define X_OVERCURRENT 2000 // current in mA where the driver will detect an over current (VALID: 375 x (1 - 16) - 6A max - rounds down) + #define X_STALLCURRENT 1500 // current in mA where the driver will detect a stall (VALID: 31.25 * (1-128) - 4A max - rounds down) + #define X_MAX_VOLTAGE 127 // 0-255, max effective voltage seen by stepper + #define X_CHAIN_POS 0 // position in SPI chain, 0 - not in chain, 1- nearest MOSI - #define X2_MICROSTEPS 16 + #define X2_MICROSTEPS 128 #define X2_OVERCURRENT 2000 #define X2_STALLCURRENT 1500 + #define X2_MAX_VOLTAGE 127 + #define X2_CHAIN_POS 0 - #define Y_MICROSTEPS 16 + #define Y_MICROSTEPS 128 #define Y_OVERCURRENT 2000 #define Y_STALLCURRENT 1500 + #define Y_MAX_VOLTAGE 127 + #define Y_CHAIN_POS 0 - #define Y2_MICROSTEPS 16 + #define Y2_MICROSTEPS 128 #define Y2_OVERCURRENT 2000 #define Y2_STALLCURRENT 1500 + #define Y2_MAX_VOLTAGE 127 + #define Y2_CHAIN_POS 0 - #define Z_MICROSTEPS 16 + #define Z_MICROSTEPS 128 #define Z_OVERCURRENT 2000 #define Z_STALLCURRENT 1500 + #define Z_MAX_VOLTAGE 127 + #define Z_CHAIN_POS 0 - #define Z2_MICROSTEPS 16 + #define Z2_MICROSTEPS 128 #define Z2_OVERCURRENT 2000 #define Z2_STALLCURRENT 1500 + #define Z2_MAX_VOLTAGE 127 + #define Z2_CHAIN_POS 0 - #define Z3_MICROSTEPS 16 + #define Z3_MICROSTEPS 128 #define Z3_OVERCURRENT 2000 #define Z3_STALLCURRENT 1500 + #define Z3_MAX_VOLTAGE 127 + #define Z3_CHAIN_POS 0 - #define E0_MICROSTEPS 16 + #define E0_MICROSTEPS 128 #define E0_OVERCURRENT 2000 #define E0_STALLCURRENT 1500 + #define E0_MAX_VOLTAGE 127 + #define E0_CHAIN_POS 0 - #define E1_MICROSTEPS 16 + #define E1_MICROSTEPS 128 #define E1_OVERCURRENT 2000 #define E1_STALLCURRENT 1500 + #define E1_MAX_VOLTAGE 127 + #define E1_CHAIN_POS 0 - #define E2_MICROSTEPS 16 + #define E2_MICROSTEPS 128 #define E2_OVERCURRENT 2000 #define E2_STALLCURRENT 1500 + #define E2_MAX_VOLTAGE 127 + #define E2_CHAIN_POS 0 - #define E3_MICROSTEPS 16 + #define E3_MICROSTEPS 128 #define E3_OVERCURRENT 2000 #define E3_STALLCURRENT 1500 + #define E3_MAX_VOLTAGE 127 + #define E3_CHAIN_POS 0 - #define E4_MICROSTEPS 16 + #define E4_MICROSTEPS 128 #define E4_OVERCURRENT 2000 #define E4_STALLCURRENT 1500 + #define E4_MAX_VOLTAGE 127 + #define E4_CHAIN_POS 0 - #define E5_MICROSTEPS 16 + #define E5_MICROSTEPS 128 #define E5_OVERCURRENT 2000 #define E5_STALLCURRENT 1500 + #define E5_MAX_VOLTAGE 127 + #define E5_CHAIN_POS 0 + + + /** + * Monitor L6470 drivers for error conditions like over temperature and over current. + * In the case of over temperature Marlin can decrease the drive until the error condition clears. + * Other detected conditions can be used to stop the current print. + * Relevant g-codes: + * M906 - I1/2/3/4/5 Set or get motor drive level using axis codes X, Y, Z, E. Report values if no axis codes given. + * I not present or I0 or I1 - X, Y, Z or E0 + * I2 - X2, Y2, Z2 or E1 + * I3 - Z3 or E3 + * I4 - E4 + * I5 - E5 + * M916 - Increase drive level until get thermal warning + * M917 - Find minimum current thresholds + * M918 - Increase speed until max or error + * M122 S0/1 - Report driver parameters + */ + //#define MONITOR_L6470_DRIVER_STATUS + + #if ENABLED(MONITOR_L6470_DRIVER_STATUS) + #define KVAL_HOLD_STEP_DOWN 1 + //#define L6470_STOP_ON_ERROR + #endif + + #define L6470_CHITCHAT // enable display of additional status info #endif // L6470 diff --git a/Marlin/src/config/examples/delta/FLSUN/kossel/Configuration_adv.h b/Marlin/src/config/examples/delta/FLSUN/kossel/Configuration_adv.h index df9e3d07b..14bcdbe8d 100644 --- a/Marlin/src/config/examples/delta/FLSUN/kossel/Configuration_adv.h +++ b/Marlin/src/config/examples/delta/FLSUN/kossel/Configuration_adv.h @@ -1510,62 +1510,121 @@ /** * L6470 Stepper Driver options * - * The Arduino-L6470 library is required for this stepper driver. + * Arduino-L6470 library (0.7.0 or higher) is required for this stepper driver. * https://github.com/ameyer/Arduino-L6470 + * + * Requires the following to be defined in your pins_YOUR_BOARD file + * L6470_CHAIN_SCK_PIN + * L6470_CHAIN_MISO_PIN + * L6470_CHAIN_MOSI_PIN + * L6470_CHAIN_SS_PIN + * L6470_RESET_CHAIN_PIN (optional) */ #if HAS_DRIVER(L6470) - #define X_MICROSTEPS 16 // number of microsteps - #define X_OVERCURRENT 2000 // maxc current in mA. If the current goes over this value, the driver will switch off - #define X_STALLCURRENT 1500 // current in mA where the driver will detect a stall + #define X_MICROSTEPS 128 // number of microsteps (VALID: 1, 2, 4, 8, 16, 32, 128 & 128) + #define X_OVERCURRENT 2000 // current in mA where the driver will detect an over current (VALID: 375 x (1 - 16) - 6A max - rounds down) + #define X_STALLCURRENT 1500 // current in mA where the driver will detect a stall (VALID: 31.25 * (1-128) - 4A max - rounds down) + #define X_MAX_VOLTAGE 127 // 0-255, max effective voltage seen by stepper + #define X_CHAIN_POS 0 // position in SPI chain, 0 - not in chain, 1- nearest MOSI - #define X2_MICROSTEPS 16 + #define X2_MICROSTEPS 128 #define X2_OVERCURRENT 2000 #define X2_STALLCURRENT 1500 + #define X2_MAX_VOLTAGE 127 + #define X2_CHAIN_POS 0 - #define Y_MICROSTEPS 16 + #define Y_MICROSTEPS 128 #define Y_OVERCURRENT 2000 #define Y_STALLCURRENT 1500 + #define Y_MAX_VOLTAGE 127 + #define Y_CHAIN_POS 0 - #define Y2_MICROSTEPS 16 + #define Y2_MICROSTEPS 128 #define Y2_OVERCURRENT 2000 #define Y2_STALLCURRENT 1500 + #define Y2_MAX_VOLTAGE 127 + #define Y2_CHAIN_POS 0 - #define Z_MICROSTEPS 16 + #define Z_MICROSTEPS 128 #define Z_OVERCURRENT 2000 #define Z_STALLCURRENT 1500 + #define Z_MAX_VOLTAGE 127 + #define Z_CHAIN_POS 0 - #define Z2_MICROSTEPS 16 + #define Z2_MICROSTEPS 128 #define Z2_OVERCURRENT 2000 #define Z2_STALLCURRENT 1500 + #define Z2_MAX_VOLTAGE 127 + #define Z2_CHAIN_POS 0 - #define Z3_MICROSTEPS 16 + #define Z3_MICROSTEPS 128 #define Z3_OVERCURRENT 2000 #define Z3_STALLCURRENT 1500 + #define Z3_MAX_VOLTAGE 127 + #define Z3_CHAIN_POS 0 - #define E0_MICROSTEPS 16 + #define E0_MICROSTEPS 128 #define E0_OVERCURRENT 2000 #define E0_STALLCURRENT 1500 + #define E0_MAX_VOLTAGE 127 + #define E0_CHAIN_POS 0 - #define E1_MICROSTEPS 16 + #define E1_MICROSTEPS 128 #define E1_OVERCURRENT 2000 #define E1_STALLCURRENT 1500 + #define E1_MAX_VOLTAGE 127 + #define E1_CHAIN_POS 0 - #define E2_MICROSTEPS 16 + #define E2_MICROSTEPS 128 #define E2_OVERCURRENT 2000 #define E2_STALLCURRENT 1500 + #define E2_MAX_VOLTAGE 127 + #define E2_CHAIN_POS 0 - #define E3_MICROSTEPS 16 + #define E3_MICROSTEPS 128 #define E3_OVERCURRENT 2000 #define E3_STALLCURRENT 1500 + #define E3_MAX_VOLTAGE 127 + #define E3_CHAIN_POS 0 - #define E4_MICROSTEPS 16 + #define E4_MICROSTEPS 128 #define E4_OVERCURRENT 2000 #define E4_STALLCURRENT 1500 + #define E4_MAX_VOLTAGE 127 + #define E4_CHAIN_POS 0 - #define E5_MICROSTEPS 16 + #define E5_MICROSTEPS 128 #define E5_OVERCURRENT 2000 #define E5_STALLCURRENT 1500 + #define E5_MAX_VOLTAGE 127 + #define E5_CHAIN_POS 0 + + + /** + * Monitor L6470 drivers for error conditions like over temperature and over current. + * In the case of over temperature Marlin can decrease the drive until the error condition clears. + * Other detected conditions can be used to stop the current print. + * Relevant g-codes: + * M906 - I1/2/3/4/5 Set or get motor drive level using axis codes X, Y, Z, E. Report values if no axis codes given. + * I not present or I0 or I1 - X, Y, Z or E0 + * I2 - X2, Y2, Z2 or E1 + * I3 - Z3 or E3 + * I4 - E4 + * I5 - E5 + * M916 - Increase drive level until get thermal warning + * M917 - Find minimum current thresholds + * M918 - Increase speed until max or error + * M122 S0/1 - Report driver parameters + */ + //#define MONITOR_L6470_DRIVER_STATUS + + #if ENABLED(MONITOR_L6470_DRIVER_STATUS) + #define KVAL_HOLD_STEP_DOWN 1 + //#define L6470_STOP_ON_ERROR + #endif + + #define L6470_CHITCHAT // enable display of additional status info #endif // L6470 diff --git a/Marlin/src/config/examples/delta/FLSUN/kossel_mini/Configuration_adv.h b/Marlin/src/config/examples/delta/FLSUN/kossel_mini/Configuration_adv.h index 3e42f984e..079cacee4 100644 --- a/Marlin/src/config/examples/delta/FLSUN/kossel_mini/Configuration_adv.h +++ b/Marlin/src/config/examples/delta/FLSUN/kossel_mini/Configuration_adv.h @@ -1510,62 +1510,121 @@ /** * L6470 Stepper Driver options * - * The Arduino-L6470 library is required for this stepper driver. + * Arduino-L6470 library (0.7.0 or higher) is required for this stepper driver. * https://github.com/ameyer/Arduino-L6470 + * + * Requires the following to be defined in your pins_YOUR_BOARD file + * L6470_CHAIN_SCK_PIN + * L6470_CHAIN_MISO_PIN + * L6470_CHAIN_MOSI_PIN + * L6470_CHAIN_SS_PIN + * L6470_RESET_CHAIN_PIN (optional) */ #if HAS_DRIVER(L6470) - #define X_MICROSTEPS 16 // number of microsteps - #define X_OVERCURRENT 2000 // maxc current in mA. If the current goes over this value, the driver will switch off - #define X_STALLCURRENT 1500 // current in mA where the driver will detect a stall + #define X_MICROSTEPS 128 // number of microsteps (VALID: 1, 2, 4, 8, 16, 32, 128 & 128) + #define X_OVERCURRENT 2000 // current in mA where the driver will detect an over current (VALID: 375 x (1 - 16) - 6A max - rounds down) + #define X_STALLCURRENT 1500 // current in mA where the driver will detect a stall (VALID: 31.25 * (1-128) - 4A max - rounds down) + #define X_MAX_VOLTAGE 127 // 0-255, max effective voltage seen by stepper + #define X_CHAIN_POS 0 // position in SPI chain, 0 - not in chain, 1- nearest MOSI - #define X2_MICROSTEPS 16 + #define X2_MICROSTEPS 128 #define X2_OVERCURRENT 2000 #define X2_STALLCURRENT 1500 + #define X2_MAX_VOLTAGE 127 + #define X2_CHAIN_POS 0 - #define Y_MICROSTEPS 16 + #define Y_MICROSTEPS 128 #define Y_OVERCURRENT 2000 #define Y_STALLCURRENT 1500 + #define Y_MAX_VOLTAGE 127 + #define Y_CHAIN_POS 0 - #define Y2_MICROSTEPS 16 + #define Y2_MICROSTEPS 128 #define Y2_OVERCURRENT 2000 #define Y2_STALLCURRENT 1500 + #define Y2_MAX_VOLTAGE 127 + #define Y2_CHAIN_POS 0 - #define Z_MICROSTEPS 16 + #define Z_MICROSTEPS 128 #define Z_OVERCURRENT 2000 #define Z_STALLCURRENT 1500 + #define Z_MAX_VOLTAGE 127 + #define Z_CHAIN_POS 0 - #define Z2_MICROSTEPS 16 + #define Z2_MICROSTEPS 128 #define Z2_OVERCURRENT 2000 #define Z2_STALLCURRENT 1500 + #define Z2_MAX_VOLTAGE 127 + #define Z2_CHAIN_POS 0 - #define Z3_MICROSTEPS 16 + #define Z3_MICROSTEPS 128 #define Z3_OVERCURRENT 2000 #define Z3_STALLCURRENT 1500 + #define Z3_MAX_VOLTAGE 127 + #define Z3_CHAIN_POS 0 - #define E0_MICROSTEPS 16 + #define E0_MICROSTEPS 128 #define E0_OVERCURRENT 2000 #define E0_STALLCURRENT 1500 + #define E0_MAX_VOLTAGE 127 + #define E0_CHAIN_POS 0 - #define E1_MICROSTEPS 16 + #define E1_MICROSTEPS 128 #define E1_OVERCURRENT 2000 #define E1_STALLCURRENT 1500 + #define E1_MAX_VOLTAGE 127 + #define E1_CHAIN_POS 0 - #define E2_MICROSTEPS 16 + #define E2_MICROSTEPS 128 #define E2_OVERCURRENT 2000 #define E2_STALLCURRENT 1500 + #define E2_MAX_VOLTAGE 127 + #define E2_CHAIN_POS 0 - #define E3_MICROSTEPS 16 + #define E3_MICROSTEPS 128 #define E3_OVERCURRENT 2000 #define E3_STALLCURRENT 1500 + #define E3_MAX_VOLTAGE 127 + #define E3_CHAIN_POS 0 - #define E4_MICROSTEPS 16 + #define E4_MICROSTEPS 128 #define E4_OVERCURRENT 2000 #define E4_STALLCURRENT 1500 + #define E4_MAX_VOLTAGE 127 + #define E4_CHAIN_POS 0 - #define E5_MICROSTEPS 16 + #define E5_MICROSTEPS 128 #define E5_OVERCURRENT 2000 #define E5_STALLCURRENT 1500 + #define E5_MAX_VOLTAGE 127 + #define E5_CHAIN_POS 0 + + + /** + * Monitor L6470 drivers for error conditions like over temperature and over current. + * In the case of over temperature Marlin can decrease the drive until the error condition clears. + * Other detected conditions can be used to stop the current print. + * Relevant g-codes: + * M906 - I1/2/3/4/5 Set or get motor drive level using axis codes X, Y, Z, E. Report values if no axis codes given. + * I not present or I0 or I1 - X, Y, Z or E0 + * I2 - X2, Y2, Z2 or E1 + * I3 - Z3 or E3 + * I4 - E4 + * I5 - E5 + * M916 - Increase drive level until get thermal warning + * M917 - Find minimum current thresholds + * M918 - Increase speed until max or error + * M122 S0/1 - Report driver parameters + */ + //#define MONITOR_L6470_DRIVER_STATUS + + #if ENABLED(MONITOR_L6470_DRIVER_STATUS) + #define KVAL_HOLD_STEP_DOWN 1 + //#define L6470_STOP_ON_ERROR + #endif + + #define L6470_CHITCHAT // enable display of additional status info #endif // L6470 diff --git a/Marlin/src/config/examples/delta/Geeetech/Rostock 301/Configuration_adv.h b/Marlin/src/config/examples/delta/Geeetech/Rostock 301/Configuration_adv.h index 559580fe3..c2760e8bb 100644 --- a/Marlin/src/config/examples/delta/Geeetech/Rostock 301/Configuration_adv.h +++ b/Marlin/src/config/examples/delta/Geeetech/Rostock 301/Configuration_adv.h @@ -1483,62 +1483,121 @@ /** * L6470 Stepper Driver options * - * The Arduino-L6470 library is required for this stepper driver. + * Arduino-L6470 library (0.7.0 or higher) is required for this stepper driver. * https://github.com/ameyer/Arduino-L6470 + * + * Requires the following to be defined in your pins_YOUR_BOARD file + * L6470_CHAIN_SCK_PIN + * L6470_CHAIN_MISO_PIN + * L6470_CHAIN_MOSI_PIN + * L6470_CHAIN_SS_PIN + * L6470_RESET_CHAIN_PIN (optional) */ #if HAS_DRIVER(L6470) - #define X_MICROSTEPS 16 // number of microsteps - #define X_OVERCURRENT 2000 // maxc current in mA. If the current goes over this value, the driver will switch off - #define X_STALLCURRENT 1500 // current in mA where the driver will detect a stall + #define X_MICROSTEPS 128 // number of microsteps (VALID: 1, 2, 4, 8, 16, 32, 128 & 128) + #define X_OVERCURRENT 2000 // current in mA where the driver will detect an over current (VALID: 375 x (1 - 16) - 6A max - rounds down) + #define X_STALLCURRENT 1500 // current in mA where the driver will detect a stall (VALID: 31.25 * (1-128) - 4A max - rounds down) + #define X_MAX_VOLTAGE 127 // 0-255, max effective voltage seen by stepper + #define X_CHAIN_POS 0 // position in SPI chain, 0 - not in chain, 1- nearest MOSI - #define X2_MICROSTEPS 16 + #define X2_MICROSTEPS 128 #define X2_OVERCURRENT 2000 #define X2_STALLCURRENT 1500 + #define X2_MAX_VOLTAGE 127 + #define X2_CHAIN_POS 0 - #define Y_MICROSTEPS 16 + #define Y_MICROSTEPS 128 #define Y_OVERCURRENT 2000 #define Y_STALLCURRENT 1500 + #define Y_MAX_VOLTAGE 127 + #define Y_CHAIN_POS 0 - #define Y2_MICROSTEPS 16 + #define Y2_MICROSTEPS 128 #define Y2_OVERCURRENT 2000 #define Y2_STALLCURRENT 1500 + #define Y2_MAX_VOLTAGE 127 + #define Y2_CHAIN_POS 0 - #define Z_MICROSTEPS 16 + #define Z_MICROSTEPS 128 #define Z_OVERCURRENT 2000 #define Z_STALLCURRENT 1500 + #define Z_MAX_VOLTAGE 127 + #define Z_CHAIN_POS 0 - #define Z2_MICROSTEPS 16 + #define Z2_MICROSTEPS 128 #define Z2_OVERCURRENT 2000 #define Z2_STALLCURRENT 1500 + #define Z2_MAX_VOLTAGE 127 + #define Z2_CHAIN_POS 0 - #define Z3_MICROSTEPS 16 + #define Z3_MICROSTEPS 128 #define Z3_OVERCURRENT 2000 #define Z3_STALLCURRENT 1500 + #define Z3_MAX_VOLTAGE 127 + #define Z3_CHAIN_POS 0 - #define E0_MICROSTEPS 16 + #define E0_MICROSTEPS 128 #define E0_OVERCURRENT 2000 #define E0_STALLCURRENT 1500 + #define E0_MAX_VOLTAGE 127 + #define E0_CHAIN_POS 0 - #define E1_MICROSTEPS 16 + #define E1_MICROSTEPS 128 #define E1_OVERCURRENT 2000 #define E1_STALLCURRENT 1500 + #define E1_MAX_VOLTAGE 127 + #define E1_CHAIN_POS 0 - #define E2_MICROSTEPS 16 + #define E2_MICROSTEPS 128 #define E2_OVERCURRENT 2000 #define E2_STALLCURRENT 1500 + #define E2_MAX_VOLTAGE 127 + #define E2_CHAIN_POS 0 - #define E3_MICROSTEPS 16 + #define E3_MICROSTEPS 128 #define E3_OVERCURRENT 2000 #define E3_STALLCURRENT 1500 + #define E3_MAX_VOLTAGE 127 + #define E3_CHAIN_POS 0 - #define E4_MICROSTEPS 16 + #define E4_MICROSTEPS 128 #define E4_OVERCURRENT 2000 #define E4_STALLCURRENT 1500 + #define E4_MAX_VOLTAGE 127 + #define E4_CHAIN_POS 0 - #define E5_MICROSTEPS 16 + #define E5_MICROSTEPS 128 #define E5_OVERCURRENT 2000 #define E5_STALLCURRENT 1500 + #define E5_MAX_VOLTAGE 127 + #define E5_CHAIN_POS 0 + + + /** + * Monitor L6470 drivers for error conditions like over temperature and over current. + * In the case of over temperature Marlin can decrease the drive until the error condition clears. + * Other detected conditions can be used to stop the current print. + * Relevant g-codes: + * M906 - I1/2/3/4/5 Set or get motor drive level using axis codes X, Y, Z, E. Report values if no axis codes given. + * I not present or I0 or I1 - X, Y, Z or E0 + * I2 - X2, Y2, Z2 or E1 + * I3 - Z3 or E3 + * I4 - E4 + * I5 - E5 + * M916 - Increase drive level until get thermal warning + * M917 - Find minimum current thresholds + * M918 - Increase speed until max or error + * M122 S0/1 - Report driver parameters + */ + //#define MONITOR_L6470_DRIVER_STATUS + + #if ENABLED(MONITOR_L6470_DRIVER_STATUS) + #define KVAL_HOLD_STEP_DOWN 1 + //#define L6470_STOP_ON_ERROR + #endif + + #define L6470_CHITCHAT // enable display of additional status info #endif // L6470 diff --git a/Marlin/src/config/examples/delta/MKS/SBASE/Configuration_adv.h b/Marlin/src/config/examples/delta/MKS/SBASE/Configuration_adv.h index 2bd17bc01..4c52e4c88 100644 --- a/Marlin/src/config/examples/delta/MKS/SBASE/Configuration_adv.h +++ b/Marlin/src/config/examples/delta/MKS/SBASE/Configuration_adv.h @@ -1510,62 +1510,121 @@ /** * L6470 Stepper Driver options * - * The Arduino-L6470 library is required for this stepper driver. + * Arduino-L6470 library (0.7.0 or higher) is required for this stepper driver. * https://github.com/ameyer/Arduino-L6470 + * + * Requires the following to be defined in your pins_YOUR_BOARD file + * L6470_CHAIN_SCK_PIN + * L6470_CHAIN_MISO_PIN + * L6470_CHAIN_MOSI_PIN + * L6470_CHAIN_SS_PIN + * L6470_RESET_CHAIN_PIN (optional) */ #if HAS_DRIVER(L6470) - #define X_MICROSTEPS 16 // number of microsteps - #define X_OVERCURRENT 2000 // maxc current in mA. If the current goes over this value, the driver will switch off - #define X_STALLCURRENT 1500 // current in mA where the driver will detect a stall + #define X_MICROSTEPS 128 // number of microsteps (VALID: 1, 2, 4, 8, 16, 32, 128 & 128) + #define X_OVERCURRENT 2000 // current in mA where the driver will detect an over current (VALID: 375 x (1 - 16) - 6A max - rounds down) + #define X_STALLCURRENT 1500 // current in mA where the driver will detect a stall (VALID: 31.25 * (1-128) - 4A max - rounds down) + #define X_MAX_VOLTAGE 127 // 0-255, max effective voltage seen by stepper + #define X_CHAIN_POS 0 // position in SPI chain, 0 - not in chain, 1- nearest MOSI - #define X2_MICROSTEPS 16 + #define X2_MICROSTEPS 128 #define X2_OVERCURRENT 2000 #define X2_STALLCURRENT 1500 + #define X2_MAX_VOLTAGE 127 + #define X2_CHAIN_POS 0 - #define Y_MICROSTEPS 16 + #define Y_MICROSTEPS 128 #define Y_OVERCURRENT 2000 #define Y_STALLCURRENT 1500 + #define Y_MAX_VOLTAGE 127 + #define Y_CHAIN_POS 0 - #define Y2_MICROSTEPS 16 + #define Y2_MICROSTEPS 128 #define Y2_OVERCURRENT 2000 #define Y2_STALLCURRENT 1500 + #define Y2_MAX_VOLTAGE 127 + #define Y2_CHAIN_POS 0 - #define Z_MICROSTEPS 16 + #define Z_MICROSTEPS 128 #define Z_OVERCURRENT 2000 #define Z_STALLCURRENT 1500 + #define Z_MAX_VOLTAGE 127 + #define Z_CHAIN_POS 0 - #define Z2_MICROSTEPS 16 + #define Z2_MICROSTEPS 128 #define Z2_OVERCURRENT 2000 #define Z2_STALLCURRENT 1500 + #define Z2_MAX_VOLTAGE 127 + #define Z2_CHAIN_POS 0 - #define Z3_MICROSTEPS 16 + #define Z3_MICROSTEPS 128 #define Z3_OVERCURRENT 2000 #define Z3_STALLCURRENT 1500 + #define Z3_MAX_VOLTAGE 127 + #define Z3_CHAIN_POS 0 - #define E0_MICROSTEPS 16 + #define E0_MICROSTEPS 128 #define E0_OVERCURRENT 2000 #define E0_STALLCURRENT 1500 + #define E0_MAX_VOLTAGE 127 + #define E0_CHAIN_POS 0 - #define E1_MICROSTEPS 16 + #define E1_MICROSTEPS 128 #define E1_OVERCURRENT 2000 #define E1_STALLCURRENT 1500 + #define E1_MAX_VOLTAGE 127 + #define E1_CHAIN_POS 0 - #define E2_MICROSTEPS 16 + #define E2_MICROSTEPS 128 #define E2_OVERCURRENT 2000 #define E2_STALLCURRENT 1500 + #define E2_MAX_VOLTAGE 127 + #define E2_CHAIN_POS 0 - #define E3_MICROSTEPS 16 + #define E3_MICROSTEPS 128 #define E3_OVERCURRENT 2000 #define E3_STALLCURRENT 1500 + #define E3_MAX_VOLTAGE 127 + #define E3_CHAIN_POS 0 - #define E4_MICROSTEPS 16 + #define E4_MICROSTEPS 128 #define E4_OVERCURRENT 2000 #define E4_STALLCURRENT 1500 + #define E4_MAX_VOLTAGE 127 + #define E4_CHAIN_POS 0 - #define E5_MICROSTEPS 16 + #define E5_MICROSTEPS 128 #define E5_OVERCURRENT 2000 #define E5_STALLCURRENT 1500 + #define E5_MAX_VOLTAGE 127 + #define E5_CHAIN_POS 0 + + + /** + * Monitor L6470 drivers for error conditions like over temperature and over current. + * In the case of over temperature Marlin can decrease the drive until the error condition clears. + * Other detected conditions can be used to stop the current print. + * Relevant g-codes: + * M906 - I1/2/3/4/5 Set or get motor drive level using axis codes X, Y, Z, E. Report values if no axis codes given. + * I not present or I0 or I1 - X, Y, Z or E0 + * I2 - X2, Y2, Z2 or E1 + * I3 - Z3 or E3 + * I4 - E4 + * I5 - E5 + * M916 - Increase drive level until get thermal warning + * M917 - Find minimum current thresholds + * M918 - Increase speed until max or error + * M122 S0/1 - Report driver parameters + */ + //#define MONITOR_L6470_DRIVER_STATUS + + #if ENABLED(MONITOR_L6470_DRIVER_STATUS) + #define KVAL_HOLD_STEP_DOWN 1 + //#define L6470_STOP_ON_ERROR + #endif + + #define L6470_CHITCHAT // enable display of additional status info #endif // L6470 diff --git a/Marlin/src/config/examples/delta/Tevo Little Monster/Configuration_adv.h b/Marlin/src/config/examples/delta/Tevo Little Monster/Configuration_adv.h index c8792eccf..24de010da 100644 --- a/Marlin/src/config/examples/delta/Tevo Little Monster/Configuration_adv.h +++ b/Marlin/src/config/examples/delta/Tevo Little Monster/Configuration_adv.h @@ -1510,62 +1510,121 @@ /** * L6470 Stepper Driver options * - * The Arduino-L6470 library is required for this stepper driver. + * Arduino-L6470 library (0.7.0 or higher) is required for this stepper driver. * https://github.com/ameyer/Arduino-L6470 + * + * Requires the following to be defined in your pins_YOUR_BOARD file + * L6470_CHAIN_SCK_PIN + * L6470_CHAIN_MISO_PIN + * L6470_CHAIN_MOSI_PIN + * L6470_CHAIN_SS_PIN + * L6470_RESET_CHAIN_PIN (optional) */ #if HAS_DRIVER(L6470) - #define X_MICROSTEPS 16 // number of microsteps - #define X_OVERCURRENT 2000 // maxc current in mA. If the current goes over this value, the driver will switch off - #define X_STALLCURRENT 1500 // current in mA where the driver will detect a stall + #define X_MICROSTEPS 128 // number of microsteps (VALID: 1, 2, 4, 8, 16, 32, 128 & 128) + #define X_OVERCURRENT 2000 // current in mA where the driver will detect an over current (VALID: 375 x (1 - 16) - 6A max - rounds down) + #define X_STALLCURRENT 1500 // current in mA where the driver will detect a stall (VALID: 31.25 * (1-128) - 4A max - rounds down) + #define X_MAX_VOLTAGE 127 // 0-255, max effective voltage seen by stepper + #define X_CHAIN_POS 0 // position in SPI chain, 0 - not in chain, 1- nearest MOSI - #define X2_MICROSTEPS 16 + #define X2_MICROSTEPS 128 #define X2_OVERCURRENT 2000 #define X2_STALLCURRENT 1500 + #define X2_MAX_VOLTAGE 127 + #define X2_CHAIN_POS 0 - #define Y_MICROSTEPS 16 + #define Y_MICROSTEPS 128 #define Y_OVERCURRENT 2000 #define Y_STALLCURRENT 1500 + #define Y_MAX_VOLTAGE 127 + #define Y_CHAIN_POS 0 - #define Y2_MICROSTEPS 16 + #define Y2_MICROSTEPS 128 #define Y2_OVERCURRENT 2000 #define Y2_STALLCURRENT 1500 + #define Y2_MAX_VOLTAGE 127 + #define Y2_CHAIN_POS 0 - #define Z_MICROSTEPS 16 + #define Z_MICROSTEPS 128 #define Z_OVERCURRENT 2000 #define Z_STALLCURRENT 1500 + #define Z_MAX_VOLTAGE 127 + #define Z_CHAIN_POS 0 - #define Z2_MICROSTEPS 16 + #define Z2_MICROSTEPS 128 #define Z2_OVERCURRENT 2000 #define Z2_STALLCURRENT 1500 + #define Z2_MAX_VOLTAGE 127 + #define Z2_CHAIN_POS 0 - #define Z3_MICROSTEPS 16 + #define Z3_MICROSTEPS 128 #define Z3_OVERCURRENT 2000 #define Z3_STALLCURRENT 1500 + #define Z3_MAX_VOLTAGE 127 + #define Z3_CHAIN_POS 0 - #define E0_MICROSTEPS 16 + #define E0_MICROSTEPS 128 #define E0_OVERCURRENT 2000 #define E0_STALLCURRENT 1500 + #define E0_MAX_VOLTAGE 127 + #define E0_CHAIN_POS 0 - #define E1_MICROSTEPS 16 + #define E1_MICROSTEPS 128 #define E1_OVERCURRENT 2000 #define E1_STALLCURRENT 1500 + #define E1_MAX_VOLTAGE 127 + #define E1_CHAIN_POS 0 - #define E2_MICROSTEPS 16 + #define E2_MICROSTEPS 128 #define E2_OVERCURRENT 2000 #define E2_STALLCURRENT 1500 + #define E2_MAX_VOLTAGE 127 + #define E2_CHAIN_POS 0 - #define E3_MICROSTEPS 16 + #define E3_MICROSTEPS 128 #define E3_OVERCURRENT 2000 #define E3_STALLCURRENT 1500 + #define E3_MAX_VOLTAGE 127 + #define E3_CHAIN_POS 0 - #define E4_MICROSTEPS 16 + #define E4_MICROSTEPS 128 #define E4_OVERCURRENT 2000 #define E4_STALLCURRENT 1500 + #define E4_MAX_VOLTAGE 127 + #define E4_CHAIN_POS 0 - #define E5_MICROSTEPS 16 + #define E5_MICROSTEPS 128 #define E5_OVERCURRENT 2000 #define E5_STALLCURRENT 1500 + #define E5_MAX_VOLTAGE 127 + #define E5_CHAIN_POS 0 + + + /** + * Monitor L6470 drivers for error conditions like over temperature and over current. + * In the case of over temperature Marlin can decrease the drive until the error condition clears. + * Other detected conditions can be used to stop the current print. + * Relevant g-codes: + * M906 - I1/2/3/4/5 Set or get motor drive level using axis codes X, Y, Z, E. Report values if no axis codes given. + * I not present or I0 or I1 - X, Y, Z or E0 + * I2 - X2, Y2, Z2 or E1 + * I3 - Z3 or E3 + * I4 - E4 + * I5 - E5 + * M916 - Increase drive level until get thermal warning + * M917 - Find minimum current thresholds + * M918 - Increase speed until max or error + * M122 S0/1 - Report driver parameters + */ + //#define MONITOR_L6470_DRIVER_STATUS + + #if ENABLED(MONITOR_L6470_DRIVER_STATUS) + #define KVAL_HOLD_STEP_DOWN 1 + //#define L6470_STOP_ON_ERROR + #endif + + #define L6470_CHITCHAT // enable display of additional status info #endif // L6470 diff --git a/Marlin/src/config/examples/delta/generic/Configuration_adv.h b/Marlin/src/config/examples/delta/generic/Configuration_adv.h index 3e42f984e..079cacee4 100644 --- a/Marlin/src/config/examples/delta/generic/Configuration_adv.h +++ b/Marlin/src/config/examples/delta/generic/Configuration_adv.h @@ -1510,62 +1510,121 @@ /** * L6470 Stepper Driver options * - * The Arduino-L6470 library is required for this stepper driver. + * Arduino-L6470 library (0.7.0 or higher) is required for this stepper driver. * https://github.com/ameyer/Arduino-L6470 + * + * Requires the following to be defined in your pins_YOUR_BOARD file + * L6470_CHAIN_SCK_PIN + * L6470_CHAIN_MISO_PIN + * L6470_CHAIN_MOSI_PIN + * L6470_CHAIN_SS_PIN + * L6470_RESET_CHAIN_PIN (optional) */ #if HAS_DRIVER(L6470) - #define X_MICROSTEPS 16 // number of microsteps - #define X_OVERCURRENT 2000 // maxc current in mA. If the current goes over this value, the driver will switch off - #define X_STALLCURRENT 1500 // current in mA where the driver will detect a stall + #define X_MICROSTEPS 128 // number of microsteps (VALID: 1, 2, 4, 8, 16, 32, 128 & 128) + #define X_OVERCURRENT 2000 // current in mA where the driver will detect an over current (VALID: 375 x (1 - 16) - 6A max - rounds down) + #define X_STALLCURRENT 1500 // current in mA where the driver will detect a stall (VALID: 31.25 * (1-128) - 4A max - rounds down) + #define X_MAX_VOLTAGE 127 // 0-255, max effective voltage seen by stepper + #define X_CHAIN_POS 0 // position in SPI chain, 0 - not in chain, 1- nearest MOSI - #define X2_MICROSTEPS 16 + #define X2_MICROSTEPS 128 #define X2_OVERCURRENT 2000 #define X2_STALLCURRENT 1500 + #define X2_MAX_VOLTAGE 127 + #define X2_CHAIN_POS 0 - #define Y_MICROSTEPS 16 + #define Y_MICROSTEPS 128 #define Y_OVERCURRENT 2000 #define Y_STALLCURRENT 1500 + #define Y_MAX_VOLTAGE 127 + #define Y_CHAIN_POS 0 - #define Y2_MICROSTEPS 16 + #define Y2_MICROSTEPS 128 #define Y2_OVERCURRENT 2000 #define Y2_STALLCURRENT 1500 + #define Y2_MAX_VOLTAGE 127 + #define Y2_CHAIN_POS 0 - #define Z_MICROSTEPS 16 + #define Z_MICROSTEPS 128 #define Z_OVERCURRENT 2000 #define Z_STALLCURRENT 1500 + #define Z_MAX_VOLTAGE 127 + #define Z_CHAIN_POS 0 - #define Z2_MICROSTEPS 16 + #define Z2_MICROSTEPS 128 #define Z2_OVERCURRENT 2000 #define Z2_STALLCURRENT 1500 + #define Z2_MAX_VOLTAGE 127 + #define Z2_CHAIN_POS 0 - #define Z3_MICROSTEPS 16 + #define Z3_MICROSTEPS 128 #define Z3_OVERCURRENT 2000 #define Z3_STALLCURRENT 1500 + #define Z3_MAX_VOLTAGE 127 + #define Z3_CHAIN_POS 0 - #define E0_MICROSTEPS 16 + #define E0_MICROSTEPS 128 #define E0_OVERCURRENT 2000 #define E0_STALLCURRENT 1500 + #define E0_MAX_VOLTAGE 127 + #define E0_CHAIN_POS 0 - #define E1_MICROSTEPS 16 + #define E1_MICROSTEPS 128 #define E1_OVERCURRENT 2000 #define E1_STALLCURRENT 1500 + #define E1_MAX_VOLTAGE 127 + #define E1_CHAIN_POS 0 - #define E2_MICROSTEPS 16 + #define E2_MICROSTEPS 128 #define E2_OVERCURRENT 2000 #define E2_STALLCURRENT 1500 + #define E2_MAX_VOLTAGE 127 + #define E2_CHAIN_POS 0 - #define E3_MICROSTEPS 16 + #define E3_MICROSTEPS 128 #define E3_OVERCURRENT 2000 #define E3_STALLCURRENT 1500 + #define E3_MAX_VOLTAGE 127 + #define E3_CHAIN_POS 0 - #define E4_MICROSTEPS 16 + #define E4_MICROSTEPS 128 #define E4_OVERCURRENT 2000 #define E4_STALLCURRENT 1500 + #define E4_MAX_VOLTAGE 127 + #define E4_CHAIN_POS 0 - #define E5_MICROSTEPS 16 + #define E5_MICROSTEPS 128 #define E5_OVERCURRENT 2000 #define E5_STALLCURRENT 1500 + #define E5_MAX_VOLTAGE 127 + #define E5_CHAIN_POS 0 + + + /** + * Monitor L6470 drivers for error conditions like over temperature and over current. + * In the case of over temperature Marlin can decrease the drive until the error condition clears. + * Other detected conditions can be used to stop the current print. + * Relevant g-codes: + * M906 - I1/2/3/4/5 Set or get motor drive level using axis codes X, Y, Z, E. Report values if no axis codes given. + * I not present or I0 or I1 - X, Y, Z or E0 + * I2 - X2, Y2, Z2 or E1 + * I3 - Z3 or E3 + * I4 - E4 + * I5 - E5 + * M916 - Increase drive level until get thermal warning + * M917 - Find minimum current thresholds + * M918 - Increase speed until max or error + * M122 S0/1 - Report driver parameters + */ + //#define MONITOR_L6470_DRIVER_STATUS + + #if ENABLED(MONITOR_L6470_DRIVER_STATUS) + #define KVAL_HOLD_STEP_DOWN 1 + //#define L6470_STOP_ON_ERROR + #endif + + #define L6470_CHITCHAT // enable display of additional status info #endif // L6470 diff --git a/Marlin/src/config/examples/delta/kossel_mini/Configuration_adv.h b/Marlin/src/config/examples/delta/kossel_mini/Configuration_adv.h index 3e42f984e..079cacee4 100644 --- a/Marlin/src/config/examples/delta/kossel_mini/Configuration_adv.h +++ b/Marlin/src/config/examples/delta/kossel_mini/Configuration_adv.h @@ -1510,62 +1510,121 @@ /** * L6470 Stepper Driver options * - * The Arduino-L6470 library is required for this stepper driver. + * Arduino-L6470 library (0.7.0 or higher) is required for this stepper driver. * https://github.com/ameyer/Arduino-L6470 + * + * Requires the following to be defined in your pins_YOUR_BOARD file + * L6470_CHAIN_SCK_PIN + * L6470_CHAIN_MISO_PIN + * L6470_CHAIN_MOSI_PIN + * L6470_CHAIN_SS_PIN + * L6470_RESET_CHAIN_PIN (optional) */ #if HAS_DRIVER(L6470) - #define X_MICROSTEPS 16 // number of microsteps - #define X_OVERCURRENT 2000 // maxc current in mA. If the current goes over this value, the driver will switch off - #define X_STALLCURRENT 1500 // current in mA where the driver will detect a stall + #define X_MICROSTEPS 128 // number of microsteps (VALID: 1, 2, 4, 8, 16, 32, 128 & 128) + #define X_OVERCURRENT 2000 // current in mA where the driver will detect an over current (VALID: 375 x (1 - 16) - 6A max - rounds down) + #define X_STALLCURRENT 1500 // current in mA where the driver will detect a stall (VALID: 31.25 * (1-128) - 4A max - rounds down) + #define X_MAX_VOLTAGE 127 // 0-255, max effective voltage seen by stepper + #define X_CHAIN_POS 0 // position in SPI chain, 0 - not in chain, 1- nearest MOSI - #define X2_MICROSTEPS 16 + #define X2_MICROSTEPS 128 #define X2_OVERCURRENT 2000 #define X2_STALLCURRENT 1500 + #define X2_MAX_VOLTAGE 127 + #define X2_CHAIN_POS 0 - #define Y_MICROSTEPS 16 + #define Y_MICROSTEPS 128 #define Y_OVERCURRENT 2000 #define Y_STALLCURRENT 1500 + #define Y_MAX_VOLTAGE 127 + #define Y_CHAIN_POS 0 - #define Y2_MICROSTEPS 16 + #define Y2_MICROSTEPS 128 #define Y2_OVERCURRENT 2000 #define Y2_STALLCURRENT 1500 + #define Y2_MAX_VOLTAGE 127 + #define Y2_CHAIN_POS 0 - #define Z_MICROSTEPS 16 + #define Z_MICROSTEPS 128 #define Z_OVERCURRENT 2000 #define Z_STALLCURRENT 1500 + #define Z_MAX_VOLTAGE 127 + #define Z_CHAIN_POS 0 - #define Z2_MICROSTEPS 16 + #define Z2_MICROSTEPS 128 #define Z2_OVERCURRENT 2000 #define Z2_STALLCURRENT 1500 + #define Z2_MAX_VOLTAGE 127 + #define Z2_CHAIN_POS 0 - #define Z3_MICROSTEPS 16 + #define Z3_MICROSTEPS 128 #define Z3_OVERCURRENT 2000 #define Z3_STALLCURRENT 1500 + #define Z3_MAX_VOLTAGE 127 + #define Z3_CHAIN_POS 0 - #define E0_MICROSTEPS 16 + #define E0_MICROSTEPS 128 #define E0_OVERCURRENT 2000 #define E0_STALLCURRENT 1500 + #define E0_MAX_VOLTAGE 127 + #define E0_CHAIN_POS 0 - #define E1_MICROSTEPS 16 + #define E1_MICROSTEPS 128 #define E1_OVERCURRENT 2000 #define E1_STALLCURRENT 1500 + #define E1_MAX_VOLTAGE 127 + #define E1_CHAIN_POS 0 - #define E2_MICROSTEPS 16 + #define E2_MICROSTEPS 128 #define E2_OVERCURRENT 2000 #define E2_STALLCURRENT 1500 + #define E2_MAX_VOLTAGE 127 + #define E2_CHAIN_POS 0 - #define E3_MICROSTEPS 16 + #define E3_MICROSTEPS 128 #define E3_OVERCURRENT 2000 #define E3_STALLCURRENT 1500 + #define E3_MAX_VOLTAGE 127 + #define E3_CHAIN_POS 0 - #define E4_MICROSTEPS 16 + #define E4_MICROSTEPS 128 #define E4_OVERCURRENT 2000 #define E4_STALLCURRENT 1500 + #define E4_MAX_VOLTAGE 127 + #define E4_CHAIN_POS 0 - #define E5_MICROSTEPS 16 + #define E5_MICROSTEPS 128 #define E5_OVERCURRENT 2000 #define E5_STALLCURRENT 1500 + #define E5_MAX_VOLTAGE 127 + #define E5_CHAIN_POS 0 + + + /** + * Monitor L6470 drivers for error conditions like over temperature and over current. + * In the case of over temperature Marlin can decrease the drive until the error condition clears. + * Other detected conditions can be used to stop the current print. + * Relevant g-codes: + * M906 - I1/2/3/4/5 Set or get motor drive level using axis codes X, Y, Z, E. Report values if no axis codes given. + * I not present or I0 or I1 - X, Y, Z or E0 + * I2 - X2, Y2, Z2 or E1 + * I3 - Z3 or E3 + * I4 - E4 + * I5 - E5 + * M916 - Increase drive level until get thermal warning + * M917 - Find minimum current thresholds + * M918 - Increase speed until max or error + * M122 S0/1 - Report driver parameters + */ + //#define MONITOR_L6470_DRIVER_STATUS + + #if ENABLED(MONITOR_L6470_DRIVER_STATUS) + #define KVAL_HOLD_STEP_DOWN 1 + //#define L6470_STOP_ON_ERROR + #endif + + #define L6470_CHITCHAT // enable display of additional status info #endif // L6470 diff --git a/Marlin/src/config/examples/delta/kossel_xl/Configuration_adv.h b/Marlin/src/config/examples/delta/kossel_xl/Configuration_adv.h index 6241afcd6..9739ab8a2 100644 --- a/Marlin/src/config/examples/delta/kossel_xl/Configuration_adv.h +++ b/Marlin/src/config/examples/delta/kossel_xl/Configuration_adv.h @@ -1510,62 +1510,121 @@ /** * L6470 Stepper Driver options * - * The Arduino-L6470 library is required for this stepper driver. + * Arduino-L6470 library (0.7.0 or higher) is required for this stepper driver. * https://github.com/ameyer/Arduino-L6470 + * + * Requires the following to be defined in your pins_YOUR_BOARD file + * L6470_CHAIN_SCK_PIN + * L6470_CHAIN_MISO_PIN + * L6470_CHAIN_MOSI_PIN + * L6470_CHAIN_SS_PIN + * L6470_RESET_CHAIN_PIN (optional) */ #if HAS_DRIVER(L6470) - #define X_MICROSTEPS 16 // number of microsteps - #define X_OVERCURRENT 2000 // maxc current in mA. If the current goes over this value, the driver will switch off - #define X_STALLCURRENT 1500 // current in mA where the driver will detect a stall + #define X_MICROSTEPS 128 // number of microsteps (VALID: 1, 2, 4, 8, 16, 32, 128 & 128) + #define X_OVERCURRENT 2000 // current in mA where the driver will detect an over current (VALID: 375 x (1 - 16) - 6A max - rounds down) + #define X_STALLCURRENT 1500 // current in mA where the driver will detect a stall (VALID: 31.25 * (1-128) - 4A max - rounds down) + #define X_MAX_VOLTAGE 127 // 0-255, max effective voltage seen by stepper + #define X_CHAIN_POS 0 // position in SPI chain, 0 - not in chain, 1- nearest MOSI - #define X2_MICROSTEPS 16 + #define X2_MICROSTEPS 128 #define X2_OVERCURRENT 2000 #define X2_STALLCURRENT 1500 + #define X2_MAX_VOLTAGE 127 + #define X2_CHAIN_POS 0 - #define Y_MICROSTEPS 16 + #define Y_MICROSTEPS 128 #define Y_OVERCURRENT 2000 #define Y_STALLCURRENT 1500 + #define Y_MAX_VOLTAGE 127 + #define Y_CHAIN_POS 0 - #define Y2_MICROSTEPS 16 + #define Y2_MICROSTEPS 128 #define Y2_OVERCURRENT 2000 #define Y2_STALLCURRENT 1500 + #define Y2_MAX_VOLTAGE 127 + #define Y2_CHAIN_POS 0 - #define Z_MICROSTEPS 16 + #define Z_MICROSTEPS 128 #define Z_OVERCURRENT 2000 #define Z_STALLCURRENT 1500 + #define Z_MAX_VOLTAGE 127 + #define Z_CHAIN_POS 0 - #define Z2_MICROSTEPS 16 + #define Z2_MICROSTEPS 128 #define Z2_OVERCURRENT 2000 #define Z2_STALLCURRENT 1500 + #define Z2_MAX_VOLTAGE 127 + #define Z2_CHAIN_POS 0 - #define Z3_MICROSTEPS 16 + #define Z3_MICROSTEPS 128 #define Z3_OVERCURRENT 2000 #define Z3_STALLCURRENT 1500 + #define Z3_MAX_VOLTAGE 127 + #define Z3_CHAIN_POS 0 - #define E0_MICROSTEPS 16 + #define E0_MICROSTEPS 128 #define E0_OVERCURRENT 2000 #define E0_STALLCURRENT 1500 + #define E0_MAX_VOLTAGE 127 + #define E0_CHAIN_POS 0 - #define E1_MICROSTEPS 16 + #define E1_MICROSTEPS 128 #define E1_OVERCURRENT 2000 #define E1_STALLCURRENT 1500 + #define E1_MAX_VOLTAGE 127 + #define E1_CHAIN_POS 0 - #define E2_MICROSTEPS 16 + #define E2_MICROSTEPS 128 #define E2_OVERCURRENT 2000 #define E2_STALLCURRENT 1500 + #define E2_MAX_VOLTAGE 127 + #define E2_CHAIN_POS 0 - #define E3_MICROSTEPS 16 + #define E3_MICROSTEPS 128 #define E3_OVERCURRENT 2000 #define E3_STALLCURRENT 1500 + #define E3_MAX_VOLTAGE 127 + #define E3_CHAIN_POS 0 - #define E4_MICROSTEPS 16 + #define E4_MICROSTEPS 128 #define E4_OVERCURRENT 2000 #define E4_STALLCURRENT 1500 + #define E4_MAX_VOLTAGE 127 + #define E4_CHAIN_POS 0 - #define E5_MICROSTEPS 16 + #define E5_MICROSTEPS 128 #define E5_OVERCURRENT 2000 #define E5_STALLCURRENT 1500 + #define E5_MAX_VOLTAGE 127 + #define E5_CHAIN_POS 0 + + + /** + * Monitor L6470 drivers for error conditions like over temperature and over current. + * In the case of over temperature Marlin can decrease the drive until the error condition clears. + * Other detected conditions can be used to stop the current print. + * Relevant g-codes: + * M906 - I1/2/3/4/5 Set or get motor drive level using axis codes X, Y, Z, E. Report values if no axis codes given. + * I not present or I0 or I1 - X, Y, Z or E0 + * I2 - X2, Y2, Z2 or E1 + * I3 - Z3 or E3 + * I4 - E4 + * I5 - E5 + * M916 - Increase drive level until get thermal warning + * M917 - Find minimum current thresholds + * M918 - Increase speed until max or error + * M122 S0/1 - Report driver parameters + */ + //#define MONITOR_L6470_DRIVER_STATUS + + #if ENABLED(MONITOR_L6470_DRIVER_STATUS) + #define KVAL_HOLD_STEP_DOWN 1 + //#define L6470_STOP_ON_ERROR + #endif + + #define L6470_CHITCHAT // enable display of additional status info #endif // L6470 diff --git a/Marlin/src/config/examples/gCreate/gMax1.5+/Configuration_adv.h b/Marlin/src/config/examples/gCreate/gMax1.5+/Configuration_adv.h index 8aaef6ee1..e27d90d37 100644 --- a/Marlin/src/config/examples/gCreate/gMax1.5+/Configuration_adv.h +++ b/Marlin/src/config/examples/gCreate/gMax1.5+/Configuration_adv.h @@ -1508,62 +1508,121 @@ /** * L6470 Stepper Driver options * - * The Arduino-L6470 library is required for this stepper driver. + * Arduino-L6470 library (0.7.0 or higher) is required for this stepper driver. * https://github.com/ameyer/Arduino-L6470 + * + * Requires the following to be defined in your pins_YOUR_BOARD file + * L6470_CHAIN_SCK_PIN + * L6470_CHAIN_MISO_PIN + * L6470_CHAIN_MOSI_PIN + * L6470_CHAIN_SS_PIN + * L6470_RESET_CHAIN_PIN (optional) */ #if HAS_DRIVER(L6470) - #define X_MICROSTEPS 16 // number of microsteps - #define X_OVERCURRENT 2000 // maxc current in mA. If the current goes over this value, the driver will switch off - #define X_STALLCURRENT 1500 // current in mA where the driver will detect a stall + #define X_MICROSTEPS 128 // number of microsteps (VALID: 1, 2, 4, 8, 16, 32, 128 & 128) + #define X_OVERCURRENT 2000 // current in mA where the driver will detect an over current (VALID: 375 x (1 - 16) - 6A max - rounds down) + #define X_STALLCURRENT 1500 // current in mA where the driver will detect a stall (VALID: 31.25 * (1-128) - 4A max - rounds down) + #define X_MAX_VOLTAGE 127 // 0-255, max effective voltage seen by stepper + #define X_CHAIN_POS 0 // position in SPI chain, 0 - not in chain, 1- nearest MOSI - #define X2_MICROSTEPS 16 + #define X2_MICROSTEPS 128 #define X2_OVERCURRENT 2000 #define X2_STALLCURRENT 1500 + #define X2_MAX_VOLTAGE 127 + #define X2_CHAIN_POS 0 - #define Y_MICROSTEPS 16 + #define Y_MICROSTEPS 128 #define Y_OVERCURRENT 2000 #define Y_STALLCURRENT 1500 + #define Y_MAX_VOLTAGE 127 + #define Y_CHAIN_POS 0 - #define Y2_MICROSTEPS 16 + #define Y2_MICROSTEPS 128 #define Y2_OVERCURRENT 2000 #define Y2_STALLCURRENT 1500 + #define Y2_MAX_VOLTAGE 127 + #define Y2_CHAIN_POS 0 - #define Z_MICROSTEPS 16 + #define Z_MICROSTEPS 128 #define Z_OVERCURRENT 2000 #define Z_STALLCURRENT 1500 + #define Z_MAX_VOLTAGE 127 + #define Z_CHAIN_POS 0 - #define Z2_MICROSTEPS 16 + #define Z2_MICROSTEPS 128 #define Z2_OVERCURRENT 2000 #define Z2_STALLCURRENT 1500 + #define Z2_MAX_VOLTAGE 127 + #define Z2_CHAIN_POS 0 - #define Z3_MICROSTEPS 16 + #define Z3_MICROSTEPS 128 #define Z3_OVERCURRENT 2000 #define Z3_STALLCURRENT 1500 + #define Z3_MAX_VOLTAGE 127 + #define Z3_CHAIN_POS 0 - #define E0_MICROSTEPS 16 + #define E0_MICROSTEPS 128 #define E0_OVERCURRENT 2000 #define E0_STALLCURRENT 1500 + #define E0_MAX_VOLTAGE 127 + #define E0_CHAIN_POS 0 - #define E1_MICROSTEPS 16 + #define E1_MICROSTEPS 128 #define E1_OVERCURRENT 2000 #define E1_STALLCURRENT 1500 + #define E1_MAX_VOLTAGE 127 + #define E1_CHAIN_POS 0 - #define E2_MICROSTEPS 16 + #define E2_MICROSTEPS 128 #define E2_OVERCURRENT 2000 #define E2_STALLCURRENT 1500 + #define E2_MAX_VOLTAGE 127 + #define E2_CHAIN_POS 0 - #define E3_MICROSTEPS 16 + #define E3_MICROSTEPS 128 #define E3_OVERCURRENT 2000 #define E3_STALLCURRENT 1500 + #define E3_MAX_VOLTAGE 127 + #define E3_CHAIN_POS 0 - #define E4_MICROSTEPS 16 + #define E4_MICROSTEPS 128 #define E4_OVERCURRENT 2000 #define E4_STALLCURRENT 1500 + #define E4_MAX_VOLTAGE 127 + #define E4_CHAIN_POS 0 - #define E5_MICROSTEPS 16 + #define E5_MICROSTEPS 128 #define E5_OVERCURRENT 2000 #define E5_STALLCURRENT 1500 + #define E5_MAX_VOLTAGE 127 + #define E5_CHAIN_POS 0 + + + /** + * Monitor L6470 drivers for error conditions like over temperature and over current. + * In the case of over temperature Marlin can decrease the drive until the error condition clears. + * Other detected conditions can be used to stop the current print. + * Relevant g-codes: + * M906 - I1/2/3/4/5 Set or get motor drive level using axis codes X, Y, Z, E. Report values if no axis codes given. + * I not present or I0 or I1 - X, Y, Z or E0 + * I2 - X2, Y2, Z2 or E1 + * I3 - Z3 or E3 + * I4 - E4 + * I5 - E5 + * M916 - Increase drive level until get thermal warning + * M917 - Find minimum current thresholds + * M918 - Increase speed until max or error + * M122 S0/1 - Report driver parameters + */ + //#define MONITOR_L6470_DRIVER_STATUS + + #if ENABLED(MONITOR_L6470_DRIVER_STATUS) + #define KVAL_HOLD_STEP_DOWN 1 + //#define L6470_STOP_ON_ERROR + #endif + + #define L6470_CHITCHAT // enable display of additional status info #endif // L6470 diff --git a/Marlin/src/config/examples/makibox/Configuration_adv.h b/Marlin/src/config/examples/makibox/Configuration_adv.h index e1d901d38..e204b8220 100644 --- a/Marlin/src/config/examples/makibox/Configuration_adv.h +++ b/Marlin/src/config/examples/makibox/Configuration_adv.h @@ -1508,62 +1508,121 @@ /** * L6470 Stepper Driver options * - * The Arduino-L6470 library is required for this stepper driver. + * Arduino-L6470 library (0.7.0 or higher) is required for this stepper driver. * https://github.com/ameyer/Arduino-L6470 + * + * Requires the following to be defined in your pins_YOUR_BOARD file + * L6470_CHAIN_SCK_PIN + * L6470_CHAIN_MISO_PIN + * L6470_CHAIN_MOSI_PIN + * L6470_CHAIN_SS_PIN + * L6470_RESET_CHAIN_PIN (optional) */ #if HAS_DRIVER(L6470) - #define X_MICROSTEPS 16 // number of microsteps - #define X_OVERCURRENT 2000 // maxc current in mA. If the current goes over this value, the driver will switch off - #define X_STALLCURRENT 1500 // current in mA where the driver will detect a stall + #define X_MICROSTEPS 128 // number of microsteps (VALID: 1, 2, 4, 8, 16, 32, 128 & 128) + #define X_OVERCURRENT 2000 // current in mA where the driver will detect an over current (VALID: 375 x (1 - 16) - 6A max - rounds down) + #define X_STALLCURRENT 1500 // current in mA where the driver will detect a stall (VALID: 31.25 * (1-128) - 4A max - rounds down) + #define X_MAX_VOLTAGE 127 // 0-255, max effective voltage seen by stepper + #define X_CHAIN_POS 0 // position in SPI chain, 0 - not in chain, 1- nearest MOSI - #define X2_MICROSTEPS 16 + #define X2_MICROSTEPS 128 #define X2_OVERCURRENT 2000 #define X2_STALLCURRENT 1500 + #define X2_MAX_VOLTAGE 127 + #define X2_CHAIN_POS 0 - #define Y_MICROSTEPS 16 + #define Y_MICROSTEPS 128 #define Y_OVERCURRENT 2000 #define Y_STALLCURRENT 1500 + #define Y_MAX_VOLTAGE 127 + #define Y_CHAIN_POS 0 - #define Y2_MICROSTEPS 16 + #define Y2_MICROSTEPS 128 #define Y2_OVERCURRENT 2000 #define Y2_STALLCURRENT 1500 + #define Y2_MAX_VOLTAGE 127 + #define Y2_CHAIN_POS 0 - #define Z_MICROSTEPS 16 + #define Z_MICROSTEPS 128 #define Z_OVERCURRENT 2000 #define Z_STALLCURRENT 1500 + #define Z_MAX_VOLTAGE 127 + #define Z_CHAIN_POS 0 - #define Z2_MICROSTEPS 16 + #define Z2_MICROSTEPS 128 #define Z2_OVERCURRENT 2000 #define Z2_STALLCURRENT 1500 + #define Z2_MAX_VOLTAGE 127 + #define Z2_CHAIN_POS 0 - #define Z3_MICROSTEPS 16 + #define Z3_MICROSTEPS 128 #define Z3_OVERCURRENT 2000 #define Z3_STALLCURRENT 1500 + #define Z3_MAX_VOLTAGE 127 + #define Z3_CHAIN_POS 0 - #define E0_MICROSTEPS 16 + #define E0_MICROSTEPS 128 #define E0_OVERCURRENT 2000 #define E0_STALLCURRENT 1500 + #define E0_MAX_VOLTAGE 127 + #define E0_CHAIN_POS 0 - #define E1_MICROSTEPS 16 + #define E1_MICROSTEPS 128 #define E1_OVERCURRENT 2000 #define E1_STALLCURRENT 1500 + #define E1_MAX_VOLTAGE 127 + #define E1_CHAIN_POS 0 - #define E2_MICROSTEPS 16 + #define E2_MICROSTEPS 128 #define E2_OVERCURRENT 2000 #define E2_STALLCURRENT 1500 + #define E2_MAX_VOLTAGE 127 + #define E2_CHAIN_POS 0 - #define E3_MICROSTEPS 16 + #define E3_MICROSTEPS 128 #define E3_OVERCURRENT 2000 #define E3_STALLCURRENT 1500 + #define E3_MAX_VOLTAGE 127 + #define E3_CHAIN_POS 0 - #define E4_MICROSTEPS 16 + #define E4_MICROSTEPS 128 #define E4_OVERCURRENT 2000 #define E4_STALLCURRENT 1500 + #define E4_MAX_VOLTAGE 127 + #define E4_CHAIN_POS 0 - #define E5_MICROSTEPS 16 + #define E5_MICROSTEPS 128 #define E5_OVERCURRENT 2000 #define E5_STALLCURRENT 1500 + #define E5_MAX_VOLTAGE 127 + #define E5_CHAIN_POS 0 + + + /** + * Monitor L6470 drivers for error conditions like over temperature and over current. + * In the case of over temperature Marlin can decrease the drive until the error condition clears. + * Other detected conditions can be used to stop the current print. + * Relevant g-codes: + * M906 - I1/2/3/4/5 Set or get motor drive level using axis codes X, Y, Z, E. Report values if no axis codes given. + * I not present or I0 or I1 - X, Y, Z or E0 + * I2 - X2, Y2, Z2 or E1 + * I3 - Z3 or E3 + * I4 - E4 + * I5 - E5 + * M916 - Increase drive level until get thermal warning + * M917 - Find minimum current thresholds + * M918 - Increase speed until max or error + * M122 S0/1 - Report driver parameters + */ + //#define MONITOR_L6470_DRIVER_STATUS + + #if ENABLED(MONITOR_L6470_DRIVER_STATUS) + #define KVAL_HOLD_STEP_DOWN 1 + //#define L6470_STOP_ON_ERROR + #endif + + #define L6470_CHITCHAT // enable display of additional status info #endif // L6470 diff --git a/Marlin/src/config/examples/tvrrug/Round2/Configuration_adv.h b/Marlin/src/config/examples/tvrrug/Round2/Configuration_adv.h index d5b7ad3bd..d63dd2c4f 100644 --- a/Marlin/src/config/examples/tvrrug/Round2/Configuration_adv.h +++ b/Marlin/src/config/examples/tvrrug/Round2/Configuration_adv.h @@ -1508,62 +1508,121 @@ /** * L6470 Stepper Driver options * - * The Arduino-L6470 library is required for this stepper driver. + * Arduino-L6470 library (0.7.0 or higher) is required for this stepper driver. * https://github.com/ameyer/Arduino-L6470 + * + * Requires the following to be defined in your pins_YOUR_BOARD file + * L6470_CHAIN_SCK_PIN + * L6470_CHAIN_MISO_PIN + * L6470_CHAIN_MOSI_PIN + * L6470_CHAIN_SS_PIN + * L6470_RESET_CHAIN_PIN (optional) */ #if HAS_DRIVER(L6470) - #define X_MICROSTEPS 16 // number of microsteps - #define X_OVERCURRENT 2000 // maxc current in mA. If the current goes over this value, the driver will switch off - #define X_STALLCURRENT 1500 // current in mA where the driver will detect a stall + #define X_MICROSTEPS 128 // number of microsteps (VALID: 1, 2, 4, 8, 16, 32, 128 & 128) + #define X_OVERCURRENT 2000 // current in mA where the driver will detect an over current (VALID: 375 x (1 - 16) - 6A max - rounds down) + #define X_STALLCURRENT 1500 // current in mA where the driver will detect a stall (VALID: 31.25 * (1-128) - 4A max - rounds down) + #define X_MAX_VOLTAGE 127 // 0-255, max effective voltage seen by stepper + #define X_CHAIN_POS 0 // position in SPI chain, 0 - not in chain, 1- nearest MOSI - #define X2_MICROSTEPS 16 + #define X2_MICROSTEPS 128 #define X2_OVERCURRENT 2000 #define X2_STALLCURRENT 1500 + #define X2_MAX_VOLTAGE 127 + #define X2_CHAIN_POS 0 - #define Y_MICROSTEPS 16 + #define Y_MICROSTEPS 128 #define Y_OVERCURRENT 2000 #define Y_STALLCURRENT 1500 + #define Y_MAX_VOLTAGE 127 + #define Y_CHAIN_POS 0 - #define Y2_MICROSTEPS 16 + #define Y2_MICROSTEPS 128 #define Y2_OVERCURRENT 2000 #define Y2_STALLCURRENT 1500 + #define Y2_MAX_VOLTAGE 127 + #define Y2_CHAIN_POS 0 - #define Z_MICROSTEPS 16 + #define Z_MICROSTEPS 128 #define Z_OVERCURRENT 2000 #define Z_STALLCURRENT 1500 + #define Z_MAX_VOLTAGE 127 + #define Z_CHAIN_POS 0 - #define Z2_MICROSTEPS 16 + #define Z2_MICROSTEPS 128 #define Z2_OVERCURRENT 2000 #define Z2_STALLCURRENT 1500 + #define Z2_MAX_VOLTAGE 127 + #define Z2_CHAIN_POS 0 - #define Z3_MICROSTEPS 16 + #define Z3_MICROSTEPS 128 #define Z3_OVERCURRENT 2000 #define Z3_STALLCURRENT 1500 + #define Z3_MAX_VOLTAGE 127 + #define Z3_CHAIN_POS 0 - #define E0_MICROSTEPS 16 + #define E0_MICROSTEPS 128 #define E0_OVERCURRENT 2000 #define E0_STALLCURRENT 1500 + #define E0_MAX_VOLTAGE 127 + #define E0_CHAIN_POS 0 - #define E1_MICROSTEPS 16 + #define E1_MICROSTEPS 128 #define E1_OVERCURRENT 2000 #define E1_STALLCURRENT 1500 + #define E1_MAX_VOLTAGE 127 + #define E1_CHAIN_POS 0 - #define E2_MICROSTEPS 16 + #define E2_MICROSTEPS 128 #define E2_OVERCURRENT 2000 #define E2_STALLCURRENT 1500 + #define E2_MAX_VOLTAGE 127 + #define E2_CHAIN_POS 0 - #define E3_MICROSTEPS 16 + #define E3_MICROSTEPS 128 #define E3_OVERCURRENT 2000 #define E3_STALLCURRENT 1500 + #define E3_MAX_VOLTAGE 127 + #define E3_CHAIN_POS 0 - #define E4_MICROSTEPS 16 + #define E4_MICROSTEPS 128 #define E4_OVERCURRENT 2000 #define E4_STALLCURRENT 1500 + #define E4_MAX_VOLTAGE 127 + #define E4_CHAIN_POS 0 - #define E5_MICROSTEPS 16 + #define E5_MICROSTEPS 128 #define E5_OVERCURRENT 2000 #define E5_STALLCURRENT 1500 + #define E5_MAX_VOLTAGE 127 + #define E5_CHAIN_POS 0 + + + /** + * Monitor L6470 drivers for error conditions like over temperature and over current. + * In the case of over temperature Marlin can decrease the drive until the error condition clears. + * Other detected conditions can be used to stop the current print. + * Relevant g-codes: + * M906 - I1/2/3/4/5 Set or get motor drive level using axis codes X, Y, Z, E. Report values if no axis codes given. + * I not present or I0 or I1 - X, Y, Z or E0 + * I2 - X2, Y2, Z2 or E1 + * I3 - Z3 or E3 + * I4 - E4 + * I5 - E5 + * M916 - Increase drive level until get thermal warning + * M917 - Find minimum current thresholds + * M918 - Increase speed until max or error + * M122 S0/1 - Report driver parameters + */ + //#define MONITOR_L6470_DRIVER_STATUS + + #if ENABLED(MONITOR_L6470_DRIVER_STATUS) + #define KVAL_HOLD_STEP_DOWN 1 + //#define L6470_STOP_ON_ERROR + #endif + + #define L6470_CHITCHAT // enable display of additional status info #endif // L6470 diff --git a/Marlin/src/config/examples/wt150/Configuration_adv.h b/Marlin/src/config/examples/wt150/Configuration_adv.h index c13e95341..785b5ffdc 100644 --- a/Marlin/src/config/examples/wt150/Configuration_adv.h +++ b/Marlin/src/config/examples/wt150/Configuration_adv.h @@ -1509,62 +1509,121 @@ /** * L6470 Stepper Driver options * - * The Arduino-L6470 library is required for this stepper driver. + * Arduino-L6470 library (0.7.0 or higher) is required for this stepper driver. * https://github.com/ameyer/Arduino-L6470 + * + * Requires the following to be defined in your pins_YOUR_BOARD file + * L6470_CHAIN_SCK_PIN + * L6470_CHAIN_MISO_PIN + * L6470_CHAIN_MOSI_PIN + * L6470_CHAIN_SS_PIN + * L6470_RESET_CHAIN_PIN (optional) */ #if HAS_DRIVER(L6470) - #define X_MICROSTEPS 16 // number of microsteps - #define X_OVERCURRENT 2000 // maxc current in mA. If the current goes over this value, the driver will switch off - #define X_STALLCURRENT 1500 // current in mA where the driver will detect a stall + #define X_MICROSTEPS 128 // number of microsteps (VALID: 1, 2, 4, 8, 16, 32, 128 & 128) + #define X_OVERCURRENT 2000 // current in mA where the driver will detect an over current (VALID: 375 x (1 - 16) - 6A max - rounds down) + #define X_STALLCURRENT 1500 // current in mA where the driver will detect a stall (VALID: 31.25 * (1-128) - 4A max - rounds down) + #define X_MAX_VOLTAGE 127 // 0-255, max effective voltage seen by stepper + #define X_CHAIN_POS 0 // position in SPI chain, 0 - not in chain, 1- nearest MOSI - #define X2_MICROSTEPS 16 + #define X2_MICROSTEPS 128 #define X2_OVERCURRENT 2000 #define X2_STALLCURRENT 1500 + #define X2_MAX_VOLTAGE 127 + #define X2_CHAIN_POS 0 - #define Y_MICROSTEPS 16 + #define Y_MICROSTEPS 128 #define Y_OVERCURRENT 2000 #define Y_STALLCURRENT 1500 + #define Y_MAX_VOLTAGE 127 + #define Y_CHAIN_POS 0 - #define Y2_MICROSTEPS 16 + #define Y2_MICROSTEPS 128 #define Y2_OVERCURRENT 2000 #define Y2_STALLCURRENT 1500 + #define Y2_MAX_VOLTAGE 127 + #define Y2_CHAIN_POS 0 - #define Z_MICROSTEPS 16 + #define Z_MICROSTEPS 128 #define Z_OVERCURRENT 2000 #define Z_STALLCURRENT 1500 + #define Z_MAX_VOLTAGE 127 + #define Z_CHAIN_POS 0 - #define Z2_MICROSTEPS 16 + #define Z2_MICROSTEPS 128 #define Z2_OVERCURRENT 2000 #define Z2_STALLCURRENT 1500 + #define Z2_MAX_VOLTAGE 127 + #define Z2_CHAIN_POS 0 - #define Z3_MICROSTEPS 16 + #define Z3_MICROSTEPS 128 #define Z3_OVERCURRENT 2000 #define Z3_STALLCURRENT 1500 + #define Z3_MAX_VOLTAGE 127 + #define Z3_CHAIN_POS 0 - #define E0_MICROSTEPS 16 + #define E0_MICROSTEPS 128 #define E0_OVERCURRENT 2000 #define E0_STALLCURRENT 1500 + #define E0_MAX_VOLTAGE 127 + #define E0_CHAIN_POS 0 - #define E1_MICROSTEPS 16 + #define E1_MICROSTEPS 128 #define E1_OVERCURRENT 2000 #define E1_STALLCURRENT 1500 + #define E1_MAX_VOLTAGE 127 + #define E1_CHAIN_POS 0 - #define E2_MICROSTEPS 16 + #define E2_MICROSTEPS 128 #define E2_OVERCURRENT 2000 #define E2_STALLCURRENT 1500 + #define E2_MAX_VOLTAGE 127 + #define E2_CHAIN_POS 0 - #define E3_MICROSTEPS 16 + #define E3_MICROSTEPS 128 #define E3_OVERCURRENT 2000 #define E3_STALLCURRENT 1500 + #define E3_MAX_VOLTAGE 127 + #define E3_CHAIN_POS 0 - #define E4_MICROSTEPS 16 + #define E4_MICROSTEPS 128 #define E4_OVERCURRENT 2000 #define E4_STALLCURRENT 1500 + #define E4_MAX_VOLTAGE 127 + #define E4_CHAIN_POS 0 - #define E5_MICROSTEPS 16 + #define E5_MICROSTEPS 128 #define E5_OVERCURRENT 2000 #define E5_STALLCURRENT 1500 + #define E5_MAX_VOLTAGE 127 + #define E5_CHAIN_POS 0 + + + /** + * Monitor L6470 drivers for error conditions like over temperature and over current. + * In the case of over temperature Marlin can decrease the drive until the error condition clears. + * Other detected conditions can be used to stop the current print. + * Relevant g-codes: + * M906 - I1/2/3/4/5 Set or get motor drive level using axis codes X, Y, Z, E. Report values if no axis codes given. + * I not present or I0 or I1 - X, Y, Z or E0 + * I2 - X2, Y2, Z2 or E1 + * I3 - Z3 or E3 + * I4 - E4 + * I5 - E5 + * M916 - Increase drive level until get thermal warning + * M917 - Find minimum current thresholds + * M918 - Increase speed until max or error + * M122 S0/1 - Report driver parameters + */ + //#define MONITOR_L6470_DRIVER_STATUS + + #if ENABLED(MONITOR_L6470_DRIVER_STATUS) + #define KVAL_HOLD_STEP_DOWN 1 + //#define L6470_STOP_ON_ERROR + #endif + + #define L6470_CHITCHAT // enable display of additional status info #endif // L6470 diff --git a/Marlin/src/core/enum.h b/Marlin/src/core/enum.h index 7abfe0bb8..0a37018f0 100644 --- a/Marlin/src/core/enum.h +++ b/Marlin/src/core/enum.h @@ -43,6 +43,10 @@ enum AxisEnum : unsigned char { NO_AXIS = 0xFF }; +#if HAS_DRIVER(L6470) + enum L6470_driver_enum : unsigned char { X, Y, Z, X2, Y2, Z2, Z3, E0, E1, E2, E3, E4, E5 }; +#endif + #define LOOP_S_LE_N(VAR, S, N) for (uint8_t VAR=(S); VAR<=(N); VAR++) #define LOOP_S_L_N(VAR, S, N) for (uint8_t VAR=(S); VAR<(N); VAR++) #define LOOP_LE_N(VAR, N) LOOP_S_LE_N(VAR, 0, N) diff --git a/Marlin/src/core/utility.cpp b/Marlin/src/core/utility.cpp index 7491dd751..17a52921c 100644 --- a/Marlin/src/core/utility.cpp +++ b/Marlin/src/core/utility.cpp @@ -441,3 +441,10 @@ void safe_delay(millis_t ms) { } #endif // DEBUG_LEVELING_FEATURE + +void print_bin(const uint16_t val) { + for (uint8_t i = 16; i--;) { + SERIAL_ECHO(TEST(val, i)); + if (!(i & 0x3)) SERIAL_CHAR(' '); + } +} diff --git a/Marlin/src/core/utility.h b/Marlin/src/core/utility.h index f4944299a..b59500f0c 100644 --- a/Marlin/src/core/utility.h +++ b/Marlin/src/core/utility.h @@ -119,3 +119,5 @@ inline void serial_delay(const millis_t ms) { #if ENABLED(DEBUG_LEVELING_FEATURE) void log_machine_info(); #endif + +void print_bin(const uint16_t val); diff --git a/Marlin/src/feature/pause.cpp b/Marlin/src/feature/pause.cpp index f1fdde6cc..fb26bbded 100644 --- a/Marlin/src/feature/pause.cpp +++ b/Marlin/src/feature/pause.cpp @@ -294,7 +294,7 @@ bool unload_filament(const float &unload_length, const bool show_lcd/*=false*/, #endif // Disable extruders steppers for manual filament changing (only on boards that have separate ENABLE_PINS) - #if (E0_ENABLE_PIN != X_ENABLE_PIN && E1_ENABLE_PIN != Y_ENABLE_PIN) || AXIS_DRIVER_TYPE(E0, TMC2660) || AXIS_DRIVER_TYPE(E1, TMC2660) || AXIS_DRIVER_TYPE(E2, TMC2660) || AXIS_DRIVER_TYPE(E3, TMC2660) || AXIS_DRIVER_TYPE(E4, TMC2660) || AXIS_DRIVER_TYPE(E5, TMC2660) + #if (E0_ENABLE_PIN != X_ENABLE_PIN && E1_ENABLE_PIN != Y_ENABLE_PIN) || AXIS_DRIVER_TYPE_E0(TMC2660) || AXIS_DRIVER_TYPE_E1(TMC2660) || AXIS_DRIVER_TYPE_E2(TMC2660) || AXIS_DRIVER_TYPE_E3(TMC2660) || AXIS_DRIVER_TYPE_E4(TMC2660) || AXIS_DRIVER_TYPE_E5(TMC2660) disable_e_stepper(active_extruder); safe_delay(100); #endif diff --git a/Marlin/src/gcode/calibrate/G28.cpp b/Marlin/src/gcode/calibrate/G28.cpp index 479af9583..defb0f62e 100644 --- a/Marlin/src/gcode/calibrate/G28.cpp +++ b/Marlin/src/gcode/calibrate/G28.cpp @@ -45,6 +45,10 @@ #include "../../lcd/ultralcd.h" +#if HAS_DRIVER(L6470) // set L6470 absolute position registers to counts + #include "../../libs/L6470/L6470_Marlin.h" +#endif + #if ENABLED(QUICK_HOME) static void quick_home_xy() { @@ -440,4 +444,12 @@ void GcodeSuite::G28(const bool always_home_all) { #if ENABLED(DEBUG_LEVELING_FEATURE) if (DEBUGGING(LEVELING)) SERIAL_ECHOLNPGM("<<< G28"); #endif + + #if HAS_DRIVER(L6470) + // Set L6470 absolute position registers to counts + for (uint8_t j = 1; j <= L6470::chain[0]; j++) { + const uint8_t cv = L6470::chain[j]; + L6470.set_param(cv, L6470_ABS_POS, stepper.position((AxisEnum)L6470.axis_xref[cv])); + } + #endif } diff --git a/Marlin/src/gcode/control/M17_M18_M84.cpp b/Marlin/src/gcode/control/M17_M18_M84.cpp index 354152477..3e123b404 100644 --- a/Marlin/src/gcode/control/M17_M18_M84.cpp +++ b/Marlin/src/gcode/control/M17_M18_M84.cpp @@ -55,7 +55,7 @@ void GcodeSuite::M18_M84() { if (parser.seen('Y')) disable_Y(); if (parser.seen('Z')) disable_Z(); // Only disable on boards that have separate ENABLE_PINS or another method for disabling the driver - #if (E0_ENABLE_PIN != X_ENABLE_PIN && E1_ENABLE_PIN != Y_ENABLE_PIN) || AXIS_DRIVER_TYPE(E0, TMC2660) || AXIS_DRIVER_TYPE(E1, TMC2660) || AXIS_DRIVER_TYPE(E2, TMC2660) || AXIS_DRIVER_TYPE(E3, TMC2660) || AXIS_DRIVER_TYPE(E4, TMC2660) || AXIS_DRIVER_TYPE(E5, TMC2660) + #if (E0_ENABLE_PIN != X_ENABLE_PIN && E1_ENABLE_PIN != Y_ENABLE_PIN) || AXIS_DRIVER_TYPE_E0(TMC2660) || AXIS_DRIVER_TYPE_E1(TMC2660) || AXIS_DRIVER_TYPE_E2(TMC2660) || AXIS_DRIVER_TYPE_E3(TMC2660) || AXIS_DRIVER_TYPE_E4(TMC2660) || AXIS_DRIVER_TYPE_E5(TMC2660) if (parser.seen('E')) disable_e_steppers(); #endif } diff --git a/Marlin/src/gcode/feature/L6470/M122.cpp b/Marlin/src/gcode/feature/L6470/M122.cpp new file mode 100644 index 000000000..85dc15da1 --- /dev/null +++ b/Marlin/src/gcode/feature/L6470/M122.cpp @@ -0,0 +1,115 @@ +/** + * Marlin 3D Printer Firmware + * Copyright (C) 2016 MarlinFirmware [https://github.com/MarlinFirmware/Marlin] + * + * Based on Sprinter and grbl. + * Copyright (C) 2011 Camiel Gubbels / Erik van der Zalm + * + * This program 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. + * + * This program 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 this program. If not, see . + * + */ + +#include "../../../inc/MarlinConfig.h" + +#if HAS_DRIVER(L6470) + +#include "../../gcode.h" +#include "../../../libs/L6470/L6470_Marlin.h" +#include "../../../module/stepper_indirection.h" + +inline void echo_yes_no(const bool yes) { serialprintPGM(yes ? PSTR(" YES") : PSTR(" NO ")); } + +void L6470_status_decode(const uint16_t status, const uint8_t axis) { + if (L6470.spi_abort) return; // don't do anything if set_directions() has occurred + L6470.say_axis(axis); + #if ENABLED(L6470_CHITCHAT) + char temp_buf[20]; + sprintf_P(temp_buf, PSTR(" status: %4x "), status); + SERIAL_ECHO(temp_buf); + print_bin(status); + #endif + SERIAL_ECHOPGM("\n...OUTPUT: "); + serialprintPGM(status & STATUS_HIZ ? PSTR("OFF") : PSTR("ON ")); + SERIAL_ECHOPGM(" BUSY: "); echo_yes_no(!(status & STATUS_BUSY)); + SERIAL_ECHOPGM(" DIR: "); + serialprintPGM((((status & STATUS_DIR) >> 4) ^ L6470.index_to_dir[axis]) ? PSTR("FORWARD") : PSTR("REVERSE")); + SERIAL_ECHOPGM(" Last Command: "); + if (status & STATUS_WRONG_CMD) SERIAL_ECHOPGM("IN"); + SERIAL_ECHOPGM("VALID "); + serialprintPGM(status & STATUS_NOTPERF_CMD ? PSTR("Not PERFORMED") : PSTR("COMPLETED ")); + SERIAL_ECHOPAIR("\n...THERMAL: ", !(status & STATUS_TH_SD) ? "SHUTDOWN" : !(status & STATUS_TH_WRN) ? "WARNING " : "OK "); + SERIAL_ECHOPGM(" OVERCURRENT:"); echo_yes_no(!(status & STATUS_OCD)); + SERIAL_ECHOPGM(" STALL:"); echo_yes_no(!(status & STATUS_STEP_LOSS_A) || !(status & STATUS_STEP_LOSS_B)); + SERIAL_ECHOPGM(" STEP-CLOCK MODE:"); echo_yes_no(status & STATUS_SCK_MOD); + SERIAL_EOL(); +} + +/** + * M122: Debug L6470 drivers + */ +void GcodeSuite::M122() { + + L6470.spi_active = true; // let set_directions() know we're in the middle of a series of SPI transfers + + #define L6470_SAY_STATUS(Q) L6470_status_decode(stepper##Q.getStatus(), Q) + + //if (parser.seen('S')) + // tmc_set_report_status(parser.value_bool()); + //else + + #if AXIS_DRIVER_TYPE_X(L6470) + L6470_SAY_STATUS(X); + #endif + #if AXIS_DRIVER_TYPE_X2(L6470) + L6470_SAY_STATUS(X2); + #endif + #if AXIS_DRIVER_TYPE_Y(L6470) + L6470_SAY_STATUS(Y); + #endif + #if AXIS_DRIVER_TYPE_Y2(L6470) + L6470_SAY_STATUS(Y2); + #endif + #if AXIS_DRIVER_TYPE_Z(L6470) + L6470_SAY_STATUS(Z); + #endif + #if AXIS_DRIVER_TYPE_Z2(L6470) + L6470_SAY_STATUS(Z2); + #endif + #if AXIS_DRIVER_TYPE_Z3(L6470) + L6470_SAY_STATUS(Z3); + #endif + #if AXIS_DRIVER_TYPE_E0(L6470) + L6470_SAY_STATUS(E0); + #endif + #if AXIS_DRIVER_TYPE_E1(L6470) + L6470_SAY_STATUS(E1); + #endif + #if AXIS_DRIVER_TYPE_E2(L6470) + L6470_SAY_STATUS(E2); + #endif + #if AXIS_DRIVER_TYPE_E3(L6470) + L6470_SAY_STATUS(E3); + #endif + #if AXIS_DRIVER_TYPE_E4(L6470) + L6470_SAY_STATUS(E4); + #endif + #if AXIS_DRIVER_TYPE_E5(L6470) + L6470_SAY_STATUS(E5); + #endif + + L6470.spi_active = false; // done with all SPI transfers - clear handshake flags + L6470.spi_abort = false; +} + +#endif // HAS_DRIVER(L6470) diff --git a/Marlin/src/gcode/feature/L6470/M906.cpp b/Marlin/src/gcode/feature/L6470/M906.cpp new file mode 100644 index 000000000..b30375cb2 --- /dev/null +++ b/Marlin/src/gcode/feature/L6470/M906.cpp @@ -0,0 +1,259 @@ +/** + * Marlin 3D Printer Firmware + * Copyright (C) 2018 MarlinFirmware [https://github.com/MarlinFirmware/Marlin] + * + * Based on Sprinter and grbl. + * Copyright (C) 2011 Camiel Gubbels / Erik van der Zalm + * + * This program 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. + * + * This program 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 this program. If not, see . + * + */ + +#include "../../../inc/MarlinConfig.h" + +#if HAS_DRIVER(L6470) + +#include "../../gcode.h" +#include "../../../libs/L6470/L6470_Marlin.h" +#include "../../../module/stepper_indirection.h" +#include "../../../module/planner.h" + +/** + * + * M906: report or set KVAL_HOLD which sets the maximum effective voltage provided by the + * PWMs to the steppers + * + * J - select which driver(s) to monitor on multi-driver axis + * 0 - (default) monitor all drivers on the axis or E0 + * 1 - monitor only X, Y, Z or E1 + * 2 - monitor only X2, Y2, Z2 or E2 + * 3 - monitor only Z3 or E3 + * 4 - monitor only E4 + * 5 - monitor only E5 + * Xxxx, Yxxx, Zxxx, Exxx - axis to be monitored with displacement + * xxx (1-255) is distance moved on either side of current position + * + * I - over current threshold + * optional - will report current value from driver if not specified + * + * K - value for KVAL_HOLD (0 - 255) (optional) + * optional - will report current value from driver if not specified + * + */ + +/** + * Sets KVAL_HOLD wich affects the current being driven through the stepper. + * + * L6470 is used in the STEP-CLOCK mode. KVAL_HOLD is the only KVAL_xxx + * that affects the effective voltage seen by the stepper. + * + */ + +/** + * MACRO to fetch information on the items associated with current limiting + * and maximum voltage output. + * + * L6470 can be setup to shutdown if either current threshold is exceeded. + * + * L6470 output current can not be set directly. It is set indirectly by + * setting the maximum effective output voltage. + * + * Effective output voltage is set by PWM duty cycle. + * + * Maximum effective output voltage is affected by MANY variables. The main ones are: + * KVAL_HOLD + * KVAL_RUN + * KVAL_ACC + * KVAL_DEC + * Vs compensation (if enabled) + */ + +void L6470_report_current(L6470 &motor, const uint8_t axis) { + if (L6470.spi_abort) return; // don't do anything if set_directions() has occurred + const uint16_t status = motor.getStatus() ; + const uint8_t overcurrent_threshold = (uint8_t)motor.GetParam(L6470_OCD_TH), + stall_threshold = (uint8_t)motor.GetParam(L6470_STALL_TH), + motor_status = (status & (STATUS_MOT_STATUS)) >> 13, + adc_out = motor.GetParam(L6470_ADC_OUT), + adc_out_limited = constrain(adc_out, 8, 24); + const float comp_coef = 1600.0f / adc_out_limited; + const int microsteps = _BV(motor.GetParam(L6470_STEP_MODE) & 0x07); + char temp_buf[80]; + L6470.say_axis(axis); + #if ENABLED(L6470_CHITCHAT) + sprintf_P(temp_buf, PSTR(" status: %4x "), status); + SERIAL_ECHO(temp_buf); + print_bin(status); + #endif + sprintf_P(temp_buf, PSTR("\n...OverCurrent Threshold: %2d (%4d mA)"), overcurrent_threshold, (overcurrent_threshold + 1) * 375); + SERIAL_ECHO(temp_buf); + sprintf_P(temp_buf, PSTR(" Stall Threshold: %2d (%7.2f mA)"), stall_threshold, (stall_threshold + 1) * 31.25); + SERIAL_ECHO(temp_buf); + SERIAL_ECHOPGM(" Motor Status: "); + const char * const stat_str; + switch (motor_status) { + default: + case 0: stat_str = PSTR("stopped"); break; + case 1: stat_str = PSTR("accelerating"); break; + case 2: stat_str = PSTR("decelerating"); break; + case 3: stat_str = PSTR("at constant speed"); break; + } + serialprintPGM(stat_str); + SERIAL_EOL(); + SERIAL_ECHOPAIR("...microsteps: ", microsteps); + SERIAL_ECHOPAIR(" ADC_OUT: ", adc_out); + SERIAL_ECHOPGM(" Vs_compensation: "); + serialprintPGM((motor.GetParam(L6470_CONFIG) & CONFIG_EN_VSCOMP) ? PSTR("ENABLED ") : PSTR("DISABLED")); + sprintf_P(temp_buf, PSTR(" Compensation coefficient: ~%4.2f\n"), comp_coef * 0.01f); + SERIAL_ECHO(temp_buf); + SERIAL_ECHOPAIR("...KVAL_HOLD: ", motor.GetParam(L6470_KVAL_HOLD)); + SERIAL_ECHOPAIR(" KVAL_RUN : ", motor.GetParam(L6470_KVAL_RUN)); + SERIAL_ECHOPAIR(" KVAL_ACC: ", motor.GetParam(L6470_KVAL_ACC)); + SERIAL_ECHOPAIR(" KVAL_DEC: ", motor.GetParam(L6470_KVAL_DEC)); + SERIAL_ECHOPGM(" V motor max = "); + switch (motor_status) { + case 0: sprintf_P(temp_buf, PSTR(" %4.1f%% (KVAL_HOLD)\n"), float(motor.GetParam(L6470_KVAL_HOLD)) * 100 / 256); break; + case 1: sprintf_P(temp_buf, PSTR(" %4.1f%% (KVAL_RUN) \n"), float(motor.GetParam(L6470_KVAL_RUN)) * 100 / 256); break; + case 2: sprintf_P(temp_buf, PSTR(" %4.1f%% (KVAL_ACC) \n"), float(motor.GetParam(L6470_KVAL_ACC)) * 100 / 256); break; + case 3: sprintf_P(temp_buf, PSTR(" %4.1f%% (KVAL_DEC) \n"), float(motor.GetParam(L6470_KVAL_DEC)) * 100 / 256); break; + } + SERIAL_ECHO(temp_buf); +} + +void GcodeSuite::M906() { + #define L6470_SET_KVAL_HOLD(Q) stepper##Q.SetParam(L6470_KVAL_HOLD, value) + + L6470_ECHOLNPGM("M906"); + + bool report_current = true; + + #if HAS_DRIVER(L6470) + const uint8_t index = parser.byteval('I'); + #endif + + LOOP_XYZE(i) if (uint8_t value = parser.byteval(axis_codes[i])) { + + report_current = false; + + if (planner.has_blocks_queued() || planner.cleaning_buffer_counter) { + SERIAL_ECHOLNPGM("ERROR - can't set KVAL_HOLD while steppers are moving"); + return; + } + + switch (i) { + case X_AXIS: + #if AXIS_DRIVER_TYPE_X(L6470) + if (index == 0) L6470_SET_KVAL_HOLD(X); + #endif + #if AXIS_DRIVER_TYPE_X2(L6470) + if (index == 1) L6470_SET_KVAL_HOLD(X2); + #endif + break; + case Y_AXIS: + #if AXIS_DRIVER_TYPE_Y(L6470) + if (index == 0) L6470_SET_KVAL_HOLD(Y); + #endif + #if AXIS_DRIVER_TYPE_Y2(L6470) + if (index == 1) L6470_SET_KVAL_HOLD(Y2); + #endif + break; + case Z_AXIS: + #if AXIS_DRIVER_TYPE_Z(L6470) + if (index == 0) L6470_SET_KVAL_HOLD(Z); + #endif + #if AXIS_DRIVER_TYPE_Z2(L6470) + if (index == 1) L6470_SET_KVAL_HOLD(Z2); + #endif + #if AXIS_DRIVER_TYPE_Z3(L6470) + if (index == 2) L6470_SET_KVAL_HOLD(Z3); + #endif + break; + case E_AXIS: { + const int8_t target_extruder = get_target_extruder_from_command(); + if (target_extruder < 0) return; + switch (target_extruder) { + #if AXIS_DRIVER_TYPE_E0(L6470) + case 0: L6470_SET_KVAL_HOLD(E0); break; + #endif + #if AXIS_DRIVER_TYPE_E1(L6470) + case 1: L6470_SET_KVAL_HOLD(E1); break; + #endif + #if AXIS_DRIVER_TYPE_E2(L6470) + case 2: L6470_SET_KVAL_HOLD(E2); break; + #endif + #if AXIS_DRIVER_TYPE_E3(L6470) + case 3: L6470_SET_KVAL_HOLD(E3); break; + #endif + #if AXIS_DRIVER_TYPE_E4(L6470) + case 4: L6470_SET_KVAL_HOLD(E4); break; + #endif + #if AXIS_DRIVER_TYPE_E5(L6470) + case 5: L6470_SET_KVAL_HOLD(E5); break; + #endif + } + } break; + } + } + + if (report_current) { + #define L6470_REPORT_CURRENT(Q) L6470_report_current(stepper##Q, Q) + + L6470.spi_active = true; // let set_directions() know we're in the middle of a series of SPI transfers + + #if AXIS_DRIVER_TYPE_X(L6470) + L6470_REPORT_CURRENT(X); + #endif + #if AXIS_DRIVER_TYPE_X2(L6470) + L6470_REPORT_CURRENT(X2); + #endif + #if AXIS_DRIVER_TYPE_Y(L6470) + L6470_REPORT_CURRENT(Y); + #endif + #if AXIS_DRIVER_TYPE_Y2(L6470) + L6470_REPORT_CURRENT(Y2); + #endif + #if AXIS_DRIVER_TYPE_Z(L6470) + L6470_REPORT_CURRENT(Z); + #endif + #if AXIS_DRIVER_TYPE_Z2(L6470) + L6470_REPORT_CURRENT(Z2); + #endif + #if AXIS_DRIVER_TYPE_Z3(L6470) + L6470_REPORT_CURRENT(Z3); + #endif + #if AXIS_DRIVER_TYPE_E0(L6470) + L6470_REPORT_CURRENT(E0); + #endif + #if AXIS_DRIVER_TYPE_E1(L6470) + L6470_REPORT_CURRENT(E1); + #endif + #if AXIS_DRIVER_TYPE_E2(L6470) + L6470_REPORT_CURRENT(E2); + #endif + #if AXIS_DRIVER_TYPE_E3(L6470) + L6470_REPORT_CURRENT(E3); + #endif + #if AXIS_DRIVER_TYPE_E4(L6470) + L6470_REPORT_CURRENT(E4); + #endif + #if AXIS_DRIVER_TYPE_E5(L6470) + L6470_REPORT_CURRENT(E5); + #endif + + L6470.spi_active = false; // done with all SPI transfers - clear handshake flags + L6470.spi_abort = false; + } +} + +#endif // HAS_DRIVER(L6470) diff --git a/Marlin/src/gcode/feature/L6470/M916-918.cpp b/Marlin/src/gcode/feature/L6470/M916-918.cpp new file mode 100644 index 000000000..32b0add30 --- /dev/null +++ b/Marlin/src/gcode/feature/L6470/M916-918.cpp @@ -0,0 +1,544 @@ +/** + * Marlin 3D Printer Firmware + * Copyright (C) 2018 MarlinFirmware [https://github.com/MarlinFirmware/Marlin] + * + * Based on Sprinter and grbl. + * Copyright (C) 2011 Camiel Gubbels / Erik van der Zalm + * + * This program 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. + * + * This program 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 this program. If not, see . + * + */ + +#include "../../../inc/MarlinConfig.h" + +#if HAS_DRIVER(L6470) + +#include "../../gcode.h" +#include "../../../module/stepper_indirection.h" +#include "../../../module/planner.h" +#include "../../../libs/L6470/L6470_Marlin.h" + +/** + * + * M916: increase KVAL_HOLD until get thermal warning + * + * + * J - select which driver(s) to monitor on multi-driver axis + * 0 - (default) monitor all drivers on the axis or E0 + * 1 - monitor only X, Y, Z, E1 + * 2 - monitor only X2, Y2, Z2, E2 + * 3 - monitor only Z3, E3 + * + * Xxxx, Yxxx, Zxxx, Exxx - axis to be monitored with displacement + * xxx (1-255) is distance moved on either side of current position + * + * F - feedrate + * optional - will use default max feedrate from configuration.h if not specified + * + * K - starting value for KVAL_HOLD (0 - 255) + * optional - will use & report current value from driver if not specified + * + */ + +/** + * This routine is also useful for determining the approximate KVAL_HOLD + * where the stepper stops losing steps. The sound will get noticeably quieter + * as it stops losing steps. + */ + +void GcodeSuite::M916() { + + L6470_ECHOLNPGM("M916"); + + // Variables used by L6470_get_user_input function - some may not be used + char axis_mon[3][3] = { " ", " ", " " }; // list of Axes to be monitored + uint8_t axis_index[3]; + uint16_t axis_status[3]; + uint8_t driver_count = 1; + float position_max; + float position_min; + float final_feedrate; + uint8_t kval_hold; + uint8_t ocd_th_val = 0; + uint8_t stall_th_val = 0; + uint16_t over_current_threshold; + constexpr bool over_current_flag = false; // M916 doesn't play with the overcurrent thresholds + + uint8_t j; // general purpose counter + + if (L6470.get_user_input(driver_count, axis_index, axis_mon, position_max, position_min, final_feedrate, kval_hold, over_current_flag, ocd_th_val, stall_th_val, over_current_threshold)) + return; // quit if invalid user input + + L6470_ECHOLNPAIR("feedrate = ", final_feedrate); + + planner.synchronize(); // wait for all current movement commands to complete + + for (j = 0; j < driver_count; j++) + L6470.get_status(axis_index[j]); // clear out any pre-existing error flags + + char temp_axis_string[] = " "; + temp_axis_string[0] = axis_mon[0][0]; // need to have a string for use within sprintf format section + char gcode_string[80]; + uint16_t status_composite = 0; + + L6470_ECHOLNPGM(".\n."); + + do { + + L6470_ECHOLNPAIR("kval_hold = ", kval_hold); // set & report KVAL_HOLD for this run + + for (j = 0; j < driver_count; j++) + L6470.set_param(axis_index[j], L6470_KVAL_HOLD, kval_hold); + + // turn the motor(s) both directions + sprintf_P(gcode_string, PSTR("G0 %s%4.3f F%4.3f"), temp_axis_string, position_min, final_feedrate); + gcode.process_subcommands_now_P(gcode_string); + + sprintf_P(gcode_string, PSTR("G0 %s%4.3f F%4.3f"), temp_axis_string, position_max, final_feedrate); + gcode.process_subcommands_now_P(gcode_string); + + // get the status after the motors have stopped + planner.synchronize(); + + status_composite = 0; // clear out the old bits + + for (j = 0; j < driver_count; j++) { + axis_status[j] = (~L6470.get_status(axis_index[j])) & L6470_ERROR_MASK; // bits of interest are all active low + status_composite |= axis_status[j] ; + } + + if (status_composite && (status_composite & STATUS_UVLO)) { + L6470_ECHOLNPGM("Test aborted (Undervoltage lockout active)"); + for (j = 0; j < driver_count; j++) { + L6470_ECHOPGM("..."); + L6470.error_status_decode(axis_status[j], axis_index[j]); + } + return; + } + + // increment KVAL_HOLD if not yet at thermal warning/shutdown + if (!(status_composite & (STATUS_TH_WRN | STATUS_TH_SD))) + kval_hold++; + + } while (!(status_composite & (STATUS_TH_WRN | STATUS_TH_SD)) && kval_hold); // exit when kval_hold == 0 (rolls over) + + L6470_ECHOPGM(".\n.\nThermal warning/shutdown "); + if ((status_composite & (STATUS_TH_WRN | STATUS_TH_SD))) { + L6470_ECHOLNPGM("has occurred"); + for (j = 0; j < driver_count; j++) { + L6470_ECHOPGM("..."); + L6470.error_status_decode(axis_status[j], axis_index[j]); + } + } + else + L6470_ECHOLNPGM("(Unable to get)"); + + L6470_ECHOLNPGM("."); +} + +/** + * + * M917: Find minimum current thresholds + * + * Decrease OCD current until overcurrent error + * Increase OCD until overcurrent error goes away + * Decrease stall threshold until stall + * Increase stall until stall error goes away + * + * J - select which driver(s) to monitor on multi-driver axis + * 0 - (default) monitor all drivers on the axis or E0 + * 1 - monitor only X, Y, Z, E1 + * 2 - monitor only X2, Y2, Z2, E2 + * Xxxx, Yxxx, Zxxx, Exxx - axis to be monitored with displacement + * xxx (1-255) is distance moved on either side of current position + * + * F - feedrate + * optional - will use default max feedrate from Configuration.h if not specified + * + * I - starting over-current threshold + * optional - will report current value from driver if not specified + * if there are multiple drivers on the axis then all will be set the same + * + * K - value for KVAL_HOLD (0 - 255) + * optional - will report current value from driver if not specified + * + */ +void GcodeSuite::M917() { + + L6470_ECHOLNPGM("M917"); + + char axis_mon[3][3] = { " ", " ", " " }; // list of axes to be monitored + uint8_t axis_index[3]; + uint16_t axis_status[3]; + uint8_t driver_count = 1; + float position_max; + float position_min; + float final_feedrate; + uint8_t kval_hold; + uint8_t ocd_th_val = 0; + uint8_t stall_th_val = 0; + uint16_t over_current_threshold; + constexpr bool over_current_flag = true; + + uint8_t j; // general purpose counter + + if (L6470.get_user_input(driver_count, axis_index, axis_mon, position_max, position_min, final_feedrate, kval_hold, over_current_flag, ocd_th_val, stall_th_val, over_current_threshold)) + return; // quit if invalid user input + + L6470_ECHOLNPAIR("feedrate = ", final_feedrate); + + planner.synchronize(); // wait for all current movement commands to complete + for (j = 0; j < driver_count; j++) + L6470.get_status(axis_index[j]); // clear out any pre-existing error flags + char temp_axis_string[] = " "; + temp_axis_string[0] = axis_mon[0][0]; // need to have a string for use within sprintf format section + char gcode_string[80]; + uint16_t status_composite = 0; + uint8_t test_phase = 0; + // 0 - decreasing OCD - exit when OCD warning occurs (ignore STALL) + // 1 - increasing OCD - exit when OCD warning stops (ignore STALL) - + // 2 - OCD finalized - decreasing STALL - exit when STALL warning happens + // 3 - OCD finalized - increasing STALL - exit when STALL warning stop + // 4 - all testing completed + L6470_ECHOPAIR(".\n.\n.\nover_current threshold : ", (ocd_th_val + 1) * 375); // first status display + L6470_ECHOPAIR(" (OCD_TH: : ", ocd_th_val); + L6470_ECHOPAIR(") Stall threshold: ", (stall_th_val + 1) * 31.25); + L6470_ECHOPAIR(" (STALL_TH: ", stall_th_val); + L6470_ECHOLNPGM(")"); + + do { + + L6470_ECHOPAIR("STALL threshold : ", (stall_th_val + 1) * 31.25); + L6470_ECHOLNPAIR(" OCD threshold : ", (ocd_th_val + 1) * 375); + + sprintf_P(gcode_string, PSTR("G0 %s%4.3f F%4.3f"), temp_axis_string, position_min, final_feedrate); + gcode.process_subcommands_now_P(gcode_string); + + sprintf_P(gcode_string, PSTR("G0 %s%4.3f F%4.3f"), temp_axis_string, position_max, final_feedrate); + gcode.process_subcommands_now_P(gcode_string); + + planner.synchronize(); + + status_composite = 0; // clear out the old bits + + for (j = 0; j < driver_count; j++) { + axis_status[j] = (~L6470.get_status(axis_index[j])) & L6470_ERROR_MASK; // bits of interest are all active low + status_composite |= axis_status[j]; + } + + if (status_composite && (status_composite & STATUS_UVLO)) { + L6470_ECHOLNPGM("Test aborted (Undervoltage lockout active)"); + for (j = 0; j < driver_count; j++) { + L6470_ECHOPGM("..."); + L6470.error_status_decode(axis_status[j], axis_index[j]); + } + return; + } + + if (status_composite & (STATUS_TH_WRN | STATUS_TH_SD)) { + L6470_ECHOLNPGM("thermal problem - waiting for chip(s) to cool down "); + uint16_t status_composite_temp = 0; + uint8_t k = 0; + do { + k++; + if (!(k % 4)) { + kval_hold *= 0.95; + L6470_EOL(); + L6470_ECHOLNPAIR("Lowering KVAL_HOLD by about 5% to ", kval_hold); + for (j = 0; j < driver_count; j++) + L6470.set_param(axis_index[j], L6470_KVAL_HOLD, kval_hold); + } + L6470_ECHOLNPGM("."); + gcode.reset_stepper_timeout(); // reset_stepper_timeout to keep steppers powered + watchdog_reset(); // beat the dog + safe_delay(5000); + status_composite_temp = 0; + for (j = 0; j < driver_count; j++) { + axis_status[j] = (~L6470.get_status(axis_index[j])) & L6470_ERROR_MASK; // bits of interest are all active low + status_composite_temp |= axis_status[j]; + } + } + while (status_composite_temp & (STATUS_TH_WRN | STATUS_TH_SD)); + L6470_EOL(); + } + if (status_composite & (STATUS_STEP_LOSS_A | STATUS_STEP_LOSS_B | STATUS_OCD)) { + switch (test_phase) { + + case 0: { + if (status_composite & STATUS_OCD) { + // phase 0 with OCD warning - time to go to next phase + if (ocd_th_val >=15) { + ocd_th_val = 15; // limit to max + test_phase = 2; // at highest value so skip phase 1 + L6470_ECHOLNPGM("LOGIC E0A OCD at highest - skip to 2"); + } + else { + ocd_th_val++; // normal exit to next phase + test_phase = 1; // setup for first pass of phase 1 + L6470_ECHOLNPGM("LOGIC E0B - inc OCD & go to 1"); + } + } + else { // phase 0 without OCD warning - keep on decrementing if can + if (ocd_th_val) { + ocd_th_val--; // try lower value + L6470_ECHOLNPGM("LOGIC E0C - dec OCD"); + } + else { + test_phase = 2; // at lowest value without warning so skip phase 1 + L6470_ECHOLNPGM("LOGIC E0D - OCD at latest - go to 2"); + } + } + } break; + + case 1: { + if (status_composite & STATUS_OCD) { + // phase 1 with OCD warning - increment if can + if (ocd_th_val >= 15) { + ocd_th_val = 15; // limit to max + test_phase = 2; // at highest value so go to next phase + L6470_ECHOLNPGM("LOGIC E1A - OCD at max - go to 2"); + } + else { + ocd_th_val++; // try a higher value + L6470_ECHOLNPGM("LOGIC E1B - inc OCD"); + } + } + else { // phase 1 without OCD warning - normal exit to phase 2 + test_phase = 2; + L6470_ECHOLNPGM("LOGIC E1C - no OCD warning - go to 1"); + } + } break; + + case 2: { + if (status_composite & (STATUS_STEP_LOSS_A | STATUS_STEP_LOSS_B)) { + // phase 2 with stall warning - time to go to next phase + if (stall_th_val >= 127) { + stall_th_val = 127; // limit to max + L6470_ECHOLNPGM("LOGIC E2A - STALL warning, STALL at max, quit"); + L6470_ECHOLNPGM("finished - STALL at maximum value but still have stall warning"); + test_phase = 4; + } + else { + test_phase = 3; // normal exit to next phase (found failing value of STALL) + stall_th_val++; // setup for first pass of phase 3 + L6470_ECHOLNPGM("LOGIC E2B - INC - STALL warning, inc Stall, go to 3"); + } + } + else { // phase 2 without stall warning - decrement if can + if (stall_th_val) { + stall_th_val--; // try a lower value + L6470_ECHOLNPGM("LOGIC E2C - no STALL, dec STALL"); + } + else { + L6470_ECHOLNPGM("finished - STALL at lowest value but still do NOT have stall warning"); + test_phase = 4; + L6470_ECHOLNPGM("LOGIC E2D - no STALL, at lowest so quit"); + } + } + } break; + + case 3: { + if (status_composite & (STATUS_STEP_LOSS_A | STATUS_STEP_LOSS_B)) { + // phase 3 with stall warning - increment if can + if (stall_th_val >= 127) { + stall_th_val = 127; // limit to max + L6470_ECHOLNPGM("finished - STALL at maximum value but still have stall warning"); + test_phase = 4; + L6470_ECHOLNPGM("LOGIC E3A - STALL, at max so quit"); + } + else { + stall_th_val++; // still looking for passing value + L6470_ECHOLNPGM("LOGIC E3B - STALL, inc stall"); + } + } + else { //phase 3 without stall warning but have OCD warning + L6470_ECHOLNPGM("Hardware problem - OCD warning without STALL warning"); + test_phase = 4; + L6470_ECHOLNPGM("LOGIC E3C - not STALLED, hardware problem (quit)"); + } + } break; + + } + + } + else { + switch (test_phase) { + case 0: { // phase 0 without OCD warning - keep on decrementing if can + if (ocd_th_val) { + ocd_th_val--; // try lower value + L6470_ECHOLNPGM("LOGIC N0A - DEC OCD"); + } + else { + test_phase = 2; // at lowest value without warning so skip phase 1 + L6470_ECHOLNPGM("LOGIC N0B - OCD at lowest (go to phase 2)"); + } + } break; + + case 1: L6470_ECHOLNPGM("LOGIC N1 (go directly to 2)"); // phase 1 without OCD warning - drop directly to phase 2 + + case 2: { // phase 2 without stall warning - keep on decrementing if can + if (stall_th_val) { + stall_th_val--; // try a lower value (stay in phase 2) + L6470_ECHOLNPGM("LOGIC N2B - dec STALL"); + } + else { + L6470_ECHOLNPGM("finished - STALL at lowest value but still no stall warning"); + test_phase = 4; + L6470_ECHOLNPGM("LOGIC N2C - STALL at lowest (quit)"); + } + } break; + + case 3: { test_phase = 4; + L6470_ECHOLNPGM("LOGIC N3 - finished!"); + } break; // phase 3 without any warnings - desired exit + } // + } // end of status checks + + if (test_phase != 4) { + for (j = 0; j < driver_count; j++) { // update threshold(s) + L6470.set_param(axis_index[j], L6470_OCD_TH, ocd_th_val); + L6470.set_param(axis_index[j], L6470_STALL_TH, stall_th_val); + if (L6470.get_param(axis_index[j], L6470_OCD_TH) != ocd_th_val) L6470_ECHOLNPGM("OCD mismatch"); + if (L6470.get_param(axis_index[j], L6470_STALL_TH) != stall_th_val) L6470_ECHOLNPGM("STALL mismatch"); + } + } + + } while (test_phase != 4); + + if (status_composite) { + L6470_ECHOLNPGM("Completed with errors"); + for (j = 0; j < driver_count; j++) { + L6470_ECHOPGM("..."); + L6470.error_status_decode(axis_status[j], axis_index[j]); + } + } + else + L6470_ECHOLNPGM("Completed with no errors"); + +} // M917 + +/** + * + * M918: increase speed until error or max feedrate achieved (as shown in configuration.h)) + * + * J - select which driver(s) to monitor on multi-driver axis + * 0 - (default) monitor all drivers on the axis or E0 + * 1 - monitor only X, Y, Z, E1 + * 2 - monitor only X2, Y2, Z2, E2 + * Xxxx, Yxxx, Zxxx, Exxx - axis to be monitored with displacement + * xxx (1-255) is distance moved on either side of current position + * + * I - over current threshold + * optional - will report current value from driver if not specified + * + * K - value for KVAL_HOLD (0 - 255) (optional) + * optional - will report current value from driver if not specified + * + */ +void GcodeSuite::M918() { + + L6470_ECHOLNPGM("M918"); + + char axis_mon[3][3] = { " ", " ", " " }; // List of axes to monitor + uint8_t axis_index[3]; + uint16_t axis_status[3]; + uint8_t driver_count = 1; + float position_max, position_min; + float final_feedrate; + uint8_t kval_hold; + uint8_t ocd_th_val = 0; + uint8_t stall_th_val = 0; + uint16_t over_current_threshold; + constexpr bool over_current_flag = true; + + uint8_t j; // general purpose counter + + if (L6470.get_user_input(driver_count, axis_index, axis_mon, position_max, position_min, final_feedrate, kval_hold, over_current_flag, ocd_th_val, stall_th_val, over_current_threshold)) + return; // quit if invalid user input + + uint8_t m_steps = parser.byteval('M'); + LIMIT(m_steps, 0, 128); + L6470_ECHOLNPAIR("M = ", m_steps); + + int8_t m_bits = -1; + if (m_steps > 85) m_bits = 7; // 128 (no synch output) + else if (m_steps > 42) m_bits = 6; // 64 (no synch output) + else if (m_steps > 22) m_bits = 5; // 32 (no synch output) + else if (m_steps > 12) m_bits = 4; // 16 (no synch output) + else if (m_steps > 5) m_bits = 3; // 8 (no synch output) + else if (m_steps > 2) m_bits = 2; // 4 (no synch output) + else if (m_steps == 2) m_bits = 1; // 2 (no synch output) + else if (m_steps == 1) m_bits = 0; // 1 (no synch output) + else if (m_steps == 0) m_bits = 7; // 128 (no synch output) + + if (m_bits >= 0) { + const int micros = _BV(m_bits); + if (micros < 100) { L6470_CHAR(' '); if (micros < 10) L6470_CHAR(' '); } + L6470_ECHO(micros); + L6470_ECHOPGM(" uSTEPS"); + } + + for (j = 0; j < driver_count; j++) + L6470.set_param(axis_index[j], L6470_STEP_MODE, m_bits); // set microsteps + + L6470_ECHOLNPAIR("target (maximum) feedrate = ",final_feedrate); + + float feedrate_inc = final_feedrate / 10, // start at 1/10 of max & go up by 1/10 per step) + current_feedrate = 0; + + planner.synchronize(); // wait for all current movement commands to complete + + for (j = 0; j < driver_count; j++) + L6470.get_status(axis_index[j]); // clear all error flags + + char temp_axis_string[2]; + temp_axis_string[0] = axis_mon[0][0]; // need to have a string for use within sprintf format section + temp_axis_string[1] = '\n'; + + char gcode_string[80]; + uint16_t status_composite = 0; + L6470_ECHOLNPGM(".\n.\n."); // make the feedrate prints easier to see + + do { + current_feedrate += feedrate_inc; + L6470_ECHOLNPAIR("...feedrate = ", current_feedrate); + + sprintf_P(gcode_string, PSTR("G0 %s%4.3f F%4.3f"), temp_axis_string, position_min, current_feedrate); + gcode.process_subcommands_now_P(gcode_string); + + sprintf_P(gcode_string, PSTR("G0 %s%4.3f F%4.3f"), temp_axis_string, position_max, current_feedrate); + gcode.process_subcommands_now_P(gcode_string); + + planner.synchronize(); + + for (j = 0; j < driver_count; j++) { + axis_status[j] = (~L6470.get_status(axis_index[j])) & 0x0800; // bits of interest are all active low + status_composite |= axis_status[j]; + } + if (status_composite) break; // quit if any errors flags are raised + } while (current_feedrate < final_feedrate * 0.99); + + if (status_composite) { + L6470_ECHOLNPGM("Completed with errors"); + for (j = 0; j < driver_count; j++) { + L6470_ECHOPGM("..."); + L6470.error_status_decode(axis_status[j], axis_index[j]); + } + } + else + L6470_ECHOLNPGM("Completed with no errors"); + +} // M918 + +#endif // HAS_DRIVER(L6470) diff --git a/Marlin/src/gcode/gcode.cpp b/Marlin/src/gcode/gcode.cpp index 900d6d007..45ebbe381 100644 --- a/Marlin/src/gcode/gcode.cpp +++ b/Marlin/src/gcode/gcode.cpp @@ -667,6 +667,14 @@ void GcodeSuite::process_parsed_command( #endif #endif + #if HAS_DRIVER(L6470) + case 122: M122(); break; // M122: Report status + case 906: M906(); break; // M906: Set or get motor drive level + case 916: M916(); break; // M916: L6470 tuning: Increase drive level until thermal warning + case 917: M917(); break; // M917: L6470 tuning: Find minimum current thresholds + case 918: M918(); break; // M918: L6470 tuning: Increase speed until max or error + #endif + #if HAS_MICROSTEPS case 350: M350(); break; // M350: Set microstepping mode. Warning: Steps per unit remains unchanged. S code sets stepping mode for all drivers. case 351: M351(); break; // M351: Toggle MS1 MS2 pins directly, S# determines MS1 or MS2, X# sets the pin high/low. diff --git a/Marlin/src/gcode/gcode.h b/Marlin/src/gcode/gcode.h index 6aeeb35b2..34b4c8035 100644 --- a/Marlin/src/gcode/gcode.h +++ b/Marlin/src/gcode/gcode.h @@ -240,6 +240,8 @@ * M912 - Clear stepper driver overtemperature pre-warn condition flag. (Requires at least one _DRIVER_TYPE defined as TMC2130/TMC2208/TMC2660) * M913 - Set HYBRID_THRESHOLD speed. (Requires HYBRID_THRESHOLD) * M914 - Set StallGuard sensitivity. (Requires SENSORLESS_HOMING or SENSORLESS_PROBING) + * M917 - L6470 tuning: Find minimum current thresholds + * M918 - L6470 tuning: Increase speed until max or error * * M360 - SCARA calibration: Move to cal-position ThetaA (0 deg calibration) * M361 - SCARA calibration: Move to cal-position ThetaB (90 deg calibration - steps per degree) @@ -812,6 +814,14 @@ private: #endif #endif + #if HAS_DRIVER(L6470) + static void M122(); + static void M906(); + static void M916(); + static void M917(); + static void M918(); + #endif + #if HAS_DIGIPOTSS || HAS_MOTOR_CURRENT_PWM || ENABLED(DIGIPOT_I2C) || ENABLED(DAC_STEPPER_CURRENT) static void M907(); #if HAS_DIGIPOTSS || ENABLED(DAC_STEPPER_CURRENT) diff --git a/Marlin/src/gcode/host/M114.cpp b/Marlin/src/gcode/host/M114.cpp index edd9df2cf..19db2c238 100644 --- a/Marlin/src/gcode/host/M114.cpp +++ b/Marlin/src/gcode/host/M114.cpp @@ -28,6 +28,12 @@ #if ENABLED(M114_DETAIL) + #if HAS_DRIVER(L6470) + //C:\Users\bobku\Documents\GitHub\Marlin-Bob-2\Marlin\src\gcode\host\M114.cpp + //C:\Users\bobku\Documents\GitHub\Marlin-Bob-2\Marlin\src\module\bob_L6470.cpp + #include "../../module/L6470/L6470_Marlin.h" + #endif + void report_xyze(const float pos[], const uint8_t n = 4, const uint8_t precision = 3) { char str[12]; for (uint8_t i = 0; i < n; i++) { @@ -79,6 +85,62 @@ planner.synchronize(); + #if HAS_DRIVER(L6470) + char temp_buf[80]; + int32_t temp; + //#define ABS_POS_SIGN_MASK 0b1111 1111 1110 0000 0000 0000 0000 0000 + #define ABS_POS_SIGN_MASK 0b11111111111000000000000000000000 + #define REPORT_ABSOLUTE_POS(Q) do{ \ + L6470.say_axis(Q, false); \ + temp = L6470_GETPARAM(L6470_ABS_POS,Q); \ + if (temp & ABS_POS_SIGN_MASK) temp |= ABS_POS_SIGN_MASK; \ + sprintf_P(temp_buf, PSTR(":%8ld "), temp); \ + L6470_ECHO(temp_buf); \ + }while(0) + + L6470_ECHOPGM("\nL6470:"); + #if AXIS_DRIVER_TYPE_X(L6470) + REPORT_ABSOLUTE_POS(X); + #endif + #if AXIS_DRIVER_TYPE_X2(L6470) + REPORT_ABSOLUTE_POS(X2); + #endif + #if AXIS_DRIVER_TYPE_Y(L6470) + REPORT_ABSOLUTE_POS(Y); + #endif + #if AXIS_DRIVER_TYPE_Y2(L6470) + REPORT_ABSOLUTE_POS(Y2); + #endif + #if AXIS_DRIVER_TYPE_Z(L6470) + REPORT_ABSOLUTE_POS(Z); + #endif + #if AXIS_DRIVER_TYPE_Z2(L6470) + REPORT_ABSOLUTE_POS(Z2); + #endif + #if AXIS_DRIVER_TYPE_Z3(L6470) + REPORT_ABSOLUTE_POS(Z3); + #endif + #if AXIS_DRIVER_TYPE_E0(L6470) + REPORT_ABSOLUTE_POS(E0); + #endif + #if AXIS_DRIVER_TYPE_E1(L6470) + REPORT_ABSOLUTE_POS(E1); + #endif + #if AXIS_DRIVER_TYPE_E2(L6470) + REPORT_ABSOLUTE_POS(E2); + #endif + #if AXIS_DRIVER_TYPE_E3(L6470) + REPORT_ABSOLUTE_POS(E3); + #endif + #if AXIS_DRIVER_TYPE_E4(L6470) + REPORT_ABSOLUTE_POS(E4); + #endif + #if AXIS_DRIVER_TYPE_E5(L6470) + REPORT_ABSOLUTE_POS(E5); + #endif + SERIAL_EOL(); + #endif // HAS_DRIVER(L6470) + SERIAL_ECHOPGM("Stepper:"); LOOP_XYZE(i) { SERIAL_CHAR(' '); diff --git a/Marlin/src/inc/Conditionals_post.h b/Marlin/src/inc/Conditionals_post.h index fbc4ee76a..f50a0ffdc 100644 --- a/Marlin/src/inc/Conditionals_post.h +++ b/Marlin/src/inc/Conditionals_post.h @@ -1630,7 +1630,7 @@ // If platform requires early initialization of watchdog to properly boot #define EARLY_WATCHDOG (ENABLED(USE_WATCHDOG) && defined(ARDUINO_ARCH_SAM)) -#define USE_EXECUTE_COMMANDS_IMMEDIATE (ENABLED(G29_RETRY_AND_RECOVER) || ENABLED(GCODE_MACROS) || ENABLED(POWER_LOSS_RECOVERY)) +#define USE_EXECUTE_COMMANDS_IMMEDIATE (ENABLED(G29_RETRY_AND_RECOVER) || ENABLED(GCODE_MACROS) || ENABLED(POWER_LOSS_RECOVERY) || HAS_DRIVER(L6470)) #if ENABLED(Z_TRIPLE_STEPPER_DRIVERS) #define Z_STEPPER_COUNT 3 diff --git a/Marlin/src/libs/L6470/000_l6470_read_me.md b/Marlin/src/libs/L6470/000_l6470_read_me.md new file mode 100644 index 000000000..170ba6596 --- /dev/null +++ b/Marlin/src/libs/L6470/000_l6470_read_me.md @@ -0,0 +1,105 @@ +Arduino-6470 library revision 0.7.0 or above is required. + +This software can be used with any L647x chip and the powerSTEP01. L647x and powerSTEP01 devices can not be mixed within a system. A flag in the library must be set to enable use of a powerSTEP01. + +These devices use voltage PWMs to drive the stepper phases. Phase current is not directly controlled. Each microstep corresponds to a particular PWM duty cycle. The KVAL\_HOLD register scales the PWM duty cycle. + +This software assumes that all L6470 drivers are in one SPI daisy chain. + +``` {.gcode} + The hardware setup is: + + MOSI from controller tied to SDI on the first device + + SDO of the first device is tied to SDI of the next device + + SDO of the last device is tied to MISO of the controller + + all devices share the same SCK, SS\_PIN and RESET\_PIN + + Each L6470 passes the data it saw on its SDI to its neighbor on the **NEXT** SPI cycle (8 bit delay). + + Each L6470 acts on the **last** SPI data it saw when the SS\_PIN **goes high**. +``` + +The L6470 drivers operate in STEP\_CLOCK mode. In this mode the direction and enable are done via SPI commands and the phase currents are changed in response to step pulses (generated in the usual way). + +There are two different SPI routines used. + +- **uint8\_t** L6470\_Transfer(uint8\_t data, int \_SSPin, const uint8\_t chain\_position) is used to setup the chips and by the maintenance/status code. This code uses the Arduino-6470 library. + +- **void** L6470\_Transfer(uint8\_t L6470\_buf[], const uint8\_t length) is used by the set\_directions() routine to send the direction/enable commands. The library is NOT used by this code. + +**HARDWARE/SOFTWARE interaction** + +Powering up a stepper and setting the direction are done by the same command. Can't do one without the other. + +**All** directions are set **every time** a new block is popped off the queue by the stepper ISR. + +SPI transfers, when setting the directions, are minimized by using arrays and a SPI routine dedicated to this function. L6470 library calls are not used. For N L6470 drivers, this results in a N byte transfer. If library calls were used then N\*N bytes would be sent. + +**Power up (reset) sequence:** + +1. Stepper objects are created before the **setup()** entry point is reached. + +2. After the **setup()** entry point is reached and before the steppers are initialized, L6470\_init() is called to do the following + +3. If present, the hardware reset is pulsed. + +4. The L6470\_chain array is populated during **setup()**. This array is used to tell where in the SPI stream the commands/data for an stepper is positioned. + +5. The L6470 soft SPI pins are initialized. + +6. The L6470 chips are initialized during **setup()**. They can be re-initialized using the **L6470\_init\_to\_defaults()** function + +The steppers are **NOT** powered up during this sequence. + +**L6470\_chain** array + +This array is used by all routines that transmit SPI data. + +``` {.gcode} + Location 0 - number of drivers in chain + + Location 1 - axis index for first device in the chain (closest to MOSI) + + … + + Location N - axis index for last device in the N device long chain (closest to MISO) +``` + +**Direction set and enable** + +The DIR\_WRITE macros for the L6470 drivers are written so that the standard X, Y, Z and extruder logic used by the set\_directions() routine is not altered. These macros write the correct forward/reverse command to the corresponding location in the array *L6470\_dir\_commands*. + +At the end of the set\_directions() routine, the array *L6470\_chain* is used to grab the corresponding direction/enable commands out of the array *L6470\_dir\_commands* and put them in the correct sequence in the array *L6470\_buf*. Array *L6470\_buf* is then passed to the **void** L6470\_Transfer function which actually sends the data to the devices. + +**Utilities and misc** + +The **absolute position** registers should accurately reflect Marlin’s stepper position counts. They are set to zero during initialization. G28 sets them to the Marlin counts for the corresponding axis after homing. NOTE – these registers are often the negative of the Marlin counts. This is because the Marlin counts reflect the logical direction while the registers reflect the stepper direction. The register contents are displayed via the M114 D command. + +The **L6470\_monitor** feature reads the status of each device every half second. It will report if there are any error conditions present or if communications has been lost/restored. The KVAL\_HOLD value is reduced every 2 – 2.5 seconds if the thermal warning or thermal shutdown conditions are present. + +**M122** displays the settings of most of the bits in the status register plus a couple of other items. + +**M906** can be used to set the KVAL\_HOLD register one driver at a time. If a setting is not included with the command then the contents of the registers that affect the phase current/voltage are displayed. + +**M916, M917 & M918** + +These utilities are used to tune the system. They can get you in the ballpark for acceptable jerk, acceleration, top speed and KVAL\_HOLD settings. In general they seem to provide an overly optimistic KVAL\_HOLD setting because of the lag between setting KVAL\_HOLD and the driver reaching final temperature. Enabling the **L6470\_monitor** feature during prints will provide the **final useful KVAL\_HOLD setting**. + +The amount of power needed to move the stepper without skipping steps increases as jerk, acceleration and top speed increase. The power dissipated by the driver increases as the power to the stepper increases. The net result is a balancing act between jerk, acceleration, top speed and power dissipated by the driver. + +**M916 -** Increases KVAL\_HOLD while moving one axis until get thermal warning. This routine is also useful for determining the approximate KVAL\_HOLD where the stepper stops losing steps. The sound will get noticeably quieter as it stops losing steps. + +**M917 -** Find minimum current thresholds. This is done by doing the following steps while moving an axis: + +1. Decrease OCD current until overcurrent error + +2. Increase OCD until overcurrent error goes away + +3. Decrease stall threshold until stall error + +4. Increase stall until stall error goes away + +**M918 -** Increase speed until error or max feedrate achieved. diff --git a/Marlin/src/libs/L6470/L6470_Marlin.cpp b/Marlin/src/libs/L6470/L6470_Marlin.cpp new file mode 100644 index 000000000..927063564 --- /dev/null +++ b/Marlin/src/libs/L6470/L6470_Marlin.cpp @@ -0,0 +1,793 @@ +/** + * Marlin 3D Printer Firmware + * Copyright (C) 2019 MarlinFirmware [https://github.com/MarlinFirmware/Marlin] + * + * Based on Sprinter and grbl. + * Copyright (C) 2011 Camiel Gubbels / Erik van der Zalm + * + * This program 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. + * + * This program 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 this program. If not, see . + * + */ + +/** + * The monitor_driver routines are a close copy of the TMC code + */ + +#include "../../inc/MarlinConfig.h" + +#if HAS_DRIVER(L6470) + +#include "L6470_Marlin.h" + +L6470_Marlin L6470; + +#include "../stepper_indirection.h" +#include "../../gcode/gcode.h" +#include "../planner.h" + +uint8_t L6470_Marlin::dir_commands[MAX_L6470]; // array to hold direction command for each driver + +char L6470_Marlin::index_to_axis[MAX_L6470][3] = { "X ", "Y ", "Z ", "X2", "Y2", "Z2", "Z3", "E0", "E1", "E2", "E3", "E4", "E5" }; + +bool L6470_Marlin::index_to_dir[MAX_L6470] = { + INVERT_X_DIR , // 0 X + INVERT_Y_DIR , // 1 Y + INVERT_Z_DIR , // 2 Z + #if ENABLED(X_DUAL_STEPPER_DRIVERS) + INVERT_X_DIR ^ INVERT_X2_VS_X_DIR , // 3 X2 + #else + INVERT_X_DIR , // 3 X2 + #endif + #if ENABLED(Y_DUAL_STEPPER_DRIVERS) + INVERT_Y_DIR ^ INVERT_Y2_VS_Y_DIR , // 4 Y2 + #else + INVERT_Y_DIR , // 4 Y2 + #endif + INVERT_Z_DIR , // 5 Z2 + INVERT_Z_DIR , // 6 Z3 + INVERT_E0_DIR , // 7 E0 + INVERT_E1_DIR , // 8 E1 + INVERT_E2_DIR , // 9 E2 + INVERT_E3_DIR , //10 E3 + INVERT_E4_DIR , //11 E4 + INVERT_E5_DIR , //12 E5 +}; + +uint8_t L6470_Marlin::axis_xref[MAX_L6470] = { + AxisEnum(X_AXIS), // X + AxisEnum(Y_AXIS), // Y + AxisEnum(Z_AXIS), // Z + AxisEnum(X_AXIS), // X2 + AxisEnum(Y_AXIS), // Y2 + AxisEnum(Z_AXIS), // Z2 + AxisEnum(Z_AXIS), // Z3 + AxisEnum(E_AXIS), // E0 + AxisEnum(E_AXIS), // E1 + AxisEnum(E_AXIS), // E2 + AxisEnum(E_AXIS), // E3 + AxisEnum(E_AXIS), // E4 + AxisEnum(E_AXIS) // E5 +}; + +volatile bool L6470_Marlin::spi_abort = false; +bool L6470_Marlin::spi_active = false; + +void L6470_Marlin::populate_chain_array() { + + #define _L6470_INIT_SPI(Q) do{ stepper##Q.set_chain_info(Q, Q##_CHAIN_POS); }while(0) + + #if AXIS_DRIVER_TYPE_X(L6470) + _L6470_INIT_SPI(X); + #endif + #if AXIS_DRIVER_TYPE_X2(L6470) + _L6470_INIT_SPI(X2); + #endif + #if AXIS_DRIVER_TYPE_Y(L6470) + _L6470_INIT_SPI(Y); + #endif + #if AXIS_DRIVER_TYPE_Y2(L6470) + _L6470_INIT_SPI(Y2); + #endif + #if AXIS_DRIVER_TYPE_Z(L6470) + _L6470_INIT_SPI(Z); + #endif + #if AXIS_DRIVER_TYPE_Z2(L6470) + _L6470_INIT_SPI(Z2); + #endif + #if AXIS_DRIVER_TYPE_Z3(L6470) + _L6470_INIT_SPI(Z3); + #endif + #if AXIS_DRIVER_TYPE_E0(L6470) + _L6470_INIT_SPI(E0); + #endif + #if AXIS_DRIVER_TYPE_E1(L6470) + _L6470_INIT_SPI(E1); + #endif + #if AXIS_DRIVER_TYPE_E2(L6470) + _L6470_INIT_SPI(E2); + #endif + #if AXIS_DRIVER_TYPE_E3(L6470) + _L6470_INIT_SPI(E3); + #endif + #if AXIS_DRIVER_TYPE_E4(L6470) + _L6470_INIT_SPI(E4); + #endif + #if AXIS_DRIVER_TYPE_E5(L6470) + _L6470_INIT_SPI(E5); + #endif +} + +void L6470_Marlin::init() { // Set up SPI and then init chips + #if PIN_EXISTS(L6470_RESET_CHAIN) + OUT_WRITE(L6470_RESET_CHAIN_PIN, LOW); // hardware reset of drivers + delay(1); + OUT_WRITE(L6470_RESET_CHAIN_PIN, HIGH); + delay(1); // need about 650uS for the chip to fully start up + #endif + populate_chain_array(); // Set up array to control where in the SPI transfer sequence a particular stepper's data goes + L6470_spi_init(); // Set up L6470 soft SPI pins + init_to_defaults(); // init the chips +} + +uint16_t L6470_Marlin::get_status(const uint8_t axis) { + + #define GET_L6470_STATUS(Q) stepper##Q.getStatus() + + switch (axis) { + #if AXIS_DRIVER_TYPE_X(L6470) + case 0: return GET_L6470_STATUS(X); + #endif + #if AXIS_DRIVER_TYPE_Y(L6470) + case 1: return GET_L6470_STATUS(Y); + #endif + #if AXIS_DRIVER_TYPE_Z(L6470) + case 2: return GET_L6470_STATUS(Z); + #endif + #if AXIS_DRIVER_TYPE_X2(L6470) + case 3: return GET_L6470_STATUS(X2); + #endif + #if AXIS_DRIVER_TYPE_Y2(L6470) + case 4: return GET_L6470_STATUS(Y2); + #endif + #if AXIS_DRIVER_TYPE_Z2(L6470) + case 5: return GET_L6470_STATUS(Z2); + #endif + #if AXIS_DRIVER_TYPE_Z3(L6470) + case 6: return GET_L6470_STATUS(Z3); + #endif + #if AXIS_DRIVER_TYPE_E0(L6470) + case 7: return GET_L6470_STATUS(E0); + #endif + #if AXIS_DRIVER_TYPE_E1(L6470) + case 8: return GET_L6470_STATUS(E1); + #endif + #if AXIS_DRIVER_TYPE_E2(L6470) + case 9: return GET_L6470_STATUS(E2); + #endif + #if AXIS_DRIVER_TYPE_E3(L6470) + case 10: return GET_L6470_STATUS(E3); + #endif + #if AXIS_DRIVER_TYPE_E4(L6470) + case 11: return GET_L6470_STATUS(E4); + #endif + #if AXIS_DRIVER_TYPE_E5(L6470) + case 12: return GET_L6470_STATUS(E5); + #endif + } + + return 0; // Not needed but kills a compiler warning +} + +uint32_t L6470_Marlin::get_param(uint8_t axis, uint8_t param) { + + #define GET_L6470_PARAM(Q) L6470_GETPARAM(param,Q) + + switch (axis) { + #if AXIS_DRIVER_TYPE_X(L6470) + case 0: return GET_L6470_PARAM(X); + #endif + #if AXIS_DRIVER_TYPE_Y(L6470) + case 1: return GET_L6470_PARAM(Y); + #endif + #if AXIS_DRIVER_TYPE_Z(L6470) + case 2: return GET_L6470_PARAM(Z); + #endif + #if AXIS_DRIVER_TYPE_X2(L6470) + case 3: return GET_L6470_PARAM(X2); + #endif + #if AXIS_DRIVER_TYPE_Y2(L6470) + case 4: return GET_L6470_PARAM(Y2); + #endif + #if AXIS_DRIVER_TYPE_Z2(L6470) + case 5: return GET_L6470_PARAM(Z2); + #endif + #if AXIS_DRIVER_TYPE_Z3(L6470) + case 6: return GET_L6470_PARAM(Z3); + #endif + #if AXIS_DRIVER_TYPE_E0(L6470) + case 7: return GET_L6470_PARAM(E0); + #endif + #if AXIS_DRIVER_TYPE_E1(L6470) + case 8: return GET_L6470_PARAM(E1); + #endif + #if AXIS_DRIVER_TYPE_E2(L6470) + case 9: return GET_L6470_PARAM(E2); + #endif + #if AXIS_DRIVER_TYPE_E3(L6470) + case 10: return GET_L6470_PARAM(E3); + #endif + #if AXIS_DRIVER_TYPE_E4(L6470) + case 11: return GET_L6470_PARAM(E4); + #endif + #if AXIS_DRIVER_TYPE_E5(L6470) + case 12: return GET_L6470_PARAM(E5); + #endif + } + + return 0 ; // not needed but kills a compiler warning +} + +void L6470_Marlin::set_param(uint8_t axis, uint8_t param, uint32_t value) { + + #define SET_L6470_PARAM(Q) stepper##Q.SetParam(param, value) + + switch (axis) { + #if AXIS_DRIVER_TYPE_X(L6470) + case 0: SET_L6470_PARAM(X); + #endif + #if AXIS_DRIVER_TYPE_Y(L6470) + case 1: SET_L6470_PARAM(Y); + #endif + #if AXIS_DRIVER_TYPE_Z(L6470) + case 2: SET_L6470_PARAM(Z); + #endif + #if AXIS_DRIVER_TYPE_X2(L6470) + case 3: SET_L6470_PARAM(X2); + #endif + #if AXIS_DRIVER_TYPE_Y2(L6470) + case 4: SET_L6470_PARAM(Y2); + #endif + #if AXIS_DRIVER_TYPE_Z2(L6470) + case 5: SET_L6470_PARAM(Z2); + #endif + #if AXIS_DRIVER_TYPE_Z3(L6470) + case 6: SET_L6470_PARAM(Z3); + #endif + #if AXIS_DRIVER_TYPE_E0(L6470) + case 7: SET_L6470_PARAM(E0); + #endif + #if AXIS_DRIVER_TYPE_E1(L6470) + case 8: SET_L6470_PARAM(E1); + #endif + #if AXIS_DRIVER_TYPE_E2(L6470) + case 9: SET_L6470_PARAM(E2); + #endif + #if AXIS_DRIVER_TYPE_E3(L6470) + case 10: SET_L6470_PARAM(E3); + #endif + #if AXIS_DRIVER_TYPE_E4(L6470) + case 11: SET_L6470_PARAM(E4); + #endif + #if AXIS_DRIVER_TYPE_E5(L6470) + case 12: SET_L6470_PARAM(E5); + #endif + } +} + +inline void echo_min_max(const char a, const float &min, const float &max) { + L6470_CHAR(' '); L6470_CHAR(a); + L6470_ECHOPAIR(" min = ", min); + L6470_ECHOLNPAIR(" max = ", max); +} +inline void echo_oct_used(const float &oct, const bool stall) { + L6470_ECHOPAIR("over_current_threshold used : ", oct); + serialprintPGM(stall ? PSTR(" (Stall") : PSTR(" (OCD")); + L6470_ECHOLNPGM(" threshold)"); +} +inline void err_out_of_bounds() { L6470_ECHOLNPGM("ERROR - motion out of bounds"); } + +bool L6470_Marlin::get_user_input(uint8_t &driver_count, uint8_t axis_index[3], char axis_mon[3][3], + float &position_max, float &position_min, float &final_feedrate, uint8_t &kval_hold, + bool over_current_flag, uint8_t &OCD_TH_val, uint8_t &STALL_TH_val, uint16_t &over_current_threshold +) { + // Return TRUE if the calling routine needs to abort/kill + + uint16_t displacement = 0; // " = 0" to eliminate compiler warning + uint8_t j; // general purpose counter + + if (!all_axes_homed()) { + L6470_ECHOLNPGM("ERROR - home all before running this command"); + //return true; + } + + LOOP_XYZE(i) if (uint16_t _displacement = parser.intval(axis_codes[i])) { + displacement = _displacement; + uint8_t axis_offset = parser.byteval('J'); + axis_mon[0][0] = axis_codes[i]; // axis ASCII value (target character) + if (axis_offset >= 2 || axis_mon[0][0] == 'E') // Single axis, E0, or E1 + axis_mon[0][1] = axis_offset + '0'; + else if (axis_offset == 0) { // one or more axes + uint8_t driver_count_local = 0; // can't use "driver_count" directly as a subscript because it's passed by reference + for (j = 0; j < MAX_L6470; j++) // see how many drivers on this axis + if (axis_mon[0][0] == index_to_axis[j][0]) { + axis_mon[driver_count_local][0] = axis_mon[0][0]; + axis_mon[driver_count_local][1] = index_to_axis[j][1]; + axis_mon[driver_count_local][2] = index_to_axis[j][2]; // append end of string + axis_index[driver_count_local] = j; // set axis index + driver_count_local++; + } + driver_count = driver_count_local; + } + break; // only take first axis found + } + + // + // Position calcs & checks + // + + const float center[] = { + LOGICAL_X_POSITION(current_position[X_AXIS]), + LOGICAL_Y_POSITION(current_position[Y_AXIS]), + LOGICAL_Z_POSITION(current_position[Z_AXIS]), + current_position[E_AXIS] + }; + + switch (axis_mon[0][0]) { + default: position_max = position_min = 0; break; + + case 'X': { + position_min = center[X_AXIS] - displacement; + position_max = center[X_AXIS] + displacement; + echo_min_max('X', position_min, position_max); + if (false + #ifdef X_MIN_POS + || position_min < (X_MIN_POS) + #endif + #ifdef X_MAX_POS + || position_max > (X_MAX_POS) + #endif + ) { + err_out_of_bounds(); + return true; + } + } break; + + case 'Y': { + position_min = center[Y_AXIS] - displacement; + position_max = center[Y_AXIS] + displacement; + echo_min_max('Y', position_min, position_max); + if (false + #ifdef Y_MIN_POS + || position_min < (Y_MIN_POS) + #endif + #ifdef Y_MAX_POS + || position_max > (Y_MAX_POS) + #endif + ) { + err_out_of_bounds(); + return true; + } + } break; + + case 'Z': { + position_min = center[E_AXIS] - displacement; + position_max = center[E_AXIS] + displacement; + echo_min_max('Z', position_min, position_max); + if (false + #ifdef Z_MIN_POS + || position_min < (Z_MIN_POS) + #endif + #ifdef Z_MAX_POS + || position_max > (Z_MAX_POS) + #endif + ) { + err_out_of_bounds(); + return true; + } + } break; + + case 'E': { + position_min = center[E_AXIS] - displacement; + position_max = center[E_AXIS] + displacement; + echo_min_max('E', position_min, position_max); + } break; + } + + // + // Work on the drivers + // + for (uint8_t k = 0; k < driver_count; k++) { + bool not_found = true; + for (j = 1; j <= L6470::chain[0]; j++) { + const char * const ind_axis = index_to_axis[L6470::chain[j]]; + if (ind_axis[0] == axis_mon[k][0] && ind_axis[1] == axis_mon[k][1]) { // See if a L6470 driver + not_found = false; + break; + } + } + if (not_found) { + driver_count = k; + axis_mon[k][0] = ' '; // mark this entry invalid + break; + } + } + + if (driver_count == 0) { + L6470_ECHOLNPGM("ERROR - not a L6470 axis"); + return true; + } + + L6470_ECHOPGM("Monitoring:"); + for (j = 0; j < driver_count; j++) L6470_ECHOPAIR(" ", axis_mon[j]); + L6470_EOL(); + + // now have a list of driver(s) to monitor + + // + // kVAL_HOLD checks & settings + // + + kval_hold = parser.byteval('K'); + if (kval_hold) { + L6470_ECHOLNPAIR("kval_hold = ", kval_hold); + for (j = 0; j < driver_count; j++) + set_param(axis_index[j], L6470_KVAL_HOLD, kval_hold); + } + else { + // only print the KVAL_HOLD from one of the drivers + kval_hold = get_param(axis_index[0], L6470_KVAL_HOLD); + L6470_ECHOLNPAIR("KVAL_HOLD = ", kval_hold); + } + + // + // Overcurrent checks & settings + // + + if (over_current_flag) { + + uint8_t OCD_TH_val_local = 0, // compiler thinks OCD_TH_val is unused if use it directly + STALL_TH_val_local = 0; // just in case ... + + over_current_threshold = parser.intval('I'); + + if (over_current_threshold) { + + OCD_TH_val_local = over_current_threshold/375; + LIMIT(OCD_TH_val_local, 0, 15); + STALL_TH_val_local = over_current_threshold/31.25; + LIMIT(STALL_TH_val_local, 0, 127); + uint16_t OCD_TH_actual = (OCD_TH_val_local + 1) * 375, + STALL_TH_actual = (STALL_TH_val_local + 1) * 31.25; + if (OCD_TH_actual < STALL_TH_actual) { + OCD_TH_val_local++; + OCD_TH_actual = (OCD_TH_val_local + 1) * 375; + } + + L6470_ECHOLNPAIR("over_current_threshold specified: ", over_current_threshold); + echo_oct_used(STALL_TH_actual, true); + echo_oct_used(OCD_TH_actual, false); + + #define SET_OVER_CURRENT(Q) do { stepper##Q.SetParam(L6470_STALL_TH, STALL_TH_val_local); stepper##Q.SetParam(L6470_OCD_TH, OCD_TH_val_local);} while (0) + + for (j = 0; j < driver_count; j++) { + set_param(axis_index[j], L6470_STALL_TH, STALL_TH_val_local); + set_param(axis_index[j], L6470_OCD_TH, OCD_TH_val_local); + } + } + else { + // only get & print the OVER_CURRENT values from one of the drivers + STALL_TH_val_local = get_param(axis_index[0], L6470_STALL_TH); + OCD_TH_val_local = get_param(axis_index[0], L6470_OCD_TH); + + echo_oct_used((STALL_TH_val_local + 1) * 31.25, true); + echo_oct_used((OCD_TH_val_local + 1) * 375, false); + } // over_current_threshold + + for (j = 0; j < driver_count; j++) { // set all drivers on axis the same + set_param(axis_index[j], L6470_STALL_TH, STALL_TH_val_local); + set_param(axis_index[j], L6470_OCD_TH, OCD_TH_val_local); + } + + OCD_TH_val = OCD_TH_val_local; // force compiler to update the main routine's copy + STALL_TH_val = STALL_TH_val_local; // force compiler to update the main routine's copy + } // end of overcurrent + + // + // Feedrate + // + + final_feedrate = parser.floatval('F'); + if (final_feedrate == 0) { + static constexpr float default_max_feedrate[] = DEFAULT_MAX_FEEDRATE; + const uint8_t num_feedrates = COUNT(default_max_feedrate); + for (j = 0; j < num_feedrates; j++) { + if (axis_codes[j] == axis_mon[0][0]) { + final_feedrate = default_max_feedrate[j]; + break; + } + } + if (j == 3 && num_feedrates > 4) { // have more than one extruder feedrate + uint8_t extruder_num = axis_mon[0][1] - '0'; + if (j <= num_feedrates - extruder_num) // have a feedrate specifically for this extruder + final_feedrate = default_max_feedrate[j + extruder_num]; + else + final_feedrate = default_max_feedrate[3]; // use E0 feedrate for this extruder + } + final_feedrate *= 60; // convert to mm/minute + } // end of feedrate + + return false; // FALSE indicates no user input problems +} + +#if ENABLED(L6470_CHITCHAT) + inline void echo_yes_no(const bool yes) { serialprintPGM(yes ? PSTR("YES") : PSTR("NO ")); } +#endif + +void L6470_Marlin::say_axis(const uint8_t axis, const bool label/*=true*/) { + if (label) SERIAL_ECHOPGM("AXIS:"); + SERIAL_CHAR(' '); + SERIAL_CHAR(index_to_axis[axis][0]); + SERIAL_CHAR(index_to_axis[axis][1]); + SERIAL_CHAR(' '); +} + +void L6470_Marlin::error_status_decode(const uint16_t status, const uint8_t axis) { // assumes status bits have been inverted + #if ENABLED(L6470_CHITCHAT) + char temp_buf[10]; + say_axis(axis); + sprintf_P(temp_buf, PSTR(" %4x "), status); + L6470_ECHO(temp_buf); + print_bin(status); + L6470_ECHOPGM(" THERMAL: "); + serialprintPGM((status & STATUS_TH_SD) ? PSTR("SHUTDOWN") : (status & STATUS_TH_WRN) ? PSTR("WARNING ") : PSTR("OK ")); + L6470_ECHOPGM(" OVERCURRENT: "); + echo_yes_no(status & STATUS_OCD); + L6470_ECHOPGM(" STALL: "); + echo_yes_no(status & (STATUS_STEP_LOSS_A | STATUS_STEP_LOSS_B)); + L6470_EOL(); + #else + UNUSED(status); UNUSED(axis); + #endif +} + +////////////////////////////////////////////////////////////////////////////////////////////////// +//// +//// MONITOR_L6470_DRIVER_STATUS routines +//// +////////////////////////////////////////////////////////////////////////////////////////////////// + +#if ENABLED(MONITOR_L6470_DRIVER_STATUS) + + struct L6470_driver_data { + uint8_t driver_index; + uint32_t driver_status; + bool is_otw; + uint8_t otw_counter; + bool is_ot; + bool is_hi_Z; + uint8_t com_counter; + }; + + L6470_driver_data driver_L6470_data[] = { + #if AXIS_DRIVER_TYPE_X(L6470) + { 0, 0, 0, 0, 0, 0, 0 }, + #endif + #if AXIS_DRIVER_TYPE_Y(L6470) + { 1, 0, 0, 0, 0, 0, 0 }, + #endif + #if AXIS_DRIVER_TYPE_Z(L6470) + { 2, 0, 0, 0, 0, 0, 0 }, + #endif + #if AXIS_DRIVER_TYPE_X2(L6470) + { 3, 0, 0, 0, 0, 0, 0 }, + #endif + #if AXIS_DRIVER_TYPE_Y2(L6470) + { 4, 0, 0, 0, 0, 0, 0 }, + #endif + #if AXIS_DRIVER_TYPE_Z2(L6470) + { 5, 0, 0, 0, 0, 0, 0 }, + #endif + #if AXIS_DRIVER_TYPE_Z3(L6470) + { 6, 0, 0, 0, 0, 0, 0 }, + #endif + #if AXIS_DRIVER_TYPE_E0(L6470) + { 7, 0, 0, 0, 0, 0, 0 }, + #endif + #if AXIS_DRIVER_TYPE_E1(L6470) + { 8, 0, 0, 0, 0, 0, 0 }, + #endif + #if AXIS_DRIVER_TYPE_E2(L6470) + { 9, 0, 0, 0, 0, 0, 0 }, + #endif + #if AXIS_DRIVER_TYPE_E3(L6470) + { 10, 0, 0, 0, 0, 0, 0 }, + #endif + #if AXIS_DRIVER_TYPE_E4(L6470) + { 11, 0, 0, 0, 0, 0, 0 }, + #endif + #if AXIS_DRIVER_TYPE_E5(L6470) + { 12, 0, 0, 0, 0, 0, 0 } + #endif + }; + + inline void append_stepper_err(char * &p, const uint8_t stepper_index, const char * const err=NULL) { + p += sprintf_P(p, PSTR("Stepper %c%c "), char(index_to_axis[stepper_index][0]), char(index_to_axis[stepper_index][1])); + if (err) p += sprintf_P(p, err); + } + + void L6470_monitor_update(uint8_t stepper_index, uint16_t status) { + if (spi_abort) return; // don't do anything if set_directions() has occurred + uint8_t kval_hold; + char temp_buf[120]; + char* p = &temp_buf[0]; + uint8_t j; + for (j = 0; j < L6470::chain[0]; j++) // find the table for this stepper + if (driver_L6470_data[j].driver_index == stepper_index) break; + + driver_L6470_data[j].driver_status = status; + uint16_t _status = ~status; // all error bits are active low + + if (status == 0 || status == 0xFFFF) { // com problem + if (driver_L6470_data[j].com_counter == 0) { // warn user when it first happens + driver_L6470_data[j].com_counter++; + append_stepper_err(p, stepper_index, PSTR(" - communications lost\n")); + L6470_ECHO(temp_buf); + } + else { + driver_L6470_data[j].com_counter++; + if (driver_L6470_data[j].com_counter > 240) { // remind of com problem about every 2 minutes + driver_L6470_data[j].com_counter = 1; + append_stepper_err(p, stepper_index, PSTR(" - still no communications\n")); + L6470_ECHO(temp_buf); + } + } + } + else { + if (driver_L6470_data[j].com_counter) { // comms re-established + driver_L6470_data[j].com_counter = 0; + append_stepper_err(p, stepper_index, PSTR(" - communications re-established\n.. setting all drivers to default values\n")); + L6470_ECHO(temp_buf); + init_to_defaults(); + } + else { + // no com problems - do the usual checks + if (_status & L6470_ERROR_MASK) { + append_stepper_err(p, stepper_index); + + if (status & STATUS_HIZ) { // the driver has shut down HiZ is active high + driver_L6470_data[j].is_hi_Z = true; + p += sprintf_P(p, PSTR("%cIS SHUT DOWN"), ' '); + // if (_status & STATUS_TH_SD) { // strange - TH_SD never seems to go active, must be implied by the HiZ and TH_WRN + if (_status & STATUS_TH_WRN) { // over current shutdown + p += sprintf_P(p, PSTR("%cdue to over temperature"), ' '); + driver_L6470_data[j].is_ot = true; + kval_hold = get_param(stepper_index, L6470_KVAL_HOLD) - 2 * KVAL_HOLD_STEP_DOWN; + set_param(stepper_index, L6470_KVAL_HOLD, kval_hold); // reduce KVAL_HOLD + p += sprintf_P(p, PSTR(" - KVAL_HOLD reduced by %d to %d"), 2 * KVAL_HOLD_STEP_DOWN, kval_hold); // let user know + } + else + driver_L6470_data[j].is_ot = false; + } + else { + driver_L6470_data[j].is_hi_Z = false; + + if (_status & STATUS_TH_WRN) { // have an over temperature warning + driver_L6470_data[j].is_otw = true; + driver_L6470_data[j].otw_counter++; + kval_hold = get_param(stepper_index, L6470_KVAL_HOLD); + if (driver_L6470_data[j].otw_counter > 4) { // otw present for 2 - 2.5 seconds, reduce KVAL_HOLD + kval_hold -= KVAL_HOLD_STEP_DOWN; + set_param(stepper_index, L6470_KVAL_HOLD, kval_hold); // reduce KVAL_HOLD + p += sprintf_P(p, PSTR(" - KVAL_HOLD reduced by %d to %d"), KVAL_HOLD_STEP_DOWN, kval_hold); // let user know + driver_L6470_data[j].otw_counter = 0; + driver_L6470_data[j].is_otw = true; + } + else if (driver_L6470_data[j].otw_counter) + p += sprintf_P(p, PSTR("%c- thermal warning"), ' '); // warn user + } + } + + #ifdef L6470_STOP_ON_ERROR + if (_status & (STATUS_UVLO | STATUS_TH_WRN | STATUS_TH_SD)) + kill(temp_buf); + #endif + + + #if ENABLED(L6470_CHITCHAT) + + if (_status & STATUS_OCD) + p += sprintf_P(p, PSTR("%c over current"), ' '); + + if (_status & (STATUS_STEP_LOSS_A | STATUS_STEP_LOSS_B)) + p += sprintf_P(p, PSTR("%c stall"), ' '); + + if (_status & STATUS_UVLO) + p += sprintf_P(p, PSTR("%c under voltage lock out"), ' '); + + p += sprintf_P(p, PSTR("%c\n"), ' '); + #endif + + L6470_ECHOLN(temp_buf); // print the error message + } + else { + driver_L6470_data[j].is_ot = false; + driver_L6470_data[j].otw_counter = 0; //clear out warning indicators + driver_L6470_data[j].is_otw = false; + + } // end usual checks + } // comms established but have errors + } // comms re-established + } // end L6470_monitor_update() + + #define MONITOR_L6470_DRIVE(Q) L6470_monitor_update(Q, stepper##Q.getStatus()) + + void L6470_Marlin::monitor_driver() { + static millis_t next_cOT = 0; + if (ELAPSED(millis(), next_cOT)) { + next_cOT = millis() + 500; + + spi_active = true; // let set_directions() know we're in the middle of a series of SPI transfers + + #if AXIS_DRIVER_TYPE_X(L6470) + MONITOR_L6470_DRIVE(X); + #endif + #if AXIS_DRIVER_TYPE_Y(L6470) + MONITOR_L6470_DRIVE(Y); + #endif + #if AXIS_DRIVER_TYPE_Z(L6470) + MONITOR_L6470_DRIVE(Z); + #endif + #if AXIS_DRIVER_TYPE_X2(L6470) + MONITOR_L6470_DRIVE(X2); + #endif + #if AXIS_DRIVER_TYPE_Y2(L6470) + MONITOR_L6470_DRIVE(Y2); + #endif + #if AXIS_DRIVER_TYPE_Z2(L6470) + MONITOR_L6470_DRIVE(Z2); + #endif + #if AXIS_DRIVER_TYPE_Z3(L6470) + MONITOR_L6470_DRIVE(Z3); + #endif + #if AXIS_DRIVER_TYPE_E0(L6470) + MONITOR_L6470_DRIVE(E0); + #endif + #if AXIS_DRIVER_TYPE_E1(L6470) + MONITOR_L6470_DRIVE(E1); + #endif + #if AXIS_DRIVER_TYPE_E2(L6470) + MONITOR_L6470_DRIVE(E2); + #endif + #if AXIS_DRIVER_TYPE_E3(L6470) + MONITOR_L6470_DRIVE(E3); + #endif + #if AXIS_DRIVER_TYPE_E4(L6470) + MONITOR_L6470_DRIVE(E4); + #endif + #if AXIS_DRIVER_TYPE_E5(L6470) + MONITOR_L6470_DRIVE(E5); + #endif + + #if ENABLED(L6470_DEBUG) + if (report_L6470_status) L6470_EOL(); + #endif + + spi_active = false; // done with all SPI transfers - clear handshake flags + spi_abort = false; + } + } + +#endif // MONITOR_L6470_DRIVER_STATUS + +#endif // HAS_DRIVER(L6470) diff --git a/Marlin/src/libs/L6470/L6470_Marlin.h b/Marlin/src/libs/L6470/L6470_Marlin.h new file mode 100644 index 000000000..a84e87eaa --- /dev/null +++ b/Marlin/src/libs/L6470/L6470_Marlin.h @@ -0,0 +1,93 @@ +/** + * Marlin 3D Printer Firmware + * Copyright (C) 2018 MarlinFirmware [https://github.com/MarlinFirmware/Marlin] + * + * Based on Sprinter and grbl. + * Copyright (C) 2011 Camiel Gubbels / Erik van der Zalm + * + * This program 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. + * + * This program 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 this program. If not, see . + * + */ + +#include "../../inc/MarlinConfig.h" + +#include + +#if ENABLED(L6470_CHITCHAT) + #define L6470_EOL() SERIAL_EOL() + #define L6470_CHAR(C) SERIAL_CHAR(C) + #define L6470_ECHO(V) SERIAL_ECHO(V) + #define L6470_ECHOLN(V) SERIAL_ECHOLN(V) + #define L6470_ECHOPGM(S) SERIAL_ECHOPGM(S) + #define L6470_ECHOLNPGM(S) SERIAL_ECHOLNPGM(S) + #define L6470_ECHOPAIR(S,V) SERIAL_ECHOPAIR(S,V) + #define L6470_ECHOLNPAIR(S,V) SERIAL_ECHOLNPAIR(S,V) +#else + #define L6470_EOL() NOOP + #define L6470_CHAR(C) NOOP + #define L6470_ECHO(V) NOOP + #define L6470_ECHOLN(V) NOOP + #define L6470_ECHOPGM(S) NOOP + #define L6470_ECHOLNPGM(S) NOOP + #define L6470_ECHOPAIR(S,V) NOOP + #define L6470_ECHOLNPAIR(S,V) NOOP +#endif + +#define L6470_GETPARAM(P,Q) stepper##Q.GetParam(P) + +#define MAX_L6470 (7 + MAX_EXTRUDERS) // Maximum number of axes in Marlin + +#define L6470_ERROR_MASK (STATUS_UVLO | STATUS_TH_WRN | STATUS_TH_SD | STATUS_OCD | STATUS_STEP_LOSS_A | STATUS_STEP_LOSS_B) +#define dSPIN_STEP_CLOCK_FWD dSPIN_STEP_CLOCK +#define dSPIN_STEP_CLOCK_REV dSPIN_STEP_CLOCK+1 +#define HAS_L6470_EXTRUDER ( AXIS_DRIVER_TYPE_E0(L6470) || AXIS_DRIVER_TYPE_E1(L6470) || AXIS_DRIVER_TYPE_E2(L6470) \ + || AXIS_DRIVER_TYPE_E3(L6470) || AXIS_DRIVER_TYPE_E4(L6470) || AXIS_DRIVER_TYPE_E5(L6470) ) + +class L6470_Marlin { +public: + static bool index_to_dir[MAX_L6470]; + static uint8_t axis_xref[MAX_L6470]; + static char index_to_axis[MAX_L6470][3]; + static uint8_t dir_commands[MAX_L6470]; + + // flags to guarantee graceful switch if stepper interrupts L6470 SPI transfer + static volatile bool spi_abort; + static bool spi_active; + + L6470_Marlin() {} + + static uint16_t get_status(const uint8_t axis); + + static uint32_t get_param(uint8_t axis, uint8_t param); + + static void set_param(uint8_t axis, uint8_t param, uint32_t value); + + static bool get_user_input(uint8_t &driver_count, uint8_t axis_index[3], char axis_mon[3][3], + float &position_max, float &position_min, float &final_feedrate, uint8_t &kval_hold, + bool over_current_flag, uint8_t &OCD_TH_val, uint8_t &STALL_TH_val, uint16_t &over_current_threshold); + + static void error_status_decode(const uint16_t status, const uint8_t axis); + + static void monitor_driver(); + + static void init(); + static void init_to_defaults(); + + static void say_axis(const uint8_t axis, const bool label=true); + +private: + void populate_chain_array(); +}; + +extern L6470_Marlin L6470; diff --git a/Marlin/src/module/stepper.cpp b/Marlin/src/module/stepper.cpp index ef2098fee..d067e0a10 100644 --- a/Marlin/src/module/stepper.cpp +++ b/Marlin/src/module/stepper.cpp @@ -79,6 +79,8 @@ #include "stepper.h" +Stepper stepper; // Singleton + #ifdef __AVR__ #include "speed_lookuptable.h" #endif @@ -107,12 +109,14 @@ #include "../feature/mixing.h" #endif -Stepper stepper; // Singleton - #if FILAMENT_RUNOUT_DISTANCE_MM > 0 #include "../feature/runout.h" #endif +#if HAS_DRIVER(L6470) + #include "../libs/L6470/L6470_Marlin.h" +#endif + // public: #if ENABLED(X_DUAL_ENDSTOPS) || ENABLED(Y_DUAL_ENDSTOPS) || Z_MULTI_ENDSTOPS || ENABLED(Z_STEPPER_AUTO_ALIGN) @@ -350,22 +354,28 @@ void Stepper::wake_up() { */ void Stepper::set_directions() { - #define SET_STEP_DIR(A) \ - if (motor_direction(_AXIS(A))) { \ - A##_APPLY_DIR(INVERT_## A##_DIR, false); \ - count_direction[_AXIS(A)] = -1; \ - } \ - else { \ + #if HAS_DRIVER(L6470) + uint8_t L6470_buf[MAX_L6470 + 1]; // chip command sequence - element 0 not used + #endif + + #define SET_STEP_DIR(A) \ + if (motor_direction(_AXIS(A))) { \ + A##_APPLY_DIR(INVERT_## A##_DIR, false); \ + count_direction[_AXIS(A)] = -1; \ + } \ + else { \ A##_APPLY_DIR(!INVERT_## A##_DIR, false); \ - count_direction[_AXIS(A)] = 1; \ + count_direction[_AXIS(A)] = 1; \ } #if HAS_X_DIR SET_STEP_DIR(X); // A #endif + #if HAS_Y_DIR SET_STEP_DIR(Y); // B #endif + #if HAS_Z_DIR SET_STEP_DIR(Z); // C #endif @@ -394,6 +404,27 @@ void Stepper::set_directions() { #endif #endif // !LIN_ADVANCE + #if HAS_DRIVER(L6470) + + if (L6470.spi_active) { + L6470.spi_abort = true; // interrupted a SPI transfer - need to shut it down gracefully + for (uint8_t j = 1; j <= L6470::chain[0]; j++) + L6470_buf[j] = dSPIN_NOP; // fill buffer with NOOP commands + L6470.transfer(L6470_buf, L6470::chain[0]); // send enough NOOPs to complete any command + L6470.transfer(L6470_buf, L6470::chain[0]); + L6470.transfer(L6470_buf, L6470::chain[0]); + } + + // The L6470.dir_commands[] array holds the direction command for each stepper + + //scan command array and copy matches into L6470.transfer + for (uint8_t j = 1; j <= L6470::chain[0]; j++) + L6470_buf[j] = L6470.dir_commands[L6470::chain[j]]; + + L6470.transfer(L6470_buf, L6470::chain[0]); // send the command stream to the drivers + + #endif + // A small delay may be needed after changing direction #if MINIMUM_STEPPER_DIR_DELAY > 0 DELAY_NS(MINIMUM_STEPPER_DIR_DELAY); @@ -1766,10 +1797,15 @@ uint32_t Stepper::stepper_block_phase_isr() { else LA_isr_rate = LA_ADV_NEVER; #endif - if (current_block->direction_bits != last_direction_bits + if ( + #if HAS_DRIVER(L6470) + true // Always set direction for L6470 (This also enables the chips) + #else + current_block->direction_bits != last_direction_bits #if DISABLED(MIXING_EXTRUDER) || stepper_extruder != last_moved_extruder #endif + #endif ) { last_direction_bits = current_block->direction_bits; #if EXTRUDERS > 1 @@ -2113,7 +2149,10 @@ void Stepper::init() { ENABLE_STEPPER_DRIVER_INTERRUPT(); sei(); - set_directions(); // Init directions to last_direction_bits = 0 Keeps Z from being reversed + + Z_DIR_WRITE(0); // Init directions to last_direction_bits = 0 Keeps Z from being reversed + Z2_DIR_WRITE(0); + Z3_DIR_WRITE(0); } /** diff --git a/Marlin/src/module/stepper_indirection.cpp b/Marlin/src/module/stepper_indirection.cpp index 74d5aa0c1..a85d27565 100644 --- a/Marlin/src/module/stepper_indirection.cpp +++ b/Marlin/src/module/stepper_indirection.cpp @@ -37,6 +37,10 @@ #include "../module/stepper.h" +#if HAS_DRIVER(L6470) + #include "L6470/L6470_Marlin.h" +#endif + // // TMC26X Driver objects and inits // @@ -51,43 +55,43 @@ #define _TMC26X_DEFINE(ST) TMC26XStepper stepper##ST(200, ST##_CS_PIN, ST##_STEP_PIN, ST##_DIR_PIN, ST##_MAX_CURRENT, ST##_SENSE_RESISTOR) - #if AXIS_DRIVER_TYPE(X, TMC26X) + #if AXIS_DRIVER_TYPE_X(TMC26X) _TMC26X_DEFINE(X); #endif - #if AXIS_DRIVER_TYPE(X2, TMC26X) + #if AXIS_DRIVER_TYPE_X2(TMC26X) _TMC26X_DEFINE(X2); #endif - #if AXIS_DRIVER_TYPE(Y, TMC26X) + #if AXIS_DRIVER_TYPE_Y(TMC26X) _TMC26X_DEFINE(Y); #endif - #if AXIS_DRIVER_TYPE(Y2, TMC26X) + #if AXIS_DRIVER_TYPE_Y2(TMC26X) _TMC26X_DEFINE(Y2); #endif - #if AXIS_DRIVER_TYPE(Z, TMC26X) + #if AXIS_DRIVER_TYPE_Z(TMC26X) _TMC26X_DEFINE(Z); #endif - #if AXIS_DRIVER_TYPE(Z2, TMC26X) + #if AXIS_DRIVER_TYPE_Z2(TMC26X) _TMC26X_DEFINE(Z2); #endif - #if AXIS_DRIVER_TYPE(Z3, TMC26X) + #if AXIS_DRIVER_TYPE_Z3(TMC26X) _TMC26X_DEFINE(Z3); #endif - #if AXIS_DRIVER_TYPE(E0, TMC26X) + #if AXIS_DRIVER_TYPE_E0(TMC26X) _TMC26X_DEFINE(E0); #endif - #if AXIS_DRIVER_TYPE(E1, TMC26X) + #if AXIS_DRIVER_TYPE_E1(TMC26X) _TMC26X_DEFINE(E1); #endif - #if AXIS_DRIVER_TYPE(E2, TMC26X) + #if AXIS_DRIVER_TYPE_E2(TMC26X) _TMC26X_DEFINE(E2); #endif - #if AXIS_DRIVER_TYPE(E3, TMC26X) + #if AXIS_DRIVER_TYPE_E3(TMC26X) _TMC26X_DEFINE(E3); #endif - #if AXIS_DRIVER_TYPE(E4, TMC26X) + #if AXIS_DRIVER_TYPE_E4(TMC26X) _TMC26X_DEFINE(E4); #endif - #if AXIS_DRIVER_TYPE(E5, TMC26X) + #if AXIS_DRIVER_TYPE_E5(TMC26X) _TMC26X_DEFINE(E5); #endif @@ -97,43 +101,43 @@ }while(0) void tmc26x_init_to_defaults() { - #if AXIS_DRIVER_TYPE(X, TMC26X) + #if AXIS_DRIVER_TYPE_X(TMC26X) _TMC26X_INIT(X); #endif - #if AXIS_DRIVER_TYPE(X2, TMC26X) + #if AXIS_DRIVER_TYPE_X2(TMC26X) _TMC26X_INIT(X2); #endif - #if AXIS_DRIVER_TYPE(Y, TMC26X) + #if AXIS_DRIVER_TYPE_Y(TMC26X) _TMC26X_INIT(Y); #endif - #if AXIS_DRIVER_TYPE(Y2, TMC26X) + #if AXIS_DRIVER_TYPE_Y2(TMC26X) _TMC26X_INIT(Y2); #endif - #if AXIS_DRIVER_TYPE(Z, TMC26X) + #if AXIS_DRIVER_TYPE_Z(TMC26X) _TMC26X_INIT(Z); #endif - #if AXIS_DRIVER_TYPE(Z2, TMC26X) + #if AXIS_DRIVER_TYPE_Z2(TMC26X) _TMC26X_INIT(Z2); #endif - #if AXIS_DRIVER_TYPE(Z3, TMC26X) + #if AXIS_DRIVER_TYPE_Z3(TMC26X) _TMC26X_INIT(Z3); #endif - #if AXIS_DRIVER_TYPE(E0, TMC26X) + #if AXIS_DRIVER_TYPE_E0(TMC26X) _TMC26X_INIT(E0); #endif - #if AXIS_DRIVER_TYPE(E1, TMC26X) + #if AXIS_DRIVER_TYPE_E1(TMC26X) _TMC26X_INIT(E1); #endif - #if AXIS_DRIVER_TYPE(E2, TMC26X) + #if AXIS_DRIVER_TYPE_E2(TMC26X) _TMC26X_INIT(E2); #endif - #if AXIS_DRIVER_TYPE(E3, TMC26X) + #if AXIS_DRIVER_TYPE_E3(TMC26X) _TMC26X_INIT(E3); #endif - #if AXIS_DRIVER_TYPE(E4, TMC26X) + #if AXIS_DRIVER_TYPE_E4(TMC26X) _TMC26X_INIT(E4); #endif - #if AXIS_DRIVER_TYPE(E5, TMC26X) + #if AXIS_DRIVER_TYPE_E5(TMC26X) _TMC26X_INIT(E5); #endif } @@ -161,43 +165,43 @@ #define TMC2130_DEFINE(ST) _TMC2130_DEFINE(ST, TMC_##ST##_LABEL) #endif // Stepper objects of TMC2130 steppers used - #if AXIS_DRIVER_TYPE(X, TMC2130) + #if AXIS_DRIVER_TYPE_X(TMC2130) TMC2130_DEFINE(X); #endif - #if AXIS_DRIVER_TYPE(X2, TMC2130) + #if AXIS_DRIVER_TYPE_X2(TMC2130) TMC2130_DEFINE(X2); #endif - #if AXIS_DRIVER_TYPE(Y, TMC2130) + #if AXIS_DRIVER_TYPE_Y(TMC2130) TMC2130_DEFINE(Y); #endif - #if AXIS_DRIVER_TYPE(Y2, TMC2130) + #if AXIS_DRIVER_TYPE_Y2(TMC2130) TMC2130_DEFINE(Y2); #endif - #if AXIS_DRIVER_TYPE(Z, TMC2130) + #if AXIS_DRIVER_TYPE_Z(TMC2130) TMC2130_DEFINE(Z); #endif - #if AXIS_DRIVER_TYPE(Z2, TMC2130) + #if AXIS_DRIVER_TYPE_Z2(TMC2130) TMC2130_DEFINE(Z2); #endif - #if AXIS_DRIVER_TYPE(Z3, TMC2130) + #if AXIS_DRIVER_TYPE_Z3(TMC2130) TMC2130_DEFINE(Z3); #endif - #if AXIS_DRIVER_TYPE(E0, TMC2130) + #if AXIS_DRIVER_TYPE_E0(TMC2130) TMC2130_DEFINE(E0); #endif - #if AXIS_DRIVER_TYPE(E1, TMC2130) + #if AXIS_DRIVER_TYPE_E1(TMC2130) TMC2130_DEFINE(E1); #endif - #if AXIS_DRIVER_TYPE(E2, TMC2130) + #if AXIS_DRIVER_TYPE_E2(TMC2130) TMC2130_DEFINE(E2); #endif - #if AXIS_DRIVER_TYPE(E3, TMC2130) + #if AXIS_DRIVER_TYPE_E3(TMC2130) TMC2130_DEFINE(E3); #endif - #if AXIS_DRIVER_TYPE(E4, TMC2130) + #if AXIS_DRIVER_TYPE_E4(TMC2130) TMC2130_DEFINE(E4); #endif - #if AXIS_DRIVER_TYPE(E5, TMC2130) + #if AXIS_DRIVER_TYPE_E5(TMC2130) TMC2130_DEFINE(E5); #endif @@ -253,91 +257,91 @@ #define TMC2208_DEFINE_SOFTWARE(ST) _TMC2208_DEFINE_SOFTWARE(ST, TMC_##ST##_LABEL) // Stepper objects of TMC2208 steppers used - #if AXIS_DRIVER_TYPE(X, TMC2208) + #if AXIS_DRIVER_TYPE_X(TMC2208) #ifdef X_HARDWARE_SERIAL TMC2208_DEFINE_HARDWARE(X); #else TMC2208_DEFINE_SOFTWARE(X); #endif #endif - #if AXIS_DRIVER_TYPE(X2, TMC2208) + #if AXIS_DRIVER_TYPE_X2(TMC2208) #ifdef X2_HARDWARE_SERIAL TMC2208_DEFINE_HARDWARE(X2); #else TMC2208_DEFINE_SOFTWARE(X2); #endif #endif - #if AXIS_DRIVER_TYPE(Y, TMC2208) + #if AXIS_DRIVER_TYPE_Y(TMC2208) #ifdef Y_HARDWARE_SERIAL TMC2208_DEFINE_HARDWARE(Y); #else TMC2208_DEFINE_SOFTWARE(Y); #endif #endif - #if AXIS_DRIVER_TYPE(Y2, TMC2208) + #if AXIS_DRIVER_TYPE_Y2(TMC2208) #ifdef Y2_HARDWARE_SERIAL TMC2208_DEFINE_HARDWARE(Y2); #else TMC2208_DEFINE_SOFTWARE(Y2); #endif #endif - #if AXIS_DRIVER_TYPE(Z, TMC2208) + #if AXIS_DRIVER_TYPE_Z(TMC2208) #ifdef Z_HARDWARE_SERIAL TMC2208_DEFINE_HARDWARE(Z); #else TMC2208_DEFINE_SOFTWARE(Z); #endif #endif - #if AXIS_DRIVER_TYPE(Z2, TMC2208) + #if AXIS_DRIVER_TYPE_Z2(TMC2208) #ifdef Z2_HARDWARE_SERIAL TMC2208_DEFINE_HARDWARE(Z2); #else TMC2208_DEFINE_SOFTWARE(Z2); #endif #endif - #if AXIS_DRIVER_TYPE(Z3, TMC2208) + #if AXIS_DRIVER_TYPE_Z3(TMC2208) #ifdef Z3_HARDWARE_SERIAL TMC2208_DEFINE_HARDWARE(Z3); #else TMC2208_DEFINE_SOFTWARE(Z3); #endif #endif - #if AXIS_DRIVER_TYPE(E0, TMC2208) + #if AXIS_DRIVER_TYPE_E0(TMC2208) #ifdef E0_HARDWARE_SERIAL TMC2208_DEFINE_HARDWARE(E0); #else TMC2208_DEFINE_SOFTWARE(E0); #endif #endif - #if AXIS_DRIVER_TYPE(E1, TMC2208) + #if AXIS_DRIVER_TYPE_E1(TMC2208) #ifdef E1_HARDWARE_SERIAL TMC2208_DEFINE_HARDWARE(E1); #else TMC2208_DEFINE_SOFTWARE(E1); #endif #endif - #if AXIS_DRIVER_TYPE(E2, TMC2208) + #if AXIS_DRIVER_TYPE_E2(TMC2208) #ifdef E2_HARDWARE_SERIAL TMC2208_DEFINE_HARDWARE(E2); #else TMC2208_DEFINE_SOFTWARE(E2); #endif #endif - #if AXIS_DRIVER_TYPE(E3, TMC2208) + #if AXIS_DRIVER_TYPE_E3(TMC2208) #ifdef E3_HARDWARE_SERIAL TMC2208_DEFINE_HARDWARE(E3); #else TMC2208_DEFINE_SOFTWARE(E3); #endif #endif - #if AXIS_DRIVER_TYPE(E4, TMC2208) + #if AXIS_DRIVER_TYPE_E4(TMC2208) #ifdef E4_HARDWARE_SERIAL TMC2208_DEFINE_HARDWARE(E4); #else TMC2208_DEFINE_SOFTWARE(E4); #endif #endif - #if AXIS_DRIVER_TYPE(E5, TMC2208) + #if AXIS_DRIVER_TYPE_E5(TMC2208) #ifdef E5_HARDWARE_SERIAL TMC2208_DEFINE_HARDWARE(E5); #else @@ -346,91 +350,91 @@ #endif void tmc2208_serial_begin() { - #if AXIS_DRIVER_TYPE(X, TMC2208) + #if AXIS_DRIVER_TYPE_X(TMC2208) #ifdef X_HARDWARE_SERIAL X_HARDWARE_SERIAL.begin(115200); #else stepperX.beginSerial(115200); #endif #endif - #if AXIS_DRIVER_TYPE(X2, TMC2208) + #if AXIS_DRIVER_TYPE_X2(TMC2208) #ifdef X2_HARDWARE_SERIAL X2_HARDWARE_SERIAL.begin(115200); #else stepperX2.beginSerial(115200); #endif #endif - #if AXIS_DRIVER_TYPE(Y, TMC2208) + #if AXIS_DRIVER_TYPE_Y(TMC2208) #ifdef Y_HARDWARE_SERIAL Y_HARDWARE_SERIAL.begin(115200); #else stepperY.beginSerial(115200); #endif #endif - #if AXIS_DRIVER_TYPE(Y2, TMC2208) + #if AXIS_DRIVER_TYPE_Y2(TMC2208) #ifdef Y2_HARDWARE_SERIAL Y2_HARDWARE_SERIAL.begin(115200); #else stepperY2.beginSerial(115200); #endif #endif - #if AXIS_DRIVER_TYPE(Z, TMC2208) + #if AXIS_DRIVER_TYPE_Z(TMC2208) #ifdef Z_HARDWARE_SERIAL Z_HARDWARE_SERIAL.begin(115200); #else stepperZ.beginSerial(115200); #endif #endif - #if AXIS_DRIVER_TYPE(Z2, TMC2208) + #if AXIS_DRIVER_TYPE_Z2(TMC2208) #ifdef Z2_HARDWARE_SERIAL Z2_HARDWARE_SERIAL.begin(115200); #else stepperZ2.beginSerial(115200); #endif #endif - #if AXIS_DRIVER_TYPE(Z3, TMC2208) + #if AXIS_DRIVER_TYPE_Z3(TMC2208) #ifdef Z3_HARDWARE_SERIAL Z3_HARDWARE_SERIAL.begin(115200); #else stepperZ3.beginSerial(115200); #endif #endif - #if AXIS_DRIVER_TYPE(E0, TMC2208) + #if AXIS_DRIVER_TYPE_E0(TMC2208) #ifdef E0_HARDWARE_SERIAL E0_HARDWARE_SERIAL.begin(115200); #else stepperE0.beginSerial(115200); #endif #endif - #if AXIS_DRIVER_TYPE(E1, TMC2208) + #if AXIS_DRIVER_TYPE_E1(TMC2208) #ifdef E1_HARDWARE_SERIAL E1_HARDWARE_SERIAL.begin(115200); #else stepperE1.beginSerial(115200); #endif #endif - #if AXIS_DRIVER_TYPE(E2, TMC2208) + #if AXIS_DRIVER_TYPE_E2(TMC2208) #ifdef E2_HARDWARE_SERIAL E2_HARDWARE_SERIAL.begin(115200); #else stepperE2.beginSerial(115200); #endif #endif - #if AXIS_DRIVER_TYPE(E3, TMC2208) + #if AXIS_DRIVER_TYPE_E3(TMC2208) #ifdef E3_HARDWARE_SERIAL E3_HARDWARE_SERIAL.begin(115200); #else stepperE3.beginSerial(115200); #endif #endif - #if AXIS_DRIVER_TYPE(E4, TMC2208) + #if AXIS_DRIVER_TYPE_E4(TMC2208) #ifdef E4_HARDWARE_SERIAL E4_HARDWARE_SERIAL.begin(115200); #else stepperE4.beginSerial(115200); #endif #endif - #if AXIS_DRIVER_TYPE(E5, TMC2208) + #if AXIS_DRIVER_TYPE_E5(TMC2208) #ifdef E5_HARDWARE_SERIAL E5_HARDWARE_SERIAL.begin(115200); #else @@ -502,40 +506,40 @@ #endif // Stepper objects of TMC2660 steppers used - #if AXIS_DRIVER_TYPE(X, TMC2660) + #if AXIS_DRIVER_TYPE_X(TMC2660) TMC2660_DEFINE(X); #endif - #if AXIS_DRIVER_TYPE(X2, TMC2660) + #if AXIS_DRIVER_TYPE_X2(TMC2660) TMC2660_DEFINE(X2); #endif - #if AXIS_DRIVER_TYPE(Y, TMC2660) + #if AXIS_DRIVER_TYPE_Y(TMC2660) TMC2660_DEFINE(Y); #endif - #if AXIS_DRIVER_TYPE(Y2, TMC2660) + #if AXIS_DRIVER_TYPE_Y2(TMC2660) TMC2660_DEFINE(Y2); #endif - #if AXIS_DRIVER_TYPE(Z, TMC2660) + #if AXIS_DRIVER_TYPE_Z(TMC2660) TMC2660_DEFINE(Z); #endif - #if AXIS_DRIVER_TYPE(Z2, TMC2660) + #if AXIS_DRIVER_TYPE_Z2(TMC2660) TMC2660_DEFINE(Z2); #endif - #if AXIS_DRIVER_TYPE(E0, TMC2660) + #if AXIS_DRIVER_TYPE_E0(TMC2660) TMC2660_DEFINE(E0); #endif - #if AXIS_DRIVER_TYPE(E1, TMC2660) + #if AXIS_DRIVER_TYPE_E1(TMC2660) TMC2660_DEFINE(E1); #endif - #if AXIS_DRIVER_TYPE(E2, TMC2660) + #if AXIS_DRIVER_TYPE_E2(TMC2660) TMC2660_DEFINE(E2); #endif - #if AXIS_DRIVER_TYPE(E3, TMC2660) + #if AXIS_DRIVER_TYPE_E3(TMC2660) TMC2660_DEFINE(E3); #endif - #if AXIS_DRIVER_TYPE(E4, TMC2660) + #if AXIS_DRIVER_TYPE_E4(TMC2660) TMC2660_DEFINE(E4); #endif - #if AXIS_DRIVER_TYPE(E5, TMC2660) + #if AXIS_DRIVER_TYPE_E5(TMC2660) TMC2660_DEFINE(E5); #endif @@ -600,11 +604,13 @@ void restore_stepper_drivers() { } void reset_stepper_drivers() { + #if HAS_DRIVER(TMC26X) tmc26x_init_to_defaults(); #endif - #if ENABLED(HAVE_L6470DRIVER) - L6470_init_to_defaults(); + + #if HAS_DRIVER(L6470) + L6470.init_to_defaults(); #endif #if HAS_TRINAMIC @@ -703,7 +709,9 @@ void reset_stepper_drivers() { TMC_ADV() #endif - stepper.set_directions(); + #if HAS_TRINAMIC + stepper.set_directions(); + #endif } // @@ -711,99 +719,114 @@ void reset_stepper_drivers() { // #if HAS_DRIVER(L6470) - #include - #include + // create stepper objects - #define _L6470_DEFINE(ST) L6470 stepper##ST(ST##_ENABLE_PIN) + #define _L6470_DEFINE(ST) L6470 stepper##ST((const int)L6470_CHAIN_SS_PIN) // L6470 Stepper objects - #if AXIS_DRIVER_TYPE(X, L6470) + #if AXIS_DRIVER_TYPE_X(L6470) _L6470_DEFINE(X); #endif - #if AXIS_DRIVER_TYPE(X2, L6470) + #if AXIS_DRIVER_TYPE_X2(L6470) _L6470_DEFINE(X2); #endif - #if AXIS_DRIVER_TYPE(Y, L6470) + #if AXIS_DRIVER_TYPE_Y(L6470) _L6470_DEFINE(Y); #endif - #if AXIS_DRIVER_TYPE(Y2, L6470) + #if AXIS_DRIVER_TYPE_Y2(L6470) _L6470_DEFINE(Y2); #endif - #if AXIS_DRIVER_TYPE(Z, L6470) + #if AXIS_DRIVER_TYPE_Z(L6470) _L6470_DEFINE(Z); #endif - #if AXIS_DRIVER_TYPE(Z2, L6470) + #if AXIS_DRIVER_TYPE_Z2(L6470) _L6470_DEFINE(Z2); #endif - #if AXIS_DRIVER_TYPE(Z3, L6470) + #if AXIS_DRIVER_TYPE_Z3(L6470) _L6470_DEFINE(Z3); #endif - #if AXIS_DRIVER_TYPE(E0, L6470) + #if AXIS_DRIVER_TYPE_E0(L6470) _L6470_DEFINE(E0); #endif - #if AXIS_DRIVER_TYPE(E1, L6470) + #if AXIS_DRIVER_TYPE_E1(L6470) _L6470_DEFINE(E1); #endif - #if AXIS_DRIVER_TYPE(E2, L6470) + #if AXIS_DRIVER_TYPE_E2(L6470) _L6470_DEFINE(E2); #endif - #if AXIS_DRIVER_TYPE(E3, L6470) + #if AXIS_DRIVER_TYPE_E3(L6470) _L6470_DEFINE(E3); #endif - #if AXIS_DRIVER_TYPE(E4, L6470) + #if AXIS_DRIVER_TYPE_E4(L6470) _L6470_DEFINE(E4); #endif - #if AXIS_DRIVER_TYPE(E5, L6470) + #if AXIS_DRIVER_TYPE_E5(L6470) _L6470_DEFINE(E5); #endif - #define _L6470_INIT(A) do{ \ - stepper##A.init(); \ - stepper##A.softFree(); \ - stepper##A.setMicroSteps(A##_MICROSTEPS); \ - stepper##A.setOverCurrent(A##_OVERCURRENT); \ - stepper##A.setStallCurrent(A##_STALLCURRENT); \ + // not using L6470 library's init command because it + // briefly sends power to the steppers + + #define _L6470_INIT_CHIP(Q) do{ \ + stepper##Q.resetDev(); \ + stepper##Q.softFree(); \ + stepper##Q.SetParam(L6470_CONFIG, CONFIG_PWM_DIV_1 \ + | CONFIG_PWM_MUL_2 \ + | CONFIG_SR_290V_us \ + | CONFIG_OC_SD_DISABLE \ + | CONFIG_VS_COMP_DISABLE \ + | CONFIG_SW_HARD_STOP \ + | CONFIG_INT_16MHZ); \ + stepper##Q.SetParam(L6470_KVAL_RUN, 0xFF); \ + stepper##Q.SetParam(L6470_KVAL_ACC, 0xFF); \ + stepper##Q.SetParam(L6470_KVAL_DEC, 0xFF); \ + stepper##Q.setMicroSteps(Q##_MICROSTEPS); \ + stepper##Q.setOverCurrent(Q##_OVERCURRENT); \ + stepper##Q.setStallCurrent(Q##_STALLCURRENT); \ + stepper##Q.SetParam(L6470_KVAL_HOLD, Q##_MAX_VOLTAGE); \ + stepper##Q.SetParam(L6470_ABS_POS, 0); \ + stepper##Q.getStatus(); \ }while(0) - void L6470_init_to_defaults() { - #if AXIS_DRIVER_TYPE(X, L6470) - _L6470_INIT(X); + void L6470_Marlin::init_to_defaults() { + #if AXIS_DRIVER_TYPE_X(L6470) + _L6470_INIT_CHIP(X); #endif - #if AXIS_DRIVER_TYPE(X2, L6470) - _L6470_INIT(X2); + #if AXIS_DRIVER_TYPE_X2(L6470) + _L6470_INIT_CHIP(X2); #endif - #if AXIS_DRIVER_TYPE(Y, L6470) - _L6470_INIT(Y); + #if AXIS_DRIVER_TYPE_Y(L6470) + _L6470_INIT_CHIP(Y); #endif - #if AXIS_DRIVER_TYPE(Y2, L6470) - _L6470_INIT(Y2); + #if AXIS_DRIVER_TYPE_Y2(L6470) + _L6470_INIT_CHIP(Y2); #endif - #if AXIS_DRIVER_TYPE(Z, L6470) - _L6470_INIT(Z); + #if AXIS_DRIVER_TYPE_Z(L6470) + _L6470_INIT_CHIP(Z); #endif - #if AXIS_DRIVER_TYPE(Z2, L6470) - _L6470_INIT(Z2); + #if AXIS_DRIVER_TYPE_Z2(L6470) + _L6470_INIT_CHIP(Z2); #endif - #if AXIS_DRIVER_TYPE(Z3, L6470) - _L6470_INIT(Z3); + #if AXIS_DRIVER_TYPE_Z3(L6470) + _L6470_INIT_CHIP(Z3); #endif - #if AXIS_DRIVER_TYPE(E0, L6470) - _L6470_INIT(E0); + #if AXIS_DRIVER_TYPE_E0(L6470) + _L6470_INIT_CHIP(E0); #endif - #if AXIS_DRIVER_TYPE(E1, L6470) - _L6470_INIT(E1); + #if AXIS_DRIVER_TYPE_E1(L6470) + _L6470_INIT_CHIP(E1); #endif - #if AXIS_DRIVER_TYPE(E2, L6470) - _L6470_INIT(E2); + #if AXIS_DRIVER_TYPE_E2(L6470) + _L6470_INIT_CHIP(E2); #endif - #if AXIS_DRIVER_TYPE(E3, L6470) - _L6470_INIT(E3); + #if AXIS_DRIVER_TYPE_E3(L6470) + _L6470_INIT_CHIP(E3); #endif - #if AXIS_DRIVER_TYPE(E4, L6470) - _L6470_INIT(E4); + #if AXIS_DRIVER_TYPE_E4(L6470) + _L6470_INIT_CHIP(E4); #endif - #if AXIS_DRIVER_TYPE(E5, L6470) - _L6470_INIT(E5); + #if AXIS_DRIVER_TYPE_E5(L6470) + _L6470_INIT_CHIP(E5); #endif } diff --git a/Marlin/src/module/stepper_indirection.h b/Marlin/src/module/stepper_indirection.h index 6c073c75b..4279dee91 100644 --- a/Marlin/src/module/stepper_indirection.h +++ b/Marlin/src/module/stepper_indirection.h @@ -83,28 +83,27 @@ // L6470 has STEP on normal pins, but DIR/ENABLE via SPI #if HAS_DRIVER(L6470) - #include - #include - void L6470_init_to_defaults(); + #include "L6470/L6470_Marlin.h" + #define L6470_WRITE_DIR_COMMAND(STATE,Q) do{ L6470_dir_commands[Q] = (STATE ? dSPIN_STEP_CLOCK_REV : dSPIN_STEP_CLOCK_FWD); }while(0) #endif void restore_stepper_drivers(); // Called by PSU_ON void reset_stepper_drivers(); // Called by settings.load / settings.reset // X Stepper -#if AXIS_DRIVER_TYPE(X, L6470) +#if AXIS_DRIVER_TYPE_X(L6470) extern L6470 stepperX; #define X_ENABLE_INIT NOOP - #define X_ENABLE_WRITE(STATE) do{ if (STATE) stepperX.Step_Clock(stepperX.getStatus() & STATUS_HIZ); else stepperX.softFree(); }while(0) + #define X_ENABLE_WRITE(STATE) NOOP #define X_ENABLE_READ (stepperX.getStatus() & STATUS_HIZ) #define X_DIR_INIT NOOP - #define X_DIR_WRITE(STATE) stepperX.Step_Clock(STATE) + #define X_DIR_WRITE(STATE) L6470_WRITE_DIR_COMMAND(STATE,X) #define X_DIR_READ (stepperX.getStatus() & STATUS_DIR) #else #if AXIS_IS_TMC(X) extern TMC_CLASS(X) stepperX; #endif - #if AXIS_DRIVER_TYPE(X, TMC26X) + #if AXIS_DRIVER_TYPE_X(TMC26X) extern TMC26XStepper stepperX; #define X_ENABLE_INIT NOOP #define X_ENABLE_WRITE(STATE) stepperX.setEnabled(STATE) @@ -127,19 +126,19 @@ void reset_stepper_drivers(); // Called by settings.load / settings.reset #define X_STEP_READ READ(X_STEP_PIN) // Y Stepper -#if AXIS_DRIVER_TYPE(Y, L6470) +#if AXIS_DRIVER_TYPE_Y(L6470) extern L6470 stepperY; #define Y_ENABLE_INIT NOOP - #define Y_ENABLE_WRITE(STATE) do{ if (STATE) stepperY.Step_Clock(stepperY.getStatus() & STATUS_HIZ); else stepperY.softFree(); }while(0) + #define Y_ENABLE_WRITE(STATE) NOOP #define Y_ENABLE_READ (stepperY.getStatus() & STATUS_HIZ) #define Y_DIR_INIT NOOP - #define Y_DIR_WRITE(STATE) stepperY.Step_Clock(STATE) + #define Y_DIR_WRITE(STATE) L6470_WRITE_DIR_COMMAND(STATE,Y) #define Y_DIR_READ (stepperY.getStatus() & STATUS_DIR) #else #if AXIS_IS_TMC(Y) extern TMC_CLASS(Y) stepperY; #endif - #if AXIS_DRIVER_TYPE(Y, TMC26X) + #if AXIS_DRIVER_TYPE_Y(TMC26X) extern TMC26XStepper stepperY; #define Y_ENABLE_INIT NOOP #define Y_ENABLE_WRITE(STATE) stepperY.setEnabled(STATE) @@ -162,19 +161,19 @@ void reset_stepper_drivers(); // Called by settings.load / settings.reset #define Y_STEP_READ READ(Y_STEP_PIN) // Z Stepper -#if AXIS_DRIVER_TYPE(Z, L6470) +#if AXIS_DRIVER_TYPE_Z(L6470) extern L6470 stepperZ; #define Z_ENABLE_INIT NOOP - #define Z_ENABLE_WRITE(STATE) do{ if (STATE) stepperZ.Step_Clock(stepperZ.getStatus() & STATUS_HIZ); else stepperZ.softFree(); }while(0) + #define Z_ENABLE_WRITE(STATE) NOOP #define Z_ENABLE_READ (stepperZ.getStatus() & STATUS_HIZ) #define Z_DIR_INIT NOOP - #define Z_DIR_WRITE(STATE) stepperZ.Step_Clock(STATE) + #define Z_DIR_WRITE(STATE) L6470_WRITE_DIR_COMMAND(STATE,Z) #define Z_DIR_READ (stepperZ.getStatus() & STATUS_DIR) #else #if AXIS_IS_TMC(Z) extern TMC_CLASS(Z) stepperZ; #endif - #if AXIS_DRIVER_TYPE(Z, TMC26X) + #if AXIS_DRIVER_TYPE_Z(TMC26X) extern TMC26XStepper stepperZ; #define Z_ENABLE_INIT NOOP #define Z_ENABLE_WRITE(STATE) stepperZ.setEnabled(STATE) @@ -198,19 +197,19 @@ void reset_stepper_drivers(); // Called by settings.load / settings.reset // X2 Stepper #if HAS_X2_ENABLE - #if AXIS_DRIVER_TYPE(X2, L6470) + #if AXIS_DRIVER_TYPE_X2(L6470) extern L6470 stepperX2; #define X2_ENABLE_INIT NOOP - #define X2_ENABLE_WRITE(STATE) do{ if (STATE) stepperX2.Step_Clock(stepperX2.getStatus() & STATUS_HIZ); else stepperX2.softFree(); }while(0) + #define X2_ENABLE_WRITE(STATE) NOOP #define X2_ENABLE_READ (stepperX2.getStatus() & STATUS_HIZ) #define X2_DIR_INIT NOOP - #define X2_DIR_WRITE(STATE) stepperX2.Step_Clock(STATE) + #define X2_DIR_WRITE(STATE) L6470_WRITE_DIR_COMMAND(STATE,X2) #define X2_DIR_READ (stepperX2.getStatus() & STATUS_DIR) #else #if AXIS_IS_TMC(X2) extern TMC_CLASS(X2) stepperX2; #endif - #if AXIS_DRIVER_TYPE(X2, TMC26X) + #if AXIS_DRIVER_TYPE_X2(TMC26X) extern TMC26XStepper stepperX2; #define X2_ENABLE_INIT NOOP #define X2_ENABLE_WRITE(STATE) stepperX2.setEnabled(STATE) @@ -235,19 +234,19 @@ void reset_stepper_drivers(); // Called by settings.load / settings.reset // Y2 Stepper #if HAS_Y2_ENABLE - #if AXIS_DRIVER_TYPE(Y2, L6470) + #if AXIS_DRIVER_TYPE_Y2(L6470) extern L6470 stepperY2; #define Y2_ENABLE_INIT NOOP - #define Y2_ENABLE_WRITE(STATE) do{ if (STATE) stepperY2.Step_Clock(stepperY2.getStatus() & STATUS_HIZ); else stepperY2.softFree(); }while(0) + #define Y2_ENABLE_WRITE(STATE) NOOP #define Y2_ENABLE_READ (stepperY2.getStatus() & STATUS_HIZ) #define Y2_DIR_INIT NOOP - #define Y2_DIR_WRITE(STATE) stepperY2.Step_Clock(STATE) + #define Y2_DIR_WRITE(STATE) L6470_WRITE_DIR_COMMAND(STATE,Y2) #define Y2_DIR_READ (stepperY2.getStatus() & STATUS_DIR) #else #if AXIS_IS_TMC(Y2) extern TMC_CLASS(Y2) stepperY2; #endif - #if AXIS_DRIVER_TYPE(Y2, TMC26X) + #if AXIS_DRIVER_TYPE_Y2(TMC26X) extern TMC26XStepper stepperY2; #define Y2_ENABLE_INIT NOOP #define Y2_ENABLE_WRITE(STATE) stepperY2.setEnabled(STATE) @@ -268,23 +267,25 @@ void reset_stepper_drivers(); // Called by settings.load / settings.reset #define Y2_STEP_INIT SET_OUTPUT(Y2_STEP_PIN) #define Y2_STEP_WRITE(STATE) WRITE(Y2_STEP_PIN,STATE) #define Y2_STEP_READ READ(Y2_STEP_PIN) +#else + #define Y2_DIR_WRITE(STATE) NOOP #endif // Z2 Stepper #if HAS_Z2_ENABLE - #if AXIS_DRIVER_TYPE(Z2, L6470) + #if AXIS_DRIVER_TYPE_Z2(L6470) extern L6470 stepperZ2; #define Z2_ENABLE_INIT NOOP - #define Z2_ENABLE_WRITE(STATE) do{ if (STATE) stepperZ2.Step_Clock(stepperZ2.getStatus() & STATUS_HIZ); else stepperZ2.softFree(); }while(0) + #define Z2_ENABLE_WRITE(STATE) NOOP #define Z2_ENABLE_READ (stepperZ2.getStatus() & STATUS_HIZ) #define Z2_DIR_INIT NOOP - #define Z2_DIR_WRITE(STATE) stepperZ2.Step_Clock(STATE) + #define Z2_DIR_WRITE(STATE) L6470_WRITE_DIR_COMMAND(STATE,Z2) #define Z2_DIR_READ (stepperZ2.getStatus() & STATUS_DIR) #else #if AXIS_IS_TMC(Z2) extern TMC_CLASS(Z2) stepperZ2; #endif - #if AXIS_DRIVER_TYPE(Z2, TMC26X) + #if AXIS_DRIVER_TYPE_Z2(TMC26X) extern TMC26XStepper stepperZ2; #define Z2_ENABLE_INIT NOOP #define Z2_ENABLE_WRITE(STATE) stepperZ2.setEnabled(STATE) @@ -305,17 +306,19 @@ void reset_stepper_drivers(); // Called by settings.load / settings.reset #define Z2_STEP_INIT SET_OUTPUT(Z2_STEP_PIN) #define Z2_STEP_WRITE(STATE) WRITE(Z2_STEP_PIN,STATE) #define Z2_STEP_READ READ(Z2_STEP_PIN) +#else + #define Z2_DIR_WRITE(STATE) NOOP #endif // Z3 Stepper #if HAS_Z3_ENABLE - #if ENABLED(Z3_IS_L6470) + #if AXIS_DRIVER_TYPE_Z3(L6470) extern L6470 stepperZ3; #define Z3_ENABLE_INIT NOOP - #define Z3_ENABLE_WRITE(STATE) do{ if (STATE) stepperZ3.Step_Clock(stepperZ3.getStatus() & STATUS_HIZ); else stepperZ3.softFree(); }while(0) + #define Z3_ENABLE_WRITE(STATE) NOOP #define Z3_ENABLE_READ (stepperZ3.getStatus() & STATUS_HIZ) #define Z3_DIR_INIT NOOP - #define Z3_DIR_WRITE(STATE) stepperZ3.Step_Clock(STATE) + #define Z3_DIR_WRITE(STATE) L6470_WRITE_DIR_COMMAND(STATE,Z3) #define Z3_DIR_READ (stepperZ3.getStatus() & STATUS_DIR) #else #if AXIS_IS_TMC(Z3) @@ -342,22 +345,24 @@ void reset_stepper_drivers(); // Called by settings.load / settings.reset #define Z3_STEP_INIT SET_OUTPUT(Z3_STEP_PIN) #define Z3_STEP_WRITE(STATE) WRITE(Z3_STEP_PIN,STATE) #define Z3_STEP_READ READ(Z3_STEP_PIN) +#else + #define Z3_DIR_WRITE(STATE) NOOP #endif // E0 Stepper -#if AXIS_DRIVER_TYPE(E0, L6470) +#if AXIS_DRIVER_TYPE_E0(L6470) extern L6470 stepperE0; #define E0_ENABLE_INIT NOOP - #define E0_ENABLE_WRITE(STATE) do{ if (STATE) stepperE0.Step_Clock(stepperE0.getStatus() & STATUS_HIZ); else stepperE0.softFree(); }while(0) + #define E0_ENABLE_WRITE(STATE) NOOP #define E0_ENABLE_READ (stepperE0.getStatus() & STATUS_HIZ) #define E0_DIR_INIT NOOP - #define E0_DIR_WRITE(STATE) stepperE0.Step_Clock(STATE) + #define E0_DIR_WRITE(STATE) L6470_WRITE_DIR_COMMAND(STATE,E0) #define E0_DIR_READ (stepperE0.getStatus() & STATUS_DIR) #else #if AXIS_IS_TMC(E0) extern TMC_CLASS(E0) stepperE0; #endif - #if AXIS_DRIVER_TYPE(E0, TMC26X) + #if AXIS_DRIVER_TYPE_E0(TMC26X) extern TMC26XStepper stepperE0; #define E0_ENABLE_INIT NOOP #define E0_ENABLE_WRITE(STATE) stepperE0.setEnabled(STATE) @@ -380,19 +385,19 @@ void reset_stepper_drivers(); // Called by settings.load / settings.reset #define E0_STEP_READ READ(E0_STEP_PIN) // E1 Stepper -#if AXIS_DRIVER_TYPE(E1, L6470) +#if AXIS_DRIVER_TYPE_E1(L6470) extern L6470 stepperE1; #define E1_ENABLE_INIT NOOP - #define E1_ENABLE_WRITE(STATE) do{ if (STATE) stepperE1.Step_Clock(stepperE1.getStatus() & STATUS_HIZ); else stepperE1.softFree(); }while(0) + #define E1_ENABLE_WRITE(STATE) NOOP #define E1_ENABLE_READ (stepperE1.getStatus() & STATUS_HIZ) #define E1_DIR_INIT NOOP - #define E1_DIR_WRITE(STATE) stepperE1.Step_Clock(STATE) + #define E1_DIR_WRITE(STATE) L6470_WRITE_DIR_COMMAND(STATE,E1) #define E1_DIR_READ (stepperE1.getStatus() & STATUS_DIR) #else #if AXIS_IS_TMC(E1) extern TMC_CLASS(E1) stepperE1; #endif - #if AXIS_DRIVER_TYPE(E1, TMC26X) + #if AXIS_DRIVER_TYPE_E1(TMC26X) extern TMC26XStepper stepperE1; #define E1_ENABLE_INIT NOOP #define E1_ENABLE_WRITE(STATE) stepperE1.setEnabled(STATE) @@ -415,19 +420,19 @@ void reset_stepper_drivers(); // Called by settings.load / settings.reset #define E1_STEP_READ READ(E1_STEP_PIN) // E2 Stepper -#if AXIS_DRIVER_TYPE(E2, L6470) +#if AXIS_DRIVER_TYPE_E2(L6470) extern L6470 stepperE2; #define E2_ENABLE_INIT NOOP - #define E2_ENABLE_WRITE(STATE) do{ if (STATE) stepperE2.Step_Clock(stepperE2.getStatus() & STATUS_HIZ); else stepperE2.softFree(); }while(0) + #define E2_ENABLE_WRITE(STATE) NOOP #define E2_ENABLE_READ (stepperE2.getStatus() & STATUS_HIZ) #define E2_DIR_INIT NOOP - #define E2_DIR_WRITE(STATE) stepperE2.Step_Clock(STATE) + #define E2_DIR_WRITE(STATE) L6470_WRITE_DIR_COMMAND(STATE,E2) #define E2_DIR_READ (stepperE2.getStatus() & STATUS_DIR) #else #if AXIS_IS_TMC(E2) extern TMC_CLASS(E2) stepperE2; #endif - #if AXIS_DRIVER_TYPE(E2, TMC26X) + #if AXIS_DRIVER_TYPE_E2(TMC26X) extern TMC26XStepper stepperE2; #define E2_ENABLE_INIT NOOP #define E2_ENABLE_WRITE(STATE) stepperE2.setEnabled(STATE) @@ -450,19 +455,19 @@ void reset_stepper_drivers(); // Called by settings.load / settings.reset #define E2_STEP_READ READ(E2_STEP_PIN) // E3 Stepper -#if AXIS_DRIVER_TYPE(E3, L6470) +#if AXIS_DRIVER_TYPE_E3(L6470) extern L6470 stepperE3; #define E3_ENABLE_INIT NOOP - #define E3_ENABLE_WRITE(STATE) do{ if (STATE) stepperE3.Step_Clock(stepperE3.getStatus() & STATUS_HIZ); else stepperE3.softFree(); }while(0) + #define E3_ENABLE_WRITE(STATE) NOOP #define E3_ENABLE_READ (stepperE3.getStatus() & STATUS_HIZ) #define E3_DIR_INIT NOOP - #define E3_DIR_WRITE(STATE) stepperE3.Step_Clock(STATE) + #define E3_DIR_WRITE(STATE) L6470_WRITE_DIR_COMMAND(STATE,E3) #define E3_DIR_READ (stepperE3.getStatus() & STATUS_DIR) #else #if AXIS_IS_TMC(E3) extern TMC_CLASS(E3) stepperE3; #endif - #if AXIS_DRIVER_TYPE(E3, TMC26X) + #if AXIS_DRIVER_TYPE_E3(TMC26X) extern TMC26XStepper stepperE3; #define E3_ENABLE_INIT NOOP #define E3_ENABLE_WRITE(STATE) stepperE3.setEnabled(STATE) @@ -485,19 +490,19 @@ void reset_stepper_drivers(); // Called by settings.load / settings.reset #define E3_STEP_READ READ(E3_STEP_PIN) // E4 Stepper -#if AXIS_DRIVER_TYPE(E4, L6470) +#if AXIS_DRIVER_TYPE_E4(L6470) extern L6470 stepperE4; #define E4_ENABLE_INIT NOOP - #define E4_ENABLE_WRITE(STATE) do{ if (STATE) stepperE4.Step_Clock(stepperE4.getStatus() & STATUS_HIZ); else stepperE4.softFree(); }while(0) + #define E4_ENABLE_WRITE(STATE) NOOP #define E4_ENABLE_READ (stepperE4.getStatus() & STATUS_HIZ) #define E4_DIR_INIT NOOP - #define E4_DIR_WRITE(STATE) stepperE4.Step_Clock(STATE) + #define E4_DIR_WRITE(STATE) L6470_WRITE_DIR_COMMAND(STATE,E4) #define E4_DIR_READ (stepperE4.getStatus() & STATUS_DIR) #else #if AXIS_IS_TMC(E4) extern TMC_CLASS(E4) stepperE4; #endif - #if AXIS_DRIVER_TYPE(E4, TMC26X) + #if AXIS_DRIVER_TYPE_E4(TMC26X) extern TMC26XStepper stepperE4; #define E4_ENABLE_INIT NOOP #define E4_ENABLE_WRITE(STATE) stepperE4.setEnabled(STATE) @@ -520,19 +525,19 @@ void reset_stepper_drivers(); // Called by settings.load / settings.reset #define E4_STEP_READ READ(E4_STEP_PIN) // E5 Stepper -#if AXIS_DRIVER_TYPE(E5, L6470) +#if AXIS_DRIVER_TYPE_E5(L6470) extern L6470 stepperE5; #define E5_ENABLE_INIT NOOP - #define E5_ENABLE_WRITE(STATE) do{ if (STATE) stepperE5.Step_Clock(stepperE5.getStatus() & STATUS_HIZ); else stepperE5.softFree(); }while(0) + #define E5_ENABLE_WRITE(STATE) NOOP #define E5_ENABLE_READ (stepperE5.getStatus() & STATUS_HIZ) #define E5_DIR_INIT NOOP - #define E5_DIR_WRITE(STATE) stepperE5.Step_Clock(STATE) + #define E5_DIR_WRITE(STATE) L6470_WRITE_DIR_COMMAND(STATE,E5) #define E5_DIR_READ (stepperE5.getStatus() & STATUS_DIR) #else #if AXIS_IS_TMC(E5) extern TMC_CLASS(E5) stepperE5; #endif - #if AXIS_DRIVER_TYPE(E5, TMC26X) + #if AXIS_DRIVER_TYPE_E5(TMC26X) extern TMC26XStepper stepperE5; #define E5_ENABLE_INIT NOOP #define E5_ENABLE_WRITE(STATE) stepperE5.setEnabled(STATE) @@ -623,126 +628,3 @@ void reset_stepper_drivers(); // Called by settings.load / settings.reset #define NORM_E_DIR(E) E0_DIR_WRITE(!INVERT_E0_DIR) #define REV_E_DIR(E) E0_DIR_WRITE( INVERT_E0_DIR) #endif - -// -// Stepper enable / disable -// -#if HAS_X2_ENABLE - #define enable_X() do{ X_ENABLE_WRITE( X_ENABLE_ON); X2_ENABLE_WRITE( X_ENABLE_ON); }while(0) - #define disable_X() do{ X_ENABLE_WRITE(!X_ENABLE_ON); X2_ENABLE_WRITE(!X_ENABLE_ON); CBI(axis_known_position, X_AXIS); }while(0) -#elif HAS_X_ENABLE - #define enable_X() X_ENABLE_WRITE( X_ENABLE_ON) - #define disable_X() do{ X_ENABLE_WRITE(!X_ENABLE_ON); CBI(axis_known_position, X_AXIS); }while(0) -#else - #define enable_X() NOOP - #define disable_X() NOOP -#endif - -#if HAS_Y2_ENABLE - #define enable_Y() do{ Y_ENABLE_WRITE( Y_ENABLE_ON); Y2_ENABLE_WRITE(Y_ENABLE_ON); }while(0) - #define disable_Y() do{ Y_ENABLE_WRITE(!Y_ENABLE_ON); Y2_ENABLE_WRITE(!Y_ENABLE_ON); CBI(axis_known_position, Y_AXIS); }while(0) -#elif HAS_Y_ENABLE - #define enable_Y() Y_ENABLE_WRITE( Y_ENABLE_ON) - #define disable_Y() do{ Y_ENABLE_WRITE(!Y_ENABLE_ON); CBI(axis_known_position, Y_AXIS); }while(0) -#else - #define enable_Y() NOOP - #define disable_Y() NOOP -#endif - -#if HAS_Z3_ENABLE - #define enable_Z() do{ Z_ENABLE_WRITE( Z_ENABLE_ON); Z2_ENABLE_WRITE(Z_ENABLE_ON); Z3_ENABLE_WRITE(Z_ENABLE_ON); }while(0) - #define disable_Z() do{ Z_ENABLE_WRITE(!Z_ENABLE_ON); Z2_ENABLE_WRITE(!Z_ENABLE_ON); Z3_ENABLE_WRITE(!Z_ENABLE_ON); CBI(axis_known_position, Z_AXIS); }while(0) -#elif HAS_Z2_ENABLE - #define enable_Z() do{ Z_ENABLE_WRITE( Z_ENABLE_ON); Z2_ENABLE_WRITE(Z_ENABLE_ON); }while(0) - #define disable_Z() do{ Z_ENABLE_WRITE(!Z_ENABLE_ON); Z2_ENABLE_WRITE(!Z_ENABLE_ON); CBI(axis_known_position, Z_AXIS); }while(0) -#elif HAS_Z_ENABLE - #define enable_Z() Z_ENABLE_WRITE( Z_ENABLE_ON) - #define disable_Z() do{ Z_ENABLE_WRITE(!Z_ENABLE_ON); CBI(axis_known_position, Z_AXIS); }while(0) -#else - #define enable_Z() NOOP - #define disable_Z() NOOP -#endif - -#if ENABLED(MIXING_EXTRUDER) - - /** - * Mixing steppers synchronize their enable (and direction) together - */ - #if MIXING_STEPPERS > 5 - #define enable_E0() { E0_ENABLE_WRITE( E_ENABLE_ON); E1_ENABLE_WRITE( E_ENABLE_ON); E2_ENABLE_WRITE( E_ENABLE_ON); E3_ENABLE_WRITE( E_ENABLE_ON); E4_ENABLE_WRITE( E_ENABLE_ON); E5_ENABLE_WRITE( E_ENABLE_ON); } - #define disable_E0() { E0_ENABLE_WRITE(!E_ENABLE_ON); E1_ENABLE_WRITE(!E_ENABLE_ON); E2_ENABLE_WRITE(!E_ENABLE_ON); E3_ENABLE_WRITE(!E_ENABLE_ON); E4_ENABLE_WRITE(!E_ENABLE_ON); E5_ENABLE_WRITE(!E_ENABLE_ON); } - #elif MIXING_STEPPERS > 4 - #define enable_E0() { E0_ENABLE_WRITE( E_ENABLE_ON); E1_ENABLE_WRITE( E_ENABLE_ON); E2_ENABLE_WRITE( E_ENABLE_ON); E3_ENABLE_WRITE( E_ENABLE_ON); E4_ENABLE_WRITE( E_ENABLE_ON); } - #define disable_E0() { E0_ENABLE_WRITE(!E_ENABLE_ON); E1_ENABLE_WRITE(!E_ENABLE_ON); E2_ENABLE_WRITE(!E_ENABLE_ON); E3_ENABLE_WRITE(!E_ENABLE_ON); E4_ENABLE_WRITE(!E_ENABLE_ON); } - #elif MIXING_STEPPERS > 3 - #define enable_E0() { E0_ENABLE_WRITE( E_ENABLE_ON); E1_ENABLE_WRITE( E_ENABLE_ON); E2_ENABLE_WRITE( E_ENABLE_ON); E3_ENABLE_WRITE( E_ENABLE_ON); } - #define disable_E0() { E0_ENABLE_WRITE(!E_ENABLE_ON); E1_ENABLE_WRITE(!E_ENABLE_ON); E2_ENABLE_WRITE(!E_ENABLE_ON); E3_ENABLE_WRITE(!E_ENABLE_ON); } - #elif MIXING_STEPPERS > 2 - #define enable_E0() { E0_ENABLE_WRITE( E_ENABLE_ON); E1_ENABLE_WRITE( E_ENABLE_ON); E2_ENABLE_WRITE( E_ENABLE_ON); } - #define disable_E0() { E0_ENABLE_WRITE(!E_ENABLE_ON); E1_ENABLE_WRITE(!E_ENABLE_ON); E2_ENABLE_WRITE(!E_ENABLE_ON); } - #else - #define enable_E0() { E0_ENABLE_WRITE( E_ENABLE_ON); E1_ENABLE_WRITE( E_ENABLE_ON); } - #define disable_E0() { E0_ENABLE_WRITE(!E_ENABLE_ON); E1_ENABLE_WRITE(!E_ENABLE_ON); } - #endif - #define enable_E1() NOOP - #define disable_E1() NOOP - #define enable_E2() NOOP - #define disable_E2() NOOP - #define enable_E3() NOOP - #define disable_E3() NOOP - #define enable_E4() NOOP - #define disable_E4() NOOP - #define enable_E5() NOOP - #define disable_E5() NOOP - -#else // !MIXING_EXTRUDER - - #if HAS_E0_ENABLE - #define enable_E0() E0_ENABLE_WRITE( E_ENABLE_ON) - #define disable_E0() E0_ENABLE_WRITE(!E_ENABLE_ON) - #else - #define enable_E0() NOOP - #define disable_E0() NOOP - #endif - - #if E_STEPPERS > 1 && HAS_E1_ENABLE - #define enable_E1() E1_ENABLE_WRITE( E_ENABLE_ON) - #define disable_E1() E1_ENABLE_WRITE(!E_ENABLE_ON) - #else - #define enable_E1() NOOP - #define disable_E1() NOOP - #endif - - #if E_STEPPERS > 2 && HAS_E2_ENABLE - #define enable_E2() E2_ENABLE_WRITE( E_ENABLE_ON) - #define disable_E2() E2_ENABLE_WRITE(!E_ENABLE_ON) - #else - #define enable_E2() NOOP - #define disable_E2() NOOP - #endif - - #if E_STEPPERS > 3 && HAS_E3_ENABLE - #define enable_E3() E3_ENABLE_WRITE( E_ENABLE_ON) - #define disable_E3() E3_ENABLE_WRITE(!E_ENABLE_ON) - #else - #define enable_E3() NOOP - #define disable_E3() NOOP - #endif - - #if E_STEPPERS > 4 && HAS_E4_ENABLE - #define enable_E4() E4_ENABLE_WRITE( E_ENABLE_ON) - #define disable_E4() E4_ENABLE_WRITE(!E_ENABLE_ON) - #else - #define enable_E4() NOOP - #define disable_E4() NOOP - #endif - - #if E_STEPPERS > 5 && HAS_E5_ENABLE - #define enable_E5() E5_ENABLE_WRITE( E_ENABLE_ON) - #define disable_E5() E5_ENABLE_WRITE(!E_ENABLE_ON) - #else - #define enable_E5() NOOP - #define disable_E5() NOOP - #endif - -#endif // !MIXING_EXTRUDER diff --git a/Marlin/src/pins/pinsDebug_list.h b/Marlin/src/pins/pinsDebug_list.h index e7e38256e..cd5053b3d 100644 --- a/Marlin/src/pins/pinsDebug_list.h +++ b/Marlin/src/pins/pinsDebug_list.h @@ -1133,3 +1133,18 @@ #if PIN_EXISTS(E5_SERIAL_RX) REPORT_NAME_DIGITAL(__LINE__, E5_SERIAL_RX_PIN) #endif +#if PIN_EXISTS(L6470_CHAIN_SCK) + REPORT_NAME_DIGITAL(__LINE__, L6470_CHAIN_SCK_PIN) +#endif +#if PIN_EXISTS(L6470_CHAIN_MISO) + REPORT_NAME_DIGITAL(__LINE__, L6470_CHAIN_MISO_PIN) +#endif +#if PIN_EXISTS(L6470_CHAIN_MOSI) + REPORT_NAME_DIGITAL(__LINE__, L6470_CHAIN_MOSI_PIN) +#endif +#if PIN_EXISTS(L6470_CHAIN_SS) + REPORT_NAME_DIGITAL(__LINE__, L6470_CHAIN_SS_PIN) +#endif +#if PIN_EXISTS(L6470_RESET_CHAIN) + REPORT_NAME_DIGITAL(__LINE__, L6470_RESET_CHAIN_PIN) +#endif diff --git a/Marlin/src/pins/pins_EINSY_RAMBO.h b/Marlin/src/pins/pins_EINSY_RAMBO.h index 420edfd65..dd455d97b 100644 --- a/Marlin/src/pins/pins_EINSY_RAMBO.h +++ b/Marlin/src/pins/pins_EINSY_RAMBO.h @@ -33,7 +33,7 @@ // // TMC2130 Configuration_adv defaults for EinsyRambo // -#if !AXIS_DRIVER_TYPE(X, TMC2130) || !AXIS_DRIVER_TYPE(Y, TMC2130) || !AXIS_DRIVER_TYPE(Z, TMC2130) || !AXIS_DRIVER_TYPE(E0, TMC2130) +#if !AXIS_DRIVER_TYPE_X(TMC2130) || !AXIS_DRIVER_TYPE_Y(TMC2130) || !AXIS_DRIVER_TYPE_Z(TMC2130) || !AXIS_DRIVER_TYPE_E0(TMC2130) #error "You must set ([XYZ]|E0)_DRIVER_TYPE to TMC2130 in Configuration.h for EinsyRambo." #endif diff --git a/Marlin/src/pins/pins_EINSY_RETRO.h b/Marlin/src/pins/pins_EINSY_RETRO.h index 23cf3da91..ce6eea5b7 100644 --- a/Marlin/src/pins/pins_EINSY_RETRO.h +++ b/Marlin/src/pins/pins_EINSY_RETRO.h @@ -33,7 +33,7 @@ // // TMC2130 Configuration_adv defaults for EinsyRetro // -#if !AXIS_DRIVER_TYPE(X, TMC2130) || !AXIS_DRIVER_TYPE(Y, TMC2130) || !AXIS_DRIVER_TYPE(Z, TMC2130) || !AXIS_DRIVER_TYPE(E0, TMC2130) +#if !AXIS_DRIVER_TYPE_X(TMC2130) || !AXIS_DRIVER_TYPE_Y(TMC2130) || !AXIS_DRIVER_TYPE_Z(TMC2130) || !AXIS_DRIVER_TYPE_E0(TMC2130) #error "You must set ([XYZ]|E0)_DRIVER_TYPE to TMC2130 in Configuration.h for EinsyRetro." #endif diff --git a/buildroot/share/tests/LPC1768_tests b/buildroot/share/tests/LPC1768_tests index f79cefa00..57d90c0b3 100755 --- a/buildroot/share/tests/LPC1768_tests +++ b/buildroot/share/tests/LPC1768_tests @@ -70,6 +70,7 @@ opt_disable Z_MIN_PROBE_USES_Z_MIN_ENDSTOP_PIN opt_set X_DRIVER_TYPE TMC2130 opt_set Y_DRIVER_TYPE TMC2130 opt_set Z_DRIVER_TYPE TMC2130 +opt_set E0_DRIVER_TYPE L6470 opt_enable TMC_USE_SW_SPI MONITOR_DRIVER_STATUS STEALTHCHOP HYBRID_THRESHOLD TMC_DEBUG \ SENSORLESS_PROBING X_STALL_SENSITIVITY Y_STALL_SENSITIVITY Z_STALL_SENSITIVITY exec_test $1 $2 "Delta Config (generic) + BOARD_COHESION3D_REMIX + UBL + EEPROM_SETTINGS + SENSORLESS_PROBING" diff --git a/platformio.ini b/platformio.ini index c957114dd..b096d5a56 100644 --- a/platformio.ini +++ b/platformio.ini @@ -34,7 +34,7 @@ lib_deps = TMCStepper@<1.0.0 Adafruit NeoPixel@1.1.3 https://github.com/lincomatic/LiquidTWI2/archive/30aa480.zip - https://github.com/ameyer/Arduino-L6470/archive/master.zip + https://github.com/ameyer/Arduino-L6470/archive/dev.zip https://github.com/trinamic/TMC26XStepper/archive/c1921b4.zip https://github.com/mikeshub/SailfishLCD.git https://github.com/mikeshub/SailfishRGB_LED.git