BLTouch V3.0 support (#13406)
parent
49cf92dc36
commit
691e5c3bb8
@ -0,0 +1,93 @@
|
||||
/**
|
||||
* Marlin 3D Printer Firmware
|
||||
* Copyright (C) 2019 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 <http://www.gnu.org/licenses/>.
|
||||
*
|
||||
*/
|
||||
|
||||
#include "../inc/MarlinConfig.h"
|
||||
|
||||
#if ENABLED(BLTOUCH)
|
||||
|
||||
#include "bltouch.h"
|
||||
|
||||
BLTouch bltouch;
|
||||
|
||||
#include "../module/servo.h"
|
||||
|
||||
void stop();
|
||||
|
||||
#define DEBUG_OUT ENABLED(DEBUG_LEVELING_FEATURE)
|
||||
#include "../core/debug_out.h"
|
||||
|
||||
void BLTouch::command(const BLTCommand cmd) {
|
||||
MOVE_SERVO(Z_PROBE_SERVO_NR, cmd);
|
||||
safe_delay(BLTOUCH_DELAY);
|
||||
}
|
||||
|
||||
void BLTouch::init() {
|
||||
reset(); // Clear all BLTouch error conditions
|
||||
stow();
|
||||
}
|
||||
|
||||
bool BLTouch::triggered() {
|
||||
return (
|
||||
#if ENABLED(Z_MIN_PROBE_USES_Z_MIN_ENDSTOP_PIN)
|
||||
READ(Z_MIN_PIN) != Z_MIN_ENDSTOP_INVERTING
|
||||
#else
|
||||
READ(Z_MIN_PROBE_PIN) != Z_MIN_PROBE_ENDSTOP_INVERTING
|
||||
#endif
|
||||
);
|
||||
}
|
||||
|
||||
bool BLTouch::set_deployed(const bool in_deploy) {
|
||||
if (in_deploy && triggered()) { // If BLTouch says it's triggered
|
||||
reset(); // try to reset it.
|
||||
_deploy(); _stow(); // Deploy and stow to clear the "triggered" condition.
|
||||
safe_delay(1500); // Wait for internal self-test to complete.
|
||||
// (Measured completion time was 0.65 seconds
|
||||
// after reset, deploy, and stow sequence)
|
||||
if (triggered()) { // If it still claims to be triggered...
|
||||
SERIAL_ERROR_MSG(MSG_STOP_BLTOUCH);
|
||||
stop(); // punt!
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
#if ENABLED(BLTOUCH_V3)
|
||||
#if ENABLED(BLTOUCH_FORCE_5V_MODE)
|
||||
set_5V_mode(); // Assume 5V DC logic level if endstop pullup resistors are enabled
|
||||
#else
|
||||
set_OD_mode();
|
||||
#endif
|
||||
#endif
|
||||
|
||||
if (in_deploy) {
|
||||
_deploy();
|
||||
#if ENABLED(BLTOUCH_V3)
|
||||
set_SW_mode(); // Ensure Switch mode is activated for BLTouch V3. Ignored on V2.
|
||||
#endif
|
||||
}
|
||||
else _stow();
|
||||
|
||||
if (DEBUGGING(LEVELING)) DEBUG_ECHOLNPAIR("bltouch.set_deployed(", in_deploy, ")");
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
#endif // BLTOUCH
|
@ -0,0 +1,59 @@
|
||||
/**
|
||||
* Marlin 3D Printer Firmware
|
||||
* Copyright (C) 2019 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 <http://www.gnu.org/licenses/>.
|
||||
*
|
||||
*/
|
||||
#pragma once
|
||||
|
||||
#include "../inc/MarlinConfigPre.h"
|
||||
|
||||
// BLTouch commands are sent as servo angles
|
||||
typedef unsigned char BLTCommand;
|
||||
|
||||
#define BLTOUCH_DEPLOY 10
|
||||
#define BLTOUCH_SW_MODE 60
|
||||
#define BLTOUCH_STOW 90
|
||||
#define BLTOUCH_SELFTEST 120
|
||||
#define BLTOUCH_5V_MODE 140
|
||||
#define BLTOUCH_OD_MODE 150
|
||||
#define BLTOUCH_RESET 160
|
||||
|
||||
class BLTouch {
|
||||
public:
|
||||
static void init();
|
||||
static void command(const BLTCommand cmd);
|
||||
static bool triggered();
|
||||
|
||||
FORCE_INLINE static void reset() { command(BLTOUCH_RESET); }
|
||||
FORCE_INLINE static void set_5V_mode() { command(BLTOUCH_5V_MODE); }
|
||||
FORCE_INLINE static void set_OD_mode() { command(BLTOUCH_OD_MODE); }
|
||||
FORCE_INLINE static void set_SW_mode() { command(BLTOUCH_SW_MODE); }
|
||||
|
||||
FORCE_INLINE static bool deploy() { return set_deployed(true); }
|
||||
FORCE_INLINE static bool stow() { return set_deployed(false); }
|
||||
|
||||
private:
|
||||
FORCE_INLINE static void _deploy() { command(BLTOUCH_DEPLOY); }
|
||||
FORCE_INLINE static void _stow() { command(BLTOUCH_STOW); }
|
||||
static bool set_deployed(const bool deploy);
|
||||
};
|
||||
|
||||
#define BLTOUCH_ANGLES { BLTOUCH_DEPLOY, BLTOUCH_STOW }
|
||||
|
||||
extern BLTouch bltouch;
|
Some files were not shown because too many files have changed in this diff Show More
Loading…
Reference in New Issue