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

Added $Axes setting.

This commit is contained in:
bdring
2020-12-14 22:55:30 -06:00
parent ce2837c15c
commit bee5af877f
8 changed files with 30 additions and 161 deletions

View File

@@ -1,119 +0,0 @@
#pragma once
// clang-format off
/*
6_pack_stepstick_XYZ_pc.h
Covers all V1 versions V1p0, V1p1, etc
Part of Grbl_ESP32
Pin assignments for the ESP32 I2S 6-axis board
2018 - Bart Dring
2020 - Mitch Bradley
2020 - Michiyasu Odaki
Grbl_ESP32 is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
Grbl is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with Grbl_ESP32. If not, see <http://www.gnu.org/licenses/>.
*/
#define MACHINE_NAME "6 Pack StepStick XYZ pins"
#define N_AXIS 3
// === Special Features
// I2S (steppers & other output-only pins)
#define USE_I2S_OUT
#define USE_I2S_STEPS
//#define DEFAULT_STEPPER ST_I2S_STATIC
// === Default settings
#define DEFAULT_STEP_PULSE_MICROSECONDS I2S_OUT_USEC_PER_PULSE
#define USE_STEPSTICK // makes sure MS1,2,3 !reset and !sleep are set
#define I2S_OUT_BCK "GPIO.22"
#define I2S_OUT_WS "GPIO.17"
#define I2S_OUT_DATA "GPIO.21"
// Motor Socket #1
#define X_DISABLE_PIN "i2so.0"
#define X_DIRECTION_PIN "i2so.1"
#define X_STEP_PIN "i2so.2"
#define X_STEPPER_MS3 "i2so.3"
// Motor Socket #2
#define Y_DIRECTION_PIN "i2so.4"
#define Y_STEP_PIN "i2so.5"
#define Y_STEPPER_MS3 "i2so.6"
#define Y_DISABLE_PIN "i2so.7"
// Motor Socket #3
#define Z_DISABLE_PIN "i2so.8"
#define Z_DIRECTION_PIN "i2so.9"
#define Z_STEP_PIN "i2so.10"
#define Z_STEPPER_MS3 "i2so.11"
/*
Socket I/O reference
The list of modules is here...
https://github.com/bdring/6-Pack_CNC_Controller/wiki/CNC-I-O-Module-List
Click on each module to get example for using the modules in the sockets
Socket #1
#1 GPIO_NUM_33
#2 GPIO_NUM_32
#3 GPIO_NUM_35 (input only)
#4 GPIO_NUM_34 (input only)
Socket #2
#1 GPIO_NUM_2
#2 GPIO_NUM_25
#3 GPIO_NUM_39 (input only)
#4 GPIO_NUM_36 (input only)
Socket #3
#1 GPIO_NUM_26
#2 GPIO_NUM_4
#3 GPIO_NUM_16
#4 GPIO_NUM_27
Socket #4
#1 GPIO_NUM_14
#2 GPIO_NUM_13
#3 GPIO_NUM_15
#4 GPIO_NUM_12
Socket #5
#1 I2SO(24) (output only)
#2 I2SO(25) (output only)
#3 I2SO26) (output only)
*/
// 4x Input Module in Socket #1
// https://github.com/bdring/6-Pack_CNC_Controller/wiki/4x-Switch-Input-module
// #define X_LIMIT_PIN GPIO_NUM_33
// #define Y_LIMIT_PIN GPIO_NUM_32
// #define Z_LIMIT_PIN GPIO_NUM_35
#define COOLANT_MIST_PIN "gpio.14"
#define COOLANT_FLOOD_PIN "gpio.13"
#define SPINDLE_OUTPUT_PIN "gpio.15"
#define SPINDLE_ENABLE_PIN "gpio.12"
#define SPINDLE_TYPE SpindleType::PWM
// ================= Setting Defaults ==========================
#define DEFAULT_X_STEPS_PER_MM 800
#define DEFAULT_Y_STEPS_PER_MM 800
#define DEFAULT_Z_STEPS_PER_MM 800

View File

