From 03c70c1990f865d25b035f812c2948864f425981 Mon Sep 17 00:00:00 2001 From: Scott Lahteine Date: Thu, 23 Jun 2016 14:33:29 -0700 Subject: [PATCH] SERVO_DEACTIVATION_DELAY => SERVO_DELAY --- Marlin/Configuration.h | 12 ++-- Marlin/SanityCheck.h | 6 +- .../Cartesio/Configuration.h | 12 ++-- .../Felix/Configuration.h | 12 ++-- .../Felix/DUAL/Configuration.h | 12 ++-- .../Hephestos/Configuration.h | 12 ++-- .../Hephestos_2/Configuration.h | 12 ++-- .../K8200/Configuration.h | 12 ++-- .../RepRapWorld/Megatronics/Configuration.h | 12 ++-- .../RigidBot/Configuration.h | 12 ++-- .../SCARA/Configuration.h | 12 ++-- .../TAZ4/Configuration.h | 12 ++-- .../WITBOX/Configuration.h | 12 ++-- .../adafruit/ST7565/Configuration.h | 12 ++-- .../delta/biv2.5/Configuration.h | 12 ++-- .../delta/generic/Configuration.h | 12 ++-- .../delta/kossel_mini/Configuration.h | 12 ++-- .../delta/kossel_pro/Configuration.h | 12 ++-- .../delta/kossel_xl/Configuration.h | 12 ++-- .../makibox/Configuration.h | 12 ++-- .../tvrrug/Round2/Configuration.h | 12 ++-- Marlin/servo.cpp | 70 ++++++++----------- Marlin/servo.h | 4 +- 23 files changed, 134 insertions(+), 186 deletions(-) diff --git a/Marlin/Configuration.h b/Marlin/Configuration.h index d8f6af1fe..ce046ca64 100644 --- a/Marlin/Configuration.h +++ b/Marlin/Configuration.h @@ -1173,18 +1173,16 @@ const bool Z_MIN_PROBE_ENDSTOP_INVERTING = false; // set to true to invert the l // //#define NUM_SERVOS 3 // Servo index starts with 0 for M280 command +// Delay (in microseconds) before the next move will start, to give the servo time to reach its target angle. +// 300ms is a good value but you can try less delay. +// If the servo can't reach the requested position, increase it. +#define SERVO_DELAY 300 + // Servo deactivation // // With this option servos are powered only during movement, then turned off to prevent jitter. //#define DEACTIVATE_SERVOS_AFTER_MOVE -#if ENABLED(DEACTIVATE_SERVOS_AFTER_MOVE) - // Delay (in microseconds) before turning the servo off. This depends on the servo speed. - // 300ms is a good value but you can try less delay. - // If the servo can't reach the requested position, increase it. - #define SERVO_DEACTIVATION_DELAY 300 -#endif - /**********************************************************************\ * Support for a filament diameter sensor * Also allows adjustment of diameter at print time (vs at slicing) diff --git a/Marlin/SanityCheck.h b/Marlin/SanityCheck.h index dda663900..81e2db8bd 100644 --- a/Marlin/SanityCheck.h +++ b/Marlin/SanityCheck.h @@ -593,8 +593,6 @@ #error "Z_LATE_ENABLE can't be used with COREXZ." #elif defined(X_HOME_RETRACT_MM) #error "[XYZ]_HOME_RETRACT_MM settings have been renamed [XYZ]_HOME_BUMP_MM." -#elif defined(PROBE_SERVO_DEACTIVATION_DELAY) - #error "PROBE_SERVO_DEACTIVATION_DELAY has been replaced with DEACTIVATE_SERVOS_AFTER_MOVE and SERVO_DEACTIVATION_DELAY." #elif defined(BEEPER) #error "BEEPER is now BEEPER_PIN. Please update your pins definitions." #elif defined(SDCARDDETECT) @@ -635,6 +633,10 @@ #error "X_ENDSTOP_SERVO_NR and Y_ENDSTOP_SERVO_NR are deprecated and should be removed." #elif defined(XY_TRAVEL_SPEED) #error "XY_TRAVEL_SPEED is deprecated. Use XY_PROBE_SPEED instead." +#elif defined(PROBE_SERVO_DEACTIVATION_DELAY) + #error "PROBE_SERVO_DEACTIVATION_DELAY is deprecated. Use DEACTIVATE_SERVOS_AFTER_MOVE instead." +#elif defined(SERVO_DEACTIVATION_DELAY) + #error "SERVO_DEACTIVATION_DELAY is deprecated. Use SERVO_DELAY instead." #endif #endif //SANITYCHECK_H diff --git a/Marlin/example_configurations/Cartesio/Configuration.h b/Marlin/example_configurations/Cartesio/Configuration.h index bbc7d10bf..69997fbab 100644 --- a/Marlin/example_configurations/Cartesio/Configuration.h +++ b/Marlin/example_configurations/Cartesio/Configuration.h @@ -1172,18 +1172,16 @@ const bool Z_MIN_PROBE_ENDSTOP_INVERTING = false; // set to true to invert the l // //#define NUM_SERVOS 3 // Servo index starts with 0 for M280 command +// Delay (in microseconds) before the next move will start, to give the servo time to reach its target angle. +// 300ms is a good value but you can try less delay. +// If the servo can't reach the requested position, increase it. +#define SERVO_DELAY 300 + // Servo deactivation // // With this option servos are powered only during movement, then turned off to prevent jitter. //#define DEACTIVATE_SERVOS_AFTER_MOVE -#if ENABLED(DEACTIVATE_SERVOS_AFTER_MOVE) - // Delay (in microseconds) before turning the servo off. This depends on the servo speed. - // 300ms is a good value but you can try less delay. - // If the servo can't reach the requested position, increase it. - #define SERVO_DEACTIVATION_DELAY 300 -#endif - /**********************************************************************\ * Support for a filament diameter sensor * Also allows adjustment of diameter at print time (vs at slicing) diff --git a/Marlin/example_configurations/Felix/Configuration.h b/Marlin/example_configurations/Felix/Configuration.h index 4c79f69a1..9acb21c1c 100644 --- a/Marlin/example_configurations/Felix/Configuration.h +++ b/Marlin/example_configurations/Felix/Configuration.h @@ -1156,18 +1156,16 @@ const bool Z_MIN_PROBE_ENDSTOP_INVERTING = false; // set to true to invert the l // //#define NUM_SERVOS 3 // Servo index starts with 0 for M280 command +// Delay (in microseconds) before the next move will start, to give the servo time to reach its target angle. +// 300ms is a good value but you can try less delay. +// If the servo can't reach the requested position, increase it. +#define SERVO_DELAY 300 + // Servo deactivation // // With this option servos are powered only during movement, then turned off to prevent jitter. //#define DEACTIVATE_SERVOS_AFTER_MOVE -#if ENABLED(DEACTIVATE_SERVOS_AFTER_MOVE) - // Delay (in microseconds) before turning the servo off. This depends on the servo speed. - // 300ms is a good value but you can try less delay. - // If the servo can't reach the requested position, increase it. - #define SERVO_DEACTIVATION_DELAY 300 -#endif - /**********************************************************************\ * Support for a filament diameter sensor * Also allows adjustment of diameter at print time (vs at slicing) diff --git a/Marlin/example_configurations/Felix/DUAL/Configuration.h b/Marlin/example_configurations/Felix/DUAL/Configuration.h index 28e0862fa..9431c2084 100644 --- a/Marlin/example_configurations/Felix/DUAL/Configuration.h +++ b/Marlin/example_configurations/Felix/DUAL/Configuration.h @@ -1154,18 +1154,16 @@ const bool Z_MIN_PROBE_ENDSTOP_INVERTING = false; // set to true to invert the l // //#define NUM_SERVOS 3 // Servo index starts with 0 for M280 command +// Delay (in microseconds) before the next move will start, to give the servo time to reach its target angle. +// 300ms is a good value but you can try less delay. +// If the servo can't reach the requested position, increase it. +#define SERVO_DELAY 300 + // Servo deactivation // // With this option servos are powered only during movement, then turned off to prevent jitter. //#define DEACTIVATE_SERVOS_AFTER_MOVE -#if ENABLED(DEACTIVATE_SERVOS_AFTER_MOVE) - // Delay (in microseconds) before turning the servo off. This depends on the servo speed. - // 300ms is a good value but you can try less delay. - // If the servo can't reach the requested position, increase it. - #define SERVO_DEACTIVATION_DELAY 300 -#endif - /**********************************************************************\ * Support for a filament diameter sensor * Also allows adjustment of diameter at print time (vs at slicing) diff --git a/Marlin/example_configurations/Hephestos/Configuration.h b/Marlin/example_configurations/Hephestos/Configuration.h index 2389c10a9..fd98445be 100644 --- a/Marlin/example_configurations/Hephestos/Configuration.h +++ b/Marlin/example_configurations/Hephestos/Configuration.h @@ -1165,18 +1165,16 @@ const bool Z_MIN_PROBE_ENDSTOP_INVERTING = true; // set to true to invert the lo // //#define NUM_SERVOS 3 // Servo index starts with 0 for M280 command +// Delay (in microseconds) before the next move will start, to give the servo time to reach its target angle. +// 300ms is a good value but you can try less delay. +// If the servo can't reach the requested position, increase it. +#define SERVO_DELAY 300 + // Servo deactivation // // With this option servos are powered only during movement, then turned off to prevent jitter. //#define DEACTIVATE_SERVOS_AFTER_MOVE -#if ENABLED(DEACTIVATE_SERVOS_AFTER_MOVE) - // Delay (in microseconds) before turning the servo off. This depends on the servo speed. - // 300ms is a good value but you can try less delay. - // If the servo can't reach the requested position, increase it. - #define SERVO_DEACTIVATION_DELAY 300 -#endif - /**********************************************************************\ * Support for a filament diameter sensor * Also allows adjustment of diameter at print time (vs at slicing) diff --git a/Marlin/example_configurations/Hephestos_2/Configuration.h b/Marlin/example_configurations/Hephestos_2/Configuration.h index 46db14118..78ec36f71 100644 --- a/Marlin/example_configurations/Hephestos_2/Configuration.h +++ b/Marlin/example_configurations/Hephestos_2/Configuration.h @@ -1167,18 +1167,16 @@ const bool Z_MIN_PROBE_ENDSTOP_INVERTING = false; // set to true to invert the l // //#define NUM_SERVOS 3 // Servo index starts with 0 for M280 command +// Delay (in microseconds) before the next move will start, to give the servo time to reach its target angle. +// 300ms is a good value but you can try less delay. +// If the servo can't reach the requested position, increase it. +#define SERVO_DELAY 300 + // Servo deactivation // // With this option servos are powered only during movement, then turned off to prevent jitter. //#define DEACTIVATE_SERVOS_AFTER_MOVE -#if ENABLED(DEACTIVATE_SERVOS_AFTER_MOVE) - // Delay (in microseconds) before turning the servo off. This depends on the servo speed. - // 300ms is a good value but you can try less delay. - // If the servo can't reach the requested position, increase it. - #define SERVO_DEACTIVATION_DELAY 300 -#endif - /**********************************************************************\ * Support for a filament diameter sensor * Also allows adjustment of diameter at print time (vs at slicing) diff --git a/Marlin/example_configurations/K8200/Configuration.h b/Marlin/example_configurations/K8200/Configuration.h index 1f7504e11..115e69d61 100644 --- a/Marlin/example_configurations/K8200/Configuration.h +++ b/Marlin/example_configurations/K8200/Configuration.h @@ -1190,18 +1190,16 @@ const bool Z_MIN_PROBE_ENDSTOP_INVERTING = false; // set to true to invert the l // //#define NUM_SERVOS 3 // Servo index starts with 0 for M280 command +// Delay (in microseconds) before the next move will start, to give the servo time to reach its target angle. +// 300ms is a good value but you can try less delay. +// If the servo can't reach the requested position, increase it. +#define SERVO_DELAY 300 + // Servo deactivation // // With this option servos are powered only during movement, then turned off to prevent jitter. //#define DEACTIVATE_SERVOS_AFTER_MOVE -#if ENABLED(DEACTIVATE_SERVOS_AFTER_MOVE) - // Delay (in microseconds) before turning the servo off. This depends on the servo speed. - // 300ms is a good value but you can try less delay. - // If the servo can't reach the requested position, increase it. - #define SERVO_DEACTIVATION_DELAY 300 -#endif - /**********************************************************************\ * Support for a filament diameter sensor * Also allows adjustment of diameter at print time (vs at slicing) diff --git a/Marlin/example_configurations/RepRapWorld/Megatronics/Configuration.h b/Marlin/example_configurations/RepRapWorld/Megatronics/Configuration.h index 15e3d56ad..a0445647f 100644 --- a/Marlin/example_configurations/RepRapWorld/Megatronics/Configuration.h +++ b/Marlin/example_configurations/RepRapWorld/Megatronics/Configuration.h @@ -1173,18 +1173,16 @@ const bool Z_MIN_PROBE_ENDSTOP_INVERTING = false; // set to true to invert the l // //#define NUM_SERVOS 3 // Servo index starts with 0 for M280 command +// Delay (in microseconds) before the next move will start, to give the servo time to reach its target angle. +// 300ms is a good value but you can try less delay. +// If the servo can't reach the requested position, increase it. +#define SERVO_DELAY 300 + // Servo deactivation // // With this option servos are powered only during movement, then turned off to prevent jitter. //#define DEACTIVATE_SERVOS_AFTER_MOVE -#if ENABLED(DEACTIVATE_SERVOS_AFTER_MOVE) - // Delay (in microseconds) before turning the servo off. This depends on the servo speed. - // 300ms is a good value but you can try less delay. - // If the servo can't reach the requested position, increase it. - #define SERVO_DEACTIVATION_DELAY 300 -#endif - /**********************************************************************\ * Support for a filament diameter sensor * Also allows adjustment of diameter at print time (vs at slicing) diff --git a/Marlin/example_configurations/RigidBot/Configuration.h b/Marlin/example_configurations/RigidBot/Configuration.h index 29f26f43d..5f069bac5 100644 --- a/Marlin/example_configurations/RigidBot/Configuration.h +++ b/Marlin/example_configurations/RigidBot/Configuration.h @@ -1170,18 +1170,16 @@ const bool Z_MIN_PROBE_ENDSTOP_INVERTING = false; // set to true to invert the l // #define NUM_SERVOS 0 // DGlass3D - Servo index starts with 0 for M280 command +// Delay (in microseconds) before the next move will start, to give the servo time to reach its target angle. +// 300ms is a good value but you can try less delay. +// If the servo can't reach the requested position, increase it. +#define SERVO_DELAY 300 + // Servo deactivation // // With this option servos are powered only during movement, then turned off to prevent jitter. //#define DEACTIVATE_SERVOS_AFTER_MOVE -#if ENABLED(DEACTIVATE_SERVOS_AFTER_MOVE) - // Delay (in microseconds) before turning the servo off. This depends on the servo speed. - // 300ms is a good value but you can try less delay. - // If the servo can't reach the requested position, increase it. - #define SERVO_DEACTIVATION_DELAY 300 -#endif - /**********************************************************************\ * Support for a filament diameter sensor * Also allows adjustment of diameter at print time (vs at slicing) diff --git a/Marlin/example_configurations/SCARA/Configuration.h b/Marlin/example_configurations/SCARA/Configuration.h index 7b29ec92c..ee7a0e0f8 100644 --- a/Marlin/example_configurations/SCARA/Configuration.h +++ b/Marlin/example_configurations/SCARA/Configuration.h @@ -1181,18 +1181,16 @@ const bool Z_MIN_PROBE_ENDSTOP_INVERTING = false; // set to true to invert the l // //#define NUM_SERVOS 3 // Servo index starts with 0 for M280 command +// Delay (in microseconds) before the next move will start, to give the servo time to reach its target angle. +// 300ms is a good value but you can try less delay. +// If the servo can't reach the requested position, increase it. +#define SERVO_DELAY 300 + // Servo deactivation // // With this option servos are powered only during movement, then turned off to prevent jitter. //#define DEACTIVATE_SERVOS_AFTER_MOVE -#if ENABLED(DEACTIVATE_SERVOS_AFTER_MOVE) - // Delay (in microseconds) before turning the servo off. This depends on the servo speed. - // 300ms is a good value but you can try less delay. - // If the servo can't reach the requested position, increase it. - #define SERVO_DEACTIVATION_DELAY 300 -#endif - /**********************************************************************\ * Support for a filament diameter sensor * Also allows adjustment of diameter at print time (vs at slicing) diff --git a/Marlin/example_configurations/TAZ4/Configuration.h b/Marlin/example_configurations/TAZ4/Configuration.h index 5565df7e0..043ebb3f3 100644 --- a/Marlin/example_configurations/TAZ4/Configuration.h +++ b/Marlin/example_configurations/TAZ4/Configuration.h @@ -1194,18 +1194,16 @@ const bool Z_MIN_PROBE_ENDSTOP_INVERTING = false; // set to true to invert the l // //#define NUM_SERVOS 3 // Servo index starts with 0 for M280 command +// Delay (in microseconds) before the next move will start, to give the servo time to reach its target angle. +// 300ms is a good value but you can try less delay. +// If the servo can't reach the requested position, increase it. +#define SERVO_DELAY 300 + // Servo deactivation // // With this option servos are powered only during movement, then turned off to prevent jitter. //#define DEACTIVATE_SERVOS_AFTER_MOVE -#if ENABLED(DEACTIVATE_SERVOS_AFTER_MOVE) - // Delay (in microseconds) before turning the servo off. This depends on the servo speed. - // 300ms is a good value but you can try less delay. - // If the servo can't reach the requested position, increase it. - #define SERVO_DEACTIVATION_DELAY 300 -#endif - /**********************************************************************\ * Support for a filament diameter sensor * Also allows adjustment of diameter at print time (vs at slicing) diff --git a/Marlin/example_configurations/WITBOX/Configuration.h b/Marlin/example_configurations/WITBOX/Configuration.h index 65ffac1a1..a15f582e0 100644 --- a/Marlin/example_configurations/WITBOX/Configuration.h +++ b/Marlin/example_configurations/WITBOX/Configuration.h @@ -1165,18 +1165,16 @@ const bool Z_MIN_PROBE_ENDSTOP_INVERTING = true; // set to true to invert the lo // //#define NUM_SERVOS 3 // Servo index starts with 0 for M280 command +// Delay (in microseconds) before the next move will start, to give the servo time to reach its target angle. +// 300ms is a good value but you can try less delay. +// If the servo can't reach the requested position, increase it. +#define SERVO_DELAY 300 + // Servo deactivation // // With this option servos are powered only during movement, then turned off to prevent jitter. //#define DEACTIVATE_SERVOS_AFTER_MOVE -#if ENABLED(DEACTIVATE_SERVOS_AFTER_MOVE) - // Delay (in microseconds) before turning the servo off. This depends on the servo speed. - // 300ms is a good value but you can try less delay. - // If the servo can't reach the requested position, increase it. - #define SERVO_DEACTIVATION_DELAY 300 -#endif - /**********************************************************************\ * Support for a filament diameter sensor * Also allows adjustment of diameter at print time (vs at slicing) diff --git a/Marlin/example_configurations/adafruit/ST7565/Configuration.h b/Marlin/example_configurations/adafruit/ST7565/Configuration.h index 21a47e762..e56c6b327 100644 --- a/Marlin/example_configurations/adafruit/ST7565/Configuration.h +++ b/Marlin/example_configurations/adafruit/ST7565/Configuration.h @@ -1173,18 +1173,16 @@ const bool Z_MIN_PROBE_ENDSTOP_INVERTING = false; // set to true to invert the l // //#define NUM_SERVOS 3 // Servo index starts with 0 for M280 command +// Delay (in microseconds) before the next move will start, to give the servo time to reach its target angle. +// 300ms is a good value but you can try less delay. +// If the servo can't reach the requested position, increase it. +#define SERVO_DELAY 300 + // Servo deactivation // // With this option servos are powered only during movement, then turned off to prevent jitter. //#define DEACTIVATE_SERVOS_AFTER_MOVE -#if ENABLED(DEACTIVATE_SERVOS_AFTER_MOVE) - // Delay (in microseconds) before turning the servo off. This depends on the servo speed. - // 300ms is a good value but you can try less delay. - // If the servo can't reach the requested position, increase it. - #define SERVO_DEACTIVATION_DELAY 300 -#endif - /**********************************************************************\ * Support for a filament diameter sensor * Also allows adjustment of diameter at print time (vs at slicing) diff --git a/Marlin/example_configurations/delta/biv2.5/Configuration.h b/Marlin/example_configurations/delta/biv2.5/Configuration.h index 35202c9ea..f4147a0cc 100644 --- a/Marlin/example_configurations/delta/biv2.5/Configuration.h +++ b/Marlin/example_configurations/delta/biv2.5/Configuration.h @@ -1258,18 +1258,16 @@ const bool Z_MIN_PROBE_ENDSTOP_INVERTING = true; // set to true to invert the lo // //#define NUM_SERVOS 3 // Servo index starts with 0 for M280 command +// Delay (in microseconds) before the next move will start, to give the servo time to reach its target angle. +// 300ms is a good value but you can try less delay. +// If the servo can't reach the requested position, increase it. +#define SERVO_DELAY 300 + // Servo deactivation // // With this option servos are powered only during movement, then turned off to prevent jitter. //#define DEACTIVATE_SERVOS_AFTER_MOVE -#if ENABLED(DEACTIVATE_SERVOS_AFTER_MOVE) - // Delay (in microseconds) before turning the servo off. This depends on the servo speed. - // 300ms is a good value but you can try less delay. - // If the servo can't reach the requested position, increase it. - #define SERVO_DEACTIVATION_DELAY 300 -#endif - /**********************************************************************\ * Support for a filament diameter sensor * Also allows adjustment of diameter at print time (vs at slicing) diff --git a/Marlin/example_configurations/delta/generic/Configuration.h b/Marlin/example_configurations/delta/generic/Configuration.h index 46bb74b45..f84451d8e 100644 --- a/Marlin/example_configurations/delta/generic/Configuration.h +++ b/Marlin/example_configurations/delta/generic/Configuration.h @@ -1252,18 +1252,16 @@ const bool Z_MIN_PROBE_ENDSTOP_INVERTING = true; // set to true to invert the lo // //#define NUM_SERVOS 3 // Servo index starts with 0 for M280 command +// Delay (in microseconds) before the next move will start, to give the servo time to reach its target angle. +// 300ms is a good value but you can try less delay. +// If the servo can't reach the requested position, increase it. +#define SERVO_DELAY 300 + // Servo deactivation // // With this option servos are powered only during movement, then turned off to prevent jitter. //#define DEACTIVATE_SERVOS_AFTER_MOVE -#if ENABLED(DEACTIVATE_SERVOS_AFTER_MOVE) - // Delay (in microseconds) before turning the servo off. This depends on the servo speed. - // 300ms is a good value but you can try less delay. - // If the servo can't reach the requested position, increase it. - #define SERVO_DEACTIVATION_DELAY 300 -#endif - /**********************************************************************\ * Support for a filament diameter sensor * Also allows adjustment of diameter at print time (vs at slicing) diff --git a/Marlin/example_configurations/delta/kossel_mini/Configuration.h b/Marlin/example_configurations/delta/kossel_mini/Configuration.h index f94964a16..d6b6405af 100644 --- a/Marlin/example_configurations/delta/kossel_mini/Configuration.h +++ b/Marlin/example_configurations/delta/kossel_mini/Configuration.h @@ -1255,18 +1255,16 @@ const bool Z_MIN_PROBE_ENDSTOP_INVERTING = false; // set to true to invert the l // //#define NUM_SERVOS 3 // Servo index starts with 0 for M280 command +// Delay (in microseconds) before the next move will start, to give the servo time to reach its target angle. +// 300ms is a good value but you can try less delay. +// If the servo can't reach the requested position, increase it. +#define SERVO_DELAY 300 + // Servo deactivation // // With this option servos are powered only during movement, then turned off to prevent jitter. //#define DEACTIVATE_SERVOS_AFTER_MOVE -#if ENABLED(DEACTIVATE_SERVOS_AFTER_MOVE) - // Delay (in microseconds) before turning the servo off. This depends on the servo speed. - // 300ms is a good value but you can try less delay. - // If the servo can't reach the requested position, increase it. - #define SERVO_DEACTIVATION_DELAY 300 -#endif - /**********************************************************************\ * Support for a filament diameter sensor * Also allows adjustment of diameter at print time (vs at slicing) diff --git a/Marlin/example_configurations/delta/kossel_pro/Configuration.h b/Marlin/example_configurations/delta/kossel_pro/Configuration.h index d9b18cf7d..d6572bb97 100644 --- a/Marlin/example_configurations/delta/kossel_pro/Configuration.h +++ b/Marlin/example_configurations/delta/kossel_pro/Configuration.h @@ -1255,18 +1255,16 @@ const bool Z_MIN_PROBE_ENDSTOP_INVERTING = false; // set to true to invert the l // //#define NUM_SERVOS 3 // Servo index starts with 0 for M280 command +// Delay (in microseconds) before the next move will start, to give the servo time to reach its target angle. +// 300ms is a good value but you can try less delay. +// If the servo can't reach the requested position, increase it. +#define SERVO_DELAY 300 + // Servo deactivation // // With this option servos are powered only during movement, then turned off to prevent jitter. //#define DEACTIVATE_SERVOS_AFTER_MOVE -#if ENABLED(DEACTIVATE_SERVOS_AFTER_MOVE) - // Delay (in microseconds) before turning the servo off. This depends on the servo speed. - // 300ms is a good value but you can try less delay. - // If the servo can't reach the requested position, increase it. - #define SERVO_DEACTIVATION_DELAY 300 -#endif - /**********************************************************************\ * Support for a filament diameter sensor * Also allows adjustment of diameter at print time (vs at slicing) diff --git a/Marlin/example_configurations/delta/kossel_xl/Configuration.h b/Marlin/example_configurations/delta/kossel_xl/Configuration.h index d453fc589..49dc55403 100644 --- a/Marlin/example_configurations/delta/kossel_xl/Configuration.h +++ b/Marlin/example_configurations/delta/kossel_xl/Configuration.h @@ -1257,18 +1257,16 @@ const bool Z_MIN_PROBE_ENDSTOP_INVERTING = false; // set to true to invert the l // //#define NUM_SERVOS 3 // Servo index starts with 0 for M280 command +// Delay (in microseconds) before the next move will start, to give the servo time to reach its target angle. +// 300ms is a good value but you can try less delay. +// If the servo can't reach the requested position, increase it. +#define SERVO_DELAY 300 + // Servo deactivation // // With this option servos are powered only during movement, then turned off to prevent jitter. //#define DEACTIVATE_SERVOS_AFTER_MOVE -#if ENABLED(DEACTIVATE_SERVOS_AFTER_MOVE) - // Delay (in microseconds) before turning the servo off. This depends on the servo speed. - // 300ms is a good value but you can try less delay. - // If the servo can't reach the requested position, increase it. - #define SERVO_DEACTIVATION_DELAY 300 -#endif - /**********************************************************************\ * Support for a filament diameter sensor * Also allows adjustment of diameter at print time (vs at slicing) diff --git a/Marlin/example_configurations/makibox/Configuration.h b/Marlin/example_configurations/makibox/Configuration.h index fcc45adec..444c46e23 100644 --- a/Marlin/example_configurations/makibox/Configuration.h +++ b/Marlin/example_configurations/makibox/Configuration.h @@ -1176,18 +1176,16 @@ const bool Z_MIN_PROBE_ENDSTOP_INVERTING = false; // set to true to invert the l // //#define NUM_SERVOS 3 // Servo index starts with 0 for M280 command +// Delay (in microseconds) before the next move will start, to give the servo time to reach its target angle. +// 300ms is a good value but you can try less delay. +// If the servo can't reach the requested position, increase it. +#define SERVO_DELAY 300 + // Servo deactivation // // With this option servos are powered only during movement, then turned off to prevent jitter. //#define DEACTIVATE_SERVOS_AFTER_MOVE -#if ENABLED(DEACTIVATE_SERVOS_AFTER_MOVE) - // Delay (in microseconds) before turning the servo off. This depends on the servo speed. - // 300ms is a good value but you can try less delay. - // If the servo can't reach the requested position, increase it. - #define SERVO_DEACTIVATION_DELAY 300 -#endif - /**********************************************************************\ * Support for a filament diameter sensor * Also allows adjustment of diameter at print time (vs at slicing) diff --git a/Marlin/example_configurations/tvrrug/Round2/Configuration.h b/Marlin/example_configurations/tvrrug/Round2/Configuration.h index 7fcf6e394..5d46e05e9 100644 --- a/Marlin/example_configurations/tvrrug/Round2/Configuration.h +++ b/Marlin/example_configurations/tvrrug/Round2/Configuration.h @@ -1167,18 +1167,16 @@ const bool Z_MIN_PROBE_ENDSTOP_INVERTING = true; // set to true to invert the lo // //#define NUM_SERVOS 3 // Servo index starts with 0 for M280 command +// Delay (in microseconds) before the next move will start, to give the servo time to reach its target angle. +// 300ms is a good value but you can try less delay. +// If the servo can't reach the requested position, increase it. +#define SERVO_DELAY 300 + // Servo deactivation // // With this option servos are powered only during movement, then turned off to prevent jitter. //#define DEACTIVATE_SERVOS_AFTER_MOVE -#if ENABLED(DEACTIVATE_SERVOS_AFTER_MOVE) - // Delay (in microseconds) before turning the servo off. This depends on the servo speed. - // 300ms is a good value but you can try less delay. - // If the servo can't reach the requested position, increase it. - #define SERVO_DEACTIVATION_DELAY 300 -#endif - /**********************************************************************\ * Support for a filament diameter sensor * Also allows adjustment of diameter at print time (vs at slicing) diff --git a/Marlin/servo.cpp b/Marlin/servo.cpp index 1b8442a0d..cbc0026d4 100644 --- a/Marlin/servo.cpp +++ b/Marlin/servo.cpp @@ -21,50 +21,35 @@ */ /** - servo.cpp - Interrupt driven Servo library for Arduino using 16 bit timers- Version 2 - Copyright (c) 2009 Michael Margolis. All right reserved. - - This library is free software; you can redistribute it and/or - modify it under the terms of the GNU Lesser General Public - License as published by the Free Software Foundation; either - version 2.1 of the License, or (at your option) any later version. - - This library 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 - Lesser General Public License for more details. - - You should have received a copy of the GNU Lesser General Public - License along with this library; if not, write to the Free Software - Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA + * servo.cpp - Interrupt driven Servo library for Arduino using 16 bit timers- Version 2 + * Copyright (c) 2009 Michael Margolis. All right reserved. */ /** - - A servo is activated by creating an instance of the Servo class passing the desired pin to the attach() method. - The servos are pulsed in the background using the value most recently written using the write() method - - Note that analogWrite of PWM on pins associated with the timer are disabled when the first servo is attached. - Timers are seized as needed in groups of 12 servos - 24 servos use two timers, 48 servos will use four. - - The methods are: - - Servo - Class for manipulating servo motors connected to Arduino pins. - - attach(pin ) - Attaches a servo motor to an i/o pin. - attach(pin, min, max ) - Attaches to a pin setting min and max values in microseconds - default min is 544, max is 2400 - - write() - Sets the servo angle in degrees. (invalid angle that is valid as pulse in microseconds is treated as microseconds) - writeMicroseconds() - Sets the servo pulse width in microseconds - move(pin, angle) - Sequence of attach(pin), write(angle). - With DEACTIVATE_SERVOS_AFTER_MOVE it waits SERVO_DEACTIVATION_DELAY and detaches. - read() - Gets the last written servo pulse width as an angle between 0 and 180. - readMicroseconds() - Gets the last written servo pulse width in microseconds. (was read_us() in first release) - attached() - Returns true if there is a servo attached. - detach() - Stops an attached servos from pulsing its i/o pin. - -*/ + * A servo is activated by creating an instance of the Servo class passing the desired pin to the attach() method. + * The servos are pulsed in the background using the value most recently written using the write() method + * + * Note that analogWrite of PWM on pins associated with the timer are disabled when the first servo is attached. + * Timers are seized as needed in groups of 12 servos - 24 servos use two timers, 48 servos will use four. + * + * The methods are: + * + * Servo - Class for manipulating servo motors connected to Arduino pins. + * + * attach(pin) - Attach a servo motor to an i/o pin. + * attach(pin, min, max) - Attach to a pin, setting min and max values in microseconds + * Default min is 544, max is 2400 + * + * write() - Set the servo angle in degrees. (Invalid angles —over MIN_PULSE_WIDTH— are treated as µs.) + * writeMicroseconds() - Set the servo pulse width in microseconds. + * move(pin, angle) - Sequence of attach(pin), write(angle), delay(SERVO_DELAY). + * With DEACTIVATE_SERVOS_AFTER_MOVE it detaches after SERVO_DELAY. + * read() - Get the last-written servo pulse width as an angle between 0 and 180. + * readMicroseconds() - Get the last-written servo pulse width in microseconds. + * attached() - Return true if a servo is attached. + * detach() - Stop an attached servo from pulsing its i/o pin. + * + */ #include "Configuration.h" #if HAS_SERVOS @@ -238,6 +223,7 @@ static void finISR(timer16_Sequence_t timer) { } #else //!WIRING // For arduino - in future: call here to a currently undefined function to reset the timer + UNUSED(timer); #endif } @@ -324,8 +310,8 @@ bool Servo::attached() { return servo_info[this->servoIndex].Pin.isActive; } void Servo::move(int value) { if (this->attach(0) >= 0) { this->write(value); + delay(SERVO_DELAY); #if ENABLED(DEACTIVATE_SERVOS_AFTER_MOVE) - delay(SERVO_DEACTIVATION_DELAY); this->detach(); #endif } diff --git a/Marlin/servo.h b/Marlin/servo.h index d764fc440..07532bc30 100644 --- a/Marlin/servo.h +++ b/Marlin/servo.h @@ -63,7 +63,7 @@ attached() - Returns true if there is a servo attached. detach() - Stops an attached servos from pulsing its i/o pin. move(angle) - Sequence of attach(0), write(angle), - With DEACTIVATE_SERVOS_AFTER_MOVE wait SERVO_DEACTIVATION_DELAY and detach. + With DEACTIVATE_SERVOS_AFTER_MOVE wait SERVO_DELAY and detach. */ #ifndef servo_h @@ -147,7 +147,7 @@ class Servo { void writeMicroseconds(int value); // write pulse width in microseconds void move(int value); // attach the servo, then move to value // if value is < 200 it is treated as an angle, otherwise as pulse width in microseconds - // if DEACTIVATE_SERVOS_AFTER_MOVE wait SERVO_DEACTIVATION_DELAY, then detach + // if DEACTIVATE_SERVOS_AFTER_MOVE wait SERVO_DELAY, then detach int read(); // returns current pulse width as an angle between 0 and 180 degrees int readMicroseconds(); // returns current pulse width in microseconds for this servo (was read_us() in first release) bool attached(); // return true if this servo is attached, otherwise false