diff --git a/Grbl_Esp32/cpu_map.h b/Grbl_Esp32/cpu_map.h index 02403fc6..a452dda3 100644 --- a/Grbl_Esp32/cpu_map.h +++ b/Grbl_Esp32/cpu_map.h @@ -36,8 +36,7 @@ */ - // This is the CPU Map for the ESP32 CNC Controller R2 - + // This is the CPU Map for the ESP32 CNC Controller R2 // It is OK to comment out any step and direction pins. This // won't affect operation except that there will be no output @@ -45,24 +44,14 @@ // be handy if you are using a servo, etc. for another axis. #define X_STEP_PIN GPIO_NUM_12 #define Y_STEP_PIN GPIO_NUM_14 - #define Z_STEP_PIN GPIO_NUM_27 - #define STEP_MASK B111 // don't change - - #define X_STEP_BIT 0 // don't change - #define Y_STEP_BIT 1 // don't change - #define Z_STEP_BIT 2 // don't change - - #define X_DIRECTION_BIT 0 // don't change - #define Y_DIRECTION_BIT 1 // don't change - #define Z_DIRECTION_BIT 2 // don't change + #define Z_STEP_PIN GPIO_NUM_27 #define X_DIRECTION_PIN GPIO_NUM_26 #define Y_DIRECTION_PIN GPIO_NUM_25 #define Z_DIRECTION_PIN GPIO_NUM_33 // OK to comment out to use pin for other features - #define STEPPERS_DISABLE_PIN GPIO_NUM_13 - + #define STEPPERS_DISABLE_PIN GPIO_NUM_13 // *** the flood coolant feature code is activated by defining this pins // *** Comment it out to use the pin for other features @@ -82,27 +71,18 @@ // if these spindle function pins are defined, they will be activated in the code // comment them out to use the pins for other functions //#define SPINDLE_ENABLE_PIN GPIO_NUM_16 - //#define SPINDLE_DIR_PIN GPIO_NUM_16 - - #define X_LIMIT_BIT 0 // don't change - #define Y_LIMIT_BIT 1 // don't change - #define Z_LIMIT_BIT 2 // don't change + //#define SPINDLE_DIR_PIN GPIO_NUM_16 #define X_LIMIT_PIN GPIO_NUM_2 #define Y_LIMIT_PIN GPIO_NUM_4 - #define Z_LIMIT_PIN GPIO_NUM_15 + #define Z_LIMIT_PIN GPIO_NUM_15 - #define LIMIT_MASK B111 // don't change #define PROBE_PIN GPIO_NUM_32 - #define PROBE_MASK 1 // don't change - #define CONTROL_SAFETY_DOOR_PIN GPIO_NUM_35 // needs external pullup #define CONTROL_RESET_PIN GPIO_NUM_34 // needs external pullup #define CONTROL_FEED_HOLD_PIN GPIO_NUM_36 // needs external pullup - #define CONTROL_CYCLE_START_PIN GPIO_NUM_39 // needs external pullup - #define CONTROL_MASK B1111 // don't change - #define INVERT_CONTROL_PIN_MASK B1110 + #define CONTROL_CYCLE_START_PIN GPIO_NUM_39 // needs external pullup // These are some ESP32 CPU Settings that the program needs, but are generally not changed #define F_TIMERS 80000000 // a reference to the speed of ESP32 timers @@ -113,4 +93,28 @@ #define STEP_PULSE_MIN 2 // uSeconds #define STEP_PULSE_MAX 10 // uSeconds + // =============== Don't change or comment these out ====================== + // They are for legacy purposes and will not affect your I/O + + #define X_STEP_BIT 0 // don't change + #define Y_STEP_BIT 1 // don't change + #define Z_STEP_BIT 2 // don't change + #define STEP_MASK B111 // don't change + + #define X_DIRECTION_BIT 0 // don't change + #define Y_DIRECTION_BIT 1 // don't change + #define Z_DIRECTION_BIT 2 // don't change + + #define X_LIMIT_BIT 0 // don't change + #define Y_LIMIT_BIT 1 // don't change + #define Z_LIMIT_BIT 2 // don't change + #define LIMIT_MASK B111 // don't change + + #define PROBE_MASK 1 // don't change + + #define CONTROL_MASK B1111 // don't change + #define INVERT_CONTROL_PIN_MASK B1110 // don't change + + // ======================================================================= + #endif \ No newline at end of file diff --git a/Grbl_Esp32/grbl.h b/Grbl_Esp32/grbl.h index afdf0289..aff71b70 100644 --- a/Grbl_Esp32/grbl.h +++ b/Grbl_Esp32/grbl.h @@ -20,7 +20,7 @@ // Grbl versioning system #define GRBL_VERSION "1.1f" -#define GRBL_VERSION_BUILD "20180910" +#define GRBL_VERSION_BUILD "20180919" //#include #include diff --git a/Grbl_Esp32/limits.cpp b/Grbl_Esp32/limits.cpp index 7ebc99de..eae28bf1 100644 --- a/Grbl_Esp32/limits.cpp +++ b/Grbl_Esp32/limits.cpp @@ -260,20 +260,38 @@ void limits_init() { #ifndef DISABLE_LIMIT_PIN_PULL_UP - pinMode(X_LIMIT_PIN, INPUT_PULLUP); // input with pullup - pinMode(Y_LIMIT_PIN, INPUT_PULLUP); - pinMode(Z_LIMIT_PIN, INPUT_PULLUP); + #ifdef X_LIMIT_PIN + pinMode(X_LIMIT_PIN, INPUT_PULLUP); // input with pullup + #endif + #ifdef Y_LIMIT_PIN + pinMode(Y_LIMIT_PIN, INPUT_PULLUP); + #endif + #ifdef Z_LIMIT_PIN + pinMode(Z_LIMIT_PIN, INPUT_PULLUP); + #endif #else - pinMode(X_LIMIT_PIN, INPUT); // input no pullup - pinMode(Y_LIMIT_PIN, INPUT); - pinMode(Z_LIMIT_PIN, INPUT); + #ifdef X_LIMIT_PIN + pinMode(X_LIMIT_PIN, INPUT); // input no pullup + #endif + #ifdef Y_LIMIT_PIN + pinMode(Y_LIMIT_PIN, INPUT); + #endif + #ifdef Z_LIMIT_PIN + pinMode(Z_LIMIT_PIN, INPUT); + #endif #endif if (bit_istrue(settings.flags,BITFLAG_HARD_LIMIT_ENABLE)) { // attach interrupt to them - attachInterrupt(digitalPinToInterrupt(X_LIMIT_PIN), isr_limit_switches, CHANGE); - attachInterrupt(digitalPinToInterrupt(Y_LIMIT_PIN), isr_limit_switches, CHANGE); - attachInterrupt(digitalPinToInterrupt(Z_LIMIT_PIN), isr_limit_switches, CHANGE); + #ifdef X_LIMIT_PIN + attachInterrupt(digitalPinToInterrupt(X_LIMIT_PIN), isr_limit_switches, CHANGE); + #endif + #ifdef Y_LIMIT_PIN + attachInterrupt(digitalPinToInterrupt(Y_LIMIT_PIN), isr_limit_switches, CHANGE); + #endif + #ifdef Z_LIMIT_PIN + attachInterrupt(digitalPinToInterrupt(Z_LIMIT_PIN), isr_limit_switches, CHANGE); + #endif } else { limits_disable(); } @@ -304,8 +322,18 @@ void limits_disable() // number in bit position, i.e. Z_AXIS is (1<<2) or bit 2, and Y_AXIS is (1<<1) or bit 1. uint8_t limits_get_state() { - uint8_t limit_state = 0; - uint8_t pin = (digitalRead(X_LIMIT_PIN) + (digitalRead(Y_LIMIT_PIN) << Y_AXIS) + (digitalRead(Z_LIMIT_PIN) << Z_AXIS) ); + uint8_t limit_state = 0; + uint8_t pin = 0; + + #ifdef X_LIMIT_PIN + pin += digitalRead(X_LIMIT_PIN); + #endif + #ifdef Y_LIMIT_PIN + pin += (digitalRead(Y_LIMIT_PIN) << Y_AXIS); + #endif + #ifdef Z_LIMIT_PIN + pin += (digitalRead(Z_LIMIT_PIN) << Z_AXIS); + #endif #ifdef INVERT_LIMIT_PIN_MASK // not normally used..unless you have both normal and inverted switches pin ^= INVERT_LIMIT_PIN_MASK; diff --git a/README.md b/README.md index c01992e6..7a3beda3 100644 --- a/README.md +++ b/README.md @@ -2,11 +2,7 @@ # Grbl (CNC Controller) For ESP32 -![ESP32](http://www.buildlog.net/blog/wp-content/uploads/2018/07/20180718_175943.jpg) - -### Status: Functional Beta (See minor issues below) - - +![ESP32](http://www.buildlog.net/blog/wp-content/uploads/2018/08/20180819_170123.jpg) ### Project Overview @@ -33,7 +29,7 @@ This is a port of [Grbl](https://github.com/gnea/grbl) for the ESP32. The ESP32 The code should be compiled using the latest Arduino IDE. [Follow instructions here](https://github.com/espressif/arduino-esp32) on how to setup ESP32 in the IDE. The choice was made to use the Arduino IDE over the ESP-IDF to make the code a little more accessible to novices trying to compile the code. -I use the NodeMCU 32S version of the ESP32. I suggest starting with that if you don't have hardware yet. +I use the ESP32 Dev Module version of the ESP32. I suggest starting with that if you don't have hardware yet. For basic instructions on using Grbl use the [gnea/grbl wiki](https://github.com/gnea/grbl/wiki). That is the Arduino version of Grbl, so keep that in mind regarding hardware setup. If you have questions ask via the GitHub issue system for this project. @@ -49,15 +45,16 @@ Using SD Card ### Roadmap -- Add Wifi support and a web page interface +- [Wifi Support](https://github.com/bdring/Grbl_Esp32/wiki/ESP3D-Web-UI-for-Grbl_ESP32) is currently in development. Use the [WebUI branch](https://github.com/bdring/Grbl_Esp32/tree/WebUI) if you want to check it out. +- Add support for additional axes ### Credits The original [Grbl](https://github.com/gnea/grbl) is an awesome project by Sungeon (Sonny) Jeon. I have known him for many years and he is always very helpful. I have used Grbl on many projects. I only ported because of the limitation of the processors it was designed for. The core engine design is virtually unchanged. -### Contribute +The Wifi and WebUI is based on [this project.](https://github.com/luc-github/ESP3D-WEBUI) -I would love to have help with this project. There are many things that need to be improved and added, especially BlueTooth and/or WiFi. If you need hardware to test with, I might be able to help with a test PCB. +### Contribute ![](http://www.buildlog.net/blog/wp-content/uploads/2018/07/slack_hash_128.png) There is a slack channel for the development this project. Ask for an Invite