Compile-option for inverting spindle enable.
- Installed a compile-option for inverting the spindle enable pin for certain electronics boards users have reported needing this.
This commit is contained in:
		| @@ -156,6 +156,13 @@ | |||||||
| // NOTE: Will eventually be added to Grbl settings in v1.0. | // NOTE: Will eventually be added to Grbl settings in v1.0. | ||||||
| // #define INVERT_CONTROL_PIN // Default disabled. Uncomment to enable. | // #define INVERT_CONTROL_PIN // 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. | ||||||
|  | // NOTE: If VARIABLE_SPINDLE is enabled(default), this option has no effect as the PWM output and  | ||||||
|  | // spindle enable are combined to one pin. If you need both this option and spindle speed PWM,  | ||||||
|  | // uncomment the config option USE_SPINDLE_DIR_AS_ENABLE_PIN below. | ||||||
|  | // #define INVERT_SPINDLE_ENABLE_PIN // Default disabled. Uncomment to enable. | ||||||
|  |  | ||||||
| // Enable limit pin states feedback in status reports. The data is presented as 0 (low) or 1(high),  | // Enable limit pin states feedback in status reports. The data is presented as 0 (low) or 1(high),  | ||||||
| // where the order is XYZ. For example, if the Y- and Z-limit pins are active, Grbl will include the  | // where the order is XYZ. For example, if the Y- and Z-limit pins are active, Grbl will include the  | ||||||
| // following string in the status report "Lim:011". This is generally useful for setting up a new | // following string in the status report "Lim:011". This is generally useful for setting up a new | ||||||
|   | |||||||
| @@ -49,10 +49,18 @@ void spindle_stop() | |||||||
|   #ifdef VARIABLE_SPINDLE |   #ifdef VARIABLE_SPINDLE | ||||||
|     TCCRA_REGISTER &= ~(1<<COMB_BIT); // Disable PWM. Output voltage is zero. |     TCCRA_REGISTER &= ~(1<<COMB_BIT); // Disable PWM. Output voltage is zero. | ||||||
|     #if defined(CPU_MAP_ATMEGA2560) || defined(USE_SPINDLE_DIR_AS_ENABLE_PIN) |     #if defined(CPU_MAP_ATMEGA2560) || defined(USE_SPINDLE_DIR_AS_ENABLE_PIN) | ||||||
|       SPINDLE_ENABLE_PORT &= ~(1<<SPINDLE_ENABLE_BIT); // Set pin to low. |       #ifdef INVERT_SPINDLE_ENABLE_PIN | ||||||
|  | 		SPINDLE_ENABLE_PORT |= (1<<SPINDLE_ENABLE_BIT);  // Set pin to high | ||||||
|  | 	  #else | ||||||
|  | 		SPINDLE_ENABLE_PORT &= ~(1<<SPINDLE_ENABLE_BIT); // Set pin to low | ||||||
|  | 	  #endif | ||||||
|     #endif |     #endif | ||||||
|   #else |   #else | ||||||
|     SPINDLE_ENABLE_PORT &= ~(1<<SPINDLE_ENABLE_BIT); // Set pin to low. |     #ifdef INVERT_SPINDLE_ENABLE_PIN | ||||||
|  | 	  SPINDLE_ENABLE_PORT |= (1<<SPINDLE_ENABLE_BIT);  // Set pin to high | ||||||
|  | 	#else | ||||||
|  | 	  SPINDLE_ENABLE_PORT &= ~(1<<SPINDLE_ENABLE_BIT); // Set pin to low | ||||||
|  | 	#endif | ||||||
|   #endif   |   #endif   | ||||||
| } | } | ||||||
|  |  | ||||||
| @@ -101,12 +109,20 @@ void spindle_set_state(uint8_t state, float rpm) | |||||||
|      |      | ||||||
|       // On the Uno, spindle enable and PWM are shared, unless otherwise specified. |       // On the Uno, spindle enable and PWM are shared, unless otherwise specified. | ||||||
|       #if defined(CPU_MAP_ATMEGA2560) || defined(USE_SPINDLE_DIR_AS_ENABLE_PIN)  |       #if defined(CPU_MAP_ATMEGA2560) || 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); |           SPINDLE_ENABLE_PORT |= (1<<SPINDLE_ENABLE_BIT); | ||||||
|         #endif |         #endif | ||||||
|  |       #endif | ||||||
|        |        | ||||||
|  |     #else    | ||||||
|  |       #ifdef INVERT_SPINDLE_ENABLE_PIN | ||||||
|  | 		SPINDLE_ENABLE_PORT &= ~(1<<SPINDLE_ENABLE_BIT); | ||||||
| 	  #else | 	  #else | ||||||
| 		SPINDLE_ENABLE_PORT |= (1<<SPINDLE_ENABLE_BIT); | 		SPINDLE_ENABLE_PORT |= (1<<SPINDLE_ENABLE_BIT); | ||||||
| 	  #endif | 	  #endif | ||||||
|  |     #endif | ||||||
|  |  | ||||||
|   } |   } | ||||||
| } | } | ||||||
|   | |||||||
		Reference in New Issue
	
	Block a user