Merge branch 'prusa3d_MK3' into MK3_dev
This commit is contained in:
commit
adde0d3944
13 changed files with 536 additions and 291 deletions
Firmware
161
Firmware/mmu.cpp
161
Firmware/mmu.cpp
|
@ -7,22 +7,22 @@
|
|||
#include "uart2.h"
|
||||
#include "temperature.h"
|
||||
#include "Configuration_prusa.h"
|
||||
#include "fsensor.h"
|
||||
#include "cardreader.h"
|
||||
#include "ultralcd.h"
|
||||
#include "sound.h"
|
||||
|
||||
|
||||
extern const char* lcd_display_message_fullscreen_P(const char *msg);
|
||||
extern void lcd_show_fullscreen_message_and_wait_P(const char *msg);
|
||||
extern int8_t lcd_show_fullscreen_message_yes_no_and_wait_P(const char *msg, bool allow_timeouting = true, bool default_yes = false);
|
||||
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
|
||||
#define MMU_CMD_TIMEOUT 300000ul //5min timeout for mmu commands (except P0)
|
||||
#define MMU_P0_TIMEOUT 3000ul //timeout for P0 command: 3seconds
|
||||
|
||||
#define MMU_HWRESET
|
||||
#define MMU_RST_PIN 76
|
||||
|
||||
#define MMU_REQUIRED_FW_BUILDNR 81
|
||||
|
||||
bool mmu_enabled = false;
|
||||
|
||||
|
@ -138,6 +138,9 @@ void mmu_loop(void)
|
|||
{
|
||||
fscanf_P(uart2io, PSTR("%u"), &mmu_buildnr); //scan buildnr from buffer
|
||||
printf_P(PSTR("MMU => '%dok'\n"), mmu_buildnr);
|
||||
bool version_valid = mmu_check_version();
|
||||
if (!version_valid) mmu_show_warning();
|
||||
else puts_P(PSTR("MMU version valid"));
|
||||
puts_P(PSTR("MMU <= 'P0'"));
|
||||
mmu_puts_P(PSTR("P0\n")); //send 'read finda' request
|
||||
mmu_state = -4;
|
||||
|
@ -170,9 +173,21 @@ void mmu_loop(void)
|
|||
mmu_printf_P(PSTR("L%d\n"), filament);
|
||||
mmu_state = 3; // wait for response
|
||||
}
|
||||
else if (mmu_cmd == MMU_CMD_C0)
|
||||
{
|
||||
printf_P(PSTR("MMU <= 'C0'\n"));
|
||||
mmu_puts_P(PSTR("C0\n")); //send 'continue loading'
|
||||
mmu_state = 3;
|
||||
}
|
||||
else if (mmu_cmd == MMU_CMD_U0)
|
||||
{
|
||||
printf_P(PSTR("MMU <= 'U0'\n"));
|
||||
mmu_puts_P(PSTR("U0\n")); //send 'unload current filament'
|
||||
mmu_state = 3;
|
||||
}
|
||||
mmu_cmd = 0;
|
||||
}
|
||||
else if ((mmu_last_response + 1000) < millis()) //request every 1s
|
||||
else if ((mmu_last_response + 300) < millis()) //request every 300ms
|
||||
{
|
||||
puts_P(PSTR("MMU <= 'P0'"));
|
||||
mmu_puts_P(PSTR("P0\n")); //send 'read finda' request
|
||||
|
@ -184,11 +199,18 @@ 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
|
||||
if (lcd_autoDeplete) enquecommand_front_P(PSTR("M600 AUTO")); //save print and run M600 command
|
||||
else enquecommand_front_P(PSTR("M600")); //save print and run M600 command
|
||||
}
|
||||
mmu_state = 1;
|
||||
if (mmu_cmd == 0)
|
||||
mmu_ready = true;
|
||||
}
|
||||
else if ((mmu_last_request + 30000) < millis())
|
||||
else if ((mmu_last_request + MMU_P0_TIMEOUT) < millis())
|
||||
{ //resend request after timeout (30s)
|
||||
mmu_state = 1;
|
||||
}
|
||||
|
@ -196,12 +218,12 @@ void mmu_loop(void)
|
|||
case 3: //response to commands T0-T4
|
||||
if (mmu_rx_ok() > 0)
|
||||
{
|
||||
printf_P(PSTR("MMU => 'ok'\n"), mmu_finda);
|
||||
printf_P(PSTR("MMU => 'ok'\n"));
|
||||
mmu_ready = true;
|
||||
mmu_state = 1;
|
||||
}
|
||||
else if ((mmu_last_request + 30000) < millis())
|
||||
{ //resend request after timeout (30s)
|
||||
else if ((mmu_last_request + MMU_CMD_TIMEOUT) < millis())
|
||||
{ //resend request after timeout (5 min)
|
||||
mmu_state = 1;
|
||||
}
|
||||
return;
|
||||
|
@ -297,7 +319,7 @@ void manage_response(bool move_axes, bool turn_off_nozzle)
|
|||
}
|
||||
st_synchronize();
|
||||
mmu_print_saved = true;
|
||||
|
||||
printf_P(PSTR("MMU not responding\n"));
|
||||
hotend_temp_bckp = degTargetHotend(active_extruder);
|
||||
if (move_axes) {
|
||||
z_position_bckp = current_position[Z_AXIS];
|
||||
|
@ -319,23 +341,28 @@ void manage_response(bool move_axes, bool turn_off_nozzle)
|
|||
if (turn_off_nozzle) {
|
||||
//set nozzle target temperature to 0
|
||||
setAllTargetHotends(0);
|
||||
printf_P(PSTR("MMU not responding\n"));
|
||||
lcd_show_fullscreen_message_and_wait_P(_i("MMU needs user attention. Please press knob to resume nozzle target temperature."));
|
||||
setTargetHotend(hotend_temp_bckp, active_extruder);
|
||||
while ((degTargetHotend(active_extruder) - degHotend(active_extruder)) > 5) {
|
||||
delay_keep_alive(1000);
|
||||
lcd_wait_for_heater();
|
||||
}
|
||||
}
|
||||
}
|
||||
lcd_display_message_fullscreen_P(_i("Check MMU. Fix the issue and then press button on MMU unit."));
|
||||
lcd_display_message_fullscreen_P(_i("MMU needs user attention. Fix the issue and then press button on MMU unit."));
|
||||
delay_keep_alive(1000);
|
||||
}
|
||||
else if (mmu_print_saved) {
|
||||
printf_P(PSTR("MMU start responding\n"));
|
||||
lcd_clear();
|
||||
lcd_display_message_fullscreen_P(_i("MMU OK. Resuming..."));
|
||||
printf_P(PSTR("MMU starts responding\n"));
|
||||
if (turn_off_nozzle)
|
||||
{
|
||||
lcd_clear();
|
||||
setTargetHotend(hotend_temp_bckp, active_extruder);
|
||||
lcd_display_message_fullscreen_P(_i("MMU OK. Resuming temperature..."));
|
||||
delay_keep_alive(3000);
|
||||
while ((degTargetHotend(active_extruder) - degHotend(active_extruder)) > 5)
|
||||
{
|
||||
delay_keep_alive(1000);
|
||||
lcd_wait_for_heater();
|
||||
}
|
||||
}
|
||||
if (move_axes) {
|
||||
lcd_clear();
|
||||
lcd_display_message_fullscreen_P(_i("MMU OK. Resuming position..."));
|
||||
current_position[X_AXIS] = x_position_bckp;
|
||||
current_position[Y_AXIS] = y_position_bckp;
|
||||
plan_buffer_line(current_position[X_AXIS], current_position[Y_AXIS], current_position[Z_AXIS], current_position[E_AXIS], 50, active_extruder);
|
||||
|
@ -345,6 +372,8 @@ void manage_response(bool move_axes, bool turn_off_nozzle)
|
|||
st_synchronize();
|
||||
}
|
||||
else {
|
||||
lcd_clear();
|
||||
lcd_display_message_fullscreen_P(_i("MMU OK. Resuming..."));
|
||||
delay_keep_alive(1000); //delay just for showing MMU OK message for a while in case that there are no xyz movements
|
||||
}
|
||||
}
|
||||
|
@ -377,33 +406,79 @@ void mmu_load_to_nozzle()
|
|||
if (!saved_e_relative_mode) axis_relative_modes[E_AXIS] = false;
|
||||
}
|
||||
|
||||
void mmu_M600_wait_and_beep() {
|
||||
//Beep and wait for user to remove old filament and prepare new filament for load
|
||||
|
||||
KEEPALIVE_STATE(PAUSED_FOR_USER);
|
||||
|
||||
int counterBeep = 0;
|
||||
lcd_display_message_fullscreen_P(_i("Remove old filament and press the knob to start loading new filament."));
|
||||
bool bFirst=true;
|
||||
|
||||
while (!lcd_clicked()){
|
||||
manage_heater();
|
||||
manage_inactivity(true);
|
||||
|
||||
#if BEEPER > 0
|
||||
if (counterBeep == 500) {
|
||||
counterBeep = 0;
|
||||
}
|
||||
SET_OUTPUT(BEEPER);
|
||||
if (counterBeep == 0) {
|
||||
if((eSoundMode==e_SOUND_MODE_LOUD)||((eSoundMode==e_SOUND_MODE_ONCE)&&bFirst))
|
||||
{
|
||||
bFirst=false;
|
||||
WRITE(BEEPER, HIGH);
|
||||
}
|
||||
}
|
||||
if (counterBeep == 20) {
|
||||
WRITE(BEEPER, LOW);
|
||||
}
|
||||
|
||||
counterBeep++;
|
||||
#endif //BEEPER > 0
|
||||
|
||||
delay_keep_alive(4);
|
||||
}
|
||||
WRITE(BEEPER, LOW);
|
||||
}
|
||||
|
||||
void mmu_M600_load_filament(bool automatic)
|
||||
{
|
||||
//load filament for mmu v2
|
||||
uint8_t filament = mmu_extruder;
|
||||
bool yes = false;
|
||||
tmp_extruder = mmu_extruder;
|
||||
if (!automatic) {
|
||||
bool yes = lcd_show_fullscreen_message_yes_no_and_wait_P(_i("Do you want to switch extruder?"), false);
|
||||
if(yes) filament = choose_extruder_menu();
|
||||
}
|
||||
mmu_M600_wait_and_beep();
|
||||
#ifdef MMU_M600_SWITCH_EXTRUDER
|
||||
yes = lcd_show_fullscreen_message_yes_no_and_wait_P(_i("Do you want to switch extruder?"), false);
|
||||
if(yes) tmp_extruder = choose_extruder_menu();
|
||||
else tmp_extruder = mmu_extruder;
|
||||
#else
|
||||
tmp_extruder = mmu_extruder;
|
||||
#endif //MMU_M600_SWITCH_EXTRUDER
|
||||
}
|
||||
else {
|
||||
filament = (filament+1)%5;
|
||||
tmp_extruder = (tmp_extruder+1)%5;
|
||||
}
|
||||
lcd_update_enable(false);
|
||||
lcd_clear();
|
||||
lcd_set_cursor(0, 1); lcd_puts_P(_T(MSG_LOADING_FILAMENT));
|
||||
lcd_print(" ");
|
||||
lcd_print(filament + 1);
|
||||
snmm_filaments_used |= (1 << filament); //for stop print
|
||||
lcd_print(tmp_extruder + 1);
|
||||
snmm_filaments_used |= (1 << tmp_extruder); //for stop print
|
||||
|
||||
// printf_P(PSTR("T code: %d \n"), filament);
|
||||
// mmu_printf_P(PSTR("T%d\n"), filament);
|
||||
mmu_command(MMU_CMD_T0 + filament);
|
||||
// printf_P(PSTR("T code: %d \n"), tmp_extruder);
|
||||
// mmu_printf_P(PSTR("T%d\n"), tmp_extruder);
|
||||
mmu_command(MMU_CMD_T0 + tmp_extruder);
|
||||
|
||||
manage_response(false, true);
|
||||
mmu_extruder = filament; //filament change is finished
|
||||
mmu_command(MMU_CMD_C0);
|
||||
mmu_extruder = tmp_extruder; //filament change is finished
|
||||
|
||||
mmu_load_to_nozzle();
|
||||
|
||||
|
||||
st_synchronize();
|
||||
current_position[E_AXIS]+= FILAMENTCHANGE_FINALFEED ;
|
||||
plan_buffer_line(current_position[X_AXIS], current_position[Y_AXIS], current_position[Z_AXIS], current_position[E_AXIS], 2, active_extruder);
|
||||
|
@ -577,9 +652,8 @@ void extr_unload()
|
|||
current_position[E_AXIS] -= 80;
|
||||
plan_buffer_line(current_position[X_AXIS], current_position[Y_AXIS], current_position[Z_AXIS], current_position[E_AXIS], 2500 / 60, active_extruder);
|
||||
st_synchronize();
|
||||
printf_P(PSTR("U0\n"));
|
||||
fprintf_P(uart2io, PSTR("U0\n"));
|
||||
|
||||
mmu_command(MMU_CMD_U0);
|
||||
// get response
|
||||
manage_response(false, true);
|
||||
|
||||
|
@ -820,3 +894,14 @@ void extr_unload_4()
|
|||
change_extr(4);
|
||||
extr_unload();
|
||||
}
|
||||
|
||||
bool mmu_check_version()
|
||||
{
|
||||
return (mmu_buildnr >= MMU_REQUIRED_FW_BUILDNR);
|
||||
}
|
||||
|
||||
void mmu_show_warning()
|
||||
{
|
||||
printf_P(PSTR("MMU2 firmware version invalid. Required version: build number %d or higher."), MMU_REQUIRED_FW_BUILDNR);
|
||||
kill(_i("Please update firmware in your MMU2. Waiting for reset."));
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue