1
0
mirror of https://github.com/bdring/Grbl_Esp32.git synced 2025-08-22 14:12:59 +02:00

Updated to control and door pins & reporting

- Updated Build Codes
- Improved door and control switch options
- Updated defaults to match test machine
- removed unused print.h & .cpp
- added missing reported build options
- added missing parking buffer functions
This commit is contained in:
bdring
2018-08-23 21:04:54 -05:00
parent 315dc7a7a7
commit 8b20ae8572
10 changed files with 109 additions and 234 deletions

View File

@@ -189,7 +189,7 @@ Some features should not be changed. See notes below.
// immediately forces a feed hold and then safely de-energizes the machine. Resuming is blocked until // immediately forces a feed hold and then safely de-energizes the machine. Resuming is blocked until
// the safety door is re-engaged. When it is, Grbl will re-energize the machine and then resume on the // the safety door is re-engaged. When it is, Grbl will re-energize the machine and then resume on the
// previous tool path, as if nothing happened. // previous tool path, as if nothing happened.
#define ENABLE_SAFETY_DOOR_INPUT_PIN // ESP32 Leave this enabled for now .. code for undefined not ready //#define ENABLE_SAFETY_DOOR_INPUT_PIN // Default disabled. Uncomment to enable.
// After the safety door switch has been toggled and restored, this setting sets the power-up delay // After the safety door switch has been toggled and restored, this setting sets the power-up delay
// between restoring the spindle and coolant and resuming the cycle. // between restoring the spindle and coolant and resuming the cycle.
@@ -211,6 +211,10 @@ Some features should not be changed. See notes below.
// inverting only two control pins, the safety door and reset. See cpu_map.h for other bit definitions. // inverting only two control pins, the safety door and reset. See cpu_map.h for other bit definitions.
//#define INVERT_CONTROL_PIN_MASK CONTROL_MASK // Default disabled. Uncomment to disable. //#define INVERT_CONTROL_PIN_MASK CONTROL_MASK // Default disabled. Uncomment to disable.
// This allows control pins to be ignored.
// Since these are typically used on the pins that don't have pullups, they will float and cause
// problems if not externally pulled up. Ignoring will always return not activated when read.
//#define IGNORE_CONTROL_PINS
// Inverts select limit pin states based on the following mask. This effects all limit pin functions, // Inverts select limit pin states based on the following mask. This effects all limit pin functions,
// such as hard limits and homing. However, this is different from overall invert limits setting. // such as hard limits and homing. However, this is different from overall invert limits setting.
@@ -579,7 +583,7 @@ Some features should not be changed. See notes below.
// NOTE: Still a work-in-progress. Machine coordinates must be in all negative space and // NOTE: Still a work-in-progress. Machine coordinates must be in all negative space and
// does not work with HOMING_FORCE_SET_ORIGIN enabled. Parking motion also moves only in // does not work with HOMING_FORCE_SET_ORIGIN enabled. Parking motion also moves only in
// positive direction. // positive direction.
// #define PARKING_ENABLE // Default disabled. Uncomment to enable //#define PARKING_ENABLE // Default disabled. Uncomment to enable
// Configure options for the parking motion, if enabled. // Configure options for the parking motion, if enabled.
#define PARKING_AXIS Z_AXIS // Define which axis that performs the parking motion #define PARKING_AXIS Z_AXIS // Define which axis that performs the parking motion

View File

