mirror of
https://github.com/bdring/Grbl_Esp32.git
synced 2025-09-03 03:13:25 +02:00
More cleanup and testing
- A basic PWM spindle appears to work now. - More testing of options and edge cases needed.
This commit is contained in:
@@ -31,19 +31,20 @@ PWMSpindle my_spindle;
|
||||
void spindle_init() {
|
||||
my_spindle.init();
|
||||
my_spindle.config_message();
|
||||
grbl_msg_sendf(CLIENT_SERIAL, MSG_LEVEL_INFO, "Spindle is rate adjustable %d", my_spindle.isRateAdjusted());
|
||||
}
|
||||
|
||||
void spindle_stop() {
|
||||
my_spindle.stop();
|
||||
}
|
||||
|
||||
|
||||
uint8_t spindle_get_state() {
|
||||
return my_spindle.get_state();
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
// Called by spindle_set_state() and step segment generator. Keep routine small and efficient.
|
||||
void spindle_set_state(uint8_t state, float rpm) {
|
||||
my_spindle.set_state(state, rpm);
|
||||
|
@@ -81,8 +81,10 @@ float PWMSpindle::set_rpm(float rpm) {
|
||||
sys.spindle_speed = 0.0;
|
||||
pwm_value = _pwm_off_value;
|
||||
} else { // Set minimum PWM output
|
||||
sys.spindle_speed = settings.rpm_min;
|
||||
rpm = settings.rpm_min;
|
||||
sys.spindle_speed = rpm;
|
||||
pwm_value = _pwm_min_value;
|
||||
grbl_msg_sendf(CLIENT_SERIAL, MSG_LEVEL_INFO, "Spindle RPM less than min RPM:%5.2f %d", rpm, pwm_value);
|
||||
}
|
||||
} else {
|
||||
// Compute intermediate PWM value with linear spindle speed model.
|
||||
@@ -92,6 +94,7 @@ float PWMSpindle::set_rpm(float rpm) {
|
||||
pwm_value = piecewise_linear_fit(rpm);
|
||||
#else
|
||||
pwm_value = floor((rpm - settings.rpm_min) * _pwm_gradient) + _pwm_min_value;
|
||||
//pwm_value = map_float(rpm, settings.rpm_min, settings.rpm_max, _pwm_min_value, _pwm_max_value);
|
||||
#endif
|
||||
}
|
||||
|
||||
@@ -140,6 +143,7 @@ void PWMSpindle::stop() {
|
||||
// prints the startup message of the spindle config
|
||||
void PWMSpindle :: config_message() {
|
||||
grbl_msg_sendf(CLIENT_SERIAL, MSG_LEVEL_INFO, "PWM spindle on GPIO %d, freq %.2fHz, Res %d bits", SPINDLE_PWM_PIN, settings.spindle_pwm_freq, SPINDLE_PWM_BIT_PRECISION);
|
||||
//grbl_msg_sendf(CLIENT_SERIAL, MSG_LEVEL_INFO, "PWM Off:%d Min:%d Max:%d", _pwm_off_value, _pwm_min_value, _pwm_max_value);
|
||||
}
|
||||
|
||||
|
||||
|
@@ -41,6 +41,18 @@ class Spindle {
|
||||
|
||||
};
|
||||
|
||||
// This is a dummy spindle that has no I/O.
|
||||
// It is used to ignore spindle activity when no spinde is desired
|
||||
class NullSpindle : public Spindle {
|
||||
void init();
|
||||
float set_rpm(float rpm);
|
||||
void set_pwm(uint32_t duty);
|
||||
void set_state(uint8_t state, float rpm);
|
||||
uint8_t get_state();
|
||||
void stop();
|
||||
void config_message();
|
||||
};
|
||||
|
||||
class PWMSpindle : public Spindle {
|
||||
public:
|
||||
void init();
|
||||
|
Reference in New Issue
Block a user