Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix runout sensor for mixing extruder #20327

Merged
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
Add test and extra conditional
thinkyhead committed Feb 28, 2021
commit cbb33b1afe4b6f2ce0f5fd179e92f3ec55e7a61f
6 changes: 1 addition & 5 deletions Marlin/src/feature/pause.cpp
Original file line number Diff line number Diff line change
@@ -201,11 +201,7 @@ bool load_filament(const float &slow_load_length/*=0*/, const float &fast_load_l
KEEPALIVE_STATE(PAUSED_FOR_USER);
wait_for_user = true; // LCD click or M108 will clear this
#if ENABLED(HOST_PROMPT_SUPPORT)
const char tool = '0'
#if NUM_RUNOUT_SENSORS > 1
+ active_extruder
#endif
;
const char tool = '0' + TERN0(MULTI_FILAMENT_SENSOR, active_extruder);
host_prompt_do(PROMPT_USER_CONTINUE, PSTR("Load Filament T"), tool, CONTINUE_STR);
#endif

10 changes: 4 additions & 6 deletions Marlin/src/feature/runout.cpp
Original file line number Diff line number Diff line change
@@ -86,11 +86,9 @@ void event_filament_runout(const uint8_t extruder) {

TERN_(EXTENSIBLE_UI, ExtUI::onFilamentRunout(ExtUI::getTool(extruder)));

const char tool = '0'
#if E_STEPPERS > 1
+ extruder
#endif
;
#if ANY(HOST_PROMPT_SUPPORT, ACTION_ON_FILAMENT_RUNOUT, MULTI_FILAMENT_SENSOR)
const char tool = '0' + TERN0(MULTI_FILAMENT_SENSOR, extruder);
#endif

//action:out_of_filament
#if ENABLED(HOST_PROMPT_SUPPORT)
@@ -126,7 +124,7 @@ void event_filament_runout(const uint8_t extruder) {
#endif // HOST_ACTION_COMMANDS

if (run_runout_script) {
#if NUM_RUNOUT_SENSORS > 1
#if MULTI_FILAMENT_SENSOR
char script[strlen(FILAMENT_RUNOUT_SCRIPT) + 1];
sprintf_P(script, PSTR(FILAMENT_RUNOUT_SCRIPT), tool);
#if ENABLED(FILAMENT_RUNOUT_SENSOR_DEBUG)
8 changes: 4 additions & 4 deletions Marlin/src/feature/runout.h
Original file line number Diff line number Diff line change
@@ -126,7 +126,7 @@ class TFilamentMonitor : public FilamentMonitorBase {
sensor.run();
const uint8_t sensor_bitmask = response.has_run_out();
TERN_(HAS_FILAMENT_RUNOUT_DISTANCE, sei());
#if NUM_RUNOUT_SENSORS > 1
#if MULTI_FILAMENT_SENSOR
#if ENABLED(WATCH_ALL_RUNOUT_SENSORS)
const bool ran_out = !!sensor_bitmask; // any sensor triggers
uint8_t extruder = 0;
@@ -301,12 +301,12 @@ class FilamentSensorBase {
private:
static inline bool poll_runout_state(const uint8_t extruder) {
const uint8_t runout_states = poll_runout_states();
#if NUM_RUNOUT_SENSORS == 1
UNUSED(extruder);
#else
#if MULTI_FILAMENT_SENSOR
if ( !TERN0(DUAL_X_CARRIAGE, idex_is_duplicating())
&& !TERN0(MULTI_NOZZLE_DUPLICATION, extruder_duplication_enabled)
) return TEST(runout_states, extruder); // A specific extruder ran out
#else
UNUSED(extruder);
#endif
return !!runout_states; // Any extruder ran out
}
2 changes: 1 addition & 1 deletion Marlin/src/gcode/feature/pause/M600.cpp
Original file line number Diff line number Diff line change
@@ -86,7 +86,7 @@ void GcodeSuite::M600() {
int8_t DXC_ext = target_extruder;
if (!parser.seen('T')) { // If no tool index is specified, M600 was (probably) sent in response to filament runout.
// In this case, for duplicating modes set DXC_ext to the extruder that ran out.
#if HAS_FILAMENT_SENSOR && NUM_RUNOUT_SENSORS > 1
#if MULTI_FILAMENT_SENSOR
if (idex_is_duplicating())
DXC_ext = (READ(FIL_RUNOUT2_PIN) == FIL_RUNOUT2_STATE) ? 1 : 0;
#else
3 changes: 3 additions & 0 deletions Marlin/src/inc/Conditionals_adv.h
Original file line number Diff line number Diff line change
@@ -128,6 +128,9 @@

#if ENABLED(FILAMENT_RUNOUT_SENSOR)
#define HAS_FILAMENT_SENSOR 1
#if NUM_RUNOUT_SENSORS > 1
#define MULTI_FILAMENT_SENSOR 1
#endif
#ifdef FILAMENT_RUNOUT_DISTANCE_MM
#define HAS_FILAMENT_RUNOUT_DISTANCE 1
#endif
26 changes: 13 additions & 13 deletions Marlin/src/inc/SanityCheck.h
Original file line number Diff line number Diff line change
@@ -813,22 +813,22 @@ static_assert(Y_MAX_LENGTH >= Y_BED_SIZE, "Movement bounds (Y_MIN_POS, Y_MAX_POS
#error "FILAMENT_RUNOUT_SENSOR requires FIL_RUNOUT_PIN."
#elif HAS_PRUSA_MMU2 && NUM_RUNOUT_SENSORS != 1
#error "NUM_RUNOUT_SENSORS must be 1 with MMU2 / MMU2S."
#elif !(NUM_RUNOUT_SENSORS == 1 || NUM_RUNOUT_SENSORS == E_STEPPERS)
#elif NUM_RUNOUT_SENSORS != 1 && NUM_RUNOUT_SENSORS != E_STEPPERS
#error "NUM_RUNOUT_SENSORS must be either 1 or number of E steppers."
#elif NUM_RUNOUT_SENSORS >= 2 && !PIN_EXISTS(FIL_RUNOUT2)
#error "FIL_RUNOUT2_PIN is required with NUM_RUNOUT_SENSORS >= 2."
#elif NUM_RUNOUT_SENSORS >= 3 && !PIN_EXISTS(FIL_RUNOUT3)
#error "FIL_RUNOUT3_PIN is required with NUM_RUNOUT_SENSORS >= 3."
#elif NUM_RUNOUT_SENSORS >= 4 && !PIN_EXISTS(FIL_RUNOUT4)
#error "FIL_RUNOUT4_PIN is required with NUM_RUNOUT_SENSORS >= 4."
#elif NUM_RUNOUT_SENSORS >= 5 && !PIN_EXISTS(FIL_RUNOUT5)
#error "FIL_RUNOUT5_PIN is required with NUM_RUNOUT_SENSORS >= 5."
#elif NUM_RUNOUT_SENSORS >= 6 && !PIN_EXISTS(FIL_RUNOUT6)
#error "FIL_RUNOUT6_PIN is required with NUM_RUNOUT_SENSORS >= 6."
#elif NUM_RUNOUT_SENSORS >= 7 && !PIN_EXISTS(FIL_RUNOUT7)
#error "FIL_RUNOUT7_PIN is required with NUM_RUNOUT_SENSORS >= 7."
#elif NUM_RUNOUT_SENSORS >= 8 && !PIN_EXISTS(FIL_RUNOUT8)
#error "FIL_RUNOUT8_PIN is required with NUM_RUNOUT_SENSORS >= 8."
#elif NUM_RUNOUT_SENSORS >= 7 && !PIN_EXISTS(FIL_RUNOUT7)
#error "FIL_RUNOUT7_PIN is required with NUM_RUNOUT_SENSORS >= 7."
#elif NUM_RUNOUT_SENSORS >= 6 && !PIN_EXISTS(FIL_RUNOUT6)
#error "FIL_RUNOUT6_PIN is required with NUM_RUNOUT_SENSORS >= 6."
#elif NUM_RUNOUT_SENSORS >= 5 && !PIN_EXISTS(FIL_RUNOUT5)
#error "FIL_RUNOUT5_PIN is required with NUM_RUNOUT_SENSORS >= 5."
#elif NUM_RUNOUT_SENSORS >= 4 && !PIN_EXISTS(FIL_RUNOUT4)
#error "FIL_RUNOUT4_PIN is required with NUM_RUNOUT_SENSORS >= 4."
#elif NUM_RUNOUT_SENSORS >= 3 && !PIN_EXISTS(FIL_RUNOUT3)
#error "FIL_RUNOUT3_PIN is required with NUM_RUNOUT_SENSORS >= 3."
#elif NUM_RUNOUT_SENSORS >= 2 && !PIN_EXISTS(FIL_RUNOUT2)
#error "FIL_RUNOUT2_PIN is required with NUM_RUNOUT_SENSORS >= 2."
#elif BOTH(FIL_RUNOUT1_PULLUP, FIL_RUNOUT1_PULLDOWN)
#error "You can't enable FIL_RUNOUT1_PULLUP and FIL_RUNOUT1_PULLDOWN at the same time."
#elif BOTH(FIL_RUNOUT2_PULLUP, FIL_RUNOUT2_PULLDOWN)
32 changes: 15 additions & 17 deletions Marlin/src/module/endstops.cpp
Original file line number Diff line number Diff line change
@@ -461,24 +461,22 @@ void _O2 Endstops::report_states() {
#if HAS_CUSTOM_PROBE_PIN
print_es_state(PROBE_TRIGGERED(), PSTR(STR_Z_PROBE));
#endif
#if HAS_FILAMENT_SENSOR
#if NUM_RUNOUT_SENSORS == 1
print_es_state(READ(FIL_RUNOUT1_PIN) != FIL_RUNOUT1_STATE, PSTR(STR_FILAMENT_RUNOUT_SENSOR));
#else
#define _CASE_RUNOUT(N) case N: pin = FIL_RUNOUT##N##_PIN; state = FIL_RUNOUT##N##_STATE; break;
LOOP_S_LE_N(i, 1, NUM_RUNOUT_SENSORS) {
pin_t pin;
uint8_t state;
switch (i) {
default: continue;
REPEAT_S(1, INCREMENT(NUM_RUNOUT_SENSORS), _CASE_RUNOUT)
}
SERIAL_ECHOPGM(STR_FILAMENT_RUNOUT_SENSOR);
if (i > 1) SERIAL_CHAR(' ', '0' + i);
print_es_state(extDigitalRead(pin) != state);
#if MULTI_FILAMENT_SENSOR
#define _CASE_RUNOUT(N) case N: pin = FIL_RUNOUT##N##_PIN; state = FIL_RUNOUT##N##_STATE; break;
LOOP_S_LE_N(i, 1, NUM_RUNOUT_SENSORS) {
pin_t pin;
uint8_t state;
switch (i) {
default: continue;
REPEAT_S(1, INCREMENT(NUM_RUNOUT_SENSORS), _CASE_RUNOUT)
}
#undef _CASE_RUNOUT
#endif
SERIAL_ECHOPGM(STR_FILAMENT_RUNOUT_SENSOR);
if (i > 1) SERIAL_CHAR(' ', '0' + i);
print_es_state(extDigitalRead(pin) != state);
}
#undef _CASE_RUNOUT
#elif HAS_FILAMENT_SENSOR
print_es_state(READ(FIL_RUNOUT1_PIN) != FIL_RUNOUT1_STATE, PSTR(STR_FILAMENT_RUNOUT_SENSOR));
#endif

TERN_(BLTOUCH, bltouch._reset_SW_mode());
2 changes: 1 addition & 1 deletion Marlin/src/pins/ramps/pins_RAMPS_CREALITY.h
Original file line number Diff line number Diff line change
@@ -35,7 +35,7 @@
#define MOSFET_D_PIN 7

#define FIL_RUNOUT_PIN 2
#if NUM_RUNOUT_SENSORS > 1
#if NUM_RUNOUT_SENSORS >= 2
#define FIL_RUNOUT2_PIN 15 // Creality CR-X can use dual runout sensors
#endif

8 changes: 7 additions & 1 deletion buildroot/tests/mega2560-tests
Original file line number Diff line number Diff line change
@@ -129,8 +129,14 @@ restore_configs
opt_set MOTHERBOARD BOARD_AZTEEG_X3_PRO
opt_set LCD_LANGUAGE el_gr
opt_enable MIXING_EXTRUDER GRADIENT_MIX GRADIENT_VTOOL CR10_STOCKDISPLAY \
USE_CONTROLLER_FAN CONTROLLER_FAN_EDITABLE CONTROLLER_FAN_IGNORE_Z
USE_CONTROLLER_FAN CONTROLLER_FAN_EDITABLE CONTROLLER_FAN_IGNORE_Z \
FILAMENT_RUNOUT_SENSOR ADVANCED_PAUSE_FEATURE NOZZLE_PARK_FEATURE
opt_set MIXING_STEPPERS 5
opt_set NUM_RUNOUT_SENSORS E_STEPPERS
opt_set FIL_RUNOUT2_PIN 16
opt_set FIL_RUNOUT3_PIN 17
opt_set FIL_RUNOUT4_PIN 4
opt_set FIL_RUNOUT5_PIN 5
opt_set LCD_LANGUAGE ru
exec_test $1 $2 "Azteeg X3 | Mixing Extruder (x5) | Gradient Mix | Greek" "$3"