From 01e20dc42731421cc3c59e712e499cbb5f6ba815 Mon Sep 17 00:00:00 2001 From: Daniel Michalik Date: Sun, 22 Dec 2019 17:29:26 +0100 Subject: [PATCH 1/5] Prepare constants for spindle ESC support, set pwm off value in spindle_stop() --- grbl/config.h | 4 ++++ grbl/cpu_map.h | 20 +++++++++++++++++--- grbl/spindle_control.c | 6 +++++- 3 files changed, 26 insertions(+), 4 deletions(-) diff --git a/grbl/config.h b/grbl/config.h index 6c2abecbd..a6aa77a84 100644 --- a/grbl/config.h +++ b/grbl/config.h @@ -210,6 +210,10 @@ //#define INVERT_MAX_LIMIT_PIN_MASK ((1< Date: Sun, 22 Dec 2019 21:43:43 +0100 Subject: [PATCH 2/5] Fix constants, pwm running when set min RPM --- grbl/cpu_map.h | 6 +++--- grbl/spindle_control.c | 5 ++++- 2 files changed, 7 insertions(+), 4 deletions(-) diff --git a/grbl/cpu_map.h b/grbl/cpu_map.h index 9368859c0..c831fb6d8 100644 --- a/grbl/cpu_map.h +++ b/grbl/cpu_map.h @@ -109,8 +109,8 @@ // Advanced Configuration Below You should not need to touch these variables // Set Timer up to use TIMER4B which is attached to Digital Pin 7 #ifdef ENABLE_SPINDLE_SERVO_SIGNAL - #define SPINDLE_PWM_MIN_VALUE 1000 // 1 ms - #define SPINDLE_PWM_MAX_VALUE 2000 // 2 ms + #define SPINDLE_PWM_MIN_VALUE 2000 // 1 ms + #define SPINDLE_PWM_MAX_VALUE 4000 // 2 ms #else #define SPINDLE_PWM_MAX_VALUE 1024.0 // Translates to about 1.9 kHz PWM frequency at 1/8 prescaler #endif @@ -119,7 +119,7 @@ #endif #ifdef ENABLE_SPINDLE_SERVO_SIGNAL - #define SPINDLE_PWM_OFF_VALUE 1000 + #define SPINDLE_PWM_OFF_VALUE 2000 #else #define SPINDLE_PWM_OFF_VALUE 0 #endif diff --git a/grbl/spindle_control.c b/grbl/spindle_control.c index 991d73e51..dcb76392d 100644 --- a/grbl/spindle_control.c +++ b/grbl/spindle_control.c @@ -60,7 +60,8 @@ uint8_t spindle_get_state() void spindle_stop() { #ifdef ENABLE_SPINDLE_SERVO_SIGNAL - SPINDLE_OCR_REGISTER = SPINDLE_PWM_OFF_VALUE; + SPINDLE_OCR_REGISTER = SPINDLE_PWM_OFF_VALUE; // Set off value of PWM. + SPINDLE_TCCRA_REGISTER |= (1 << SPINDLE_COMB_BIT); // Ensure PWM output is enabled. #else SPINDLE_TCCRA_REGISTER &= ~(1< Date: Sun, 22 Dec 2019 23:33:33 +0100 Subject: [PATCH 3/5] Rename macro in config --- grbl/config.h | 2 +- grbl/cpu_map.h | 6 +++--- grbl/spindle_control.c | 4 ++-- 3 files changed, 6 insertions(+), 6 deletions(-) diff --git a/grbl/config.h b/grbl/config.h index a6aa77a84..e1e7dbf43 100644 --- a/grbl/config.h +++ b/grbl/config.h @@ -212,7 +212,7 @@ // Enable spindle control using servo signal. Timer generate 50 Hz PWM signal, positive pulse width 1ms // for stopped spindle and 2 ms for full speed of servo. It's suitable for ESC using. -#define ENABLE_SPINDLE_SERVO_SIGNAL +#define ENABLE_SPINDLE_ESC // Inverts the spindle enable pin from low-disabled/high-enabled to low-enabled/high-disabled. Useful // for some pre-built electronic boards. diff --git a/grbl/cpu_map.h b/grbl/cpu_map.h index c831fb6d8..5737bfd9a 100644 --- a/grbl/cpu_map.h +++ b/grbl/cpu_map.h @@ -108,7 +108,7 @@ // Advanced Configuration Below You should not need to touch these variables // Set Timer up to use TIMER4B which is attached to Digital Pin 7 - #ifdef ENABLE_SPINDLE_SERVO_SIGNAL + #ifdef ENABLE_SPINDLE_ESC #define SPINDLE_PWM_MIN_VALUE 2000 // 1 ms #define SPINDLE_PWM_MAX_VALUE 4000 // 2 ms #else @@ -118,7 +118,7 @@ #define SPINDLE_PWM_MIN_VALUE 1 // Must be greater than zero. #endif - #ifdef ENABLE_SPINDLE_SERVO_SIGNAL + #ifdef ENABLE_SPINDLE_ESC #define SPINDLE_PWM_OFF_VALUE 2000 #else #define SPINDLE_PWM_OFF_VALUE 0 @@ -133,7 +133,7 @@ #define SPINDLE_TCCRA_INIT_MASK ((1< Date: Sun, 22 Dec 2019 23:34:39 +0100 Subject: [PATCH 4/5] Default disable ESC spindle --- grbl/config.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/grbl/config.h b/grbl/config.h index e1e7dbf43..dc1146d7a 100644 --- a/grbl/config.h +++ b/grbl/config.h @@ -212,7 +212,7 @@ // Enable spindle control using servo signal. Timer generate 50 Hz PWM signal, positive pulse width 1ms // for stopped spindle and 2 ms for full speed of servo. It's suitable for ESC using. -#define ENABLE_SPINDLE_ESC +// #define ENABLE_SPINDLE_ESC // Default disabled. Uncomment to enable. // Inverts the spindle enable pin from low-disabled/high-enabled to low-enabled/high-disabled. Useful // for some pre-built electronic boards. From 39ca1b4e43311b0322018c1174245a40dcfe07ad Mon Sep 17 00:00:00 2001 From: Daniel Michalik Date: Sun, 22 Dec 2019 23:56:56 +0100 Subject: [PATCH 5/5] Fix macro name --- grbl/config.h | 2 +- grbl/cpu_map.h | 6 +++--- grbl/spindle_control.c | 4 ++-- 3 files changed, 6 insertions(+), 6 deletions(-) diff --git a/grbl/config.h b/grbl/config.h index dc1146d7a..46a0b1d9a 100644 --- a/grbl/config.h +++ b/grbl/config.h @@ -212,7 +212,7 @@ // Enable spindle control using servo signal. Timer generate 50 Hz PWM signal, positive pulse width 1ms // for stopped spindle and 2 ms for full speed of servo. It's suitable for ESC using. -// #define ENABLE_SPINDLE_ESC // Default disabled. Uncomment to enable. +// #define ENABLE_ESC_SPINDLE // Default disabled. Uncomment to enable. // Inverts the spindle enable pin from low-disabled/high-enabled to low-enabled/high-disabled. Useful // for some pre-built electronic boards. diff --git a/grbl/cpu_map.h b/grbl/cpu_map.h index 5737bfd9a..b114749f3 100644 --- a/grbl/cpu_map.h +++ b/grbl/cpu_map.h @@ -108,7 +108,7 @@ // Advanced Configuration Below You should not need to touch these variables // Set Timer up to use TIMER4B which is attached to Digital Pin 7 - #ifdef ENABLE_SPINDLE_ESC + #ifdef ENABLE_ESC_SPINDLE #define SPINDLE_PWM_MIN_VALUE 2000 // 1 ms #define SPINDLE_PWM_MAX_VALUE 4000 // 2 ms #else @@ -118,7 +118,7 @@ #define SPINDLE_PWM_MIN_VALUE 1 // Must be greater than zero. #endif - #ifdef ENABLE_SPINDLE_ESC + #ifdef ENABLE_ESC_SPINDLE #define SPINDLE_PWM_OFF_VALUE 2000 #else #define SPINDLE_PWM_OFF_VALUE 0 @@ -133,7 +133,7 @@ #define SPINDLE_TCCRA_INIT_MASK ((1<