mirror of
https://github.com/bdring/Grbl_Esp32.git
synced 2025-09-03 03:13:25 +02:00
Cleaned up calculation of limits
This commit is contained in:
@@ -1,9 +1,5 @@
|
|||||||
#pragma once
|
#pragma once
|
||||||
|
|
||||||
#ifndef SPINDLE_TYPE
|
|
||||||
# define SPINDLE_TYPE SpindleType::PWM
|
|
||||||
#endif
|
|
||||||
|
|
||||||
// Grbl setting that are common to all machines
|
// Grbl setting that are common to all machines
|
||||||
// It should not be necessary to change anything herein
|
// It should not be necessary to change anything herein
|
||||||
|
|
||||||
|
@@ -77,7 +77,7 @@ namespace Motors {
|
|||||||
void Dynamixel2::config_message() {
|
void Dynamixel2::config_message() {
|
||||||
grbl_msg_sendf(CLIENT_SERIAL,
|
grbl_msg_sendf(CLIENT_SERIAL,
|
||||||
MsgLevel::Info,
|
MsgLevel::Info,
|
||||||
"%s Axis Dynamixel Servo ID:%d Count(%5.0f,%5.0f) Limits(%0.3fmm,%5.3f)",
|
"%s Axis Dynamixel Servo ID:%d Count(%5.0f,%5.0f) Limits(%0.3f,%5.3f)",
|
||||||
_axis_name,
|
_axis_name,
|
||||||
_id,
|
_id,
|
||||||
_dxl_count_min,
|
_dxl_count_min,
|
||||||
@@ -123,16 +123,7 @@ namespace Motors {
|
|||||||
}
|
}
|
||||||
|
|
||||||
void Dynamixel2::read_settings() {
|
void Dynamixel2::read_settings() {
|
||||||
float travel = axis_settings[_axis_index]->max_travel->get();
|
read_limits();
|
||||||
float mpos = axis_settings[_axis_index]->home_mpos->get();
|
|
||||||
|
|
||||||
if (bit_istrue(homing_dir_mask->get(), bit(_axis_index))) {
|
|
||||||
_position_min = mpos;
|
|
||||||
_position_max = mpos + travel;
|
|
||||||
} else {
|
|
||||||
_position_min = mpos - travel;
|
|
||||||
_position_max = mpos;
|
|
||||||
}
|
|
||||||
|
|
||||||
_dxl_count_min = DXL_COUNT_MIN;
|
_dxl_count_min = DXL_COUNT_MIN;
|
||||||
_dxl_count_max = DXL_COUNT_MAX;
|
_dxl_count_max = DXL_COUNT_MAX;
|
||||||
|
@@ -41,7 +41,7 @@ namespace Motors {
|
|||||||
void Motor::config_message() {}
|
void Motor::config_message() {}
|
||||||
void Motor::debug_message() {}
|
void Motor::debug_message() {}
|
||||||
|
|
||||||
void Motor::read_settings() {
|
void Motor::read_limits() {
|
||||||
float max_travel = axis_settings[_axis_index]->max_travel->get();
|
float max_travel = axis_settings[_axis_index]->max_travel->get();
|
||||||
float mpos = axis_settings[_axis_index]->home_mpos->get();
|
float mpos = axis_settings[_axis_index]->home_mpos->get();
|
||||||
|
|
||||||
@@ -54,6 +54,7 @@ namespace Motors {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void Motor::read_settings() { read_limits(); }
|
||||||
void Motor::set_disable(bool disable) {}
|
void Motor::set_disable(bool disable) {}
|
||||||
void Motor::set_direction_pins(uint8_t onMask) {}
|
void Motor::set_direction_pins(uint8_t onMask) {}
|
||||||
void Motor::step(uint8_t step_mask, uint8_t dir_mask) {}
|
void Motor::step(uint8_t step_mask, uint8_t dir_mask) {}
|
||||||
|
@@ -42,6 +42,7 @@ namespace Motors {
|
|||||||
virtual void config_message();
|
virtual void config_message();
|
||||||
virtual void debug_message();
|
virtual void debug_message();
|
||||||
virtual void read_settings();
|
virtual void read_settings();
|
||||||
|
virtual void read_limits();
|
||||||
virtual void set_homing_mode(uint8_t homing_mask, bool isHoming);
|
virtual void set_homing_mode(uint8_t homing_mask, bool isHoming);
|
||||||
virtual void set_disable(bool disable);
|
virtual void set_disable(bool disable);
|
||||||
virtual void set_direction_pins(uint8_t onMask);
|
virtual void set_direction_pins(uint8_t onMask);
|
||||||
|
@@ -124,17 +124,7 @@ namespace Motors {
|
|||||||
}
|
}
|
||||||
|
|
||||||
void RcServo::read_settings() {
|
void RcServo::read_settings() {
|
||||||
float travel = axis_settings[_axis_index]->max_travel->get();
|
read_limits();
|
||||||
float mpos = axis_settings[_axis_index]->home_mpos->get();
|
|
||||||
//float max_mpos, min_mpos;
|
|
||||||
|
|
||||||
if (bit_istrue(homing_dir_mask->get(), bit(_axis_index))) {
|
|
||||||
_position_min = mpos;
|
|
||||||
_position_max = mpos + travel;
|
|
||||||
} else {
|
|
||||||
_position_min = mpos - travel;
|
|
||||||
_position_max = mpos;
|
|
||||||
}
|
|
||||||
|
|
||||||
_pwm_pulse_min = SERVO_MIN_PULSE * _cal_min;
|
_pwm_pulse_min = SERVO_MIN_PULSE * _cal_min;
|
||||||
_pwm_pulse_max = SERVO_MAX_PULSE * _cal_max;
|
_pwm_pulse_max = SERVO_MAX_PULSE * _cal_max;
|
||||||
|
@@ -1,18 +0,0 @@
|
|||||||
#pragma once
|
|
||||||
|
|
||||||
#include "RcServo.h"
|
|
||||||
|
|
||||||
namespace Motors {
|
|
||||||
class Solenoid : public RcServo {
|
|
||||||
public:
|
|
||||||
Solenoid();
|
|
||||||
Solenoid(uint8_t axis_index, gpio_num_t pwm_pin, float transition_poiont);
|
|
||||||
void config_message();
|
|
||||||
void set_location();
|
|
||||||
void update();
|
|
||||||
void init();
|
|
||||||
void set_disable(bool disable);
|
|
||||||
|
|
||||||
float _transition_poiont;
|
|
||||||
};
|
|
||||||
}
|
|
@@ -66,9 +66,10 @@ namespace Motors {
|
|||||||
tmcstepper->setSPISpeed(TRINAMIC_SPI_FREQ);
|
tmcstepper->setSPISpeed(TRINAMIC_SPI_FREQ);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
read_settings(); // pull info from settings
|
||||||
config_message();
|
config_message();
|
||||||
|
|
||||||
// init() must be called later, after all TMC drivers have CS pins setup.
|
// init() must be called by Motors.cpp after all TMC drivers have CS pins setup.
|
||||||
}
|
}
|
||||||
|
|
||||||
void TrinamicDriver::init() {
|
void TrinamicDriver::init() {
|
||||||
@@ -79,8 +80,8 @@ namespace Motors {
|
|||||||
SPI.begin(); // this will get called for each motor, but does not seem to hurt anything
|
SPI.begin(); // this will get called for each motor, but does not seem to hurt anything
|
||||||
|
|
||||||
tmcstepper->begin();
|
tmcstepper->begin();
|
||||||
test(); // Try communicating with motor. Prints an error if there is a problem.
|
test(); // Try communicating with motor. Prints an error if there is a problem.
|
||||||
read_settings(); // pull info from settings
|
|
||||||
set_mode(false);
|
set_mode(false);
|
||||||
|
|
||||||
_homing_mask = 0;
|
_homing_mask = 0;
|
||||||
@@ -163,6 +164,8 @@ namespace Motors {
|
|||||||
if (has_errors)
|
if (has_errors)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
|
read_limits();
|
||||||
|
|
||||||
uint16_t run_i_ma = (uint16_t)(axis_settings[_axis_index]->run_current->get() * 1000.0);
|
uint16_t run_i_ma = (uint16_t)(axis_settings[_axis_index]->run_current->get() * 1000.0);
|
||||||
float hold_i_percent;
|
float hold_i_percent;
|
||||||
|
|
||||||
@@ -211,7 +214,7 @@ namespace Motors {
|
|||||||
tmcstepper->pwm_autoscale(true);
|
tmcstepper->pwm_autoscale(true);
|
||||||
tmcstepper->diag1_stall(false);
|
tmcstepper->diag1_stall(false);
|
||||||
break;
|
break;
|
||||||
case TrinamicMode :: CoolStep:
|
case TrinamicMode ::CoolStep:
|
||||||
//grbl_msg_sendf(CLIENT_SERIAL, MsgLevel::Info, "Coolstep");
|
//grbl_msg_sendf(CLIENT_SERIAL, MsgLevel::Info, "Coolstep");
|
||||||
tmcstepper->en_pwm_mode(false);
|
tmcstepper->en_pwm_mode(false);
|
||||||
tmcstepper->pwm_autoscale(false);
|
tmcstepper->pwm_autoscale(false);
|
||||||
|
Reference in New Issue
Block a user