@@ -120,6 +120,10 @@ Socket #5
// #define CONTROL_SAFETY_DOOR_PIN "gpio.27"
// ================= Setting Defaults ==========================
// https://github.com/bdring/Grbl_Esp32/wiki/Setting-Defaults
#define DEFAULT_X_STEPS_PER_MM 800
#define DEFAULT_Y_STEPS_PER_MM 800
#define DEFAULT_Z_STEPS_PER_MM 800
#define DEFAULT_HOMING_DIR_MASK bit(X_AXIS)

View File

@@ -331,7 +331,7 @@ void mc_homing_cycle(uint8_t cycle_mask) {
else
#endif
{
for (int cycle = 0; cycle < MAX_N_AXIS; cycle++) {
for (int cycle = 0; cycle < number_axis->get(); cycle++) {
auto homing_mask = homing_cycle[cycle]->get();
if (homing_mask) { // if there are some axes in this cycle
no_cycles_defined = false;

View File

@@ -64,11 +64,11 @@ const int DELAY_MODE_SYS_SUSPEND = 1;
// Useful macros
#define clear_vector(a) memset(a, 0, sizeof(a))
#define clear_vector_float(a) memset(a, 0.0, sizeof(float) * MAX_N_AXIS)
// #define clear_vector_long(a) memset(a, 0.0, sizeof(long)*MAX_N_AXIS)
#define clear_vector_float(a) memset(a, 0.0, sizeof(float) * number_axis->get())
// #define clear_vector_long(a) memset(a, 0.0, sizeof(long) * number_axis->get())
#define MAX(a, b) (((a) > (b)) ? (a) : (b)) // changed to upper case to remove conflicts with other libraries
#define MIN(a, b) (((a) < (b)) ? (a) : (b)) // changed to upper case to remove conflicts with other libraries
#define isequal_position_vector(a, b) !(memcmp(a, b, sizeof(float) * MAX_N_AXIS))
#define isequal_position_vector(a, b) !(memcmp(a, b, sizeof(float) * number_axis->get()))
// Bit field and masking macros
// bit(n) is defined in Arduino.h. We redefine it here so we can apply

View File

@@ -174,7 +174,6 @@ void grbl_notifyf(const char* title, const char* format, ...) {
}
static const int coordStringLen = 20;
static const int axesStringLen = coordStringLen * MAX_N_AXIS;
// formats axis values into a string and returns that string in rpt
// NOTE: rpt should have at least size: axesStringLen
@@ -210,6 +209,7 @@ static String report_util_axis_values(const float* axis_value) {
decimals = 4; // Report inches to 4 decimal places
}
auto n_axis = number_axis->get();
grbl_msg_sendf(CLIENT_SERIAL, MsgLevel::Info, "N axes %d", n_axis);
for (idx = 0; idx < n_axis; idx++) {
rpt += String(axis_value[idx] * unit_conv, decimals);
if (idx < (number_axis->get() - 1)) {
@@ -319,6 +319,8 @@ void report_grbl_help(uint8_t client) {
// These values are retained until Grbl is power-cycled, whereby they will be re-zeroed.
void report_probe_parameters(uint8_t client) {
// Report in terms of machine position.
int axesStringLen = coordStringLen * number_axis->get();
float print_position[MAX_N_AXIS];
char probe_rpt[(axesStringLen + 13 + 6 + 1)]; // the probe report we are building here
char temp[axesStringLen];

View File

@@ -234,7 +234,7 @@ const char* AxisMaskSetting::getCompatibleValue() {
static char* maskToString(uint32_t mask, char* strval) {
char* s = strval;
for (int i = 0; i < MAX_N_AXIS; i++) {
for (int i = 0; i < number_axis->get(); i++) {
if (mask & bit(i)) {
*s++ = "XYZABC"[i];
}
@@ -255,7 +255,7 @@ const char* AxisMaskSetting::getStringValue() {
void AxisMaskSetting::addWebui(WebUI::JSONencoder* j) {
if (getDescription()) {
j->begin_webui(getName(), getDescription(), "I", getStringValue(), 0, (1 << MAX_N_AXIS) - 1);
j->begin_webui(getName(), getDescription(), "I", getStringValue(), 0, (1 << number_axis->get()) - 1);
j->end_object();
}
}

View File

@@ -4,7 +4,7 @@ bool motorSettingChanged = false;
FlagSetting* verbose_errors;
FakeSetting<int>* number_axis;
IntSetting* number_axis;
StringSetting* startup_line_0;
StringSetting* startup_line_1;
@@ -65,13 +65,6 @@ enum_opt_t spindleTypes = {
// clang-format on
};
AxisSettings* x_axis_settings;
AxisSettings* y_axis_settings;
AxisSettings* z_axis_settings;
AxisSettings* a_axis_settings;
AxisSettings* b_axis_settings;
AxisSettings* c_axis_settings;
AxisSettings* axis_settings[MAX_N_AXIS];
typedef struct {
@@ -224,6 +217,9 @@ extern void make_pin_settings();
void make_settings() {
Setting::init();
number_axis = new IntSetting(EXTENDED, WG, NULL, "Axes", N_AXIS, 3, 6, NULL, false);
number_axis->load();
// Propagate old coordinate system data to the new format if necessary.
// G54 - G59 work coordinate systems, G28, G30 reference positions, etc
make_coordinate(CoordIndex::G54, "G54");
@@ -237,79 +233,71 @@ void make_settings() {
verbose_errors = new FlagSetting(EXTENDED, WG, NULL, "Errors/Verbose", DEFAULT_VERBOSE_ERRORS);
// number_axis = new IntSetting(EXTENDED, WG, NULL, "NumberAxis", N_AXIS, 0, 6, NULL, true);
number_axis = new FakeSetting<int>(N_AXIS);
// Create the axis settings in the order that people are
// accustomed to seeing.
int axis;
axis_defaults_t* def;
for (axis = 0; axis < MAX_N_AXIS; axis++) {
for (axis = 0; axis < number_axis->get(); axis++) {
def = &axis_defaults[axis];
axis_settings[axis] = new AxisSettings(def->name);
}
x_axis_settings = axis_settings[X_AXIS];
y_axis_settings = axis_settings[Y_AXIS];
z_axis_settings = axis_settings[Z_AXIS];
a_axis_settings = axis_settings[A_AXIS];
b_axis_settings = axis_settings[B_AXIS];
c_axis_settings = axis_settings[C_AXIS];
for (axis = MAX_N_AXIS - 1; axis >= 0; axis--) {
for (axis = 0; axis < number_axis->get(); axis++) {
def = &axis_defaults[axis];
auto setting = new IntSetting(
EXTENDED, WG, makeGrblName(axis, 170), makename(def->name, "StallGuard"), def->stallguard, -64, 63, checkStallguard);
setting->setAxis(axis);
axis_settings[axis]->stallguard = setting;
}
for (axis = MAX_N_AXIS - 1; axis >= 0; axis--) {
for (axis = 0; axis < number_axis->get(); axis++) {
def = &axis_defaults[axis];
auto setting = new IntSetting(
EXTENDED, WG, makeGrblName(axis, 160), makename(def->name, "Microsteps"), def->microsteps, 0, 256, checkMicrosteps);
setting->setAxis(axis);
axis_settings[axis]->microsteps = setting;
}
for (axis = MAX_N_AXIS - 1; axis >= 0; axis--) {
for (axis = 0; axis < number_axis->get(); axis++) {
def = &axis_defaults[axis];
auto setting = new FloatSetting(
EXTENDED, WG, makeGrblName(axis, 150), makename(def->name, "Current/Hold"), def->hold_current, 0.05, 20.0, checkHoldcurrent); // Amps
setting->setAxis(axis);
axis_settings[axis]->hold_current = setting;
}
for (axis = MAX_N_AXIS - 1; axis >= 0; axis--) {
for (axis = 0; axis < number_axis->get(); axis++) {
def = &axis_defaults[axis];
auto setting = new FloatSetting(
EXTENDED, WG, makeGrblName(axis, 140), makename(def->name, "Current/Run"), def->run_current, 0.0, 20.0, checkRunCurrent); // Amps
setting->setAxis(axis);
axis_settings[axis]->run_current = setting;
}
for (axis = MAX_N_AXIS - 1; axis >= 0; axis--) {
for (axis = 0; axis < number_axis->get(); axis++) {
def = &axis_defaults[axis];
auto setting = new FloatSetting(GRBL, WG, makeGrblName(axis, 130), makename(def->name, "MaxTravel"), def->max_travel, 1.0, 100000.0);
setting->setAxis(axis);
axis_settings[axis]->max_travel = setting;
}
for (axis = MAX_N_AXIS - 1; axis >= 0; axis--) {
for (axis = 0; axis < number_axis->get(); axis++) {
def = &axis_defaults[axis];
auto setting = new FloatSetting(EXTENDED, WG, NULL, makename(def->name, "Home/Mpos"), def->home_mpos, -100000.0, 100000.0);
setting->setAxis(axis);
axis_settings[axis]->home_mpos = setting;
}
for (axis = MAX_N_AXIS - 1; axis >= 0; axis--) {
for (axis = 0; axis < number_axis->get(); axis++) {
def = &axis_defaults[axis];
auto setting =
new FloatSetting(GRBL, WG, makeGrblName(axis, 120), makename(def->name, "Acceleration"), def->acceleration, 1.0, 100000.0);
setting->setAxis(axis);
axis_settings[axis]->acceleration = setting;
}
for (axis = MAX_N_AXIS - 1; axis >= 0; axis--) {
for (axis = 0; axis < number_axis->get(); axis++) {
def = &axis_defaults[axis];
auto setting = new FloatSetting(GRBL, WG, makeGrblName(axis, 110), makename(def->name, "MaxRate"), def->max_rate, 1.0, 100000.0);
setting->setAxis(axis);
axis_settings[axis]->max_rate = setting;
}
for (axis = MAX_N_AXIS - 1; axis >= 0; axis--) {
for (axis = 0; axis < number_axis->get(); axis++) {
def = &axis_defaults[axis];
auto setting =
new FloatSetting(GRBL, WG, makeGrblName(axis, 100), makename(def->name, "StepsPerMm"), def->steps_per_mm, 1.0, 100000.0);
@@ -323,7 +311,7 @@ void make_settings() {
spindle_pwm_off_value =
new FloatSetting(EXTENDED, WG, "34", "Spindle/PWM/Off", DEFAULT_SPINDLE_OFF_VALUE, 0.0, 100.0); // these are percentages
// IntSetting spindle_pwm_bit_precision(EXTENDED, WG, "Spindle/PWM/Precision", DEFAULT_SPINDLE_BIT_PRECISION, 1, 16);
spindle_pwm_freq = new FloatSetting(EXTENDED, WG, "33", "Spindle/PWM/Frequency", DEFAULT_SPINDLE_FREQ, 0, 100000);
spindle_pwm_freq = new FloatSetting(EXTENDED, WG, "33", "Spindle/PWM/Frequency", DEFAULT_SPINDLE_FREQ, 0, 100000);
spindle_delay_spinup = new FloatSetting(EXTENDED, WG, NULL, "Spindle/Delay/SpinUp", DEFAULT_SPINDLE_DELAY_SPINUP, 0, 30);
spindle_delay_spindown = new FloatSetting(EXTENDED, WG, NULL, "Spindle/Delay/SpinDown", DEFAULT_SPINDLE_DELAY_SPINUP, 0, 30);

View File

@@ -4,14 +4,8 @@ extern bool motorSettingChanged;
extern FlagSetting* verbose_errors;
extern FakeSetting<int>* number_axis;
extern IntSetting* number_axis;
extern AxisSettings* x_axis_settings;
extern AxisSettings* y_axis_settings;
extern AxisSettings* z_axis_settings;
extern AxisSettings* a_axis_settings;
extern AxisSettings* b_axis_settings;
extern AxisSettings* c_axis_settings;
extern AxisSettings* axis_settings[];
extern StringSetting* startup_line_0;