Merge pull request #1075 from PavelSindler/mmu_filament_sensor
Mmu filament sensor
This commit is contained in:
commit
168bc74102
7 changed files with 143 additions and 77 deletions
|
@ -359,6 +359,9 @@ extern uint8_t print_percent_done_normal;
|
|||
extern uint32_t print_time_remaining_normal;
|
||||
extern uint8_t print_percent_done_silent;
|
||||
extern uint32_t print_time_remaining_silent;
|
||||
extern uint16_t mcode_in_progress;
|
||||
extern uint16_t gcode_in_progress;
|
||||
|
||||
#define PRINT_TIME_REMAINING_INIT 0xffffffff
|
||||
#define PRINT_PERCENT_DONE_INIT 0xff
|
||||
#define PRINTER_ACTIVE (IS_SD_PRINTING || is_usb_printing || isPrintPaused || (custom_message_type == CUSTOM_MSG_TYPE_TEMCAL) || saved_printing || (lcd_commands_type == LCD_COMMAND_V2_CAL) || card.paused || mmu_print_saved)
|
||||
|
|
|
@ -1962,8 +1962,8 @@ void loop()
|
|||
checkHitEndstops();
|
||||
lcd_update(0);
|
||||
#ifdef FILAMENT_SENSOR
|
||||
if (mcode_in_progress != 600) //M600 not in progress
|
||||
fsensor_update();
|
||||
if (mcode_in_progress != 600 && !mmu_enabled) //M600 not in progress
|
||||
fsensor_update();
|
||||
#endif //FILAMENT_SENSOR
|
||||
#ifdef TMC2130
|
||||
tmc2130_check_overtemp();
|
||||
|
@ -3173,7 +3173,10 @@ void gcode_M701()
|
|||
custom_message_type = CUSTOM_MSG_TYPE_F_LOAD;
|
||||
|
||||
#ifdef FILAMENT_SENSOR
|
||||
fsensor_oq_meassure_start(40);
|
||||
if (mmu_enabled == false)
|
||||
{
|
||||
fsensor_oq_meassure_start(40);
|
||||
}
|
||||
#endif //FILAMENT_SENSOR
|
||||
|
||||
lcd_setstatuspgm(_T(MSG_LOADING_FILAMENT));
|
||||
|
@ -3215,15 +3218,18 @@ void gcode_M701()
|
|||
custom_message_type = CUSTOM_MSG_TYPE_STATUS;
|
||||
|
||||
#ifdef FILAMENT_SENSOR
|
||||
fsensor_oq_meassure_stop();
|
||||
|
||||
if (!fsensor_oq_result())
|
||||
if (mmu_enabled == false)
|
||||
{
|
||||
bool disable = lcd_show_fullscreen_message_yes_no_and_wait_P(_i("Fil. sensor response is poor, disable it?"), false, true);
|
||||
lcd_update_enable(true);
|
||||
lcd_update(2);
|
||||
if (disable)
|
||||
fsensor_disable();
|
||||
fsensor_oq_meassure_stop();
|
||||
|
||||
if (!fsensor_oq_result())
|
||||
{
|
||||
bool disable = lcd_show_fullscreen_message_yes_no_and_wait_P(_i("Fil. sensor response is poor, disable it?"), false, true);
|
||||
lcd_update_enable(true);
|
||||
lcd_update(2);
|
||||
if (disable)
|
||||
fsensor_disable();
|
||||
}
|
||||
}
|
||||
#endif //FILAMENT_SENSOR
|
||||
}
|
||||
|
@ -3411,7 +3417,9 @@ void process_commands()
|
|||
}
|
||||
#endif //BACKLASH_Y
|
||||
#endif //TMC2130
|
||||
|
||||
else if (code_seen("FSENSOR_RECOVER")) {
|
||||
fsensor_restore_print_and_continue();
|
||||
}
|
||||
else if(code_seen("PRUSA")){
|
||||
if (code_seen("Ping")) { //PRUSA Ping
|
||||
if (farm_mode) {
|
||||
|
@ -7304,38 +7312,41 @@ static void handleSafetyTimer()
|
|||
void manage_inactivity(bool ignore_stepper_queue/*=false*/) //default argument set in Marlin.h
|
||||
{
|
||||
#ifdef FILAMENT_SENSOR
|
||||
if (mcode_in_progress != 600) //M600 not in progress
|
||||
if (mmu_enabled == false)
|
||||
{
|
||||
if (!moves_planned() && !IS_SD_PRINTING && !is_usb_printing && (lcd_commands_type != LCD_COMMAND_V2_CAL))
|
||||
if (mcode_in_progress != 600) //M600 not in progress
|
||||
{
|
||||
if (fsensor_check_autoload())
|
||||
if (!moves_planned() && !IS_SD_PRINTING && !is_usb_printing && (lcd_commands_type != LCD_COMMAND_V2_CAL))
|
||||
{
|
||||
fsensor_autoload_check_stop();
|
||||
if (degHotend0() > EXTRUDE_MINTEMP)
|
||||
if (fsensor_check_autoload())
|
||||
{
|
||||
if((eSoundMode==e_SOUND_MODE_LOUD)||(eSoundMode==e_SOUND_MODE_ONCE))
|
||||
tone(BEEPER, 1000);
|
||||
delay_keep_alive(50);
|
||||
noTone(BEEPER);
|
||||
loading_flag = true;
|
||||
enquecommand_front_P((PSTR("M701")));
|
||||
}
|
||||
else
|
||||
{
|
||||
lcd_update_enable(false);
|
||||
lcd_clear();
|
||||
lcd_set_cursor(0, 0);
|
||||
lcd_puts_P(_T(MSG_ERROR));
|
||||
lcd_set_cursor(0, 2);
|
||||
lcd_puts_P(_T(MSG_PREHEAT_NOZZLE));
|
||||
delay(2000);
|
||||
lcd_clear();
|
||||
lcd_update_enable(true);
|
||||
fsensor_autoload_check_stop();
|
||||
if (degHotend0() > EXTRUDE_MINTEMP)
|
||||
{
|
||||
if ((eSoundMode == e_SOUND_MODE_LOUD) || (eSoundMode == e_SOUND_MODE_ONCE))
|
||||
tone(BEEPER, 1000);
|
||||
delay_keep_alive(50);
|
||||
noTone(BEEPER);
|
||||
loading_flag = true;
|
||||
enquecommand_front_P((PSTR("M701")));
|
||||
}
|
||||
else
|
||||
{
|
||||
lcd_update_enable(false);
|
||||
lcd_clear();
|
||||
lcd_set_cursor(0, 0);
|
||||
lcd_puts_P(_T(MSG_ERROR));
|
||||
lcd_set_cursor(0, 2);
|
||||
lcd_puts_P(_T(MSG_PREHEAT_NOZZLE));
|
||||
delay(2000);
|
||||
lcd_clear();
|
||||
lcd_update_enable(true);
|
||||
}
|
||||
}
|
||||
}
|
||||
else
|
||||
fsensor_autoload_check_stop();
|
||||
}
|
||||
else
|
||||
fsensor_autoload_check_stop();
|
||||
}
|
||||
#endif //FILAMENT_SENSOR
|
||||
|
||||
|
|
|
@ -7,6 +7,8 @@
|
|||
#include "uart2.h"
|
||||
#include "temperature.h"
|
||||
#include "Configuration_prusa.h"
|
||||
#include "fsensor.h"
|
||||
#include "cardreader.h"
|
||||
|
||||
|
||||
extern const char* lcd_display_message_fullscreen_P(const char *msg);
|
||||
|
@ -16,6 +18,7 @@ extern void lcd_return_to_status();
|
|||
extern void lcd_wait_for_heater();
|
||||
extern char choose_extruder_menu();
|
||||
|
||||
#define CHECK_FINDA ((IS_SD_PRINTING || is_usb_printing) && (mcode_in_progress != 600) && !saved_printing && e_active())
|
||||
|
||||
#define MMU_TODELAY 100
|
||||
#define MMU_TIMEOUT 10
|
||||
|
@ -189,7 +192,7 @@ void mmu_loop(void)
|
|||
}
|
||||
mmu_cmd = 0;
|
||||
}
|
||||
else if ((mmu_last_response + 1000) < millis()) //request every 1s
|
||||
else if ((mmu_last_response + 800) < millis()) //request every 800ms
|
||||
{
|
||||
puts_P(PSTR("MMU <= 'P0'"));
|
||||
mmu_puts_P(PSTR("P0\n")); //send 'read finda' request
|
||||
|
@ -201,6 +204,12 @@ void mmu_loop(void)
|
|||
{
|
||||
fscanf_P(uart2io, PSTR("%hhu"), &mmu_finda); //scan finda from buffer
|
||||
printf_P(PSTR("MMU => '%dok'\n"), mmu_finda);
|
||||
//printf_P(PSTR("Eact: %d\n"), int(e_active()));
|
||||
if (!mmu_finda && CHECK_FINDA && fsensor_enabled) {
|
||||
fsensor_stop_and_save_print();
|
||||
enquecommand_front_P(PSTR("FSENSOR_RECOVER")); //then recover
|
||||
enquecommand_front_P(PSTR("M600")); //save print and run M600 command
|
||||
}
|
||||
mmu_state = 1;
|
||||
if (mmu_cmd == 0)
|
||||
mmu_ready = true;
|
||||
|
|
|
@ -494,6 +494,23 @@ void getHighESpeed()
|
|||
}
|
||||
#endif
|
||||
|
||||
bool e_active()
|
||||
{
|
||||
unsigned char e_active = 0;
|
||||
block_t *block;
|
||||
if(block_buffer_tail != block_buffer_head)
|
||||
{
|
||||
uint8_t block_index = block_buffer_tail;
|
||||
while(block_index != block_buffer_head)
|
||||
{
|
||||
block = &block_buffer[block_index];
|
||||
if(block->steps_e.wide != 0) e_active++;
|
||||
block_index = (block_index+1) & (BLOCK_BUFFER_SIZE - 1);
|
||||
}
|
||||
}
|
||||
return (e_active > 0) ? true : false ;
|
||||
}
|
||||
|
||||
void check_axes_activity()
|
||||
{
|
||||
unsigned char x_active = 0;
|
||||
|
|
|
@ -154,7 +154,7 @@ void plan_set_position(float x, float y, float z, const float &e);
|
|||
void plan_set_z_position(const float &z);
|
||||
void plan_set_e_position(const float &e);
|
||||
|
||||
|
||||
extern bool e_active();
|
||||
|
||||
void check_axes_activity();
|
||||
|
||||
|
|
|
@ -41,6 +41,8 @@
|
|||
int fsensor_counter = 0; //counter for e-steps
|
||||
#endif //FILAMENT_SENSOR
|
||||
|
||||
#include "mmu.h"
|
||||
|
||||
#ifdef DEBUG_STACK_MONITOR
|
||||
uint16_t SP_min = 0x21FF;
|
||||
#endif //DEBUG_STACK_MONITOR
|
||||
|
@ -470,8 +472,11 @@ FORCE_INLINE void stepper_next_block()
|
|||
#endif
|
||||
|
||||
#ifdef FILAMENT_SENSOR
|
||||
fsensor_counter = 0;
|
||||
fsensor_st_block_begin(current_block);
|
||||
if (mmu_enabled == false)
|
||||
{
|
||||
fsensor_counter = 0;
|
||||
fsensor_st_block_begin(current_block);
|
||||
}
|
||||
#endif //FILAMENT_SENSOR
|
||||
// The busy flag is set by the plan_get_current_block() call.
|
||||
// current_block->busy = true;
|
||||
|
@ -901,7 +906,10 @@ FORCE_INLINE void isr() {
|
|||
if (step_loops < estep_loops)
|
||||
estep_loops = step_loops;
|
||||
#ifdef FILAMENT_SENSOR
|
||||
fsensor_counter += estep_loops;
|
||||
if (mmu_enabled == false)
|
||||
{
|
||||
fsensor_counter += estep_loops;
|
||||
}
|
||||
#endif //FILAMENT_SENSOR
|
||||
do {
|
||||
WRITE_NC(E0_STEP_PIN, !INVERT_E_STEP_PIN);
|
||||
|
@ -1027,7 +1035,9 @@ FORCE_INLINE void isr() {
|
|||
// There is not enough time to fit even a single additional tick.
|
||||
// Tick all the extruder ticks now.
|
||||
#ifdef FILAMENT_SENSOR
|
||||
fsensor_counter += e_steps;
|
||||
if (mmu_enabled == false) {
|
||||
fsensor_counter += e_steps;
|
||||
}
|
||||
#endif //FILAMENT_SENSOR
|
||||
MSerial.checkRx(); // Check for serial chars.
|
||||
do {
|
||||
|
@ -1049,15 +1059,17 @@ FORCE_INLINE void isr() {
|
|||
// If current block is finished, reset pointer
|
||||
if (step_events_completed.wide >= current_block->step_event_count.wide) {
|
||||
#ifdef FILAMENT_SENSOR
|
||||
fsensor_st_block_chunk(current_block, fsensor_counter);
|
||||
fsensor_counter = 0;
|
||||
if (mmu_enabled == false) {
|
||||
fsensor_st_block_chunk(current_block, fsensor_counter);
|
||||
fsensor_counter = 0;
|
||||
}
|
||||
#endif //FILAMENT_SENSOR
|
||||
|
||||
current_block = NULL;
|
||||
plan_discard_current_block();
|
||||
}
|
||||
#ifdef FILAMENT_SENSOR
|
||||
else if (fsensor_counter >= fsensor_chunk_len)
|
||||
else if ((fsensor_counter >= fsensor_chunk_len) && (mmu_enabled == false))
|
||||
{
|
||||
fsensor_st_block_chunk(current_block, fsensor_counter);
|
||||
fsensor_counter = 0;
|
||||
|
|
|
@ -1882,20 +1882,22 @@ static void lcd_menu_extruder_info()
|
|||
// Shutter register is an index of LASER shutter time. It is automatically controlled by the chip's internal
|
||||
// auto-exposure algorithm. When the chip is tracking on a good reflection surface, the Shutter is small.
|
||||
// When the chip is tracking on a poor reflection surface, the Shutter is large. Value ranges from 0 to 46.
|
||||
|
||||
if (!fsensor_enabled)
|
||||
lcd_puts_P(_N("Filament sensor\n" "is disabled."));
|
||||
else
|
||||
if (mmu_enabled == false)
|
||||
{
|
||||
if (!moves_planned() && !IS_SD_PRINTING && !is_usb_printing && (lcd_commands_type != LCD_COMMAND_V2_CAL))
|
||||
pat9125_update();
|
||||
lcd_printf_P(_N(
|
||||
"Fil. Xd:%3d Yd:%3d\n"
|
||||
"Int: %3d Shut: %3d"
|
||||
),
|
||||
pat9125_x, pat9125_y,
|
||||
pat9125_b, pat9125_s
|
||||
);
|
||||
if (!fsensor_enabled)
|
||||
lcd_puts_P(_N("Filament sensor\n" "is disabled."));
|
||||
else
|
||||
{
|
||||
if (!moves_planned() && !IS_SD_PRINTING && !is_usb_printing && (lcd_commands_type != LCD_COMMAND_V2_CAL))
|
||||
pat9125_update();
|
||||
lcd_printf_P(_N(
|
||||
"Fil. Xd:%3d Yd:%3d\n"
|
||||
"Int: %3d Shut: %3d"
|
||||
),
|
||||
pat9125_x, pat9125_y,
|
||||
pat9125_b, pat9125_s
|
||||
);
|
||||
}
|
||||
}
|
||||
#endif //FILAMENT_SENSOR
|
||||
|
||||
|
@ -4040,15 +4042,16 @@ static void lcd_crash_mode_set()
|
|||
static void lcd_fsensor_state_set()
|
||||
{
|
||||
FSensorStateMenu = !FSensorStateMenu; //set also from fsensor_enable() and fsensor_disable()
|
||||
if (!FSensorStateMenu) {
|
||||
fsensor_disable();
|
||||
if (fsensor_autoload_enabled)
|
||||
menu_submenu(lcd_filament_autoload_info);
|
||||
}else{
|
||||
fsensor_enable();
|
||||
if (fsensor_not_responding)
|
||||
menu_submenu(lcd_fsensor_fail);
|
||||
}
|
||||
if (!FSensorStateMenu) {
|
||||
fsensor_disable();
|
||||
if (fsensor_autoload_enabled && !mmu_enabled)
|
||||
menu_submenu(lcd_filament_autoload_info);
|
||||
}
|
||||
else {
|
||||
fsensor_enable();
|
||||
if (fsensor_not_responding && !mmu_enabled)
|
||||
menu_submenu(lcd_fsensor_fail);
|
||||
}
|
||||
}
|
||||
#endif //FILAMENT_SENSOR
|
||||
|
||||
|
@ -4546,17 +4549,23 @@ static void lcd_settings_menu()
|
|||
{
|
||||
// Filament sensor turned off, working, no problems
|
||||
MENU_ITEM_FUNCTION_P(_T(MSG_FSENSOR_OFF), lcd_fsensor_state_set);
|
||||
MENU_ITEM_SUBMENU_P(_T(MSG_FSENS_AUTOLOAD_NA), lcd_filament_autoload_info);
|
||||
if (mmu_enabled == false)
|
||||
{
|
||||
MENU_ITEM_SUBMENU_P(_T(MSG_FSENS_AUTOLOAD_NA), lcd_filament_autoload_info);
|
||||
}
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
// Filament sensor turned on, working, no problems
|
||||
MENU_ITEM_FUNCTION_P(_T(MSG_FSENSOR_ON), lcd_fsensor_state_set);
|
||||
if (fsensor_autoload_enabled)
|
||||
MENU_ITEM_FUNCTION_P(_i("F. autoload [on]"), lcd_set_filament_autoload);////MSG_FSENS_AUTOLOAD_ON c=17 r=1
|
||||
else
|
||||
MENU_ITEM_FUNCTION_P(_i("F. autoload [off]"), lcd_set_filament_autoload);////MSG_FSENS_AUTOLOAD_OFF c=17 r=1
|
||||
if (mmu_enabled == false)
|
||||
{
|
||||
if (fsensor_autoload_enabled)
|
||||
MENU_ITEM_FUNCTION_P(_i("F. autoload [on]"), lcd_set_filament_autoload);////MSG_FSENS_AUTOLOAD_ON c=17 r=1
|
||||
else
|
||||
MENU_ITEM_FUNCTION_P(_i("F. autoload [off]"), lcd_set_filament_autoload);////MSG_FSENS_AUTOLOAD_OFF c=17 r=1
|
||||
}
|
||||
}
|
||||
#endif //FILAMENT_SENSOR
|
||||
|
||||
|
@ -5558,7 +5567,7 @@ static void lcd_main_menu()
|
|||
else
|
||||
{
|
||||
#ifdef FILAMENT_SENSOR
|
||||
if ( ((fsensor_autoload_enabled == true) && (fsensor_enabled == true)))
|
||||
if ((fsensor_autoload_enabled == true) && (fsensor_enabled == true) && (mmu_enabled == false))
|
||||
MENU_ITEM_SUBMENU_P(_i("AutoLoad filament"), lcd_menu_AutoLoadFilament);////MSG_AUTOLOAD_FILAMENT c=17 r=0
|
||||
else
|
||||
#endif //FILAMENT_SENSOR
|
||||
|
@ -6079,14 +6088,19 @@ bool lcd_selftest()
|
|||
{
|
||||
_progress = lcd_selftest_screen(8, _progress, 3, true, 2000); //bed ok
|
||||
#ifdef FILAMENT_SENSOR
|
||||
_progress = lcd_selftest_screen(9, _progress, 3, true, 2000); //check filaments sensor
|
||||
_result = lcd_selftest_fsensor();
|
||||
if (mmu_enabled == false) {
|
||||
_progress = lcd_selftest_screen(9, _progress, 3, true, 2000); //check filaments sensor
|
||||
_result = lcd_selftest_fsensor();
|
||||
}
|
||||
#endif // FILAMENT_SENSOR
|
||||
}
|
||||
if (_result)
|
||||
{
|
||||
#ifdef FILAMENT_SENSOR
|
||||
_progress = lcd_selftest_screen(10, _progress, 3, true, 2000); //fil sensor OK
|
||||
if (mmu_enabled == false)
|
||||
{
|
||||
_progress = lcd_selftest_screen(10, _progress, 3, true, 2000); //fil sensor OK
|
||||
}
|
||||
#endif // FILAMENT_SENSOR
|
||||
_progress = lcd_selftest_screen(11, _progress, 3, true, 5000); //all correct
|
||||
}
|
||||
|
|
Loading…
Add table
Reference in a new issue