From cc3d931f2ccb4f5315d4fccc97f1688b53a9e542 Mon Sep 17 00:00:00 2001 From: bdring Date: Sun, 19 Apr 2020 07:12:10 -0500 Subject: [PATCH 1/4] Changed define to float value --- Grbl_Esp32/Machines/pen_laser.h | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/Grbl_Esp32/Machines/pen_laser.h b/Grbl_Esp32/Machines/pen_laser.h index 036415eb..d2bd4700 100644 --- a/Grbl_Esp32/Machines/pen_laser.h +++ b/Grbl_Esp32/Machines/pen_laser.h @@ -59,8 +59,8 @@ #ifdef USING_SERVO #define USE_SERVO_AXES #define SERVO_Z_PIN GPIO_NUM_27 - #define SERVO_Z_RANGE_MIN 0 - #define SERVO_Z_RANGE_MAX 10 + #define SERVO_Z_RANGE_MIN 0.0 + #define SERVO_Z_RANGE_MAX 10.0 #endif #ifdef USING_SOLENOID @@ -99,8 +99,8 @@ #define DEFAULT_LASER_MODE 0 // false -#define DEFAULT_X_STEPS_PER_MM 80 -#define DEFAULT_Y_STEPS_PER_MM 80 +#define DEFAULT_X_STEPS_PER_MM 80.0 +#define DEFAULT_Y_STEPS_PER_MM 80.0 #define DEFAULT_Z_STEPS_PER_MM 100.0 // This is percent in servo mode...used for calibration #define DEFAULT_X_MAX_RATE 5000.0 // mm/min From 6feb5714d819208f5f17ec6734492581411b636f Mon Sep 17 00:00:00 2001 From: bdring Date: Sun, 19 Apr 2020 09:49:49 -0500 Subject: [PATCH 2/4] fixed issue with pen_laser.h --- Grbl_Esp32/Machines/pen_laser.h | 2 +- Grbl_Esp32/servo_axis.h | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/Grbl_Esp32/Machines/pen_laser.h b/Grbl_Esp32/Machines/pen_laser.h index d2bd4700..eb405f2e 100644 --- a/Grbl_Esp32/Machines/pen_laser.h +++ b/Grbl_Esp32/Machines/pen_laser.h @@ -51,7 +51,7 @@ // If SPINDLE_PWM_PIN is commented out, this frees up the pin, but Grbl will still // use a virtual spindle. Do not comment out the other parameters for the spindle. -#define SPINDLE_PWM_PIN GPIO_NUM_17 // Laser PWM +//#define SPINDLE_PWM_PIN GPIO_NUM_17 // Laser PWM #define USING_SERVO // uncomment to use this feature //#define USING_SOLENOID // uncomment to use this feature diff --git a/Grbl_Esp32/servo_axis.h b/Grbl_Esp32/servo_axis.h index fefb71af..75d4bb35 100644 --- a/Grbl_Esp32/servo_axis.h +++ b/Grbl_Esp32/servo_axis.h @@ -79,7 +79,7 @@ #define SERVO_CAL_MIN 20.0 // Percent: the minimum allowable calibration value #define SERVO_CAL_MAX 180.0 // Percent: the maximum allowable calibration value -#define SERVO_TIMER_INT_FREQ 20 // Hz This is the task frequency +#define SERVO_TIMER_INT_FREQ 20.0 // Hz This is the task frequency #define SERVO_HOMING_OFF 0 // servo is off during homing #define SERVO_HOMING_TARGET 1 // servo is send to a location during homing From 785a27b82185719aceee7a2800ef34c06c744fa9 Mon Sep 17 00:00:00 2001 From: bdring Date: Sun, 19 Apr 2020 14:23:26 -0500 Subject: [PATCH 3/4] fixing PWM channel issue There are 8 high speed channel that share 4 timers. Each 01 23 45 67 pair must share the same settings. --- Grbl_Esp32/spindle_control.cpp | 2 +- Grbl_Esp32/system.cpp | 12 ++++++++++-- 2 files changed, 11 insertions(+), 3 deletions(-) diff --git a/Grbl_Esp32/spindle_control.cpp b/Grbl_Esp32/spindle_control.cpp index a7f0f7b2..52d26bad 100644 --- a/Grbl_Esp32/spindle_control.cpp +++ b/Grbl_Esp32/spindle_control.cpp @@ -56,7 +56,7 @@ void spindle_init() { pinMode(SPINDLE_DIR_PIN, OUTPUT); #endif // use the LED control feature to setup PWM https://docs.espressif.com/projects/esp-idf/en/latest/api-reference/peripherals/ledc.html - spindle_pwm_chan_num = sys_get_next_PWM_chan_num(); + spindle_pwm_chan_num = 0; // spindle always uses channel 0 ledcSetup(spindle_pwm_chan_num, (double)settings.spindle_pwm_freq, SPINDLE_PWM_BIT_PRECISION); // setup the channel ledcAttachPin(SPINDLE_PWM_PIN, spindle_pwm_chan_num); // attach the PWM to the pin // Start with spindle off off diff --git a/Grbl_Esp32/system.cpp b/Grbl_Esp32/system.cpp index 635e6bee..46d78710 100644 --- a/Grbl_Esp32/system.cpp +++ b/Grbl_Esp32/system.cpp @@ -589,12 +589,20 @@ int8_t sys_get_next_RMT_chan_num() { } } +/* + This returns an unused pwm channel. + The 8 channels share 4 timers, so pairs 0,1 & 2,3 , etc + have to be the same frequency. The spindle always uses channel 0 + so we start counting from 2. + There are still possible issues if requested channels use different frequencies + TODO: Make this more robust. +*/ int8_t sys_get_next_PWM_chan_num() { - static uint8_t next_PWM_chan_num = 0; // channels 0-7 are valid + static uint8_t next_PWM_chan_num = 2; // start at 2 to avoid spindle if (next_PWM_chan_num < 8) // 7 is the max PWM channel number return next_PWM_chan_num++; else { grbl_msg_sendf(CLIENT_SERIAL, MSG_LEVEL_ERROR, "Error: out of PWM channels"); return -1; } -} \ No newline at end of file +} From 774f6322d1231e0087ca6954682726abe3475983 Mon Sep 17 00:00:00 2001 From: bdring Date: Sun, 19 Apr 2020 14:24:54 -0500 Subject: [PATCH 4/4] update build date --- Grbl_Esp32/grbl.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Grbl_Esp32/grbl.h b/Grbl_Esp32/grbl.h index 31d760ca..18efe9b6 100644 --- a/Grbl_Esp32/grbl.h +++ b/Grbl_Esp32/grbl.h @@ -20,7 +20,7 @@ // Grbl versioning system #define GRBL_VERSION "1.1f" -#define GRBL_VERSION_BUILD "20200417" +#define GRBL_VERSION_BUILD "20200419" //#include #include