diff --git a/Grbl_Esp32/src/MachineCommon.h b/Grbl_Esp32/src/MachineCommon.h index eea0c7dd..627da376 100644 --- a/Grbl_Esp32/src/MachineCommon.h +++ b/Grbl_Esp32/src/MachineCommon.h @@ -1,9 +1,5 @@ #pragma once -#ifndef SPINDLE_TYPE -# define SPINDLE_TYPE SpindleType::PWM -#endif - // Grbl setting that are common to all machines // It should not be necessary to change anything herein diff --git a/Grbl_Esp32/src/Motors/Dynamixel2.cpp b/Grbl_Esp32/src/Motors/Dynamixel2.cpp index fb0314f4..253859d3 100644 --- a/Grbl_Esp32/src/Motors/Dynamixel2.cpp +++ b/Grbl_Esp32/src/Motors/Dynamixel2.cpp @@ -77,7 +77,7 @@ namespace Motors { void Dynamixel2::config_message() { grbl_msg_sendf(CLIENT_SERIAL, 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, _id, _dxl_count_min, @@ -123,16 +123,7 @@ namespace Motors { } void Dynamixel2::read_settings() { - float travel = axis_settings[_axis_index]->max_travel->get(); - 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; - } + read_limits(); _dxl_count_min = DXL_COUNT_MIN; _dxl_count_max = DXL_COUNT_MAX; diff --git a/Grbl_Esp32/src/Motors/Motor.cpp b/Grbl_Esp32/src/Motors/Motor.cpp index 5c431437..90467abf 100644 --- a/Grbl_Esp32/src/Motors/Motor.cpp +++ b/Grbl_Esp32/src/Motors/Motor.cpp @@ -41,7 +41,7 @@ namespace Motors { void Motor::config_message() {} void Motor::debug_message() {} - void Motor::read_settings() { + void Motor::read_limits() { float max_travel = axis_settings[_axis_index]->max_travel->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_direction_pins(uint8_t onMask) {} void Motor::step(uint8_t step_mask, uint8_t dir_mask) {} diff --git a/Grbl_Esp32/src/Motors/Motor.h b/Grbl_Esp32/src/Motors/Motor.h index a32dccab..be13448f 100644 --- a/Grbl_Esp32/src/Motors/Motor.h +++ b/Grbl_Esp32/src/Motors/Motor.h @@ -42,6 +42,7 @@ namespace Motors { virtual void config_message(); virtual void debug_message(); virtual void read_settings(); + virtual void read_limits(); virtual void set_homing_mode(uint8_t homing_mask, bool isHoming); virtual void set_disable(bool disable); virtual void set_direction_pins(uint8_t onMask); diff --git a/Grbl_Esp32/src/Motors/RcServo.cpp b/Grbl_Esp32/src/Motors/RcServo.cpp index eabcf27b..5989a222 100644 --- a/Grbl_Esp32/src/Motors/RcServo.cpp +++ b/Grbl_Esp32/src/Motors/RcServo.cpp @@ -124,17 +124,7 @@ namespace Motors { } void RcServo::read_settings() { - float travel = axis_settings[_axis_index]->max_travel->get(); - 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; - } + read_limits(); _pwm_pulse_min = SERVO_MIN_PULSE * _cal_min; _pwm_pulse_max = SERVO_MAX_PULSE * _cal_max; diff --git a/Grbl_Esp32/src/Motors/Solenoid.h b/Grbl_Esp32/src/Motors/Solenoid.h deleted file mode 100644 index fb973083..00000000 --- a/Grbl_Esp32/src/Motors/Solenoid.h +++ /dev/null @@ -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; - }; -} diff --git a/Grbl_Esp32/src/Motors/TrinamicDriver.cpp b/Grbl_Esp32/src/Motors/TrinamicDriver.cpp index f785862c..82eb449c 100644 --- a/Grbl_Esp32/src/Motors/TrinamicDriver.cpp +++ b/Grbl_Esp32/src/Motors/TrinamicDriver.cpp @@ -66,9 +66,10 @@ namespace Motors { tmcstepper->setSPISpeed(TRINAMIC_SPI_FREQ); } + read_settings(); // pull info from settings 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() { @@ -79,8 +80,8 @@ namespace Motors { SPI.begin(); // this will get called for each motor, but does not seem to hurt anything tmcstepper->begin(); - test(); // Try communicating with motor. Prints an error if there is a problem. - read_settings(); // pull info from settings + test(); // Try communicating with motor. Prints an error if there is a problem. + set_mode(false); _homing_mask = 0; @@ -163,6 +164,8 @@ namespace Motors { if (has_errors) return; + read_limits(); + uint16_t run_i_ma = (uint16_t)(axis_settings[_axis_index]->run_current->get() * 1000.0); float hold_i_percent; @@ -211,7 +214,7 @@ namespace Motors { tmcstepper->pwm_autoscale(true); tmcstepper->diag1_stall(false); break; - case TrinamicMode :: CoolStep: + case TrinamicMode ::CoolStep: //grbl_msg_sendf(CLIENT_SERIAL, MsgLevel::Info, "Coolstep"); tmcstepper->en_pwm_mode(false); tmcstepper->pwm_autoscale(false);