gnea\grbl-Mega  1.0f
Source Code Documentation ( Internal Workings )
spindle_control.h
Go to the documentation of this file.
1 /*
2  spindle_control.h - spindle control methods
3  Part of Grbl
4 
5  Copyright (c) 2012-2016 Sungeun K. Jeon for Gnea Research LLC
6  Copyright (c) 2009-2011 Simen Svale Skogsrud
7 
8  Grbl is free software: you can redistribute it and/or modify
9  it under the terms of the GNU General Public License as published by
10  the Free Software Foundation, either version 3 of the License, or
11  (at your option) any later version.
12 
13  Grbl is distributed in the hope that it will be useful,
14  but WITHOUT ANY WARRANTY; without even the implied warranty of
15  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16  GNU General Public License for more details.
17 
18  You should have received a copy of the GNU General Public License
19  along with Grbl. If not, see <http://www.gnu.org/licenses/>.
20 */
21 
22 #ifndef spindle_control_h
23 #define spindle_control_h
24 
25 #define SPINDLE_NO_SYNC false
26 #define SPINDLE_FORCE_SYNC true
27 
28 #define SPINDLE_STATE_DISABLE 0
29 #define SPINDLE_STATE_CW bit(0)
30 #define SPINDLE_STATE_CCW bit(1)
31 
33 void spindle_init();
35 uint8_t spindle_get_state();
37 // Immediately sets spindle running state with direction and spindle rpm via PWM, if enabled.
38 // Called by spindle_sync() after sync and parking motion/spindle stop override during restore.
40 void spindle_sync(uint8_t state, float rpm);
42 void spindle_set_state(uint8_t state, float rpm);
44 //
46 void spindle_set_speed(uint16_t pwm_value);
48 uint16_t spindle_compute_pwm_value(float rpm);
49 
50 // Stop and start spindle routines. Called by all spindle routines and stepper ISR.
51 void spindle_stop();
52 
53 
54 #endif
void spindle_init()
Initializes spindle pins and hardware PWM, if enabled.
uint16_t spindle_compute_pwm_value(float rpm)
Computes Mega2560-specific PWM register value for the given RPM for quick updating.
uint8_t spindle_get_state()
Returns current spindle output state. Overrides may alter it from programmed states.
void spindle_set_state(uint8_t state, float rpm)
Sets spindle running state with direction, enable, and spindle PWM.
void spindle_set_speed(uint16_t pwm_value)
Sets spindle PWM quickly for stepper ISR. Also called by spindle_set_state().
void spindle_sync(uint8_t state, float rpm)
Called by g-code parser when setting spindle state and requires a buffer sync.
void spindle_stop()
Disables the spindle and sets PWM output to zero when PWM variable spindle speed is enabled...