Skip to content

Commit

Permalink
PRINT:Add retry for probe and temperature protection process
Browse files Browse the repository at this point in the history
Signed-off-by: winter.tian <winter.tian@anker-in.com>
  • Loading branch information
WinterAnker committed Mar 7, 2023
1 parent 2a25d21 commit 7d1922f
Show file tree
Hide file tree
Showing 20 changed files with 854 additions and 243 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -807,7 +807,7 @@
//#define ENDSTOPPULLUP_IMIN
//#define ENDSTOPPULLUP_JMIN
//#define ENDSTOPPULLUP_KMIN
//#define ENDSTOPPULLUP_ZMIN_PROBE
#define ENDSTOPPULLUP_ZMIN_PROBE
#endif

// Enable pulldown for all endstops to prevent a floating state
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -273,7 +273,7 @@
* THERMAL_PROTECTION_HYSTERESIS and/or THERMAL_PROTECTION_PERIOD
*/
#if ENABLED(THERMAL_PROTECTION_HOTENDS)
#define THERMAL_PROTECTION_PERIOD 40 // Seconds
#define THERMAL_PROTECTION_PERIOD 20//40 // Seconds
#define THERMAL_PROTECTION_HYSTERESIS 4 // Degrees Celsius

//#define ADAPTIVE_FAN_SLOWING // Slow part cooling fan if temperature drops
Expand All @@ -294,20 +294,20 @@
* below 2.
*/
#define WATCH_TEMP_PERIOD 20//40 // Seconds
#define WATCH_TEMP_INCREASE 2 // Degrees Celsius
#define WATCH_TEMP_INCREASE 5//2 // Degrees Celsius
#endif

/**
* Thermal Protection parameters for the bed are just as above for hotends.
*/
#if ENABLED(THERMAL_PROTECTION_BED)
#define THERMAL_PROTECTION_BED_PERIOD 40 // Seconds
#define THERMAL_PROTECTION_BED_PERIOD 60//40 // Seconds
#define THERMAL_PROTECTION_BED_HYSTERESIS 2 // Degrees Celsius

/**
* As described above, except for the bed (M140/M190/M303).
*/
#define WATCH_BED_TEMP_PERIOD 60 // Seconds
#define WATCH_BED_TEMP_PERIOD 150//60 // Seconds
#define WATCH_BED_TEMP_INCREASE 2 // Degrees Celsius
#endif

Expand Down
87 changes: 55 additions & 32 deletions release_marlin2.0/maincode/Marlin/src/feature/anker/anker_align.cpp
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
/*
* @Author : harley
* @Date : 2022-04-27 20:35:23
* @LastEditors : harley
* @LastEditTime :
* @LastEditors: winter.tian
* @LastEditTime: 2023-03-01 12:17:41
* @Description :
*/
#include "../../inc/MarlinConfig.h"
Expand All @@ -16,6 +16,9 @@

Anker_Align anker_align;

