Import Marcios EMI Filtering
This commit is contained in:
@@ -6,6 +6,10 @@
|
||||
|
||||
//#define TazDualZ
|
||||
|
||||
#if ENABLED(TazPro)
|
||||
#define EMI_MITIGATION
|
||||
#endif
|
||||
|
||||
/**
|
||||
* Marlin 3D Printer Firmware
|
||||
* Copyright (c) 2020 MarlinFirmware [https://github.com/MarlinFirmware/Marlin]
|
||||
|
||||
@@ -1535,6 +1535,10 @@ void setup() {
|
||||
i2c.onRequest(i2c_on_request);
|
||||
#endif
|
||||
|
||||
#if ENABLED(EMI_MITIGATION)
|
||||
SETUP_RUN(emi_init());
|
||||
#endif
|
||||
|
||||
#if DO_SWITCH_EXTRUDER
|
||||
SETUP_RUN(move_extruder_servo(0)); // Initialize extruder servo
|
||||
#endif
|
||||
|
||||
@@ -853,6 +853,10 @@ void GcodeSuite::G425() {
|
||||
TEMPORARY_BED_LEVELING_STATE(false);
|
||||
SET_SOFT_ENDSTOP_LOOSE(true);
|
||||
|
||||
#if ENABLED(EMI_MITIGATION) && ENABLED(NOZZLE_AS_PROBE)
|
||||
enable_emi_pins(true);
|
||||
#endif
|
||||
|
||||
measurements_t m;
|
||||
const float uncertainty = parser.floatval('U', CALIBRATION_MEASUREMENT_UNCERTAIN);
|
||||
|
||||
@@ -880,6 +884,10 @@ void GcodeSuite::G425() {
|
||||
|
||||
SET_SOFT_ENDSTOP_LOOSE(false);
|
||||
|
||||
#if ENABLED(EMI_MITIGATION) && ENABLED(NOZZLE_AS_PROBE)
|
||||
enable_emi_pins(false);
|
||||
#endif
|
||||
|
||||
#ifdef CALIBRATION_SCRIPT_POST
|
||||
process_subcommands_now(F(CALIBRATION_SCRIPT_POST));
|
||||
#endif
|
||||
|
||||
@@ -27,7 +27,11 @@
|
||||
* M119: Output endstop states to serial output
|
||||
*/
|
||||
void GcodeSuite::M119() {
|
||||
|
||||
#if ENABLED(EMI_MITIGATION)
|
||||
enable_emi_pins(true);
|
||||
#endif
|
||||
endstops.report_states();
|
||||
|
||||
#if ENABLED(EMI_MITIGATION)
|
||||
enable_emi_pins(false);
|
||||
#endif
|
||||
}
|
||||
|
||||
@@ -53,6 +53,9 @@
|
||||
#include "../core/language.h"
|
||||
#include "../core/utility.h"
|
||||
#include "../core/serial.h"
|
||||
#if ENABLED(EMI_MITIGATION)
|
||||
#include "../lulzbot_emi_filtering.h"
|
||||
#endif
|
||||
|
||||
#endif
|
||||
|
||||
|
||||
@@ -30,7 +30,7 @@
|
||||
|
||||
#if ENABLED(SHOW_CUSTOM_BOOTSCREEN)
|
||||
#if ENABLED(TOUCH_UI_PORTRAIT)
|
||||
#include "../theme/bootscreen_logo_portrait.h"
|
||||
#include "../theme/_bootscreen_logo_portrait.h"
|
||||
#else
|
||||
#include "../theme/_bootscreen_landscape.h"
|
||||
#endif
|
||||
|
||||
@@ -31,10 +31,16 @@ using namespace ExtUI;
|
||||
|
||||
void EndstopStatesScreen::onEntry() {
|
||||
BaseScreen::onEntry();
|
||||
#if ENABLED(EMI_MITIGATION)
|
||||
enable_emi_pins(true);
|
||||
#endif
|
||||
}
|
||||
|
||||
void EndstopStatesScreen::onExit() {
|
||||
BaseScreen::onExit();
|
||||
#if ENABLED(EMI_MITIGATION)
|
||||
enable_emi_pins(false);
|
||||
#endif
|
||||
}
|
||||
|
||||
#define GRID_COLS 6
|
||||
|
||||
File diff suppressed because one or more lines are too long
@@ -0,0 +1,79 @@
|
||||
/******************************
|
||||
* lulzbot_emi_filtering.cpp *
|
||||
******************************/
|
||||
|
||||
/****************************************************************************
|
||||
* Written By Marcio Teixeira 2020 *
|
||||
* *
|
||||
* 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. *
|
||||
* *
|
||||
* To view a copy of the GNU General Public License, go to the following *
|
||||
* location: <http://www.gnu.org/licenses/>. *
|
||||
****************************************************************************/
|
||||
|
||||
#include "MarlinCore.h"
|
||||
|
||||
#include "lulzbot_emi_filtering.h"
|
||||
|
||||
/******************************** EMI MITIGATION *******************************/
|
||||
|
||||
#if ENABLED(EMI_MITIGATION)
|
||||
void emi_init(void) {
|
||||
enable_emi_pins(false);
|
||||
|
||||
#define EMI_SHUTOFF(pin) SET_OUTPUT(pin); WRITE(pin, LOW);
|
||||
|
||||
#if MB(ARCHIM2)
|
||||
//EMI_SHUTOFF(GPIO_PB1_J20_5)
|
||||
EMI_SHUTOFF(GPIO_PB0_J20_6)
|
||||
EMI_SHUTOFF(GPIO_PB3_J20_7)
|
||||
EMI_SHUTOFF(GPIO_PB2_J20_8)
|
||||
EMI_SHUTOFF(GPIO_PB6_J20_9)
|
||||
EMI_SHUTOFF(GPIO_PB5_J20_10)
|
||||
EMI_SHUTOFF(GPIO_PB8_J20_11)
|
||||
EMI_SHUTOFF(GPIO_PB4_J20_12)
|
||||
EMI_SHUTOFF(GPIO_PB9_J20_13)
|
||||
EMI_SHUTOFF(GPIO_PB7_J20_14)
|
||||
//EMI_SHUTOFF(GPIO_PB15_J20_15)
|
||||
//EMI_SHUTOFF(GPIO_PB15_J20_16)
|
||||
EMI_SHUTOFF(GPIO_PB14_J20_17)
|
||||
EMI_SHUTOFF(GPIO_PA18_J20_21)
|
||||
EMI_SHUTOFF(GPIO_PA17_J20_22)
|
||||
#endif
|
||||
}
|
||||
|
||||
#define SET_PIN_STATE(pin, enable) \
|
||||
if(enable) { \
|
||||
/* Set as inputs with pull-up resistor */ \
|
||||
SET_INPUT(pin); \
|
||||
WRITE(pin, HIGH); \
|
||||
} else { \
|
||||
SET_OUTPUT(pin); \
|
||||
WRITE(pin, LOW); \
|
||||
}
|
||||
|
||||
/* Enable the probe pins only only when homing/probing,
|
||||
* as this helps reduce EMI by grounding the lines.
|
||||
*/
|
||||
void enable_emi_pins(const bool enable) {
|
||||
#if DISABLED(ENDSTOPS_ALWAYS_ON_DEFAULT) && ENABLED(NOZZLE_AS_PROBE)
|
||||
#if PIN_EXISTS(Z_MIN_PIN)
|
||||
SET_PIN_STATE(Z_MIN_PIN, enable);
|
||||
#endif
|
||||
#endif
|
||||
#if PIN_EXISTS(Z_MIN_PROBE) && ENABLED(NOZZLE_AS_PROBE)
|
||||
SET_PIN_STATE(Z_MIN_PROBE_PIN, enable)
|
||||
#endif
|
||||
|
||||
/* Wait to charge up the lines */
|
||||
if(enable) delay(5);
|
||||
}
|
||||
#endif
|
||||
@@ -0,0 +1,30 @@
|
||||
/****************************
|
||||
* drunken_octopus_extras.h *
|
||||
****************************/
|
||||
|
||||
/****************************************************************************
|
||||
* Written By Marcio Teixeira 2020 *
|
||||
* *
|
||||
* 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. *
|
||||
* *
|
||||
* To view a copy of the GNU General Public License, go to the following *
|
||||
* location: <http://www.gnu.org/licenses/>. *
|
||||
****************************************************************************/
|
||||
|
||||
#pragma once
|
||||
#include <stdbool.h>
|
||||
|
||||
/******************************** EMI MITIGATION *******************************/
|
||||
|
||||
#if ENABLED(EMI_MITIGATION)
|
||||
void emi_init(void);
|
||||
void enable_emi_pins(const bool);
|
||||
#endif
|
||||
@@ -1922,6 +1922,10 @@ void prepare_line_to_destination() {
|
||||
}
|
||||
#endif
|
||||
|
||||
#if ENABLED(EMI_MITIGATION)
|
||||
enable_emi_pins(true);
|
||||
#endif
|
||||
|
||||
//
|
||||
// Back away to prevent an early sensorless trigger
|
||||
//
|
||||
@@ -2208,6 +2212,10 @@ void prepare_line_to_destination() {
|
||||
}
|
||||
#endif
|
||||
|
||||
#if ENABLED(EMI_MITIGATION)
|
||||
enable_emi_pins(false);
|
||||
#endif
|
||||
|
||||
// Clear retracted status if homing the Z axis
|
||||
#if ENABLED(FWRETRACT)
|
||||
if (axis == Z_AXIS) fwretract.current_hop = 0.0;
|
||||
|
||||
@@ -268,6 +268,9 @@ xyz_pos_t Probe::offset; // Initialized by settings.load()
|
||||
#endif
|
||||
|
||||
void Probe::set_probing_paused(const bool dopause) {
|
||||
#if ENABLED(EMI_MITIGATION) && ENABLED(NOZZLE_AS_PROBE)
|
||||
enable_emi_pins(p);
|
||||
#endif
|
||||
TERN_(PROBING_HEATERS_OFF, thermalManager.pause_heaters(dopause));
|
||||
TERN_(PROBING_FANS_OFF, thermalManager.set_fans_paused(dopause));
|
||||
TERN_(PROBING_ESTEPPERS_OFF, if (dopause) stepper.disable_e_steppers());
|
||||
|
||||
Reference in New Issue
Block a user