@@ -40,9 +40,9 @@
#define DEFAULT_DIRECTION_INVERT_MASK 0 // uint8_t #define DEFAULT_DIRECTION_INVERT_MASK 0 // uint8_t
#define DEFAULT_INVERT_ST_ENABLE 0 // boolean #define DEFAULT_INVERT_ST_ENABLE 0 // boolean
#define DEFAULT_INVERT_LIMIT_PINS 1 // boolean #define DEFAULT_INVERT_LIMIT_PINS 1 // boolean
#define DEFAULT_INVERT_PROBE_PIN 1 // boolean #define DEFAULT_INVERT_PROBE_PIN 0 // boolean
#define DEFAULT_STATUS_REPORT_MASK 1 // MPos enabled #define DEFAULT_STATUS_REPORT_MASK 2 // MPos enabled
#define DEFAULT_JUNCTION_DEVIATION 0.01 // mm #define DEFAULT_JUNCTION_DEVIATION 0.01 // mm
#define DEFAULT_ARC_TOLERANCE 0.002 // mm #define DEFAULT_ARC_TOLERANCE 0.002 // mm
@@ -53,8 +53,8 @@
#define DEFAULT_HOMING_ENABLE 0 // false #define DEFAULT_HOMING_ENABLE 0 // false
#define DEFAULT_HOMING_DIR_MASK 3 // move positive dir Z, negative X,Y #define DEFAULT_HOMING_DIR_MASK 3 // move positive dir Z, negative X,Y
#define DEFAULT_HOMING_FEED_RATE 100.0 // mm/min #define DEFAULT_HOMING_FEED_RATE 200.0 // mm/min
#define DEFAULT_HOMING_SEEK_RATE 500.0 // mm/min #define DEFAULT_HOMING_SEEK_RATE 2000.0 // mm/min
#define DEFAULT_HOMING_DEBOUNCE_DELAY 250 // msec (0-65k) #define DEFAULT_HOMING_DEBOUNCE_DELAY 250 // msec (0-65k)
#define DEFAULT_HOMING_PULLOFF 1.0 // mm #define DEFAULT_HOMING_PULLOFF 1.0 // mm
@@ -63,17 +63,17 @@
#define DEFAULT_LASER_MODE 0 // false #define DEFAULT_LASER_MODE 0 // false
#define DEFAULT_X_STEPS_PER_MM 250.0 #define DEFAULT_X_STEPS_PER_MM 800.0
#define DEFAULT_Y_STEPS_PER_MM 250.0 #define DEFAULT_Y_STEPS_PER_MM 800.0
#define DEFAULT_Z_STEPS_PER_MM 250.0 #define DEFAULT_Z_STEPS_PER_MM 800.0
#define DEFAULT_X_MAX_RATE 6000.0 // mm/min #define DEFAULT_X_MAX_RATE 5000.0 // mm/min
#define DEFAULT_Y_MAX_RATE 6000.0 // mm/min #define DEFAULT_Y_MAX_RATE 4000.0 // mm/min
#define DEFAULT_Z_MAX_RATE 6000.0 // mm/min #define DEFAULT_Z_MAX_RATE 3000.0 // mm/min
#define DEFAULT_X_ACCELERATION (50.0*60*60) // 10*60*60 mm/min^2 = 10 mm/sec^2 #define DEFAULT_X_ACCELERATION (200.0*60*60) // 10*60*60 mm/min^2 = 10 mm/sec^2
#define DEFAULT_Y_ACCELERATION (50.0*60*60) // 10*60*60 mm/min^2 = 10 mm/sec^2 #define DEFAULT_Y_ACCELERATION (200.0*60*60) // 10*60*60 mm/min^2 = 10 mm/sec^2
#define DEFAULT_Z_ACCELERATION (50.0*60*60) // 10*60*60 mm/min^2 = 10 mm/sec^2 #define DEFAULT_Z_ACCELERATION (200.0*60*60) // 10*60*60 mm/min^2 = 10 mm/sec^2
#define DEFAULT_X_MAX_TRAVEL 300.0 // mm NOTE: Must be a positive value. #define DEFAULT_X_MAX_TRAVEL 300.0 // mm NOTE: Must be a positive value.
#define DEFAULT_Y_MAX_TRAVEL 300.0 // mm NOTE: Must be a positive value. #define DEFAULT_Y_MAX_TRAVEL 300.0 // mm NOTE: Must be a positive value.

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 "20180817" #define GRBL_VERSION_BUILD "20180823"
//#include <sdkconfig.h> //#include <sdkconfig.h>
#include <arduino.h> #include <arduino.h>
@@ -44,7 +44,6 @@
#include "gcode.h" #include "gcode.h"
#include "limits.h" #include "limits.h"
#include "motion_control.h" #include "motion_control.h"
#include "print.h"
#include "probe.h" #include "probe.h"
#include "protocol.h" #include "protocol.h"
#include "report.h" #include "report.h"

View File

