mirror of
https://github.com/bdring/Grbl_Esp32.git
synced 2025-09-02 10:53:01 +02:00
Merge remote-tracking branch 'upstream/Devt' into Devt
This commit is contained in:
@@ -37,7 +37,6 @@
|
||||
*/
|
||||
|
||||
|
||||
|
||||
#ifdef CPU_MAP_ESP32
|
||||
// This is the CPU Map for the ESP32 CNC Controller R2
|
||||
|
||||
@@ -180,8 +179,7 @@
|
||||
#define CONTROL_FEED_HOLD_PIN GPIO_NUM_36 // needs external pullup
|
||||
#define CONTROL_CYCLE_START_PIN GPIO_NUM_39 // needs external pullup
|
||||
|
||||
#endif
|
||||
|
||||
#endif
|
||||
|
||||
#ifdef CPU_MAP_PEN_LASER // The Buildlog.net pen laser controller V1
|
||||
|
||||
@@ -330,17 +328,22 @@
|
||||
#define Y_LIMIT_PIN GPIO_NUM_4
|
||||
#define LIMIT_MASK B11
|
||||
|
||||
#ifndef USE_PEN_SERVO // maybe set in config.h
|
||||
#define USE_PEN_SERVO
|
||||
#ifndef USE_SERVO_AXES // maybe set in config.h
|
||||
#define USE_SERVO_AXES
|
||||
#endif
|
||||
|
||||
#define SERVO_Z_PIN GPIO_NUM_27
|
||||
#define SERVO_Z_CHANNEL_NUM 5
|
||||
#define SERVO_Z_RANGE_MIN 0.0
|
||||
#define SERVO_Z_RANGE_MAX 5.0
|
||||
|
||||
#ifndef IGNORE_CONTROL_PINS // maybe set in config.h
|
||||
#define IGNORE_CONTROL_PINS
|
||||
#endif
|
||||
#define CONTROL_SAFETY_DOOR_PIN GPIO_NUM_35 // needs external pullup
|
||||
#define CONTROL_RESET_PIN GPIO_NUM_34 // needs external pullup
|
||||
#define CONTROL_FEED_HOLD_PIN GPIO_NUM_36 // needs external pullup
|
||||
#define CONTROL_CYCLE_START_PIN GPIO_NUM_39 // needs external pullup
|
||||
//#define CONTROL_SAFETY_DOOR_PIN GPIO_NUM_35 // needs external pullup
|
||||
//#define CONTROL_RESET_PIN GPIO_NUM_34 // needs external pullup
|
||||
//#define CONTROL_FEED_HOLD_PIN GPIO_NUM_36 // needs external pullup
|
||||
//#define CONTROL_CYCLE_START_PIN GPIO_NUM_39 // needs external pullup
|
||||
|
||||
// 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.
|
||||
@@ -412,7 +415,7 @@
|
||||
|
||||
#define DEFAULT_LASER_MODE 0 // false
|
||||
|
||||
#define DEFAULT_X_STEPS_PER_MM 100.0
|
||||
#define DEFAULT_X_STEPS_PER_MM 200.0
|
||||
#define DEFAULT_Y_STEPS_PER_MM 100.0
|
||||
#define DEFAULT_Z_STEPS_PER_MM 100.0 // This is percent in servo mode
|
||||
|
||||
@@ -424,10 +427,9 @@
|
||||
#define DEFAULT_Y_ACCELERATION (200.0*60*60) // 10*60*60 mm/min^2 = 10 mm/sec^2
|
||||
#define DEFAULT_Z_ACCELERATION (100.0*60*60)
|
||||
|
||||
#define DEFAULT_X_MAX_TRAVEL 50.0 // mm NOTE: Must be a positive value.
|
||||
#define DEFAULT_Y_MAX_TRAVEL 300.0 // mm NOTE: Must be a positive value.
|
||||
#define DEFAULT_Z_MAX_TRAVEL 100.0 // This is percent in servo mode
|
||||
|
||||
#define DEFAULT_X_MAX_TRAVEL 100.0 // mm NOTE: Must be a positive value.
|
||||
#define DEFAULT_Y_MAX_TRAVEL 100.0 // mm NOTE: Must be a positive value.
|
||||
#define DEFAULT_Z_MAX_TRAVEL 100.0 // This is percent in servo mode
|
||||
|
||||
#endif
|
||||
|
||||
@@ -647,7 +649,6 @@
|
||||
|
||||
#endif
|
||||
|
||||
|
||||
#ifdef CPU_MAP_SM // String art machine definition
|
||||
|
||||
|
||||
|
@@ -185,3 +185,5 @@ float mapConstrain(float x, float in_min, float in_max, float out_min, float out
|
||||
x = constrain_float(x, in_min, in_max);
|
||||
return map_float(x, in_min, in_max, out_min, out_max);
|
||||
}
|
||||
|
||||
|
||||
|
@@ -85,4 +85,9 @@ float mapConstrain(float x, float in_min, float in_max, float out_min, float out
|
||||
float map_float(float x, float in_min, float in_max, float out_min, float out_max);
|
||||
float constrain_float(float in, float min, float max);
|
||||
|
||||
template <class T> void swap ( T& a, T& b )
|
||||
{
|
||||
T c(a); a=b; b=c;
|
||||
}
|
||||
|
||||
#endif
|
||||
|
@@ -112,74 +112,6 @@ void ServoAxis::init()
|
||||
ledcAttachPin(_pin_num, _channel_num);
|
||||
disable();
|
||||
}
|
||||
/*
|
||||
void ServoAxis::set_location()
|
||||
{
|
||||
// These are the pulse lengths for the minimum and maximum positions
|
||||
// Note: Some machines will have the physical max/min inverted with pulse length max/min due to invert setting $3=...
|
||||
float servo_pulse_min, servo_pulse_max;
|
||||
float min_pulse_cal, max_pulse_cal; // calibration values in percent 110% = 1.1
|
||||
uint32_t servo_pulse_len;
|
||||
float mpos, offset, wpos;
|
||||
|
||||
// skip location if we are in alarm mode
|
||||
if (_disable_on_alarm && (sys.state == STATE_ALARM)) {
|
||||
disable();
|
||||
return;
|
||||
}
|
||||
|
||||
// track the disable status of the steppers if desired.
|
||||
if (_disable_with_steppers && get_stepper_disable()) {
|
||||
disable();
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
if ( (_homing_type == SERVO_HOMING_TARGET) && (sys.state == STATE_HOMING) ) {
|
||||
wpos = _homing_position; // go to servos home position
|
||||
}
|
||||
else {
|
||||
mpos = system_convert_axis_steps_to_mpos(sys_position, _axis); // get the axis machine position in mm
|
||||
offset = gc_state.coord_system[_axis]+gc_state.coord_offset[_axis]; // get the current axis work offset
|
||||
wpos = mpos - offset; // determine the current work position
|
||||
}
|
||||
|
||||
// get the calibration values
|
||||
if (_cal_is_valid()) { // if calibration settings are OK then apply them
|
||||
min_pulse_cal = (settings.steps_per_mm[_axis] / 100.0);
|
||||
max_pulse_cal = (settings.max_travel[_axis] / -100.0);
|
||||
if (bit_istrue(settings.dir_invert_mask,bit(_axis))) { // the offset needs to be backwards
|
||||
min_pulse_cal = 1.0 + (1.0 - min_pulse_cal);
|
||||
max_pulse_cal = 1.0 + (1.0 - max_pulse_cal);
|
||||
}
|
||||
}
|
||||
else { // settings are not valid so don't apply any calibration
|
||||
min_pulse_cal = 1.0;
|
||||
max_pulse_cal = 1.0;
|
||||
}
|
||||
|
||||
|
||||
if (bit_istrue(settings.dir_invert_mask,bit(_axis))) { // this allows the user to change the direction via settings
|
||||
servo_pulse_min = SERVO_MAX_PULSE;
|
||||
servo_pulse_max = SERVO_MIN_PULSE;
|
||||
}
|
||||
else {
|
||||
servo_pulse_min = SERVO_MIN_PULSE;
|
||||
servo_pulse_max = SERVO_MAX_PULSE;
|
||||
}
|
||||
|
||||
// apply the calibrations
|
||||
servo_pulse_min *= min_pulse_cal;
|
||||
servo_pulse_max *= max_pulse_cal;
|
||||
|
||||
// determine the pulse length
|
||||
servo_pulse_len = (uint32_t)mapConstrain(wpos,
|
||||
_position_min, _position_max,
|
||||
servo_pulse_min, servo_pulse_max );
|
||||
|
||||
_write_pwm(servo_pulse_len);
|
||||
}
|
||||
*/
|
||||
|
||||
void ServoAxis::set_location()
|
||||
{
|
||||
@@ -209,49 +141,52 @@ void ServoAxis::set_location()
|
||||
else {
|
||||
mpos = system_convert_axis_steps_to_mpos(sys_position, _axis); // get the axis machine position in mm
|
||||
if (_use_mpos) {
|
||||
servo_pos = mpos;
|
||||
|
||||
servo_pos = mpos;
|
||||
}
|
||||
else {
|
||||
offset = gc_state.coord_system[_axis]+gc_state.coord_offset[_axis]; // get the current axis work offset
|
||||
servo_pos = mpos - offset; // determine the current work position
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
// 1. Get the pulse ranges of the servos
|
||||
// 2. Invert if selected in the settings
|
||||
// 3. Get the calibration values from the settings
|
||||
// 4. Adjust the calibration offset direction of the cal based on the direction
|
||||
// 5. Apply the calibrarion
|
||||
|
||||
|
||||
servo_pulse_min = SERVO_MIN_PULSE;
|
||||
servo_pulse_max = SERVO_MAX_PULSE;
|
||||
|
||||
if (bit_istrue(settings.dir_invert_mask,bit(_axis))) { // this allows the user to change the direction via settings
|
||||
swap(servo_pulse_min, servo_pulse_max);
|
||||
}
|
||||
|
||||
// get the calibration values
|
||||
if (_cal_is_valid()) { // if calibration settings are OK then apply them
|
||||
|
||||
min_pulse_cal = (settings.steps_per_mm[_axis] / 100.0);
|
||||
max_pulse_cal = (settings.max_travel[_axis] / -100.0);
|
||||
if (bit_istrue(settings.dir_invert_mask,bit(_axis))) { // the offset needs to be backwards
|
||||
min_pulse_cal = 1.0 + (1.0 - min_pulse_cal);
|
||||
max_pulse_cal = 1.0 + (1.0 - max_pulse_cal);
|
||||
}
|
||||
|
||||
if (bit_istrue(settings.dir_invert_mask,bit(_axis))) {
|
||||
min_pulse_cal = 2.0 - min_pulse_cal;
|
||||
max_pulse_cal = 2.0 - max_pulse_cal;
|
||||
}
|
||||
}
|
||||
else { // settings are not valid so don't apply any calibration
|
||||
min_pulse_cal = 1.0;
|
||||
max_pulse_cal = 1.0;
|
||||
}
|
||||
|
||||
|
||||
if (bit_istrue(settings.dir_invert_mask,bit(_axis))) { // this allows the user to change the direction via settings
|
||||
servo_pulse_min = SERVO_MAX_PULSE;
|
||||
servo_pulse_max = SERVO_MIN_PULSE;
|
||||
}
|
||||
else {
|
||||
servo_pulse_min = SERVO_MIN_PULSE;
|
||||
servo_pulse_max = SERVO_MAX_PULSE;
|
||||
max_pulse_cal = 1.0;
|
||||
}
|
||||
|
||||
// apply the calibrations
|
||||
servo_pulse_min *= min_pulse_cal;
|
||||
servo_pulse_max *= max_pulse_cal;
|
||||
|
||||
// determine the pulse length
|
||||
servo_pulse_len = (uint32_t)mapConstrain(servo_pos,
|
||||
_position_min, _position_max,
|
||||
servo_pulse_min, servo_pulse_max );
|
||||
|
||||
_write_pwm(servo_pulse_len);
|
||||
// determine the pulse length
|
||||
servo_pulse_len = (uint32_t)mapConstrain(servo_pos, _position_min, _position_max, servo_pulse_min, servo_pulse_max );
|
||||
_write_pwm(servo_pulse_len);
|
||||
}
|
||||
|
||||
void ServoAxis::_write_pwm(uint32_t duty)
|
||||
@@ -289,7 +224,7 @@ bool ServoAxis::_cal_is_valid()
|
||||
settingsOK = false;
|
||||
}
|
||||
|
||||
showError = false; // to show error once
|
||||
//showError = false; // to show error once
|
||||
return settingsOK;
|
||||
}
|
||||
|
||||
|
Reference in New Issue
Block a user