diff --git a/grbl/config.h b/grbl/config.h index f48d9586..18636137 100644 --- a/grbl/config.h +++ b/grbl/config.h @@ -210,6 +210,11 @@ // uncomment the config option USE_SPINDLE_DIR_AS_ENABLE_PIN below. // #define INVERT_SPINDLE_ENABLE_PIN // Default disabled. Uncomment to enable. +// Inverts the PWM signal of the spindle. This can be used, if the inverter of the spindle requires +// inverted speed signals. Another example are some power supplies of the K40 lasers which fire the laser +// at 0V and disable them at 5V. +// #define INVERT_SPINDLE_PWM // Default disabled. Uncomment to enable. + // Inverts the selected coolant pin from low-disabled/high-enabled to low-enabled/high-disabled. Useful // for some pre-built electronic boards. // #define INVERT_COOLANT_FLOOD_PIN // Default disabled. Uncomment to enable. diff --git a/grbl/spindle_control.c b/grbl/spindle_control.c index 550b7520..6b07dac6 100644 --- a/grbl/spindle_control.c +++ b/grbl/spindle_control.c @@ -26,6 +26,14 @@ static float pwm_gradient; // Precalulated value to speed up rpm to PWM conversions. #endif +static void enable_pwm() { + SPINDLE_TCCRA_REGISTER |= (1<