1
0
mirror of https://github.com/bdring/Grbl_Esp32.git synced 2025-09-09 05:40:46 +02:00

Tweaked the servo axis feature

This commit is contained in:
Bart Dring
2019-08-31 09:06:19 -05:00
parent 431fad28b4
commit 6878c584b4
2 changed files with 37 additions and 14 deletions

View File

@@ -408,7 +408,9 @@
#define SERVO_Z_CHANNEL_NUM 5 #define SERVO_Z_CHANNEL_NUM 5
#define SERVO_Z_RANGE_MIN 0.0 #define SERVO_Z_RANGE_MIN 0.0
#define SERVO_Z_RANGE_MAX 5.0 #define SERVO_Z_RANGE_MAX 5.0
#define SERVO_Z_MPOS false #define SERVO_Z_HOMING_TYPE SERVO_HOMING_TARGET // during homing it will instantly move to a target value
#define SERVO_Z_HOME_POS SERVO_Z_RANGE_MAX // move to max during homing
#define SERVO_Z_MPOS false // will not use mpos, uses work coordinates
#ifndef IGNORE_CONTROL_PINS // maybe set in config.h #ifndef IGNORE_CONTROL_PINS // maybe set in config.h
#define IGNORE_CONTROL_PINS #define IGNORE_CONTROL_PINS
@@ -1198,11 +1200,17 @@
#define SERVO_Z_CHANNEL_NUM 6 #define SERVO_Z_CHANNEL_NUM 6
#define SERVO_Z_RANGE_MIN 0.0 #define SERVO_Z_RANGE_MIN 0.0
#define SERVO_Z_RANGE_MAX 5.0 #define SERVO_Z_RANGE_MAX 5.0
#define SERVO_Z_HOMING_TYPE SERVO_HOMING_TARGET // during homing it will instantly move to a target value
#define SERVO_Z_HOME_POS SERVO_Z_RANGE_MAX // move to max during homing
#define SERVO_Z_MPOS false // will not use mpos, uses work coordinates
#define SERVO_C_PIN GPIO_NUM_2 #define SERVO_C_PIN GPIO_NUM_2
#define SERVO_C_CHANNEL_NUM 7 #define SERVO_C_CHANNEL_NUM 7
#define SERVO_C_RANGE_MIN 0.0 #define SERVO_C_RANGE_MIN 0.0
#define SERVO_C_RANGE_MAX 5.0 #define SERVO_C_RANGE_MAX 5.0
#define SERVO_C_HOMING_TYPE SERVO_HOMING_TARGET // during homing it will instantly move to a target value
#define SERVO_C_HOME_POS SERVO_C_RANGE_MAX // move to max during homing
#define SERVO_C_MPOS false // will not use mpos, uses work coordinates
// limit switches // limit switches
#define X_LIMIT_PIN GPIO_NUM_21 #define X_LIMIT_PIN GPIO_NUM_21

View File

@@ -68,8 +68,12 @@ void init_servos()
grbl_send(CLIENT_SERIAL, "[MSG:Init Z Servo]\r\n"); grbl_send(CLIENT_SERIAL, "[MSG:Init Z Servo]\r\n");
Z_Servo_Axis.init(); Z_Servo_Axis.init();
Z_Servo_Axis.set_range(SERVO_Z_RANGE_MIN, SERVO_Z_RANGE_MAX); Z_Servo_Axis.set_range(SERVO_Z_RANGE_MIN, SERVO_Z_RANGE_MAX);
Z_Servo_Axis.set_homing_type(SERVO_HOMING_TARGET); #ifdef SERVO_Z_HOMING_TYPE
Z_Servo_Axis.set_homing_position(SERVO_Z_RANGE_MAX); Z_Servo_Axis.set_homing_type(SERVO_Z_HOMING_TYPE);
#endif
#ifdef SERVO_Z_HOME_POS
Z_Servo_Axis.set_homing_position(SERVO_Z_HOME_POS);
#endif
#ifdef SERVO_Z_MPOS // value should be true or false #ifdef SERVO_Z_MPOS // value should be true or false
Z_Servo_Axis.set_use_mpos(SERVO_Z_MPOS); Z_Servo_Axis.set_use_mpos(SERVO_Z_MPOS);
#endif #endif
@@ -92,8 +96,17 @@ void init_servos()
grbl_send(CLIENT_SERIAL, "[MSG:Init C Servo]\r\n"); grbl_send(CLIENT_SERIAL, "[MSG:Init C Servo]\r\n");
C_Servo_Axis.init(); C_Servo_Axis.init();
C_Servo_Axis.set_range(SERVO_C_RANGE_MIN, SERVO_C_RANGE_MAX); C_Servo_Axis.set_range(SERVO_C_RANGE_MIN, SERVO_C_RANGE_MAX);
C_Servo_Axis.set_homing_type(SERVO_HOMING_TARGET); //C_Servo_Axis.set_homing_type(SERVO_HOMING_TARGET);
C_Servo_Axis.set_homing_position(SERVO_C_RANGE_MAX); //C_Servo_Axis.set_homing_position(SERVO_C_RANGE_MAX);
#ifdef SERVO_C_HOMING_TYPE
C_Servo_Axis.set_homing_type(SERVO_C_HOMING_TYPE);
#endif
#ifdef SERVO_C_HOME_POS
C_Servo_Axis.set_homing_position(SERVO_C_HOME_POS);
#endif
#ifdef SERVO_C_MPOS // value should be true or false
C_Servo_Axis.set_use_mpos(SERVO_C_MPOS);
#endif
#endif #endif
@@ -217,13 +230,15 @@ void ServoAxis::set_location()
// get the calibration values // get the calibration values
if (_cal_is_valid()) { // if calibration settings are OK then apply them if (_cal_is_valid()) { // if calibration settings are OK then apply them
// apply a calibration
min_pulse_cal = (settings.steps_per_mm[_axis] / 100.0); // the cals apply differently if the direction is reverse (i.e. longer pulse is lower position)
max_pulse_cal = (settings.max_travel[_axis] / -100.0); if (bit_isfalse(settings.dir_invert_mask,bit(_axis))) { // normal direction
min_pulse_cal = 2.0 - (settings.steps_per_mm[_axis] / 100.0);
if (bit_istrue(settings.dir_invert_mask,bit(_axis))) { max_pulse_cal = (settings.max_travel[_axis] / -100.0);
min_pulse_cal = 2.0 - min_pulse_cal; }
max_pulse_cal = 2.0 - max_pulse_cal; else { // inverted direction
min_pulse_cal = (settings.steps_per_mm[_axis] / 100.0);
max_pulse_cal = 2.0 - (settings.max_travel[_axis] / -100.0);
} }
} }
else { // settings are not valid so don't apply any calibration else { // settings are not valid so don't apply any calibration