Comms ACK working for new FS command
Added FS command to MMU when filament is sensed at MK3 FSensor
This commit is contained in:
parent
2c084d4fd9
commit
3d7841f3aa
File diff suppressed because it is too large
Load Diff
|
|
@ -7456,9 +7456,6 @@ void manage_inactivity(bool ignore_stepper_queue/*=false*/) //default argument s
|
||||||
{
|
{
|
||||||
if ((lcd_commands_type != LCD_COMMAND_V2_CAL) && !wizard_active && mmuFSensorLoading) {
|
if ((lcd_commands_type != LCD_COMMAND_V2_CAL) && !wizard_active && mmuFSensorLoading) {
|
||||||
fsensor_check_autoload();
|
fsensor_check_autoload();
|
||||||
} else {
|
|
||||||
fsensor_autoload_check_stop();
|
|
||||||
//fsensor_update();
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -215,7 +215,7 @@ void fsensor_autoload_check_start(void)
|
||||||
printf_P(ERRMSG_PAT9125_NOT_RESP, 3);
|
printf_P(ERRMSG_PAT9125_NOT_RESP, 3);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
puts_P(_N("fsensor_autoload_check_start - autoload ENABLED\n"));
|
if (mmu_enabled) puts_P(_N("fsensor_autoload_check_start - autoload ENABLED\n"));
|
||||||
fsensor_autoload_y = pat9125_y; //save current y value
|
fsensor_autoload_y = pat9125_y; //save current y value
|
||||||
fsensor_autoload_c = 0; //reset number of changes counter
|
fsensor_autoload_c = 0; //reset number of changes counter
|
||||||
fsensor_autoload_sum = 0;
|
fsensor_autoload_sum = 0;
|
||||||
|
|
@ -233,7 +233,7 @@ void fsensor_autoload_check_stop(void)
|
||||||
if (!fsensor_autoload_enabled) return;
|
if (!fsensor_autoload_enabled) return;
|
||||||
// puts_P(_N("fsensor_autoload_check_stop 2\n"));
|
// puts_P(_N("fsensor_autoload_check_stop 2\n"));
|
||||||
if (!fsensor_watch_autoload) return;
|
if (!fsensor_watch_autoload) return;
|
||||||
puts_P(_N("fsensor_autoload_check_stop - autoload DISABLED\n"));
|
if (mmu_enabled) puts_P(_N("fsensor_autoload_check_stop - autoload DISABLED\n"));
|
||||||
fsensor_autoload_sum = 0;
|
fsensor_autoload_sum = 0;
|
||||||
fsensor_watch_autoload = false;
|
fsensor_watch_autoload = false;
|
||||||
fsensor_watch_runout = true;
|
fsensor_watch_runout = true;
|
||||||
|
|
@ -284,11 +284,12 @@ bool fsensor_check_autoload(void)
|
||||||
// if ((fsensor_autoload_c >= 15) && (fsensor_autoload_sum > 30))
|
// if ((fsensor_autoload_c >= 15) && (fsensor_autoload_sum > 30))
|
||||||
if ((fsensor_autoload_c >= 12) && (fsensor_autoload_sum > 20))
|
if ((fsensor_autoload_c >= 12) && (fsensor_autoload_sum > 20))
|
||||||
{
|
{
|
||||||
puts_P(_N("fsensor_check_autoload = true !!!\n"));
|
//puts_P(_N("fsensor_check_autoload = true !!!\n"));
|
||||||
//if (mmu_enabled) {
|
if (mmu_enabled) {
|
||||||
mmuFilamentMK3Moving = true;
|
//mmuFilamentMK3Moving = true;
|
||||||
fsensor_autoload_check_stop();
|
mmu_command(MMU_CMD_FS);
|
||||||
//}
|
fsensor_autoload_check_stop();
|
||||||
|
}
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
return false;
|
return false;
|
||||||
|
|
|
||||||
|
|
@ -14,7 +14,7 @@ extern bool fsensor_not_responding;
|
||||||
//enable/disable quality meassurement
|
//enable/disable quality meassurement
|
||||||
extern bool fsensor_oq_meassure_enabled;
|
extern bool fsensor_oq_meassure_enabled;
|
||||||
|
|
||||||
extern bool mmuFilamentMK3Moving;
|
//extern bool mmuFilamentMK3Moving;
|
||||||
extern bool mmuFSensorLoading;
|
extern bool mmuFSensorLoading;
|
||||||
|
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -29,7 +29,7 @@ bool mmu_enabled = false;
|
||||||
|
|
||||||
bool mmu_ready = false;
|
bool mmu_ready = false;
|
||||||
|
|
||||||
bool mmuFilamentMK3Moving = false;
|
//bool mmuFilamentMK3Moving = false;
|
||||||
bool mmuFSensorLoading = false;
|
bool mmuFSensorLoading = false;
|
||||||
bool singleLog = true;
|
bool singleLog = true;
|
||||||
int lastLoadedFilament = -10;
|
int lastLoadedFilament = -10;
|
||||||
|
|
@ -141,8 +141,11 @@ int8_t mmu_rx_echo(void)
|
||||||
case MMU_CMD_R0: // R0
|
case MMU_CMD_R0: // R0
|
||||||
res = uart2_rx_str_P(PSTR("R0\n"));
|
res = uart2_rx_str_P(PSTR("R0\n"));
|
||||||
break;
|
break;
|
||||||
|
case MMU_CMD_FS: // FS
|
||||||
|
res = uart2_rx_str_P(PSTR("FS\n"));
|
||||||
|
break;
|
||||||
}
|
}
|
||||||
if (res == 0) puts_P(PSTR("MMU Didn't see CMD and ECHO"));
|
//if (res == 0) puts_P(PSTR("MMU Didn't see CMD and ECHO"));
|
||||||
if (res == 1) mmu_last_response = millis();
|
if (res == 1) mmu_last_response = millis();
|
||||||
return res;
|
return res;
|
||||||
}
|
}
|
||||||
|
|
@ -348,6 +351,9 @@ void mmu_loop(void)
|
||||||
case MMU_CMD_R0:
|
case MMU_CMD_R0:
|
||||||
mmu_puts_P(PSTR("R0\n"));
|
mmu_puts_P(PSTR("R0\n"));
|
||||||
break;
|
break;
|
||||||
|
case MMU_CMD_FS:
|
||||||
|
mmu_puts_P(PSTR("FS\n"));
|
||||||
|
break;
|
||||||
}
|
}
|
||||||
mmu_state = 10;
|
mmu_state = 10;
|
||||||
} else if (mmu_cmd && ack_received) {
|
} else if (mmu_cmd && ack_received) {
|
||||||
|
|
@ -364,7 +370,7 @@ void mmu_loop(void)
|
||||||
fsensor_autoload_check_start();
|
fsensor_autoload_check_start();
|
||||||
mmuFSensorLoading = true;
|
mmuFSensorLoading = true;
|
||||||
fsensor_autoload_enabled = true;
|
fsensor_autoload_enabled = true;
|
||||||
mmuFilamentMK3Moving = false;
|
//mmuFilamentMK3Moving = false;
|
||||||
}
|
}
|
||||||
lastLoadedFilament = filament;
|
lastLoadedFilament = filament;
|
||||||
}
|
}
|
||||||
|
|
@ -407,6 +413,13 @@ void mmu_loop(void)
|
||||||
mmu_puts_P(PSTR("EE\n")); // Advise MMU CMD is correct, execute
|
mmu_puts_P(PSTR("EE\n")); // Advise MMU CMD is correct, execute
|
||||||
mmu_state = 3; // wait for response
|
mmu_state = 3; // wait for response
|
||||||
}
|
}
|
||||||
|
else if (mmu_cmd == MMU_CMD_FS)
|
||||||
|
{
|
||||||
|
mmu_puts_P(PSTR("EE\n"));
|
||||||
|
printf_P(PSTR("MMU <= 'Filament seen at extruder'\n"));
|
||||||
|
mmuFSensorLoading = false;
|
||||||
|
mmu_state = 3; // wait for response
|
||||||
|
}
|
||||||
mmu_cmd = 0;
|
mmu_cmd = 0;
|
||||||
}
|
}
|
||||||
else if ((mmu_last_response + 500) < millis()) //request every 500ms
|
else if ((mmu_last_response + 500) < millis()) //request every 500ms
|
||||||
|
|
@ -439,26 +452,20 @@ void mmu_loop(void)
|
||||||
if (mmu_rx_ok() > 0)
|
if (mmu_rx_ok() > 0)
|
||||||
{
|
{
|
||||||
if (mmuFSensorLoading == false) {
|
if (mmuFSensorLoading == false) {
|
||||||
delay(100);
|
//delay(100);
|
||||||
printf_P(PSTR("MMU => 'ok'\n"));
|
printf_P(PSTR("MMU => 'ok'\n"));
|
||||||
mmu_ready = true;
|
mmu_ready = true;
|
||||||
mmu_state = 1;
|
mmu_state = 1;
|
||||||
} else if (mmuFilamentMK3Moving == true) {
|
|
||||||
mmu_printf_P(PSTR("FS%d\n"), 1);
|
|
||||||
printf_P(PSTR("MMU <= 'Filament seen at extruder'\n"));
|
|
||||||
mmuFSensorLoading = false;
|
|
||||||
singleLog = true;
|
singleLog = true;
|
||||||
} else {
|
} else if (singleLog) {
|
||||||
if (singleLog) {
|
|
||||||
printf_P(PSTR("MMU => 'waiting for filament @ MK3 Sensor'\n"));
|
printf_P(PSTR("MMU => 'waiting for filament @ MK3 Sensor'\n"));
|
||||||
singleLog = false;
|
singleLog = false;
|
||||||
}
|
mmu_state = 1;
|
||||||
mmu_printf_P(PSTR("FS%d\n"), 0);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else if ((mmu_last_request + MMU_CMD_TIMEOUT) < millis())
|
else if ((mmu_last_request + MMU_CMD_TIMEOUT) < millis())
|
||||||
{ //resend request after timeout (5 min)
|
{ //resend request after timeout (5 min)
|
||||||
printf_P(PSTR("MMU => 'Error State, do something here??'\n"));
|
printf_P(PSTR("MMU => 'Error State, do something here??'\n"));
|
||||||
mmu_ready = false;
|
mmu_ready = false;
|
||||||
mmu_state = 20;
|
mmu_state = 20;
|
||||||
}
|
}
|
||||||
|
|
@ -470,7 +477,8 @@ void mmu_loop(void)
|
||||||
//mmu_puts_P(PSTR("EE\n")); // Advise MMU CMD is correct, execute
|
//mmu_puts_P(PSTR("EE\n")); // Advise MMU CMD is correct, execute
|
||||||
ack_received = true;
|
ack_received = true;
|
||||||
mmu_state = 1; // Do normal Await command completion confirmation
|
mmu_state = 1; // Do normal Await command completion confirmation
|
||||||
} else if ((mmu_last_request + 250) < millis()) { // Timeout if echo doesn't match request, resend cmd
|
} else if ((mmu_last_request + 1000) < millis()) { // Timeout if echo doesn't match request, resend cmd
|
||||||
|
printf_P(PSTR("MMU => 'CMD RETRY'\n"));
|
||||||
mmu_state = 1;
|
mmu_state = 1;
|
||||||
}
|
}
|
||||||
return;
|
return;
|
||||||
|
|
@ -523,8 +531,11 @@ bool mmu_get_response(void)
|
||||||
while (!mmu_ready)
|
while (!mmu_ready)
|
||||||
{
|
{
|
||||||
//if ((mmu_last_response + MMU_CMD_TIMEOUT) < millis()) break;
|
//if ((mmu_last_response + MMU_CMD_TIMEOUT) < millis()) break;
|
||||||
if ((mmu_state != 3) || (mmu_state != 10)) break;
|
if ((mmu_state == 3) || (mmu_state == 10) || (mmuFSensorLoading)) {
|
||||||
delay_keep_alive(100);
|
delay_keep_alive(100);
|
||||||
|
} else {
|
||||||
|
break;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
bool ret = mmu_ready;
|
bool ret = mmu_ready;
|
||||||
mmu_ready = false;
|
mmu_ready = false;
|
||||||
|
|
@ -710,7 +721,7 @@ void mmu_M600_load_filament(bool automatic)
|
||||||
manage_response(false, true);
|
manage_response(false, true);
|
||||||
mmu_command(MMU_CMD_C0);
|
mmu_command(MMU_CMD_C0);
|
||||||
mmu_extruder = tmp_extruder; //filament change is finished
|
mmu_extruder = tmp_extruder; //filament change is finished
|
||||||
|
delay(100);
|
||||||
mmu_load_to_nozzle();
|
mmu_load_to_nozzle();
|
||||||
|
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -36,8 +36,7 @@ extern int16_t mmu_buildnr;
|
||||||
#define MMU_CMD_E4 0x54
|
#define MMU_CMD_E4 0x54
|
||||||
#define MMU_CMD_R0 0x60
|
#define MMU_CMD_R0 0x60
|
||||||
#define MMU_CMD_P0 0x70
|
#define MMU_CMD_P0 0x70
|
||||||
#define MMU_CMD_FS0 0x80
|
#define MMU_CMD_FS 0x81
|
||||||
#define MMU_CMD_FS1 0x81
|
|
||||||
|
|
||||||
extern int mmu_puts_P(const char* str);
|
extern int mmu_puts_P(const char* str);
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue