mirror of
https://github.com/MarlinFirmware/Marlin.git
synced 2025-12-30 19:30:46 -07:00
drill cycles
This commit is contained in:
parent
cc3269a50b
commit
6f92950a25
6 changed files with 231 additions and 0 deletions
|
|
@ -4436,6 +4436,34 @@
|
|||
#define FREEZE_STATE LOW // State of pin indicating freeze
|
||||
#endif
|
||||
|
||||
/**
|
||||
* Adds canned drilling cycle G Codes:
|
||||
* G73: Shallow peck drill cycle
|
||||
* G80: Cancel drill cycle
|
||||
* G81: Basic drill cycle
|
||||
* G82: Normal drill cycle (Basic with dwell)
|
||||
* G83: Deep drill cycle (Normal with peck)
|
||||
* G98: Start drill - retract to initial
|
||||
* G99: Start drill - retract to specified
|
||||
* or when DRILL_USE_81_ONLY is specified:
|
||||
* G81.4: Shallow peck drill cycle
|
||||
* G81.0: Cancel drill cycle
|
||||
* G81.1: Basic drill cycle
|
||||
* G81.2: Normal drill cycle (Basic with dwell)
|
||||
* G81.3: Deep drill cycle (Normal with peck)
|
||||
* G81.18: Start drill - retract to initial
|
||||
* G81.19: Start drill - retract to specified
|
||||
*/
|
||||
#define DRILL_CYCLES
|
||||
#if ENABLED(DRILL_CYCLES)
|
||||
//#define DRILL_USE_81_ONLY
|
||||
#define DRILL_CYCLES_XY_FEEDRATE 1600
|
||||
#define DRILL_CYCLES_RETRACT_FEEDRATE 1200
|
||||
#define DRILL_CYCLES_DEFAULT_FEEDRATE 300
|
||||
#define DRILL_CYCLES_DEFAULT_PECK 2.0
|
||||
#define DRILL_CYCLES_DEFAULT_DWELL 0
|
||||
#endif
|
||||
|
||||
/**
|
||||
* MAX7219 Debug Matrix
|
||||
*
|
||||
|
|
|
|||
|
|
@ -463,6 +463,20 @@ void GcodeSuite::process_parsed_command(bool no_ok/*=false*/) {
|
|||
case 80: G80(); break; // G80: Reset the current motion mode
|
||||
#endif
|
||||
|
||||
#if ENABLED(DRILL_CYCLES)
|
||||
#if ENABLED(DRILL_USE_81_ONLY) || ENABLED(GCODE_MOTION_MODES)
|
||||
case 81: G81(parser.subcode); break; // G81: Drill cycle G81: Cancel, G81.18 G81.19 Start, G81.1 G81.2 G81.3 G81.4 Cycles
|
||||
#else
|
||||
case 73: G81(4); break; // G73: Shallow peck drill cycle
|
||||
case 80: G81(0); break; // G80: Cancel drill cycle
|
||||
case 81: G81(1); break; // G81: Basic drill cycle
|
||||
case 82: G81(2); break; // G82: Normal drill cycle (Basic with dwell)
|
||||
case 83: G81(3); break; // G83: Deep drill cycle (Normal with peck)
|
||||
case 98: G81(18); break; // G98: Retract to initial
|
||||
case 99: G81(19); break; // G99: Retract to specified
|
||||
#endif
|
||||
#endif
|
||||
|
||||
case 90: G90(); break; // G90: Absolute Mode
|
||||
case 91: G91(); break; // G91: Relative Mode
|
||||
|
||||
|
|
|
|||
|
|
@ -66,11 +66,18 @@
|
|||
* G42 - Coordinated move to a mesh point (Requires MESH_BED_LEVELING, AUTO_BED_LEVELING_BLINEAR, or AUTO_BED_LEVELING_UBL)
|
||||
* G60 - Save current position. (Requires SAVED_POSITIONS)
|
||||
* G61 - Apply/Restore saved coordinates. (Requires SAVED_POSITIONS)
|
||||
* G73 - Shallow peck drill cycle
|
||||
* G76 - Calibrate first layer temperature offsets. (Requires PTC_PROBE and PTC_BED)
|
||||
* G80 - Cancel current motion mode (Requires GCODE_MOTION_MODES)
|
||||
* G80 - Cancel drill cancel
|
||||
* G81 - Basic drill cycle
|
||||
* G82 - Normal drill cycle
|
||||
* G83 - Deep drill cycle
|
||||
* G90 - Use Absolute Coordinates
|
||||
* G91 - Use Relative Coordinates
|
||||
* G92 - Set current position to coordinates given
|
||||
* G98 - Start drill - retract to initial
|
||||
* G99 - Start drill - retract to specified
|
||||
*
|
||||
* "M" Codes
|
||||
*
|
||||
|
|
@ -644,6 +651,10 @@ private:
|
|||
static void G80();
|
||||
#endif
|
||||
|
||||
#if ENABLED(DRILL_CYCLES)
|
||||
static void G81(uint8_t mode);
|
||||
#endif
|
||||
|
||||
static void G90() { set_relative_mode(false); }
|
||||
static void G91() { set_relative_mode(true); }
|
||||
|
||||
|
|
|
|||
|
|
@ -226,6 +226,9 @@ void GcodeSuite::M115() {
|
|||
// MOTION_MODES (M80-M89)
|
||||
cap_line(F("MOTION_MODES"), ENABLED(GCODE_MOTION_MODES));
|
||||
|
||||
// DRILL CYCLES (G73-99)
|
||||
cap_line(F("DRILL_CYCLES"), ENABLED(DRILL_CYCLES));
|
||||
|
||||
// ARC_SUPPORT (G2-G3)
|
||||
cap_line(F("ARCS"), ENABLED(ARC_SUPPORT));
|
||||
|
||||
|
|
|
|||
174
Marlin/src/gcode/motion/G81.cpp
Normal file
174
Marlin/src/gcode/motion/G81.cpp
Normal file
|
|
@ -0,0 +1,174 @@
|
|||
/**
|
||||
* Marlin 3D Printer Firmware
|
||||
* Copyright (c) 2020 MarlinFirmware [https://github.com/MarlinFirmware/Marlin]
|
||||
*
|
||||
* Based on Sprinter and grbl.
|
||||
* Copyright (c) 2011 Camiel Gubbels / Erik van der Zalm
|
||||
*
|
||||
* This program 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.
|
||||
*
|
||||
* This program 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 this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
*
|
||||
*/
|
||||
|
||||
#include "../../inc/MarlinConfig.h"
|
||||
|
||||
#if ENABLED(DRILL_CYCLES)
|
||||
|
||||
#include "../gcode.h"
|
||||
#include "../../module/motion.h"
|
||||
|
||||
/**
|
||||
* G73: Shallow peck drill cycle
|
||||
* G80: Cancel drill cycle
|
||||
* G81: Basic drill cycle
|
||||
* G82: Normal drill cycle (Basic with dwell)
|
||||
* G83: Deep drill cycle (Normal with peck)
|
||||
* G98: Start drill - retract to initial
|
||||
* G99: Start drill - retract to specified
|
||||
*/
|
||||
|
||||
//#define DRILL_CYCLE_DEBUG
|
||||
|
||||
bool retract_to_initial = true;
|
||||
bool drill_cycle_started = false;
|
||||
|
||||
void move_to_XYZF(float x, float y, float z, uint16_t f) {
|
||||
char gcode_str[50], x_str[10], y_str[10], z_str[10];
|
||||
dtostrf(x, 1, 3, x_str);
|
||||
dtostrf(y, 1, 3, y_str);
|
||||
dtostrf(z, 1, 3, z_str);
|
||||
|
||||
sprintf_P(gcode_str, PSTR("G1 X%s Y%s Z%s F%d"), x_str, y_str, z_str, f);
|
||||
#if ENABLED(DRILL_CYCLE_DEBUG)
|
||||
SERIAL_ECHOPGM("DEBUG: ", gcode_str);
|
||||
#endif
|
||||
gcode.process_subcommands_now(gcode_str);
|
||||
}
|
||||
|
||||
void drill_start(bool initial) {
|
||||
if(!drill_cycle_started) {
|
||||
drill_cycle_started = true;
|
||||
retract_to_initial = initial;
|
||||
}
|
||||
}
|
||||
|
||||
void drill_stop() {
|
||||
drill_cycle_started = false;
|
||||
}
|
||||
|
||||
void drill_cycle(uint8_t mode) {
|
||||
if(!drill_cycle_started) return;
|
||||
|
||||
bool allow_peck = mode == 83 || mode == 73;
|
||||
bool allow_dwell = mode == 82 || mode == 83 || mode == 73;
|
||||
|
||||
float drill_x_position = parser.seenval(AXIS_CHAR(X_AXIS)) ? parser.value_float() : NATIVE_TO_LOGICAL(current_position.x, X_AXIS);
|
||||
float drill_y_position = parser.seenval(AXIS_CHAR(Y_AXIS)) ? parser.value_float() : NATIVE_TO_LOGICAL(current_position.y, Y_AXIS);
|
||||
float drill_initial_z = NATIVE_TO_LOGICAL(current_position.z, Z_AXIS);
|
||||
|
||||
if(!parser.seenval(AXIS_CHAR(Z_AXIS))) return;
|
||||
float drill_finish_depth = parser.value_float();
|
||||
|
||||
float drill_rapid_z = parser.seenval('R') ? parser.value_float() : drill_initial_z;
|
||||
float drill_retract_z = retract_to_initial ? drill_initial_z : drill_rapid_z;
|
||||
float drill_current_depth = drill_rapid_z;
|
||||
|
||||
uint16_t drill_feedrate = parser.seenval('F') ? parser.value_int() : (drill_feedrate > 0 ? drill_feedrate : DRILL_CYCLES_DEFAULT_FEEDRATE);
|
||||
float drill_peck_distance = allow_peck ? (parser.seenval('Q') ? parser.value_float() : (DRILL_CYCLES_DEFAULT_PECK > 0 ? DRILL_CYCLES_DEFAULT_PECK : 10000)) : 10000;
|
||||
uint16_t drill_dwell_time = allow_dwell ? (parser.seenval('P') ? parser.value_int() : DRILL_CYCLES_DEFAULT_DWELL) : 0;
|
||||
|
||||
//move to initial xy position
|
||||
move_to_XYZF(drill_x_position,
|
||||
drill_y_position,
|
||||
drill_initial_z,
|
||||
DRILL_CYCLES_XY_FEEDRATE);
|
||||
|
||||
//move to rapid z position
|
||||
move_to_XYZF(drill_x_position,
|
||||
drill_y_position,
|
||||
drill_rapid_z,
|
||||
DRILL_CYCLES_RETRACT_FEEDRATE);
|
||||
|
||||
//start drill cycle
|
||||
float drill_last_z = drill_rapid_z;
|
||||
while(drill_current_depth > drill_finish_depth) {
|
||||
//calculate new drill depth
|
||||
drill_current_depth -= drill_peck_distance;
|
||||
if(drill_current_depth < drill_finish_depth) drill_current_depth = drill_finish_depth;
|
||||
|
||||
//drill into material
|
||||
move_to_XYZF(drill_x_position,
|
||||
drill_y_position,
|
||||
drill_current_depth,
|
||||
drill_feedrate);
|
||||
|
||||
//do dwell
|
||||
if(drill_dwell_time > 0) {
|
||||
char gcode_str[15];
|
||||
sprintf_P(gcode_str, PSTR("G4 P%d"), drill_dwell_time);
|
||||
#if ENABLED(DRILL_CYCLE_DEBUG)
|
||||
SERIAL_ECHOPGM("DEBUG: ", gcode_str);
|
||||
#endif
|
||||
gcode.process_subcommands_now(gcode_str);
|
||||
}
|
||||
|
||||
//move to rapid z position
|
||||
move_to_XYZF(drill_x_position,
|
||||
drill_y_position,
|
||||
mode == 73 ? drill_last_z : drill_rapid_z,
|
||||
DRILL_CYCLES_RETRACT_FEEDRATE);
|
||||
|
||||
//store current depth
|
||||
drill_last_z = drill_current_depth;
|
||||
}
|
||||
|
||||
//retract to final z
|
||||
move_to_XYZF(drill_x_position,
|
||||
drill_y_position,
|
||||
drill_retract_z,
|
||||
DRILL_CYCLES_RETRACT_FEEDRATE);
|
||||
}
|
||||
|
||||
void GcodeSuite::G81(uint8_t mode) {
|
||||
switch(mode) {
|
||||
case 0:
|
||||
drill_stop();
|
||||
break;
|
||||
|
||||
case 1:
|
||||
drill_cycle(81);
|
||||
break;
|
||||
|
||||
case 2:
|
||||
drill_cycle(82);
|
||||
break;
|
||||
|
||||
case 3:
|
||||
drill_cycle(83);
|
||||
break;
|
||||
|
||||
case 4:
|
||||
drill_cycle(73);
|
||||
break;
|
||||
|
||||
case 18:
|
||||
drill_start(true);
|
||||
break;
|
||||
|
||||
case 19:
|
||||
drill_start(false);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
#endif // DRILL_CYCLES
|
||||
|
|
@ -349,6 +349,7 @@ HAS_MULTI_LANGUAGE = build_src_filter=+<src/gcode/lcd/M414.c
|
|||
TOUCH_SCREEN_CALIBRATION = build_src_filter=+<src/gcode/lcd/M995.cpp>
|
||||
ARC_SUPPORT = build_src_filter=+<src/gcode/motion/G2_G3.cpp>
|
||||
GCODE_MOTION_MODES = build_src_filter=+<src/gcode/motion/G80.cpp>
|
||||
DRILL_CYCLES = build_src_filter=+<src/gcode/motion/G81.cpp>
|
||||
BABYSTEPPING = build_src_filter=+<src/gcode/motion/M290.cpp> +<src/feature/babystep.cpp>
|
||||
OTA_FIRMWARE_UPDATE = build_src_filter=+<src/gcode/ota/M936.cpp>
|
||||
Z_PROBE_SLED = build_src_filter=+<src/gcode/probe/G31_G32.cpp>
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue