Spindle enable pin with variable spindle option fix.

- [fix] When USE_SPINDLE_DIR_AS_ENABLE_PIN is enabled in config.h, the
enable pin was not being set when spindle speed is zero. This behavior
should now be fixed.
This commit is contained in:
Sonny Jeon 2017-01-03 10:10:35 -07:00
parent 864d1306b9
commit 30c0f79afd
3 changed files with 19 additions and 12 deletions

View File

@ -1,3 +1,17 @@
----------------
Date: 2016-12-19
Author: Sonny Jeon
Subject: Fixed homing fail alarm handling. Re-integrated software debouncing.
- [bug] Fixed a homing fail issue, where the alarm was not being set
right, not cleared correctly. It would report the wrong code and enter
an infinite alarm loop. This was due to how alarm codes were altered a
while back. Now updated and fixed to show the right codes.
- [feature] Re-installed optional software debouncing for hard limit
switches. By request.
---------------- ----------------
Date: 2016-12-18 Date: 2016-12-18
Author: Sonny Jeon Author: Sonny Jeon

View File

@ -23,7 +23,7 @@
// Grbl versioning system // Grbl versioning system
#define GRBL_VERSION "1.1e" #define GRBL_VERSION "1.1e"
#define GRBL_VERSION_BUILD "20161219" #define GRBL_VERSION_BUILD "20170103"
// Define standard libraries used by Grbl. // Define standard libraries used by Grbl.
#include <avr/io.h> #include <avr/io.h>

View File

@ -115,19 +115,11 @@ void spindle_stop()
// and stepper ISR. Keep routine small and efficient. // and stepper ISR. Keep routine small and efficient.
void spindle_set_speed(uint8_t pwm_value) void spindle_set_speed(uint8_t pwm_value)
{ {
if (pwm_value == SPINDLE_PWM_OFF_VALUE) {
spindle_stop();
} else {
SPINDLE_OCR_REGISTER = pwm_value; // Set PWM output level. SPINDLE_OCR_REGISTER = pwm_value; // Set PWM output level.
if (pwm_value == SPINDLE_PWM_OFF_VALUE) {
SPINDLE_TCCRA_REGISTER &= ~(1<<SPINDLE_COMB_BIT); // Disable PWM. Output voltage is zero.
} else {
SPINDLE_TCCRA_REGISTER |= (1<<SPINDLE_COMB_BIT); // Ensure PWM output is enabled. SPINDLE_TCCRA_REGISTER |= (1<<SPINDLE_COMB_BIT); // Ensure PWM output is enabled.
#if defined(USE_SPINDLE_DIR_AS_ENABLE_PIN)
#ifdef INVERT_SPINDLE_ENABLE_PIN
SPINDLE_ENABLE_PORT &= ~(1<<SPINDLE_ENABLE_BIT);
#else
SPINDLE_ENABLE_PORT |= (1<<SPINDLE_ENABLE_BIT);
#endif
#endif
} }
} }
@ -194,7 +186,8 @@ void spindle_stop()
if (state == SPINDLE_ENABLE_CCW) { rpm = 0.0; } // TODO: May need to be rpm_min*(100/MAX_SPINDLE_SPEED_OVERRIDE); if (state == SPINDLE_ENABLE_CCW) { rpm = 0.0; } // TODO: May need to be rpm_min*(100/MAX_SPINDLE_SPEED_OVERRIDE);
} }
spindle_set_speed(spindle_compute_pwm_value(rpm)); spindle_set_speed(spindle_compute_pwm_value(rpm));
#else #endif
#if defined(USE_SPINDLE_DIR_AS_ENABLE_PIN) || !defined(VARIABLE_SPINDLE)
// NOTE: Without variable spindle, the enable bit should just turn on or off, regardless // NOTE: Without variable spindle, the enable bit should just turn on or off, regardless
// if the spindle speed value is zero, as its ignored anyhow. // if the spindle speed value is zero, as its ignored anyhow.
#ifdef INVERT_SPINDLE_ENABLE_PIN #ifdef INVERT_SPINDLE_ENABLE_PIN