2 This file is part of Smoothie (http://smoothieware.org/). The motion control part is heavily based on Grbl (https://github.com/simen/grbl).
3 Smoothie is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version.
4 Smoothie is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.
5 You should have received a copy of the GNU General Public License along with Smoothie. If not, see <http://www.gnu.org/licenses/>.
8 #ifndef SPINDLE_MODULE_H
9 #define SPINDLE_MODULE_H
11 #include "libs/Module.h"
19 // This module implements closed loop PID control for spindle RPM.
20 class Spindle
: public Module
{
23 virtual ~Spindle() {};
24 void on_module_loaded();
29 void on_gcode_received(void *argument
);
30 uint32_t on_update_speed(uint32_t dummy
);
32 mbed::PwmOut
*spindle_pin
; // PWM output for spindle speed control
33 mbed::InterruptIn
*feedback_pin
; // Interrupt pin for measuring speed
36 // Current values, updated at runtime
40 float current_I_value
;
42 float current_pwm_value
;
43 int time_since_update
;
51 float smoothing_decay
;
53 // These fields are updated by the interrupt
54 uint32_t last_edge
; // Timestamp of last edge
55 volatile uint32_t last_time
; // Time delay between last two edges
56 volatile uint32_t irq_count
;