Single nozzle filament change (#11994)

This commit is contained in:
InsanityAutomation
2018-10-07 18:06:14 -04:00
committed by Scott Lahteine
parent bfcf570d68
commit 74cd6cb4fc
94 changed files with 1267 additions and 38 deletions

View File

@ -98,6 +98,11 @@ typedef struct { int16_t X, Y, Z; } tmc
#include "../feature/pause.h"
#endif
#if ENABLED(SINGLENOZZLE)
#include "tool_change.h"
void M217_report(const bool eeprom);
#endif
#if ENABLED(PID_EXTRUSION_SCALING)
#define LPQ_LEN thermalManager.lpq_len
#endif
@ -289,6 +294,15 @@ typedef struct SettingsDataStruct {
float filament_change_unload_length[EXTRUDERS], // M603 T U
filament_change_load_length[EXTRUDERS]; // M603 T L
//
// SINGLENOZZLE toolchange values
//
#if ENABLED(SINGLENOZZLE)
float singlenozzle_swap_length; // M217 S
int16_t singlenozzle_prime_speed, // M217 P
singlenozzle_retract_speed; // M217 R
#endif
} SettingsData;
#pragma pack(pop)
@ -947,6 +961,17 @@ void MarlinSettings::postprocess() {
for (uint8_t q = EXTRUDERS * 2; q--;) EEPROM_WRITE(dummy);
#endif
//
// SINGLENOZZLE
//
#if ENABLED(SINGLENOZZLE)
_FIELD_TEST(singlenozzle_swap_length);
EEPROM_WRITE(singlenozzle_swap_length);
EEPROM_WRITE(singlenozzle_prime_speed);
EEPROM_WRITE(singlenozzle_retract_speed);
#endif
//
// Validate CRC and Data Size
//
@ -1582,6 +1607,17 @@ void MarlinSettings::postprocess() {
for (uint8_t q = EXTRUDERS * 2; q--;) EEPROM_READ(dummy);
#endif
//
// SINGLENOZZLE toolchange values
//
#if ENABLED(SINGLENOZZLE)
_FIELD_TEST(singlenozzle_swap_length);
EEPROM_READ(singlenozzle_swap_length);
EEPROM_READ(singlenozzle_prime_speed);
EEPROM_READ(singlenozzle_retract_speed);
#endif
eeprom_error = size_error(eeprom_index - (EEPROM_OFFSET));
if (eeprom_error) {
#if ENABLED(EEPROM_CHITCHAT)
@ -1840,6 +1876,12 @@ void MarlinSettings::reset(PORTARG_SOLO) {
#endif
#endif
#if ENABLED(SINGLENOZZLE)
singlenozzle_swap_length = SINGLENOZZLE_SWAP_LENGTH;
singlenozzle_prime_speed = SINGLENOZZLE_SWAP_PRIME_SPEED;
singlenozzle_retract_speed = SINGLENOZZLE_SWAP_RETRACT_SPEED;
#endif
//
// Global Leveling
//
@ -2897,6 +2939,15 @@ void MarlinSettings::reset(PORTARG_SOLO) {
#endif // EXTRUDERS > 2
#endif // EXTRUDERS == 1
#endif // ADVANCED_PAUSE_FEATURE
#if ENABLED(SINGLENOZZLE)
CONFIG_ECHO_START;
if (!forReplay) {
SERIAL_ECHOLNPGM_P(port, "SINGLENOZZLE:");
CONFIG_ECHO_START;
}
M217_report(true);
#endif
}
#endif // !DISABLE_M503

View File

@ -2416,6 +2416,17 @@ void Temperature::isr() {
#endif // AUTO_REPORT_TEMPERATURES
#if ENABLED(ULTRA_LCD)
void Temperature::set_heating_message(const uint8_t e) {
const bool heating = isHeatingHotend(e);
#if HOTENDS > 1
lcd_status_printf_P(0, heating ? PSTR("E%i " MSG_HEATING) : PSTR("E%i " MSG_COOLING), int(e + 1));
#else
lcd_setstatusPGM(heating ? PSTR("E " MSG_HEATING) : PSTR("E " MSG_COOLING));
#endif
}
#endif
#if HAS_TEMP_HOTEND
#ifndef MIN_COOLING_SLOPE_DEG

View File

@ -616,6 +616,10 @@ class Temperature {
#endif
#endif
#if ENABLED(ULTRA_LCD)
static void set_heating_message(const uint8_t e);
#endif
private:
#if ENABLED(FAST_PWM_FAN)
@ -659,7 +663,6 @@ class Temperature {
#endif
#endif // THERMAL_PROTECTION
};
extern Temperature thermalManager;

View File

@ -25,9 +25,24 @@
#include "probe.h"
#include "motion.h"
#include "planner.h"
#include "temperature.h"
#include "../Marlin.h"
#if ENABLED(SINGLENOZZLE)
float singlenozzle_swap_length = SINGLENOZZLE_SWAP_LENGTH;
int16_t singlenozzle_prime_speed = SINGLENOZZLE_SWAP_PRIME_SPEED,
singlenozzle_retract_speed = SINGLENOZZLE_SWAP_RETRACT_SPEED;
uint16_t singlenozzle_temp[EXTRUDERS];
#if FAN_COUNT > 0
uint8_t singlenozzle_fan_speed[EXTRUDERS];
#endif
#if ENABLED(SINGLENOZZLE_SWAP_PARK)
#include "../libs/point_t.h"
const point_t singlenozzle_change_point = SINGLENOZZLE_TOOLCHANGE_POSITION;
#endif
#endif
#if ENABLED(PARKING_EXTRUDER) && PARKING_EXTRUDER_SOLENOIDS_DELAY > 0
#include "../gcode/gcode.h" // for dwell()
#endif
@ -625,16 +640,89 @@ void tool_change(const uint8_t tmp_extruder, const float fr_mm_s/*=0.0*/, bool n
UNUSED(no_move);
#if ENABLED(MK2_MULTIPLEXER)
if (tmp_extruder >= E_STEPPERS)
return invalid_extruder_error(tmp_extruder);
if (tmp_extruder >= E_STEPPERS) return invalid_extruder_error(tmp_extruder);
select_multiplexed_stepper(tmp_extruder);
#endif
#if EXTRUDERS > 1
// Set the new active extruder
active_extruder = tmp_extruder;
#endif
#if ENABLED(SINGLENOZZLE)
#if ENABLED(PREVENT_COLD_EXTRUSION)
if (!DEBUGGING(DRYRUN) && thermalManager.targetTooColdToExtrude(active_extruder)) {
SERIAL_ERROR_START();
SERIAL_ERRORLNPGM(MSG_HOTEND_TOO_COLD);
return;
}
#endif
#if FAN_COUNT > 0
singlenozzle_fan_speed[active_extruder] = fan_speed[0];
fan_speed[0] = singlenozzle_fan_speed[tmp_extruder];
#endif
set_destination_from_current();
current_position[Z_AXIS] += (
#if ENABLED(SINGLENOZZLE_SWAP_PARK)
singlenozzle_change_point.z
#else
SINGLENOZZLE_TOOLCHANGE_ZRAISE
#endif
);
planner.buffer_line(current_position, planner.max_feedrate_mm_s[Z_AXIS], active_extruder);
#if ENABLED(SINGLENOZZLE_SWAP_PARK)
current_position[X_AXIS] = singlenozzle_change_point.x;
current_position[Y_AXIS] = singlenozzle_change_point.y;
planner.buffer_line(current_position, planner.max_feedrate_mm_s[Y_AXIS], active_extruder);
#endif
if (singlenozzle_swap_length) {
#if ENABLED(ADVANCED_PAUSE_FEATURE)
do_pause_e_move(-singlenozzle_swap_length, MMM_TO_MMS(singlenozzle_retract_speed));
#else
current_position[E_AXIS] -= singlenozzle_swap_length / planner.e_factor[active_extruder];
planner.buffer_line(current_position, MMM_TO_MMS(singlenozzle_retract_speed), active_extruder);
#endif
}
singlenozzle_temp[active_extruder] = thermalManager.target_temperature[0];
if (singlenozzle_temp[tmp_extruder] && singlenozzle_temp[tmp_extruder] != singlenozzle_temp[active_extruder]) {
thermalManager.setTargetHotend(singlenozzle_temp[tmp_extruder], 0);
#if ENABLED(ULTRA_LCD)
thermalManager.set_heating_message(0);
#endif
(void)thermalManager.wait_for_hotend(0, false); // Wait for heating or cooling
}
active_extruder = tmp_extruder;
if (singlenozzle_swap_length) {
#if ENABLED(ADVANCED_PAUSE_FEATURE)
do_pause_e_move(singlenozzle_swap_length, singlenozzle_prime_speed);
#else
current_position[E_AXIS] += singlenozzle_swap_length / planner.e_factor[tmp_extruder];
planner.buffer_line(current_position, singlenozzle_prime_speed, tmp_extruder);
#endif
}
#if ENABLED(SINGLENOZZLE_SWAP_PARK)
current_position[X_AXIS] = destination[X_AXIS];
current_position[Y_AXIS] = destination[Y_AXIS];
planner.buffer_line(current_position, planner.max_feedrate_mm_s[Y_AXIS], active_extruder);
#endif
do_blocking_move_to(destination[X_AXIS], destination[Y_AXIS], destination[Z_AXIS]);
#else // !SINGLENOZZLE
active_extruder = tmp_extruder;
#endif // !SINGLENOZZLE
#endif // EXTRUDERS > 1
#endif // HOTENDS <= 1

View File

@ -50,6 +50,16 @@
#endif // PARKING_EXTRUDER
#if ENABLED(SINGLENOZZLE)
extern float singlenozzle_swap_length;
extern int16_t singlenozzle_prime_speed,
singlenozzle_retract_speed;
extern uint16_t singlenozzle_temp[EXTRUDERS];
#if FAN_COUNT > 0
extern uint8_t singlenozzle_fan_speed[EXTRUDERS];
#endif
#endif
/**
* Perform a tool-change, which may result in moving the
* previous tool out of the way and the new tool into place.