@@ -1,157 +0,0 @@
/*
print.c - Functions for formatting output strings
Part of Grbl
Copyright (c) 2011-2016 Sungeun K. Jeon for Gnea Research LLC
Copyright (c) 2009-2011 Simen Svale Skogsrud
2018 - Bart Dring This file was modifed for use on the ESP32
CPU. Do not use this with Grbl for atMega328P
Grbl 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. If not, see <http://www.gnu.org/licenses/>.
*/
#include "grbl.h"
// void printIntegerInBase(unsigned long n, unsigned long base)
// {
// unsigned char buf[8 * sizeof(long)]; // Assumes 8-bit chars.
// unsigned long i = 0;
//
// if (n == 0) {
// serial_write('0');
// return;
// }
//
// while (n > 0) {
// buf[i++] = n % base;
// n /= base;
// }
//
// for (; i > 0; i--)
// serial_write(buf[i - 1] < 10 ?
// '0' + buf[i - 1] :
// 'A' + buf[i - 1] - 10);
// }
// Prints an uint8 variable in base 10.
void print_uint8_base10(uint8_t n)
{
uint8_t digit_a = 0;
uint8_t digit_b = 0;
if (n >= 100) { // 100-255
digit_a = '0' + n % 10;
n /= 10;
}
if (n >= 10) { // 10-99
digit_b = '0' + n % 10;
n /= 10;
}
serial_write('0' + n);
if (digit_b) { serial_write(digit_b); }
if (digit_a) { serial_write(digit_a); }
}
// Prints an uint8 variable in base 2 with desired number of desired digits.
void print_uint8_base2_ndigit(uint8_t n, uint8_t digits) {
unsigned char buf[digits];
uint8_t i = 0;
for (; i < digits; i++) {
buf[i] = n % 2 ;
n /= 2;
}
for (; i > 0; i--)
Serial.print('0' + buf[i - 1]);
}
void print_uint32_base10(uint32_t n)
{
if (n == 0) {
Serial.print('0');
return;
}
unsigned char buf[10];
uint8_t i = 0;
while (n > 0) {
buf[i++] = n % 10;
n /= 10;
}
for (; i > 0; i--)
Serial.print('0' + buf[i-1]);
}
void printInteger(long n)
{
if (n < 0) {
Serial.print('-');
print_uint32_base10(-n);
} else {
print_uint32_base10(n);
}
}
// Convert float to string by immediately converting to a long integer, which contains
// more digits than a float. Number of decimal places, which are tracked by a counter,
// may be set by the user. The integer is then efficiently converted to a string.
// NOTE: AVR '%' and '/' integer operations are very efficient. Bitshifting speed-up
// techniques are actually just slightly slower. Found this out the hard way.
void printFloat(float n, uint8_t decimal_places)
{
Serial.print(n, decimal_places);
}
// Floating value printing handlers for special variables types used in Grbl and are defined
// in the config.h.
// - CoordValue: Handles all position or coordinate values in inches or mm reporting.
// - RateValue: Handles feed rate and current velocity in inches or mm reporting.
void printFloat_CoordValue(float n) {
if (bit_istrue(settings.flags,BITFLAG_REPORT_INCHES)) {
printFloat(n*INCH_PER_MM,N_DECIMAL_COORDVALUE_INCH);
} else {
printFloat(n,N_DECIMAL_COORDVALUE_MM);
}
}
void printFloat_RateValue(float n) {
if (bit_istrue(settings.flags,BITFLAG_REPORT_INCHES)) {
printFloat(n*INCH_PER_MM,N_DECIMAL_RATEVALUE_INCH);
} else {
printFloat(n,N_DECIMAL_RATEVALUE_MM);
}
}
// Debug tool to print free memory in bytes at the called point.
// NOTE: Keep commented unless using. Part of this function always gets compiled in.
// void printFreeMemory()
// {
// extern int __heap_start, *__brkval;
// uint16_t free; // Up to 64k values.
// free = (int) &free - (__brkval == 0 ? (int) &__heap_start : (int) __brkval);
// printInteger((int32_t)free);
// printString(" ");
// }

View File

@@ -1,54 +0,0 @@
/*
print.h - Functions for formatting output strings
Part of Grbl
Copyright (c) 2011-2016 Sungeun K. Jeon for Gnea Research LLC
Copyright (c) 2009-2011 Simen Svale Skogsrud
2018 - Bart Dring This file was modifed for use on the ESP32
CPU. Do not use this with Grbl for atMega328P
Grbl 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. If not, see <http://www.gnu.org/licenses/>.
*/
#ifndef print_h
#define print_h
void printString(const char *s);
void printPgmString(const char *s);
void printInteger(long n);
void print_uint32_base10(uint32_t n);
// Prints an uint8 variable in base 10.
void print_uint8_base10(uint8_t n);
// Prints an uint8 variable in base 2 with desired number of desired digits.
void print_uint8_base2_ndigit(uint8_t n, uint8_t digits);
void printFloat(float n, uint8_t decimal_places);
// Floating value printing handlers for special variables types used in Grbl.
// - CoordValue: Handles all position or coordinate values in inches or mm reporting.
// - RateValue: Handles feed rate and current velocity in inches or mm reporting.
void printFloat_CoordValue(float n);
void printFloat_RateValue(float n);
// Debug tool to print free memory in bytes at the called point. Not used otherwise.
void printFreeMemory();
#endif

