1
0
mirror of https://github.com/bdring/Grbl_Esp32.git synced 2025-08-19 04:41:44 +02:00

Updates to limit switches

- You can now comment out limit switch pins to free up the I/O
- Cleaned up cpu_map.h to move the "don't change" items to a section at the end
- updates on project status to readme file
This commit is contained in:
bdring
2018-09-19 09:04:07 -05:00
parent 96e01bee56
commit 207c20e880
4 changed files with 76 additions and 47 deletions

View File

@@ -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 // It is OK to comment out any step and direction pins. This
// won't affect operation except that there will be no output // 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. // be handy if you are using a servo, etc. for another axis.
#define X_STEP_PIN GPIO_NUM_12 #define X_STEP_PIN GPIO_NUM_12
#define Y_STEP_PIN GPIO_NUM_14 #define Y_STEP_PIN GPIO_NUM_14
#define Z_STEP_PIN GPIO_NUM_27 #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 X_DIRECTION_PIN GPIO_NUM_26 #define X_DIRECTION_PIN GPIO_NUM_26
#define Y_DIRECTION_PIN GPIO_NUM_25 #define Y_DIRECTION_PIN GPIO_NUM_25
#define Z_DIRECTION_PIN GPIO_NUM_33 #define Z_DIRECTION_PIN GPIO_NUM_33
// OK to comment out to use pin for other features // 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 // *** the flood coolant feature code is activated by defining this pins
// *** Comment it out to use the pin for other features // *** 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 // if these spindle function pins are defined, they will be activated in the code
// comment them out to use the pins for other functions // comment them out to use the pins for other functions
//#define SPINDLE_ENABLE_PIN GPIO_NUM_16 //#define SPINDLE_ENABLE_PIN GPIO_NUM_16
//#define SPINDLE_DIR_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 X_LIMIT_PIN GPIO_NUM_2 #define X_LIMIT_PIN GPIO_NUM_2
#define Y_LIMIT_PIN GPIO_NUM_4 #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_PIN GPIO_NUM_32
#define PROBE_MASK 1 // don't change
#define CONTROL_SAFETY_DOOR_PIN GPIO_NUM_35 // needs external pullup #define CONTROL_SAFETY_DOOR_PIN GPIO_NUM_35 // needs external pullup
#define CONTROL_RESET_PIN GPIO_NUM_34 // 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_FEED_HOLD_PIN GPIO_NUM_36 // needs external pullup
#define CONTROL_CYCLE_START_PIN GPIO_NUM_39 // 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
// These are some ESP32 CPU Settings that the program needs, but are generally not changed // 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 #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_MIN 2 // uSeconds
#define STEP_PULSE_MAX 10 // 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 #endif

View File

@@ -20,7 +20,7 @@
// Grbl versioning system // Grbl versioning system
#define GRBL_VERSION "1.1f" #define GRBL_VERSION "1.1f"
#define GRBL_VERSION_BUILD "20180910" #define GRBL_VERSION_BUILD "20180919"
//#include <sdkconfig.h> //#include <sdkconfig.h>
#include <arduino.h> #include <arduino.h>

View File

@@ -260,20 +260,38 @@ void limits_init()
{ {
#ifndef DISABLE_LIMIT_PIN_PULL_UP #ifndef DISABLE_LIMIT_PIN_PULL_UP
pinMode(X_LIMIT_PIN, INPUT_PULLUP); // input with pullup #ifdef X_LIMIT_PIN
pinMode(Y_LIMIT_PIN, INPUT_PULLUP); pinMode(X_LIMIT_PIN, INPUT_PULLUP); // input with pullup
pinMode(Z_LIMIT_PIN, INPUT_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 #else
pinMode(X_LIMIT_PIN, INPUT); // input no pullup #ifdef X_LIMIT_PIN
pinMode(Y_LIMIT_PIN, INPUT); pinMode(X_LIMIT_PIN, INPUT); // input no pullup
pinMode(Z_LIMIT_PIN, INPUT); #endif
#ifdef Y_LIMIT_PIN
pinMode(Y_LIMIT_PIN, INPUT);
#endif
#ifdef Z_LIMIT_PIN
pinMode(Z_LIMIT_PIN, INPUT);
#endif
#endif #endif
if (bit_istrue(settings.flags,BITFLAG_HARD_LIMIT_ENABLE)) { if (bit_istrue(settings.flags,BITFLAG_HARD_LIMIT_ENABLE)) {
// attach interrupt to them // attach interrupt to them
attachInterrupt(digitalPinToInterrupt(X_LIMIT_PIN), isr_limit_switches, CHANGE); #ifdef X_LIMIT_PIN
attachInterrupt(digitalPinToInterrupt(Y_LIMIT_PIN), isr_limit_switches, CHANGE); attachInterrupt(digitalPinToInterrupt(X_LIMIT_PIN), isr_limit_switches, CHANGE);
attachInterrupt(digitalPinToInterrupt(Z_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 { } else {
limits_disable(); 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. // 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 limits_get_state()
{ {
uint8_t limit_state = 0; 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 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 #ifdef INVERT_LIMIT_PIN_MASK // not normally used..unless you have both normal and inverted switches
pin ^= INVERT_LIMIT_PIN_MASK; pin ^= INVERT_LIMIT_PIN_MASK;

View File

@@ -2,11 +2,7 @@
# Grbl (CNC Controller) For ESP32 # Grbl (CNC Controller) For ESP32
![ESP32](http://www.buildlog.net/blog/wp-content/uploads/2018/07/20180718_175943.jpg) ![ESP32](http://www.buildlog.net/blog/wp-content/uploads/2018/08/20180819_170123.jpg)
### Status: Functional Beta (See minor issues below)
### Project Overview ### 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. 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. 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 ### 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 ### 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. 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 ![](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