1
0
mirror of https://github.com/bdring/Grbl_Esp32.git synced 2025-08-17 20:01:42 +02:00

Merge remote-tracking branch 'upstream/Devt' into i2s_io_expander

This commit is contained in:
odaki
2020-04-25 23:11:33 +09:00
5 changed files with 18 additions and 10 deletions

View File

@@ -51,7 +51,7 @@
// If SPINDLE_PWM_PIN is commented out, this frees up the pin, but Grbl will still // 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. // 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_SERVO // uncomment to use this feature
//#define USING_SOLENOID // uncomment to use this feature //#define USING_SOLENOID // uncomment to use this feature
@@ -59,8 +59,8 @@
#ifdef USING_SERVO #ifdef USING_SERVO
#define USE_SERVO_AXES #define USE_SERVO_AXES
#define SERVO_Z_PIN GPIO_NUM_27 #define SERVO_Z_PIN GPIO_NUM_27
#define SERVO_Z_RANGE_MIN 0 #define SERVO_Z_RANGE_MIN 0.0
#define SERVO_Z_RANGE_MAX 10 #define SERVO_Z_RANGE_MAX 10.0
#endif #endif
#ifdef USING_SOLENOID #ifdef USING_SOLENOID
@@ -99,8 +99,8 @@
#define DEFAULT_LASER_MODE 0 // false #define DEFAULT_LASER_MODE 0 // false
#define DEFAULT_X_STEPS_PER_MM 80 #define DEFAULT_X_STEPS_PER_MM 80.0
#define DEFAULT_Y_STEPS_PER_MM 80 #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_Z_STEPS_PER_MM 100.0 // This is percent in servo mode...used for calibration
#define DEFAULT_X_MAX_RATE 5000.0 // mm/min #define DEFAULT_X_MAX_RATE 5000.0 // mm/min

View File

@@ -20,7 +20,7 @@
// Grbl versioning system // Grbl versioning system
#define GRBL_VERSION "1.1f" #define GRBL_VERSION "1.1f"
#define GRBL_VERSION_BUILD "20200417" #define GRBL_VERSION_BUILD "20200419"
//#include <sdkconfig.h> //#include <sdkconfig.h>
#include <Arduino.h> #include <Arduino.h>

View File

@@ -79,7 +79,7 @@
#define SERVO_CAL_MIN 20.0 // Percent: the minimum allowable calibration value #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_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_OFF 0 // servo is off during homing
#define SERVO_HOMING_TARGET 1 // servo is send to a location during homing #define SERVO_HOMING_TARGET 1 // servo is send to a location during homing

View File

@@ -56,7 +56,7 @@ void spindle_init() {
pinMode(SPINDLE_DIR_PIN, OUTPUT); pinMode(SPINDLE_DIR_PIN, OUTPUT);
#endif #endif
// use the LED control feature to setup PWM https://docs.espressif.com/projects/esp-idf/en/latest/api-reference/peripherals/ledc.html // 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 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 ledcAttachPin(SPINDLE_PWM_PIN, spindle_pwm_chan_num); // attach the PWM to the pin
// Start with spindle off off // Start with spindle off off

View File

@@ -589,8 +589,16 @@ 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() { 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 if (next_PWM_chan_num < 8) // 7 is the max PWM channel number
return next_PWM_chan_num++; return next_PWM_chan_num++;
else { else {