View File

@@ -466,14 +466,38 @@ void report_build_info(char *line)
strcat(build_info,"H"); strcat(build_info,"H");
#endif #endif
#ifdef LIMITS_TWO_SWITCHES_ON_AXES #ifdef LIMITS_TWO_SWITCHES_ON_AXES
strcat(build_info,"L"); strcat(build_info,"T");
#endif
#ifdef ALLOW_FEED_OVERRIDE_DURING_PROBE_CYCLES
strcat(build_info,"A");
#endif
#ifdef ENABLE_SAFETY_DOOR_INPUT_PIN
strcat(build_info,"+");
#endif #endif
#ifdef ALLOW_FEED_OVERRIDE_DURING_PROBE_CYCLES #ifdef ALLOW_FEED_OVERRIDE_DURING_PROBE_CYCLES
strcat(build_info,"A"); strcat(build_info,"A");
#endif
#ifdef USE_SPINDLE_DIR_AS_ENABLE_PIN
strcat(build_info,"D");
#endif
#ifdef SPINDLE_ENABLE_OFF_WITH_ZERO_SPEED
strcat(build_info,"0");
#endif
#ifdef ENABLE_SOFTWARE_DEBOUNCE
strcat(build_info,"S");
#endif
#ifdef ENABLE_PARKING_OVERRIDE_CONTROL
strcat(build_info,"R");
#endif
#ifndef HOMING_INIT_LOCK
strcat(build_info,"L");
#endif #endif
#ifdef ENABLE_BLUETOOTH #ifdef ENABLE_BLUETOOTH
strcat(build_info,"B"); strcat(build_info,"B");
#endif #endif
#ifdef ENABLE_SAFETY_DOOR_INPUT_PIN
strcat(build_info,"+");
#endif
#ifndef ENABLE_RESTORE_EEPROM_WIPE_ALL // NOTE: Shown when disabled. #ifndef ENABLE_RESTORE_EEPROM_WIPE_ALL // NOTE: Shown when disabled.
strcat(build_info,"*"); strcat(build_info,"*");
#endif #endif

View File

@@ -63,6 +63,16 @@
#define STATUS_GCODE_G43_DYNAMIC_AXIS_ERROR 37 #define STATUS_GCODE_G43_DYNAMIC_AXIS_ERROR 37
#define STATUS_GCODE_MAX_VALUE_EXCEEDED 38 #define STATUS_GCODE_MAX_VALUE_EXCEEDED 38
#define STATUS_SD_FAILED_MOUNT 60 // SD Failed to mount
#define STATUS_SD_FAILED_READ 61 // SD Failed to read file
#define STATUS_SD_FAILED_OPEN_DIR 62 // SD card failed to open directory
#define STATUS_SD_DIR_NOT_FOUND 63 // SD Card directory not found
#define STATUS_SD_FILE_EMPTY 64 // SD Card directory not found
#define STATUS_BT_FAIL_BEGIN 70 // Bluetooth failed to start
// Define Grbl alarm codes. Valid values (1-255). 0 is reserved. // Define Grbl alarm codes. Valid values (1-255). 0 is reserved.
#define ALARM_HARD_LIMIT_ERROR EXEC_ALARM_HARD_LIMIT #define ALARM_HARD_LIMIT_ERROR EXEC_ALARM_HARD_LIMIT
#define ALARM_SOFT_LIMIT_ERROR EXEC_ALARM_SOFT_LIMIT #define ALARM_SOFT_LIMIT_ERROR EXEC_ALARM_SOFT_LIMIT
@@ -87,6 +97,8 @@
#define MESSAGE_SPINDLE_RESTORE 10 #define MESSAGE_SPINDLE_RESTORE 10
#define MESSAGE_SLEEP_MODE 11 #define MESSAGE_SLEEP_MODE 11
void grbl_send(char *text);
// Prints system status messages. // Prints system status messages.
void report_status_message(uint8_t status_code); void report_status_message(uint8_t status_code);
void report_realtime_steps(); void report_realtime_steps();

View File

