diff --git a/doc/log/commit_log_v1.1.txt b/doc/log/commit_log_v1.1.txt index 0f07fa3..2acc620 100644 --- a/doc/log/commit_log_v1.1.txt +++ b/doc/log/commit_log_v1.1.txt @@ -1,3 +1,47 @@ +---------------- +Date: 2016-10-22 +Author: Will Winder +Subject: Minor VARIABLE_SPINDLE feature toggle refactoring (#16) + +* Modify code CSV format. + +- Wrap value in quotes to avoid issue with embedded commas. This occurs + in one of the alarm codes. + +- Change header row format to allow same parsing code as data rows. + +* VARIABLE_SPINDLE feature flag experiment. + +- Use a macro for 'spindle_set_speed' and 'spindle_sync' to reduce the + number of required VARIABLE_SPINDLE checks. + + +---------------- +Date: 2016-10-18 +Author: Sonny Jeon +Subject: Improved option for v0.9 GUI compatibility. + +- Addressed an issue with backward compatibility with Grbl v0.9-style +GUIs. + +- It still may not work due to new data and states coming back from +Grbl v1.1. Regardless, DO NOT TRY TO USE THE COMPATIBILITY MODE UNTIL +THERE IS A REALLY GOOD REASON TO. + +- v0.9 GUI compatibility mode will be removed in future versions. +You’ve been warned. It’s highly recommended for GUIs to update to the +new v1.1 interface. + +- Compability mode will only fit on an Arduino Uno due to size +increases. + +- Removed the REPORT_GUI_MODE compile option since it’s part of the +v1.1 interface standard. + +- Updated the documentation to better describe the compatibility mode +build option. + + ---------------- Date: 2016-10-17 Author: Sonny Jeon diff --git a/grbl/config.h b/grbl/config.h index 4a49164..8449c8a 100644 --- a/grbl/config.h +++ b/grbl/config.h @@ -360,7 +360,8 @@ // setting, like rpm max to max PWM. So the variable spindle pin will not output the voltage range between // 0V for disabled and the voltage set by the minimum PWM for minimum rpm. // NOTE: Compute duty cycle at the minimum PWM by this equation: (% duty cycle)=(SPINDLE_MINIMUM_PWM/256)*100 -// #define SPINDLE_MINIMUM_PWM 5 // Default disabled. Uncomment to enable. Integer (0-255) +// Value must be greater than zero. +// #define SPINDLE_MINIMUM_PWM 5 // Default disabled. Uncomment to enable. Integer (1-255) // By default on a 328p(Uno), Grbl combines the variable spindle PWM and the enable into one pin to help // preserve I/O pins. For certain setups, these may need to be separate pins. This configure option uses @@ -580,6 +581,12 @@ #endif #endif +#if defined(SPINDLE_MINIMUM_PWM) + #if !(SPINDLE_MINIMUM_PWM > 0) + #error "SPINDLE_MINIMUM_PWM must be greater than zero." + #endif +#endif + /* --------------------------------------------------------------------------------------- OEM Single File Configuration Option diff --git a/grbl/cpu_map.h b/grbl/cpu_map.h index 6594765..d86bce5 100644 --- a/grbl/cpu_map.h +++ b/grbl/cpu_map.h @@ -125,7 +125,13 @@ // Variable spindle configuration below. Do not change unless you know what you are doing. // NOTE: Only used when variable spindle is enabled. #define SPINDLE_PWM_MAX_VALUE 255 // Don't change. 328p fast PWM mode fixes top value as 255. + #ifdef SPINDLE_MINIMUM_PWM + #define SPINDLE_PWM_MIN_VALUE SPINDLE_MINIMUM_PWM + #else + #define SPINDLE_PWM_MIN_VALUE 1 // Must be greater than zero. + #endif #define SPINDLE_PWM_OFF_VALUE 0 + #define SPINDLE_PWM_RANGE (SPINDLE_PWM_MAX_VALUE-SPINDLE_PWM_MIN_VALUE) #define SPINDLE_TCCRA_REGISTER TCCR2A #define SPINDLE_TCCRB_REGISTER TCCR2B #define SPINDLE_OCR_REGISTER OCR2A diff --git a/grbl/grbl.h b/grbl/grbl.h index 9d4d6e5..1a9abd9 100644 --- a/grbl/grbl.h +++ b/grbl/grbl.h @@ -23,7 +23,7 @@ // Grbl versioning system #define GRBL_VERSION "1.1d" -#define GRBL_VERSION_BUILD "20161018" +#define GRBL_VERSION_BUILD "20161023" // Define standard libraries used by Grbl. #include diff --git a/grbl/report.c b/grbl/report.c index 7a8a85c..0b2e6c7 100644 --- a/grbl/report.c +++ b/grbl/report.c @@ -734,7 +734,7 @@ void report_realtime_status() uint8_t sp_state = spindle_get_state(); uint8_t cl_state = coolant_get_state(); - if (sp_state || cl_state) { + if (sp_state | cl_state) { printPgmString(PSTR(",A:")); if (sp_state) { // != SPINDLE_STATE_DISABLE #ifdef VARIABLE_SPINDLE diff --git a/grbl/spindle_control.c b/grbl/spindle_control.c index 7b939d8..cfddcc9 100644 --- a/grbl/spindle_control.c +++ b/grbl/spindle_control.c @@ -22,13 +22,6 @@ #include "grbl.h" -#ifdef SPINDLE_MINIMUM_PWM - #define SPINDLE_PWM_MIN_VALUE SPINDLE_MINIMUM_PWM -#else - #define SPINDLE_PWM_MIN_VALUE 0.0 -#endif -#define SPINDLE_PWM_RANGE (SPINDLE_PWM_MAX_VALUE-SPINDLE_PWM_MIN_VALUE) - #ifdef VARIABLE_SPINDLE static float pwm_gradient; // Precalulated value to speed up rpm to PWM conversions. #endif @@ -142,24 +135,28 @@ void spindle_stop() // Called by spindle_set_state() and step segment generator. Keep routine small and efficient. uint8_t spindle_compute_pwm_value(float rpm) // 328p PWM register is 8-bit. { + uint8_t pwm_value; rpm *= (0.01*sys.spindle_speed_ovr); // Scale by spindle speed override value. // Calculate PWM register value based on rpm max/min settings and programmed rpm. if ((settings.rpm_min >= settings.rpm_max) || (rpm >= settings.rpm_max)) { // No PWM range possible. Set simple on/off spindle control pin state. sys.spindle_speed = settings.rpm_max; - return(SPINDLE_PWM_MAX_VALUE); - } else if (rpm < settings.rpm_min) { - if (rpm == 0.0) { + pwm_value = SPINDLE_PWM_MAX_VALUE; + } else if (rpm <= settings.rpm_min) { + if (rpm == 0.0) { // S0 disables spindle sys.spindle_speed = 0.0; - return(SPINDLE_PWM_OFF_VALUE); } - else { + pwm_value = SPINDLE_PWM_OFF_VALUE; + } else { // Set minimum PWM output sys.spindle_speed = settings.rpm_min; - return(SPINDLE_PWM_MIN_VALUE); + pwm_value = SPINDLE_PWM_MIN_VALUE; } - } else { + } else { + // Compute intermediate PWM value with linear spindle speed model. + // NOTE: A nonlinear model could be installed here, if required, but keep it light-weight. sys.spindle_speed = rpm; - return(floor( (rpm-settings.rpm_min)*pwm_gradient + (SPINDLE_PWM_MIN_VALUE+0.5))); + pwm_value = floor( (rpm-settings.rpm_min)*pwm_gradient + (SPINDLE_PWM_MIN_VALUE+0.5)); } + return(pwm_value); } #endif