From 420657fa557d811bc9fb489a9ae1dba88bee5b5a Mon Sep 17 00:00:00 2001 From: bdring Date: Thu, 5 Nov 2020 12:50:58 -0600 Subject: [PATCH] Setup --- Grbl_Esp32/Custom/atc.cpp | 43 ++++++ Grbl_Esp32/src/GCode.cpp | 1 + Grbl_Esp32/src/Machine.h | 2 +- .../src/Machines/6_pack_stepstick_XYZ_ATC.h | 132 ++++++++++++++++++ 4 files changed, 177 insertions(+), 1 deletion(-) create mode 100644 Grbl_Esp32/Custom/atc.cpp create mode 100644 Grbl_Esp32/src/Machines/6_pack_stepstick_XYZ_ATC.h diff --git a/Grbl_Esp32/Custom/atc.cpp b/Grbl_Esp32/Custom/atc.cpp new file mode 100644 index 00000000..77b62b4c --- /dev/null +++ b/Grbl_Esp32/Custom/atc.cpp @@ -0,0 +1,43 @@ +/* + Testing ATC ideas + + +*/ + + + + + +void machine_init() { + grbl_msg_sendf(CLIENT_SERIAL, MsgLevel::Info, "ATC Machine Init"); +} + + +/* + +*/ +void user_tool_change(uint8_t new_tool) { + char gcode_line[20]; + + grbl_msg_sendf(CLIENT_SERIAL, MsgLevel::Info, "ATC use tool %d", new_tool); + protocol_buffer_synchronize(); // wait for all previous moves to complete + + sprintf(gcode_line, "G53G0Z-1\r"); // + gc_execute_line(gcode_line, CLIENT_INPUT); + + sprintf(gcode_line, "G4P3.0"); // + gc_execute_line(gcode_line, CLIENT_INPUT); + + sprintf(gcode_line, "G0G0Z0"); // + gc_execute_line(gcode_line, CLIENT_INPUT); +} + + +// Polar coaster has macro buttons, this handles those button pushes. +void user_defined_macro(uint8_t index) { + +} + +void user_m30() { + grbl_msg_sendf(CLIENT_SERIAL, MsgLevel::Info, "ATC M30"); +} diff --git a/Grbl_Esp32/src/GCode.cpp b/Grbl_Esp32/src/GCode.cpp index 5a24d342..21614a86 100644 --- a/Grbl_Esp32/src/GCode.cpp +++ b/Grbl_Esp32/src/GCode.cpp @@ -436,6 +436,7 @@ Error gc_execute_line(char* line, uint8_t client) { // NOTE: Variable 'mg_word_bit' is always assigned, if the command is valid. bitmask = bit(mg_word_bit); if (bit_istrue(command_words, bitmask)) { + grbl_msg_sendf(CLIENT_SERIAL, MsgLevel::Info, "Bad:%s", line); FAIL(Error::GcodeModalGroupViolation); } command_words |= bitmask; diff --git a/Grbl_Esp32/src/Machine.h b/Grbl_Esp32/src/Machine.h index 11ab8406..0fdb353c 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/test_drive.h" +# include "Machines/6_pack_stepstick_XYZ_ATC.h" // !!! For actual use, change the line above to select a board // from Machines/, for example: diff --git a/Grbl_Esp32/src/Machines/6_pack_stepstick_XYZ_ATC.h b/Grbl_Esp32/src/Machines/6_pack_stepstick_XYZ_ATC.h new file mode 100644 index 00000000..1b7dcd4c --- /dev/null +++ b/Grbl_Esp32/src/Machines/6_pack_stepstick_XYZ_ATC.h @@ -0,0 +1,132 @@ +#pragma once +// clang-format off + +/* + 6_pack_stepstick_XYZ_v1.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 . +*/ +#define MACHINE_NAME "6 Pack Controller ATC Ideas" + +#define CUSTOM_CODE_FILENAME "Custom/atc.cpp" + +#define N_AXIS 3 + +#define USE_MACHINE_INIT +#define USE_TOOL_CHANGE +#define USE_M30 // use the user defined end of program + +// === 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_NUM_22 +#define I2S_OUT_WS GPIO_NUM_17 +#define I2S_OUT_DATA GPIO_NUM_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 + + +// // 4x Input Module in Socket #2 +// // https://github.com/bdring/6-Pack_CNC_Controller/wiki/4x-Switch-Input-module +// #define X_LIMIT_PIN GPIO_NUM_2 +// #define Y_LIMIT_PIN GPIO_NUM_25 +// #define Z_LIMIT_PIN GPIO_NUM_39 + +// // 4x Input Module in Socket #3 +// // https://github.com/bdring/6-Pack_CNC_Controller/wiki/4x-Switch-Input-module +// #define CONTROL_CYCLE_START_PIN GPIO_NUM_26 +// #define CONTROL_FEED_HOLD_PIN GPIO_NUM_4 +// #define CONTROL_RESET_PIN GPIO_NUM_16 +// #define CONTROL_SAFETY_DOOR_PIN GPIO_NUM_27 +// //#define INVERT_CONTROL_PIN_MASK B0000 + +// ================= Setting Defaults ========================== +#define DEFAULT_X_STEPS_PER_MM 800 +#define DEFAULT_Y_STEPS_PER_MM 800 +#define DEFAULT_Z_STEPS_PER_MM 800