1
0
mirror of https://github.com/bdring/Grbl_Esp32.git synced 2025-09-02 10:53:01 +02:00

Cleaned up calculation of limits

This commit is contained in:
bdring
2020-10-12 12:49:04 -05:00
parent d9dba2c908
commit 0f1c3a3c1d
7 changed files with 13 additions and 49 deletions

View File

@@ -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

View File

@@ -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;

View File

@@ -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) {}

View File

@@ -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);

View File

@@ -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;

View File

@@ -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;
};
}

View File

@@ -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);