diff --git a/Grbl_Esp32/src/Defaults.h b/Grbl_Esp32/src/Defaults.h index 4594002e..628efa5d 100644 --- a/Grbl_Esp32/src/Defaults.h +++ b/Grbl_Esp32/src/Defaults.h @@ -316,6 +316,30 @@ # define DEFAULT_C_HOMING_MPOS 0.0 #endif +#ifndef DEFAULT_HOMING_CYCLE_0 +# define DEFAULT_HOMING_CYCLE_0 bit(Z_AXIS) +#endif + +#ifndef DEFAULT_HOMING_CYCLE_1 +# define DEFAULT_HOMING_CYCLE_1 (bit(X_AXIS) | bit(Y_AXIS)) +#endif + +#ifndef DEFAULT_HOMING_CYCLE_2 +# define DEFAULT_HOMING_CYCLE_2 0 +#endif + +#ifndef DEFAULT_HOMING_CYCLE_3 +# define DEFAULT_HOMING_CYCLE_3 0 +#endif + +#ifndef DEFAULT_HOMING_CYCLE_4 +# define DEFAULT_HOMING_CYCLE_4 0 +#endif + +#ifndef DEFAULT_HOMING_CYCLE_5 +# define DEFAULT_HOMING_CYCLE_5 0 +#endif + // ========== Motor current (SPI Drivers ) ============= #ifndef DEFAULT_X_CURRENT # define DEFAULT_X_CURRENT 0.25 // $140 current in amps (extended set) diff --git a/Grbl_Esp32/src/Machine.h b/Grbl_Esp32/src/Machine.h index 145b3351..d3de7aad 100644 --- a/Grbl_Esp32/src/Machine.h +++ b/Grbl_Esp32/src/Machine.h @@ -8,7 +8,7 @@ // !!! For initial testing, start with test_drive.h which disables // all I/O pins // #include "Machines/atari_1020.h" -# include "Machines/tapster_pro_stepstick.h" +# include "Machines/tapster_pro_6P_trinamic.h" // !!! For actual use, change the line above to select a board // from Machines/, for example: diff --git a/Grbl_Esp32/src/Machines/tapster_pro.h b/Grbl_Esp32/src/Machines/tapster_pro.h index 5dbd08cd..b0897df5 100644 --- a/Grbl_Esp32/src/Machines/tapster_pro.h +++ b/Grbl_Esp32/src/Machines/tapster_pro.h @@ -94,6 +94,13 @@ #define Y_LIMIT_PIN GPIO_NUM_39 #define Z_LIMIT_PIN GPIO_NUM_34 +// Example (4x) 5V Buffer Output on socket #5 +// https://github.com/bdring/6-Pack_CNC_Controller/wiki/4x-5V-Buffered-Output-Module +#define COOLANT_MIST_PIN I2SO(24) // No PWM +#define COOLANT_FLOOD_PIN I2SO(25) +#define USER_DIGITAL_PIN_0 I2SO(26) +#define USER_DIGITAL_PIN_1 I2SO(27) + // ================= defaults =========================== #define DEFAULT_STEPPER_IDLE_LOCK_TIME 255 // keep them on, the trinamics will reduce power at idle diff --git a/Grbl_Esp32/src/Machines/tapster_pro_6P_trinamic.h b/Grbl_Esp32/src/Machines/tapster_pro_6P_trinamic.h new file mode 100644 index 00000000..32700d0b --- /dev/null +++ b/Grbl_Esp32/src/Machines/tapster_pro_6P_trinamic.h @@ -0,0 +1,174 @@ +#pragma once +// clang-format off + +/* + tapster_pro_stepstick.h + + 2020 - Bart Dring, Jason Huggins (Tapster Robotics) + + 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 . +*/ + +#define MACHINE_NAME "Tapster Pro Delta 6P Trinamic" + +#define CUSTOM_CODE_FILENAME "Custom/parallel_delta.cpp" +/* +// enable these special machine functions to be called from the main program +#define USE_KINEMATICS // there are kinematic equations for this machine +#define FWD_KINEMATICS_REPORTING // report in cartesian +#define USE_RMT_STEPS // Use the RMT periferal to generate step pulses +#define USE_TRINAMIC // some Trinamic motors are used on this machine +#define USE_MACHINE_TRINAMIC_INIT // there is a machine specific setup for the drivers +#define USE_MACHINE_INIT // There is some custom initialization for this machine + +#define SEGMENT_LENGTH 0.5 // segment length in mm +#define KIN_ANGLE_CALC_OK 0 +#define KIN_ANGLE_ERROR -1 + +#define MAX_NEGATIVE_ANGLE -36 // in degrees how far can the arms go up? + +#define HOMING_CURRENT_REDUCTION 1.0 + +*/ + +#define N_AXIS 3 + +#define USE_KINEMATICS // there are kinematic equations for this machine +#define USE_FWD_KINEMATICS // report in cartesian +#define USE_MACHINE_INIT // There is some custom initialization for this machine + +// ================== Delta Geometry =========================== + +#define RADIUS_FIXED 100.0f // radius of the fixed side (length of motor cranks) +#define RADIUS_EFF 220.0f // radius of end effector side (length of linkages) +#define LENGTH_FIXED_SIDE 294.449f // sized of fixed side triangel +#define LENGTH_EFF_SIDE 86.6025f // size of end effector side triangle +#define KINEMATIC_SEGMENT_LENGTH 1.0f // segment length in mm +#define MAX_NEGATIVE_ANGLE -0.75f // +#define MAX_POSITIVE_ANGLE (M_PI / 2.0) // + + +// ================== Config ====================== + +// Set $Homing/Cycle0=XYZ + + + +// 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_NUM_22 +#define I2S_OUT_WS GPIO_NUM_17 +#define I2S_OUT_DATA GPIO_NUM_21 + +// ================== CPU MAP ====================== + +#define X_STEPPER_MS3 I2SO(3) // X_CS +#define Y_STEPPER_MS3 I2SO(6) // Y_CS +#define Z_STEPPER_MS3 I2SO(11) // Z_CS + +#define STEPPER_RESET GPIO_NUM_19 + +// Motor Socket #1 +#define X_TRINAMIC_DRIVER 2130 +#define X_DISABLE_PIN I2SO(0) +#define X_DIRECTION_PIN I2SO(1) +#define X_STEP_PIN I2SO(2) +#define X_CS_PIN I2SO(3) +#define X_RSENSE TMC2130_RSENSE_DEFAULT + +// Motor Socket #2 +#define Y_TRINAMIC_DRIVER X_TRINAMIC_DRIVER +#define Y_DIRECTION_PIN I2SO(4) +#define Y_STEP_PIN I2SO(5) +#define Y_DISABLE_PIN I2SO(7) +#define Y_CS_PIN I2SO(6) +#define Y_RSENSE X_RSENSE + +// Motor Socket #3 +#define Z_TRINAMIC_DRIVER X_TRINAMIC_DRIVER +#define Z_DISABLE_PIN I2SO(8) +#define Z_DIRECTION_PIN I2SO(9) +#define Z_STEP_PIN I2SO(10) +#define Z_CS_PIN I2SO(11) +#define Z_RSENSE X_RSENSE + +// 4x Switch input module on CNC I/O module 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 + +//Example Quad MOSFET module on socket #5 +// https://github.com/bdring/6-Pack_CNC_Controller/wiki/Quad-MOSFET-Module +#define USER_DIGITAL_PIN_0 I2SO(24) +#define USER_DIGITAL_PIN_1 I2SO(25) +#define USER_DIGITAL_PIN_2 I2SO(26) +#define USER_DIGITAL_PIN_3 I2SO(27) + +// ================= defaults =========================== + +#define DEFAULT_STEPPER_IDLE_LOCK_TIME 255 // keep them on, the trinamics will reduce power at idle + + +#define DEFAULT_X_MICROSTEPS 8 +#define DEFAULT_Y_MICROSTEPS DEFAULT_X_MICROSTEPS +#define DEFAULT_Z_MICROSTEPS DEFAULT_X_MICROSTEPS + +// some math to figure out microsteps per unit // units could bedegrees or radians +#define UNITS_PER_REV (2.0 * M_PI) // 360.0 degrees or 6.2831853 radians +#define STEPS_PER_REV 400.0 +#define REDUCTION_RATIO (60.0 / 16.0) // the pulleys on arm and motor +#define MICROSTEPS_PER_REV (STEPS_PER_REV * (float)DEFAULT_X_MICROSTEPS * REDUCTION_RATIO) + +#define DEFAULT_X_STEPS_PER_MM (MICROSTEPS_PER_REV / UNITS_PER_REV) +#define DEFAULT_Y_STEPS_PER_MM DEFAULT_X_STEPS_PER_MM +#define DEFAULT_Z_STEPS_PER_MM DEFAULT_X_STEPS_PER_MM + +#define DEFAULT_X_MAX_RATE 100.0 // mm/min +#define DEFAULT_Y_MAX_RATE DEFAULT_X_MAX_RATE +#define DEFAULT_Z_MAX_RATE DEFAULT_X_MAX_RATE + +#define DEFAULT_X_ACCELERATION 20.0 +#define DEFAULT_Y_ACCELERATION DEFAULT_X_ACCELERATION +#define DEFAULT_Z_ACCELERATION DEFAULT_X_ACCELERATION + +// homing +#define DEFAULT_HOMING_FEED_RATE 25 +#define DEFAULT_HOMING_SEEK_RATE 100 +#define DEFAULT_HOMING_DIR_MASK (bit(X_AXIS) | bit(Y_AXIS) | bit(Z_AXIS)) // all axes home negative +#define DEFAULT_HOMING_ENABLE 1 +#define DEFAULT_INVERT_LIMIT_PINS 0 +#define DEFAULT_HOMING_CYCLE_0 #define DEFAULT_HOMING_CYCLE_0 (bit(X_AXIS) | bit(Y_AXIS) | bit(Y_AXIS)) +#define DEFAULT_HOMING_CYCLE_1 0 // override this one in defaults.h + +// The machine homes up and above center. MPos is the axis angle in radians +// at the homing posiiton + +#define DEFAULT_X_HOMING_MPOS -0.75 // neagtive because above horizontal +#define DEFAULT_Y_HOMING_MPOS -0.75 +#define DEFAULT_Z_HOMING_MPOS -0.75 + +// the total travel is straight down from horizontal (pi/2) + the up travel +#define DEFAULT_X_MAX_TRAVEL ((M_PI / 2.0) - DEFAULT_X_HOMING_MPOS) +#define DEFAULT_Y_MAX_TRAVEL DEFAULT_X_MAX_TRAVEL +#define DEFAULT_Z_MAX_TRAVEL DEFAULT_X_MAX_TRAVEL + +#define DEFAULT_HOMING_PULLOFF -DEFAULT_X_HOMING_MPOS + +#define SPINDLE_TYPE SpindleType::NONE \ No newline at end of file diff --git a/Grbl_Esp32/src/Machines/tapster_pro_stepstick.h b/Grbl_Esp32/src/Machines/tapster_pro_stepstick.h index 8bb8d3b6..366157c5 100644 --- a/Grbl_Esp32/src/Machines/tapster_pro_stepstick.h +++ b/Grbl_Esp32/src/Machines/tapster_pro_stepstick.h @@ -2,7 +2,7 @@ // clang-format off /* - tapster_pro.h + tapster_pro_stepstick.h 2020 - Bart Dring, Jason Huggins (Tapster Robotics) @@ -99,9 +99,11 @@ #define Z_DIRECTION_PIN I2SO(9) #define Z_STEP_PIN I2SO(10) -#define X_LIMIT_PIN GPIO_NUM_36 -#define Y_LIMIT_PIN GPIO_NUM_39 -#define Z_LIMIT_PIN GPIO_NUM_34 +// CNC I/O Modules + +#define X_LIMIT_PIN GPIO_NUM_33 +#define Y_LIMIT_PIN GPIO_NUM_32 +#define Z_LIMIT_PIN GPIO_NUM_35 // ================= defaults =========================== diff --git a/Grbl_Esp32/src/SettingsDefinitions.cpp b/Grbl_Esp32/src/SettingsDefinitions.cpp index c6e37b4c..afe3f280 100644 --- a/Grbl_Esp32/src/SettingsDefinitions.cpp +++ b/Grbl_Esp32/src/SettingsDefinitions.cpp @@ -35,19 +35,19 @@ IntSetting* status_mask; FloatSetting* junction_deviation; FloatSetting* arc_tolerance; -FloatSetting* homing_feed_rate; -FloatSetting* homing_seek_rate; -FloatSetting* homing_debounce; -FloatSetting* homing_pulloff; +FloatSetting* homing_feed_rate; +FloatSetting* homing_seek_rate; +FloatSetting* homing_debounce; +FloatSetting* homing_pulloff; AxisMaskSetting* homing_cycle[MAX_N_AXIS]; -FloatSetting* spindle_pwm_freq; -FloatSetting* rpm_max; -FloatSetting* rpm_min; -FloatSetting* spindle_delay_spinup; -FloatSetting* spindle_delay_spindown; -FlagSetting* spindle_enbl_off_with_zero_speed; -FlagSetting* spindle_enable_invert; -FlagSetting* spindle_output_invert; +FloatSetting* spindle_pwm_freq; +FloatSetting* rpm_max; +FloatSetting* rpm_min; +FloatSetting* spindle_delay_spinup; +FloatSetting* spindle_delay_spindown; +FlagSetting* spindle_enbl_off_with_zero_speed; +FlagSetting* spindle_enable_invert; +FlagSetting* spindle_output_invert; FloatSetting* spindle_pwm_off_value; FloatSetting* spindle_pwm_min_value; @@ -346,9 +346,10 @@ void make_settings() { spindle_type = new EnumSetting(NULL, EXTENDED, WG, NULL, "Spindle/Type", static_cast(SPINDLE_TYPE), &spindleTypes); stallguard_debug_mask = new AxisMaskSetting(EXTENDED, WG, NULL, "Report/StallGuard", 0, checkStallguardDebugMask); - const char* homing_names[] = { "Homing/Cycle0", "Homing/Cycle1", "Homing/Cycle2", - "Homing/Cycle3", "Homing/Cycle4", "Homing/Cycle5" }; - for (uint8_t i = 0; i < MAX_N_AXIS; i++) { - homing_cycle[i] = new AxisMaskSetting(EXTENDED, WG, NULL, homing_names[i], 0); - } + homing_cycle[0] = new AxisMaskSetting(EXTENDED, WG, NULL, "Homing/Cycle0", DEFAULT_HOMING_CYCLE_0); + homing_cycle[1] = new AxisMaskSetting(EXTENDED, WG, NULL, "Homing/Cycle1", DEFAULT_HOMING_CYCLE_1); + homing_cycle[2] = new AxisMaskSetting(EXTENDED, WG, NULL, "Homing/Cycle2", DEFAULT_HOMING_CYCLE_2); + homing_cycle[3] = new AxisMaskSetting(EXTENDED, WG, NULL, "Homing/Cycle3", DEFAULT_HOMING_CYCLE_3); + homing_cycle[4] = new AxisMaskSetting(EXTENDED, WG, NULL, "Homing/Cycle4", DEFAULT_HOMING_CYCLE_4); + homing_cycle[5] = new AxisMaskSetting(EXTENDED, WG, NULL, "Homing/Cycle5", DEFAULT_HOMING_CYCLE_5); }