1
0
mirror of https://github.com/MarlinFirmware/Marlin.git synced 2024-11-26 21:36:21 +00:00

BLTouch High Speed mode runtime configuration (#22916, #23337)

Co-Authored-By: Scott Lahteine <thinkyhead@users.noreply.github.com>
This commit is contained in:
InsanityAutomation 2021-12-21 23:09:55 -05:00 committed by Scott Lahteine
parent e0bed1e344
commit 9ecfa1d252
15 changed files with 140 additions and 63 deletions

View File

@ -897,12 +897,14 @@
//#define BLTOUCH_FORCE_MODE_SET
/**
* Use "HIGH SPEED" mode for probing.
* Enable "HIGH SPEED" option for probing.
* Danger: Disable if your probe sometimes fails. Only suitable for stable well-adjusted systems.
* This feature was designed for Deltabots with very fast Z moves; however, higher speed Cartesians
* might be able to use it. If the machine can't raise Z fast enough the BLTouch may go into ALARM.
*
* Set the default state here, change with 'M401 S' or UI, use M500 to save, M502 to reset.
*/
//#define BLTOUCH_HS_MODE
//#define BLTOUCH_HS_MODE true
// Safety: Enable voltage mode settings in the LCD menu.
//#define BLTOUCH_LCD_VOLTAGE_MENU

View File

@ -28,7 +28,12 @@
BLTouch bltouch;
bool BLTouch::last_written_mode; // Initialized by settings.load, 0 = Open Drain; 1 = 5V Drain
bool BLTouch::od_5v_mode; // Initialized by settings.load, 0 = Open Drain; 1 = 5V Drain
#ifdef BLTOUCH_HS_MODE
bool BLTouch::high_speed_mode; // Initialized by settings.load, 0 = Low Speed; 1 = High Speed
#else
constexpr bool BLTouch::high_speed_mode;
#endif
#include "../module/servo.h"
#include "../module/probe.h"
@ -63,18 +68,17 @@ void BLTouch::init(const bool set_voltage/*=false*/) {
#else
if (DEBUGGING(LEVELING)) {
DEBUG_ECHOLNPGM("last_written_mode - ", last_written_mode);
DEBUG_ECHOLNPGM("config mode - "
#if ENABLED(BLTOUCH_SET_5V_MODE)
"BLTOUCH_SET_5V_MODE"
#else
"OD"
#endif
);
}
#ifdef DEBUG_OUT
if (DEBUGGING(LEVELING)) {
PGMSTR(mode0, "OD");
PGMSTR(mode1, "5V");
DEBUG_ECHOPGM("BLTouch Mode: ");
DEBUG_ECHOPGM_P(bltouch.od_5v_mode ? mode1 : mode0);
DEBUG_ECHOLNPGM(" (Default " TERN(BLTOUCH_SET_5V_MODE, "5V", "OD") ")");
}
#endif
const bool should_set = last_written_mode != ENABLED(BLTOUCH_SET_5V_MODE);
const bool should_set = od_5v_mode != ENABLED(BLTOUCH_SET_5V_MODE);
#endif
@ -193,7 +197,7 @@ void BLTouch::mode_conv_proc(const bool M5V) {
_mode_store();
if (M5V) _set_5V_mode(); else _set_OD_mode();
_stow();
last_written_mode = M5V;
od_5v_mode = M5V;
}
#endif // BLTOUCH

View File

@ -23,10 +23,6 @@
#include "../inc/MarlinConfigPre.h"
#if DISABLED(BLTOUCH_HS_MODE)
#define BLTOUCH_SLOW_MODE 1
#endif
// BLTouch commands are sent as servo angles
typedef unsigned char BLTCommand;
@ -70,8 +66,17 @@ typedef unsigned char BLTCommand;
class BLTouch {
public:
static void init(const bool set_voltage=false);
static bool last_written_mode; // Initialized by settings.load, 0 = Open Drain; 1 = 5V Drain
static bool od_5v_mode; // Initialized by settings.load, 0 = Open Drain; 1 = 5V Drain
#ifdef BLTOUCH_HS_MODE
static bool high_speed_mode; // Initialized by settings.load, 0 = Low Speed; 1 = High Speed
#else
static constexpr bool high_speed_mode = false;
#endif
static inline float z_extra_clearance() { return high_speed_mode ? 7 : 0; }
// DEPLOY and STOW are wrapped for error handling - these are used by homing and by probing
static bool deploy() { return deploy_proc(); }

View File

@ -33,6 +33,10 @@
#include "../../module/tool_change.h"
#endif
#if ENABLED(BLTOUCH)
#include "../../feature/bltouch.h"
#endif
#define DEBUG_OUT ENABLED(DEBUG_LEVELING_FEATURE)
#include "../../core/debug_out.h"
@ -102,7 +106,7 @@ void GcodeSuite::G35() {
// In BLTOUCH HS mode, the probe travels in a deployed state.
// Users of G35 might have a badly misaligned bed, so raise Z by the
// length of the deployed pin (BLTOUCH stroke < 7mm)
do_blocking_move_to_z(SUM_TERN(BLTOUCH_HS_MODE, Z_CLEARANCE_BETWEEN_PROBES, 7));
do_blocking_move_to_z(Z_CLEARANCE_BETWEEN_PROBES + TERN0(BLTOUCH, bltouch.z_extra_clearance()));
const float z_probed_height = probe.probe_at_point(tramming_points[i], PROBE_PT_RAISE, 0, true);
if (isnan(z_probed_height)) {

View File

@ -45,6 +45,10 @@
#include "../../libs/least_squares_fit.h"
#endif
#if ENABLED(BLTOUCH)
#include "../../feature/bltouch.h"
#endif
#define DEBUG_OUT ENABLED(DEBUG_LEVELING_FEATURE)
#include "../../core/debug_out.h"
@ -149,7 +153,7 @@ void GcodeSuite::G34() {
// In BLTOUCH HS mode, the probe travels in a deployed state.
// Users of G34 might have a badly misaligned bed, so raise Z by the
// length of the deployed pin (BLTOUCH stroke < 7mm)
#define Z_BASIC_CLEARANCE (Z_CLEARANCE_BETWEEN_PROBES + 7.0f * BOTH(BLTOUCH, BLTOUCH_HS_MODE))
#define Z_BASIC_CLEARANCE (Z_CLEARANCE_BETWEEN_PROBES + TERN0(BLTOUCH, bltouch.z_extra_clearance()))
// Compute a worst-case clearance height to probe from. After the first
// iteration this will be re-calculated based on the actual bed position

View File

@ -28,13 +28,27 @@
#include "../../module/motion.h"
#include "../../module/probe.h"
#ifdef BLTOUCH_HS_MODE
#include "../../feature/bltouch.h"
#endif
/**
* M401: Deploy and activate the Z probe
*
* With BLTOUCH_HS_MODE:
* S<bool> Set High Speed (HS) Mode and exit without deploy
*/
void GcodeSuite::M401() {
probe.deploy();
TERN_(PROBE_TARE, probe.tare());
report_current_position();
if (parser.seen('S')) {
#ifdef BLTOUCH_HS_MODE
bltouch.high_speed_mode = parser.value_bool();
#endif
}
else {
probe.deploy();
TERN_(PROBE_TARE, probe.tare());
report_current_position();
}
}
/**

View File

@ -1579,6 +1579,9 @@ static_assert(Y_MAX_LENGTH >= Y_BED_SIZE, "Movement bounds (Y_MIN_POS, Y_MAX_POS
#endif
#endif
#if ENABLED(BLTOUCH_HS_MODE) && BLTOUCH_HS_MODE == 0
#error "BLTOUCH_HS_MODE must now be defined as true or false, indicating the default state."
#endif
#if BLTOUCH_DELAY < 200
#error "BLTOUCH_DELAY less than 200 is unsafe and is not supported."
#endif

View File

@ -491,6 +491,7 @@ namespace Language_en {
LSTR MSG_BLTOUCH_STOW = _UxGT("Stow");
LSTR MSG_BLTOUCH_DEPLOY = _UxGT("Deploy");
LSTR MSG_BLTOUCH_SW_MODE = _UxGT("SW-Mode");
LSTR MSG_BLTOUCH_SPEED_MODE = _UxGT("High Speed");
LSTR MSG_BLTOUCH_5V_MODE = _UxGT("5V-Mode");
LSTR MSG_BLTOUCH_OD_MODE = _UxGT("OD-Mode");
LSTR MSG_BLTOUCH_MODE_STORE = _UxGT("Mode-Store");

View File

@ -217,13 +217,13 @@ static void _lcd_level_bed_corners_get_next_position() {
bool _lcd_level_bed_corners_probe(bool verify=false) {
if (verify) do_blocking_move_to_z(current_position.z + LEVEL_CORNERS_Z_HOP); // do clearance if needed
TERN_(BLTOUCH_SLOW_MODE, bltouch.deploy()); // Deploy in LOW SPEED MODE on every probe action
TERN_(BLTOUCH, if (!bltouch.high_speed_mode) bltouch.deploy()); // Deploy in LOW SPEED MODE on every probe action
do_blocking_move_to_z(last_z - LEVEL_CORNERS_PROBE_TOLERANCE, MMM_TO_MMS(Z_PROBE_FEEDRATE_SLOW)); // Move down to lower tolerance
if (TEST(endstops.trigger_state(), Z_MIN_PROBE)) { // check if probe triggered
endstops.hit_on_purpose();
set_current_from_steppers_for_axis(Z_AXIS);
sync_plan_position();
TERN_(BLTOUCH_SLOW_MODE, bltouch.stow()); // Stow in LOW SPEED MODE on every trigger
TERN_(BLTOUCH, if (!bltouch.high_speed_mode) bltouch.stow()); // Stow in LOW SPEED MODE on every trigger
// Triggered outside tolerance range?
if (ABS(current_position.z - last_z) > LEVEL_CORNERS_PROBE_TOLERANCE) {
last_z = current_position.z; // Above tolerance. Set a new Z for subsequent corners.
@ -249,7 +249,7 @@ static void _lcd_level_bed_corners_get_next_position() {
}
idle();
}
TERN_(BLTOUCH_SLOW_MODE, bltouch.stow());
TERN_(BLTOUCH, if (!bltouch.high_speed_mode) bltouch.stow());
ui.goto_screen(_lcd_draw_probing);
return (probe_triggered);
}
@ -263,13 +263,14 @@ static void _lcd_level_bed_corners_get_next_position() {
do {
ui.refresh(LCDVIEW_REDRAW_NOW);
_lcd_draw_probing(); // update screen with # of good points
do_blocking_move_to_z(SUM_TERN(BLTOUCH_HS_MODE, current_position.z + LEVEL_CORNERS_Z_HOP, 7)); // clearance
do_blocking_move_to_z(current_position.z + LEVEL_CORNERS_Z_HOP + TERN0(BLTOUCH, bltouch.z_extra_clearance())); // clearance
_lcd_level_bed_corners_get_next_position(); // Select next corner coordinates
current_position -= probe.offset_xy; // Account for probe offsets
do_blocking_move_to_xy(current_position); // Goto corner
TERN_(BLTOUCH_HS_MODE, bltouch.deploy()); // Deploy in HIGH SPEED MODE
TERN_(BLTOUCH, if (bltouch.high_speed_mode) bltouch.deploy()); // Deploy in HIGH SPEED MODE
if (!_lcd_level_bed_corners_probe()) { // Probe down to tolerance
if (_lcd_level_bed_corners_raise()) { // Prompt user to raise bed if needed
#if ENABLED(LEVEL_CORNERS_VERIFY_RAISED) // Verify
@ -290,10 +291,12 @@ static void _lcd_level_bed_corners_get_next_position() {
} while (good_points < nr_edge_points); // loop until all points within tolerance
#if ENABLED(BLTOUCH_HS_MODE)
// In HIGH SPEED MODE do clearance and stow at the very end
do_blocking_move_to_z(current_position.z + LEVEL_CORNERS_Z_HOP);
bltouch.stow();
#if ENABLED(BLTOUCH)
if (bltouch.high_speed_mode) {
// In HIGH SPEED MODE do clearance and stow at the very end
do_blocking_move_to_z(current_position.z + LEVEL_CORNERS_Z_HOP);
bltouch.stow();
}
#endif
ui.goto_screen(_lcd_draw_level_prompt); // prompt for bed leveling

View File

@ -53,6 +53,8 @@
#include "../../libs/buzzer.h"
#endif
#include "../../core/debug_out.h"
#define HAS_DEBUG_MENU ENABLED(LCD_PROGRESS_BAR_TEST)
void menu_advanced_settings();
@ -217,11 +219,14 @@ void menu_advanced_settings();
#if ENABLED(BLTOUCH_LCD_VOLTAGE_MENU)
void bltouch_report() {
SERIAL_ECHOLNPGM("EEPROM Last BLTouch Mode - ", bltouch.last_written_mode);
SERIAL_ECHOLNPGM("Configuration BLTouch Mode - " TERN(BLTOUCH_SET_5V_MODE, "5V", "OD"));
PGMSTR(mode0, "OD");
PGMSTR(mode1, "5V");
DEBUG_ECHOPGM("BLTouch Mode: ");
DEBUG_ECHOPGM_P(bltouch.od_5v_mode ? mode1 : mode0);
DEBUG_ECHOLNPGM(" (Default " TERN(BLTOUCH_SET_5V_MODE, "5V", "OD") ")");
char mess[21];
strcpy_P(mess, PSTR("BLTouch Mode - "));
strcpy_P(&mess[15], bltouch.last_written_mode ? PSTR("5V") : PSTR("OD"));
strcpy_P(mess, PSTR("BLTouch Mode: "));
strcpy_P(&mess[15], bltouch.od_5v_mode ? mode1 : mode0);
ui.set_status(mess);
ui.return_to_status();
}
@ -235,6 +240,9 @@ void menu_advanced_settings();
ACTION_ITEM(MSG_BLTOUCH_DEPLOY, bltouch._deploy);
ACTION_ITEM(MSG_BLTOUCH_STOW, bltouch._stow);
ACTION_ITEM(MSG_BLTOUCH_SW_MODE, bltouch._set_SW_mode);
#ifdef BLTOUCH_HS_MODE
EDIT_ITEM(bool, MSG_BLTOUCH_SPEED_MODE, &bltouch.high_speed_mode);
#endif
#if ENABLED(BLTOUCH_LCD_VOLTAGE_MENU)
CONFIRM_ITEM(MSG_BLTOUCH_5V_MODE, MSG_BLTOUCH_5V_MODE, MSG_BUTTON_CANCEL, bltouch._set_5V_mode, nullptr, GET_TEXT(MSG_BLTOUCH_MODE_CHANGE));
CONFIRM_ITEM(MSG_BLTOUCH_OD_MODE, MSG_BLTOUCH_OD_MODE, MSG_BUTTON_CANCEL, bltouch._set_OD_mode, nullptr, GET_TEXT(MSG_BLTOUCH_MODE_CHANGE));

View File

@ -36,6 +36,10 @@
#include "../../module/probe.h"
#include "../../gcode/queue.h"
#if ENABLED(BLTOUCH)
#include "../../feature/bltouch.h"
#endif
//#define DEBUG_OUT 1
#include "../../core/debug_out.h"
@ -51,7 +55,7 @@ static int8_t reference_index; // = 0
static bool probe_single_point() {
do_blocking_move_to_z(TERN(BLTOUCH, Z_CLEARANCE_DEPLOY_PROBE, Z_CLEARANCE_BETWEEN_PROBES));
// Stow after each point with BLTouch "HIGH SPEED" mode for push-pin safety
const float z_probed_height = probe.probe_at_point(tramming_points[tram_index], TERN(BLTOUCH_HS_MODE, PROBE_PT_STOW, PROBE_PT_RAISE), 0, true);
const float z_probed_height = probe.probe_at_point(tramming_points[tram_index], TERN0(BLTOUCH, bltouch.high_speed_mode) ? PROBE_PT_STOW : PROBE_PT_RAISE, 0, true);
z_measured[tram_index] = z_probed_height;
if (reference_index < 0) reference_index = tram_index;
move_to_tramming_wait_pos();

View File

@ -1803,8 +1803,8 @@ void prepare_line_to_destination() {
if (DEBUGGING(LEVELING)) DEBUG_ECHOLNPGM("Home Fast: ", move_length, "mm");
do_homing_move(axis, move_length, 0.0, !use_probe_bump);
#if BOTH(HOMING_Z_WITH_PROBE, BLTOUCH_SLOW_MODE)
if (axis == Z_AXIS) bltouch.stow(); // Intermediate STOW (in LOW SPEED MODE)
#if BOTH(HOMING_Z_WITH_PROBE, BLTOUCH)
if (axis == Z_AXIS && !bltouch.high_speed_mode) bltouch.stow(); // Intermediate STOW (in LOW SPEED MODE)
#endif
// If a second homing move is configured...
@ -1837,8 +1837,9 @@ void prepare_line_to_destination() {
}
#endif
#if BOTH(HOMING_Z_WITH_PROBE, BLTOUCH_SLOW_MODE)
if (axis == Z_AXIS && bltouch.deploy()) return; // Intermediate DEPLOY (in LOW SPEED MODE)
#if BOTH(HOMING_Z_WITH_PROBE, BLTOUCH)
if (axis == Z_AXIS && !bltouch.high_speed_mode && bltouch.deploy())
return; // Intermediate DEPLOY (in LOW SPEED MODE)
#endif
// Slow move towards endstop until triggered

View File

@ -489,8 +489,10 @@ bool Probe::probe_down_to_z(const_float_t z, const_feedRate_t fr_mm_s) {
#if BOTH(HAS_TEMP_HOTEND, WAIT_FOR_HOTEND)
thermalManager.wait_for_hotend_heating(active_extruder);
#endif
if (TERN0(BLTOUCH_SLOW_MODE, bltouch.deploy())) return true; // Deploy in LOW SPEED MODE on every probe action
#if ENABLED(BLTOUCH)
if (!bltouch.high_speed_mode && bltouch.deploy())
return true; // Deploy in LOW SPEED MODE on every probe action
#endif
// Disable stealthChop if used. Enable diag1 pin on driver.
#if ENABLED(SENSORLESS_PROBING)
@ -531,8 +533,10 @@ bool Probe::probe_down_to_z(const_float_t z, const_feedRate_t fr_mm_s) {
set_homing_current(false);
#endif
if (probe_triggered && TERN0(BLTOUCH_SLOW_MODE, bltouch.stow())) // Stow in LOW SPEED MODE on every trigger
return true;
#if ENABLED(BLTOUCH)
if (probe_triggered && !bltouch.high_speed_mode && bltouch.stow())
return true; // Stow in LOW SPEED MODE on every trigger
#endif
// Clear endstop flags
endstops.hit_on_purpose();
@ -762,8 +766,9 @@ float Probe::probe_at_point(const_float_t rx, const_float_t ry, const ProbePtRai
DEBUG_POS("", current_position);
}
#if BOTH(BLTOUCH, BLTOUCH_HS_MODE)
if (bltouch.triggered()) bltouch._reset();
#if ENABLED(BLTOUCH)
if (bltouch.high_speed_mode && bltouch.triggered())
bltouch._reset();
#endif
// On delta keep Z below clip height or do_blocking_move_to will abort

View File

@ -301,7 +301,10 @@ typedef struct SettingsDataStruct {
//
// BLTOUCH
//
bool bltouch_last_written_mode;
bool bltouch_od_5v_mode;
#ifdef BLTOUCH_HS_MODE
bool bltouch_high_speed_mode; // M401 S
#endif
//
// Kinematic Settings
@ -918,9 +921,15 @@ void MarlinSettings::postprocess() {
// BLTOUCH
//
{
_FIELD_TEST(bltouch_last_written_mode);
const bool bltouch_last_written_mode = TERN(BLTOUCH, bltouch.last_written_mode, false);
EEPROM_WRITE(bltouch_last_written_mode);
_FIELD_TEST(bltouch_od_5v_mode);
const bool bltouch_od_5v_mode = TERN0(BLTOUCH, bltouch.od_5v_mode);
EEPROM_WRITE(bltouch_od_5v_mode);
#ifdef BLTOUCH_HS_MODE
_FIELD_TEST(bltouch_high_speed_mode);
const bool bltouch_high_speed_mode = TERN0(BLTOUCH, bltouch.high_speed_mode);
EEPROM_WRITE(bltouch_high_speed_mode);
#endif
}
//
@ -1810,13 +1819,23 @@ void MarlinSettings::postprocess() {
// BLTOUCH
//
{
_FIELD_TEST(bltouch_last_written_mode);
_FIELD_TEST(bltouch_od_5v_mode);
#if ENABLED(BLTOUCH)
const bool &bltouch_last_written_mode = bltouch.last_written_mode;
const bool &bltouch_od_5v_mode = bltouch.od_5v_mode;
#else
bool bltouch_last_written_mode;
bool bltouch_od_5v_mode;
#endif
EEPROM_READ(bltouch_od_5v_mode);
#ifdef BLTOUCH_HS_MODE
_FIELD_TEST(bltouch_high_speed_mode);
#if ENABLED(BLTOUCH)
const bool &bltouch_high_speed_mode = bltouch.high_speed_mode;
#else
bool bltouch_high_speed_mode;
#endif
EEPROM_READ(bltouch_high_speed_mode);
#endif
EEPROM_READ(bltouch_last_written_mode);
}
//
@ -2827,11 +2846,11 @@ void MarlinSettings::reset() {
TERN_(HAS_PTC, ptc.reset());
//
// BLTOUCH
// BLTouch
//
//#if ENABLED(BLTOUCH)
// bltouch.last_written_mode;
//#endif
#ifdef BLTOUCH_HS_MODE
bltouch.high_speed_mode = ENABLED(BLTOUCH_HS_MODE);
#endif
//
// Kinematic settings

View File

@ -10,8 +10,8 @@ restore_configs
opt_set MOTHERBOARD BOARD_BTT_GTR_V1_0 SERIAL_PORT 3 \
EXTRUDERS 8 TEMP_SENSOR_1 1 TEMP_SENSOR_2 1 TEMP_SENSOR_3 1 TEMP_SENSOR_4 1 TEMP_SENSOR_5 1 TEMP_SENSOR_6 1 TEMP_SENSOR_7 1
opt_enable SDSUPPORT USB_FLASH_DRIVE_SUPPORT USE_OTG_USB_HOST \
REPRAP_DISCOUNT_FULL_GRAPHIC_SMART_CONTROLLER BLTOUCH NEOPIXEL_LED Z_SAFE_HOMING \
FILAMENT_RUNOUT_SENSOR NOZZLE_PARK_FEATURE ADVANCED_PAUSE_FEATURE
REPRAP_DISCOUNT_FULL_GRAPHIC_SMART_CONTROLLER BLTOUCH LEVEL_BED_CORNERS LEVEL_CORNERS_USE_PROBE \
NEOPIXEL_LED Z_SAFE_HOMING FILAMENT_RUNOUT_SENSOR NOZZLE_PARK_FEATURE ADVANCED_PAUSE_FEATURE
# Not necessary to enable auto-fan for all extruders to hit problematic code paths
opt_set E0_AUTO_FAN_PIN PC10 E1_AUTO_FAN_PIN PC11 E2_AUTO_FAN_PIN PC12 NEOPIXEL_PIN PF13 \
X_DRIVER_TYPE TMC2208 Y_DRIVER_TYPE TMC2130 \