@@ -496,6 +496,43 @@ void st_update_plan_block_parameters()
} }
} }
#ifdef PARKING_ENABLE
// Changes the run state of the step segment buffer to execute the special parking motion.
void st_parking_setup_buffer()
{
// Store step execution data of partially completed block, if necessary.
if (prep.recalculate_flag & PREP_FLAG_HOLD_PARTIAL_BLOCK) {
prep.last_st_block_index = prep.st_block_index;
prep.last_steps_remaining = prep.steps_remaining;
prep.last_dt_remainder = prep.dt_remainder;
prep.last_step_per_mm = prep.step_per_mm;
}
// Set flags to execute a parking motion
prep.recalculate_flag |= PREP_FLAG_PARKING;
prep.recalculate_flag &= ~(PREP_FLAG_RECALCULATE);
pl_block = NULL; // Always reset parking motion to reload new block.
}
// Restores the step segment buffer to the normal run state after a parking motion.
void st_parking_restore_buffer()
{
// Restore step execution data and flags of partially completed block, if necessary.
if (prep.recalculate_flag & PREP_FLAG_HOLD_PARTIAL_BLOCK) {
st_prep_block = &st_block_buffer[prep.last_st_block_index];
prep.st_block_index = prep.last_st_block_index;
prep.steps_remaining = prep.last_steps_remaining;
prep.dt_remainder = prep.last_dt_remainder;
prep.step_per_mm = prep.last_step_per_mm;
prep.recalculate_flag = (PREP_FLAG_HOLD_PARTIAL_BLOCK | PREP_FLAG_RECALCULATE);
prep.req_mm_increment = REQ_MM_INCREMENT_SCALAR/prep.step_per_mm; // Recompute this value.
} else {
prep.recalculate_flag = false;
}
pl_block = NULL; // Set to reload next block.
}
#endif
// Generates the step and direction port invert masks used in the Stepper Interrupt Driver. // Generates the step and direction port invert masks used in the Stepper Interrupt Driver.
void st_generate_step_dir_invert_masks() void st_generate_step_dir_invert_masks()
{ {

View File

@@ -24,7 +24,9 @@
void system_ini() // Renamed from system_init() due to conflict with esp32 files void system_ini() // Renamed from system_init() due to conflict with esp32 files
{ {
// setup control inputs // setup control inputs
pinMode(CONTROL_SAFETY_DOOR_PIN, INPUT); #ifdef ENABLE_SAFETY_DOOR_INPUT_PIN
pinMode(CONTROL_SAFETY_DOOR_PIN, INPUT);
#endif
pinMode(CONTROL_RESET_PIN, INPUT); pinMode(CONTROL_RESET_PIN, INPUT);
pinMode(CONTROL_FEED_HOLD_PIN, INPUT); pinMode(CONTROL_FEED_HOLD_PIN, INPUT);
pinMode(CONTROL_CYCLE_START_PIN, INPUT); pinMode(CONTROL_CYCLE_START_PIN, INPUT);
@@ -378,8 +380,15 @@ uint8_t system_check_travel_limits(float *target)
// defined by the CONTROL_PIN_INDEX in the header file. // defined by the CONTROL_PIN_INDEX in the header file.
uint8_t system_control_get_state() uint8_t system_control_get_state()
{ {
#ifdef IGNORE_CONTROL_PINS
return 0;
#endif
uint8_t control_state = 0; uint8_t control_state = 0;
#ifdef ENABLE_SAFETY_DOOR_INPUT_PIN
if (digitalRead(CONTROL_SAFETY_DOOR_PIN)) { control_state |= CONTROL_PIN_INDEX_SAFETY_DOOR; } if (digitalRead(CONTROL_SAFETY_DOOR_PIN)) { control_state |= CONTROL_PIN_INDEX_SAFETY_DOOR; }
#endif
if (digitalRead(CONTROL_RESET_PIN)) { control_state |= CONTROL_PIN_INDEX_RESET; } if (digitalRead(CONTROL_RESET_PIN)) { control_state |= CONTROL_PIN_INDEX_RESET; }
if (digitalRead(CONTROL_FEED_HOLD_PIN)) { control_state |= CONTROL_PIN_INDEX_FEED_HOLD; } if (digitalRead(CONTROL_FEED_HOLD_PIN)) { control_state |= CONTROL_PIN_INDEX_FEED_HOLD; }
if (digitalRead(CONTROL_CYCLE_START_PIN)) { control_state |= CONTROL_PIN_INDEX_CYCLE_START; } if (digitalRead(CONTROL_CYCLE_START_PIN)) { control_state |= CONTROL_PIN_INDEX_CYCLE_START; }

View File

@@ -20,3 +20,4 @@ I,Build info write user string command,Disabled
E,Force sync upon EEPROM write,Disabled E,Force sync upon EEPROM write,Disabled
W,Force sync upon work coordinate offset change,Disabled W,Force sync upon work coordinate offset change,Disabled
L,Homing initialization auto-lock,Disabled L,Homing initialization auto-lock,Disabled
B,Bluetooth Enabled
Can't render this file because it has a wrong number of fields in line 23.