Skip to content

Commit

Permalink
Fix spindle enable pin logic
Browse files Browse the repository at this point in the history
  • Loading branch information
bdring committed Jun 27, 2020
1 parent 98559ba commit 04c75e4
Show file tree
Hide file tree
Showing 3 changed files with 5 additions and 11 deletions.
4 changes: 0 additions & 4 deletions Grbl_Esp32/Spindles/DacSpindle.cpp
Expand Up @@ -94,10 +94,6 @@ uint32_t DacSpindle::set_rpm(uint32_t rpm) {

pwm_value = map_uint32_t(rpm, _min_rpm, _max_rpm, _pwm_min_value, _pwm_max_value);
}

if (_off_with_zero_speed) {
set_enable_pin(rpm != 0);
}

set_output(pwm_value);

Expand Down
9 changes: 5 additions & 4 deletions Grbl_Esp32/Spindles/PWMSpindle.cpp
Expand Up @@ -145,9 +145,6 @@ uint32_t PWMSpindle::set_rpm(uint32_t rpm) {
pwm_value = map_uint32_t(rpm, _min_rpm, _max_rpm, _pwm_min_value, _pwm_max_value);
}

if (_off_with_zero_speed)
set_enable_pin(rpm != 0);

set_output(pwm_value);

return 0;
Expand All @@ -165,7 +162,7 @@ void PWMSpindle::set_state(uint8_t state, uint32_t rpm) {
set_rpm(rpm);
}

set_enable_pin(state == SPINDLE_DISABLE);
set_enable_pin(state != SPINDLE_DISABLE);

sys.report_ovr_counter = 0; // Set to report change immediately
}
Expand Down Expand Up @@ -227,6 +224,10 @@ void PWMSpindle::set_output(uint32_t duty) {
void PWMSpindle::set_enable_pin(bool enable) {
if (_enable_pin == UNDEFINED_PIN)
return;

if (_off_with_zero_speed && sys.spindle_speed == 0)
enable = false;

#ifndef INVERT_SPINDLE_ENABLE_PIN
digitalWrite(_enable_pin, enable);
#else
Expand Down
3 changes: 0 additions & 3 deletions Grbl_Esp32/Spindles/RelaySpindle.cpp
Expand Up @@ -66,9 +66,6 @@ uint32_t RelaySpindle::set_rpm(uint32_t rpm) {
set_output(1);
}

if (_off_with_zero_speed)
set_enable_pin(rpm != 0);

return rpm;
}

Expand Down

0 comments on commit 04c75e4

Please sign in to comment.