float Anker_Align::eeprom_z1_value=0;
float Anker_Align::eeprom_z2_value=0;
bool Anker_Align::is_g36_cmd_executing=false;
float Anker_Align::z1_value=0;
float Anker_Align::z2_value=0;
//uint8_t Anker_Align::anker_is_leveing=0;
Expand All @@ -24,9 +27,9 @@
void Anker_Align:: init(void)
{
anker_align.xy[0].x=PROBING_MARGIN;
anker_align.xy[0].y=117.5;
anker_align.xy[0].y=110;
anker_align.xy[1].x=X_BED_SIZE-PROBING_MARGIN;
anker_align.xy[1].y=117.5;
anker_align.xy[1].y=110;
#ifdef ALIGN_PER_RESET
anker_align.reset();
#endif
Expand Down Expand Up @@ -81,49 +84,69 @@
void Anker_Align::auto_align(void)
{
uint16_t num=0;
is_g36_cmd_executing = true;
const ProbePtRaise raise_after = PROBE_PT_RAISE;
anker_align.init();
gcode.process_subcommands_now_P(PSTR("G28"));
for(num=0;num<ANLIGN_NUM;num++)
{
do_blocking_move_to_z(current_position.z+ANLIGN_RISE);
const float z1 = probe.probe_at_point(anker_align.xy[0], raise_after, 0, true, false);
do_blocking_move_to_z(current_position.z+ANLIGN_RISE);
const float z2 = probe.probe_at_point(anker_align.xy[1], raise_after, 0, true, false);
float rise_z=0;
do_blocking_move_to_z(current_position.z+ANLIGN_RISE);
const float z1 = probe.probe_at_point(anker_align.xy[0], raise_after, 0, true, false);
if(isnan(z1))
{
SERIAL_ECHO("ok\r\n");
SERIAL_ERROR_MSG("z1 is nan error!\r\n");
SERIAL_ERROR_MSG(STR_ERR_PROBING_FAILED);
kill();
}
do_blocking_move_to_z(current_position.z+ANLIGN_RISE);
const float z2 = probe.probe_at_point(anker_align.xy[1], raise_after, 0, true, false);
if(isnan(z2))
{
SERIAL_ECHO("ok\r\n");
SERIAL_ERROR_MSG("z2 is nan error!\r\n");
SERIAL_ERROR_MSG(STR_ERR_PROBING_FAILED);
kill();
}
float rise_z=0;
rise_z=(SCREW_DISTANCE/(anker_align.xy[1].x-anker_align.xy[0].x))*ABS(z1-z2);
SERIAL_ECHO(" z1:");
SERIAL_ECHO(z1);
SERIAL_ECHO(" \r\n");
SERIAL_ECHO(" z2:");
SERIAL_ECHO(z2);
SERIAL_ECHO(" \r\n");
if(ABS(z1-z2)>ANLIGN_MAX_VALUE)
{
SERIAL_ECHO("ok\r\n");
SERIAL_ERROR_MSG("Adjustment range over 2mm!!\r\n");
SERIAL_ERROR_MSG(STR_ERR_PROBING_FAILED);
kill();
}
if(ABS(z1-z2)<=ANLIGN_ALLOWED)
{
SERIAL_ECHO("echo:anlign ok!\r\n");
gcode.process_subcommands_now_P(PSTR("M500\n"));
break;
}
else if(z1>z2)
{
anker_align.add_z1_value(rise_z);
}
else if(z2>z1)
{
anker_align.add_z2_value(rise_z);
}
if(ABS(z1-z2)>ANLIGN_MAX_VALUE)
{
SERIAL_ECHO("ok\r\n");
SERIAL_ERROR_MSG("Adjustment range over 2mm!!\r\n");
SERIAL_ERROR_MSG(STR_ERR_PROBING_FAILED);
kill();
}
if(ABS(z1-z2)<=ANLIGN_ALLOWED)
{
anker_align.eeprom_z1_value = anker_align.z1_value;
anker_align.eeprom_z2_value = anker_align.z2_value;
is_g36_cmd_executing = false;
SERIAL_ECHO("echo:anlign ok!\r\n");
gcode.process_subcommands_now_P(PSTR("M500\n"));
MYSERIAL2.printf("anker_align.eeprom_z1_value: %f\r\n", anker_align.eeprom_z1_value);
MYSERIAL2.printf("anker_align.eeprom_z2_value: %f\r\n", anker_align.eeprom_z2_value);
break;
}
else if(z1>z2)
{
anker_align.add_z1_value(rise_z);
}
else if(z2>z1)
{
anker_align.add_z2_value(rise_z);
}

anker_align.xy[0].x=PROBING_MARGIN;
anker_align.xy[0].y+=1.5;
anker_align.xy[0].y+=3;
anker_align.xy[1].x=X_BED_SIZE-PROBING_MARGIN;
anker_align.xy[1].y+=1.5;
anker_align.xy[1].y+=3;

if(num==(ANLIGN_NUM-1))
{
Expand Down
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
/*
* @Author : harley
* @Date : 2022-04-31 20:35:23
* @LastEditors : harley
* @LastEditTime :
* @LastEditors: winter.tian
* @LastEditTime: 2023-02-20 10:19:35
* @Description :
*/
#include "../../inc/MarlinConfig.h"
Expand All @@ -11,6 +11,8 @@
class Anker_Align {
public:
static xy_pos_t xy[NUM_Z_STEPPER_DRIVERS];
static float eeprom_z1_value,eeprom_z2_value;
static bool is_g36_cmd_executing;
static float z1_value,z2_value;
//static uint8_t anker_is_leveing;
void init(void);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
* @Author : winter
* @Date : 2022-05-12 20:30:21
* @LastEditors: winter.tian
* @LastEditTime: 2022-12-16 12:02:56
* @LastEditTime: 2023-02-07 14:49:28
* @Description :
*/
#include "anker_nozzle_board.h"
Expand Down Expand Up @@ -461,7 +461,6 @@ static void anker_nozzle_board_tx_deal(void)
memset(p_info->tx_buf, 0, sizeof(p_info->tx_buf));
p_info->com_abnormal_flag = 0;
p_info->tx_deal_step = 10;
thermalManager.temp_watch_mos2_stop_flag = false;
}
else
{
Expand All @@ -486,7 +485,6 @@ static void anker_nozzle_board_tx_deal(void)
p_info->com_abnormal_flag = 1;
p_info->tx_init_flag = 0;
p_info->tx_deal_step = 0;
thermalManager.temp_watch_mos2_stop_flag = true;
debug_log_printf("[nozzle-%d]:TX_ERROR_TIMES: %d\r\n", __LINE__, p_info->tx_error_times);
}
else
Expand Down Expand Up @@ -810,7 +808,7 @@ static void anker_nozzle_board_deal(void)
anker_nozzle_board_info_t *p_info = get_anker_nozzle_board_info();

#if ENABLED(ANKER_TEMP_WATCH)
if (thermalManager.temp_watch_is_error() || thermalManager.temp_watch_is_mos2_self_test())
if (thermalManager.temp_watch_is_error())
{
p_info->power_off();
return;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
* @Author : winter
* @Date : 2022-04-02 10:50:23
* @LastEditors: winter.tian
* @LastEditTime: 2023-03-07 10:11:48
* @LastEditTime: 2023-03-06 15:05:28
* @Description :
*/
#include "anker_pause.h"
Expand Down Expand Up @@ -128,6 +128,7 @@ static void anker_pause_block_deal(void)
planner.clear_block_buffer();
}

#define PRINT_LAYER_NUM 10
static void anker_pause_deal(void)
{
anker_pause_info_t *p_info = get_anker_pause_info();
Expand Down Expand Up @@ -166,7 +167,7 @@ static void anker_pause_deal(void)
}

memset(p_info->tmp_cmd_buf, 0, sizeof(p_info->tmp_cmd_buf));
sprintf(p_info->tmp_cmd_buf, "<== %d ==> : queue_length = %d --- %d\r\n", __LINE__, p_info->save_queue_buf.length, queue.ring_buffer.length);
snprintf(p_info->tmp_cmd_buf, sizeof(p_info->tmp_cmd_buf), "<== %d ==> : queue_length = %d --- %d\r\n", __LINE__, p_info->save_queue_buf.length, queue.ring_buffer.length);
MYSERIAL1.printf(p_info->tmp_cmd_buf);

p_info->pause_deal_step = ANKER_PAUSE_DEAL_STEP_SAVE_BLOCK;
Expand Down Expand Up @@ -230,8 +231,17 @@ static void anker_pause_deal(void)
// planner.clear_block_buffer();
p_info->pause_block_state = ANKER_PAUSE_BLOCK_DISABLE;
p_info->pause_queue_state = ANKER_PAUSE_QUEUE_DISABLE;
queue.ring_buffer.enqueue("G1 X10 Y0 F15000\r\n");
// MYSERIAL1.printf("go zero\r\n");
if(parser.report_layer_num <= PRINT_LAYER_NUM)
{
snprintf(p_info->tmp_cmd_buf, sizeof(p_info->tmp_cmd_buf), "G1 Z%f F12000\r\n", p_info->save_block_buf.cur_pos.z + 2);
queue.ring_buffer.enqueue(p_info->tmp_cmd_buf);
}
queue.ring_buffer.enqueue("G1 X10 Y0 F12000\r\n");
if(parser.report_layer_num <= PRINT_LAYER_NUM)
{
snprintf(p_info->tmp_cmd_buf, sizeof(p_info->tmp_cmd_buf), "G1 Z%f F12000\r\n", p_info->save_block_buf.cur_pos.z);
queue.ring_buffer.enqueue(p_info->tmp_cmd_buf);
}
p_info->pause_serial_state = ANKER_PAUSE_SERIAL_DISABLE;

p_info->pause_state = ANKER_PAUSE_OK;
Expand All @@ -247,20 +257,25 @@ static void anker_pause_deal(void)

memset(p_info->tmp_cmd_buf, 0, sizeof(p_info->tmp_cmd_buf));
#if ENABLED(ANKER_PAUSE_RESET)
sprintf(p_info->tmp_cmd_buf, "G28 X0 Y0 F15000\r\n");
snprintf(p_info->tmp_cmd_buf, sizeof(p_info->tmp_cmd_buf), "G28 X0 Y0 F15000\r\n");
queue.ring_buffer.enqueue(p_info->tmp_cmd_buf);
#endif
#if ENABLED(ANKER_PAUSE_PRE_EXTRUDE)
sprintf(p_info->tmp_cmd_buf, "G92 E%f\r\n", p_info->save_block_buf.cur_pos.e - 20);
snprintf(p_info->tmp_cmd_buf, sizeof(p_info->tmp_cmd_buf), "G92 E%f\r\n", p_info->save_block_buf.cur_pos.e - 20);
queue.ring_buffer.enqueue(p_info->tmp_cmd_buf);
sprintf(p_info->tmp_cmd_buf, "G1 E%f F500\r\n", p_info->save_block_buf.cur_pos.e);
snprintf(p_info->tmp_cmd_buf, sizeof(p_info->tmp_cmd_buf), "G1 E%f F500\r\n", p_info->save_block_buf.cur_pos.e);
queue.ring_buffer.enqueue(p_info->tmp_cmd_buf);
#endif
sprintf(p_info->tmp_cmd_buf, "G1 X%f Y%f Z%f F15000\r\n", p_info->save_block_buf.cur_pos.x,
if(parser.report_layer_num <= PRINT_LAYER_NUM)
{
snprintf(p_info->tmp_cmd_buf, sizeof(p_info->tmp_cmd_buf), "G1 Z%f F12000\r\n", p_info->save_block_buf.cur_pos.z + 2);
queue.ring_buffer.enqueue(p_info->tmp_cmd_buf);
}
snprintf(p_info->tmp_cmd_buf, sizeof(p_info->tmp_cmd_buf), "G1 X%f Y%f Z%f F12000\r\n", p_info->save_block_buf.cur_pos.x,
p_info->save_block_buf.cur_pos.y, p_info->save_block_buf.cur_pos.z);
queue.ring_buffer.enqueue(p_info->tmp_cmd_buf);
// MYSERIAL1.printf("<==> CONTINUE %s",p_info->tmp_cmd_buf);
sprintf(p_info->tmp_cmd_buf, "G1 F%f\r\n", p_info->save_block_buf.cur_fr_mm_s);
snprintf(p_info->tmp_cmd_buf, sizeof(p_info->tmp_cmd_buf), "G1 F%f\r\n", p_info->save_block_buf.cur_fr_mm_s);
queue.ring_buffer.enqueue(p_info->tmp_cmd_buf);

p_info->pause_deal_step = ANKER_PAUSE_DEAL_STEP_RECOVER_PRE;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -145,7 +145,7 @@ float find_max_min_diff(void)
NOLESS(hi_val, z_values[i][j]);
}
}
SERIAL_ECHOLNPAIR_P("MATRIX: MIN=",lo_val,",MAX=",hi_val,"DIFF=",hi_val-lo_val);
SERIAL_ECHOLNPAIR_P("MATRIX: MIN=",lo_val,",MAX=",hi_val,",DIFF=",hi_val-lo_val);
return hi_val - lo_val;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
* @Author : winter
* @Date : 2022-05-24 14:08:20
* @LastEditors: winter.tian
* @LastEditTime: 2022-12-16 11:36:44
* @LastEditTime: 2023-03-07 10:40:55
* @Description :
*/
#include "../../inc/MarlinConfig.h"
Expand Down Expand Up @@ -290,14 +290,6 @@ void GcodeSuite::M3009()
}
}

#if ENABLED(ANKER_TEMP_WATCH)
// M3008 MOS2 self-test
void GcodeSuite::M3008()
{
MYSERIAL2.printf("Mos2:Start\r\n");
MYSERIAL2.printf("Mos2:End\r\n");
}
#endif
#if 0
static bool flash_sector_read(uint32_t addr, uint32_t *data)
{
Expand Down
7 changes: 2 additions & 5 deletions release_marlin2.0/maincode/Marlin/src/gcode/gcode.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -227,8 +227,8 @@ void GcodeSuite::get_destination_from_command() {
if (parser.linearval('L') > 0)
{
parser.layer_change_flag = 1;
parser.layer_num = parser.value_int();
SERIAL_ECHOLNPAIR("\r\nLaySW:",parser.layer_num);
parser.layer_num = parser.value_float();
SERIAL_ECHOLNPAIR("\r\nLaySW:",(int)parser.layer_num);
}
//end add by jason.wu for detect layer change to notify remote controller capture
#endif
Expand Down Expand Up @@ -1121,9 +1121,6 @@ void GcodeSuite::process_parsed_command(const bool no_ok/*=false*/) {
case 3005: M3005(); break;
case 3009: M3009(); break;
#endif
#if ENABLED(ANKER_TEMP_WATCH)
case 3008: M3008(); break;
#endif
#if ENABLED(EVT_HOMING_5X)
case 89: M89(); break;
case 2004:M2004(); break;
Expand Down
3 changes: 0 additions & 3 deletions release_marlin2.0/maincode/Marlin/src/gcode/gcode.h
Original file line number Diff line number Diff line change
Expand Up @@ -1199,9 +1199,6 @@ class GcodeSuite {
static void M3005();
static void M3009();
#endif
#if ENABLED(ANKER_TEMP_WATCH)
static void M3008();
#endif
#endif

static void T(const int8_t tool_index);
Expand Down
5 changes: 3 additions & 2 deletions release_marlin2.0/maincode/Marlin/src/gcode/parser.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -36,12 +36,13 @@ bool GCodeParser::volumetric_enabled;
#if ENABLED(PHOTO_Z_LAYER)
//begin add by jason.wu for detect layer change to notify remote controller capture
uint8_t GCodeParser::layer_change_flag = 0;
int32_t GCodeParser::layer_num = 0;

float GCodeParser::layer_num = 0;
//end add by jason.wu for detect layer change to notify remote controller capture

/******************************************************************/
bool GCodeParser::report_layer;
int32_t GCodeParser::report_layer_num;
float GCodeParser::report_layer_num;
xyze_pos_t GCodeParser::report_pos;
#endif

Expand Down

0 comments on commit 7d1922f

Please sign in to comment.