Skip to content

Commit

Permalink
Accept Merge Request #2084: (mr/master/bugfix-1 -> master)
Browse files Browse the repository at this point in the history
Merge Request: PRINT:Fix temperature shock issue


Created By: @winter.tian
Accepted By: @pepper.hu
URL: http://codingcorp.coding.anker-in.com/p/zz_3d_platform/d/AnkerMake-Marlin-Release/git/merge/2084
  • Loading branch information
pepperAnker committed Jun 10, 2023
2 parents 288522c + 8b159d6 commit 0a35bdc
Show file tree
Hide file tree
Showing 43 changed files with 2,428 additions and 149 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -2602,7 +2602,11 @@
//
// Additional options for DGUS / DWIN displays
//

//#define ANKERUI
#if ENABLED(ANKERUI)
#define LCD_SERIAL_PORT 3
#define LCD_BAUDRATE 115200
#endif
//
// Touch-screen LCD for Malyan M200/M300 printers
//
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -426,7 +426,7 @@

// Show Temperature ADC value
// Enable for M105 to include ADC values read from temperature sensors.
//#define SHOW_TEMP_ADC_VALUES
// #define SHOW_TEMP_ADC_VALUES

/**
* High Temperature Thermistor Support
Expand Down Expand Up @@ -2993,6 +2993,12 @@
#define TCOOLTHRS_Z1 1000
#define TCOOLTHRS_Z2 1000
#endif

// Delay Sensorless Homing/Probing
#if !defined(SENSORLESS_STALLGUARD_DELAY)
#define SENSORLESS_STALLGUARD_DELAY 200
#endif

#endif

/**
Expand Down
2 changes: 2 additions & 0 deletions release_marlin2.0/maincode/Marlin/src/HAL/STM32/fastio.h
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,8 @@ void FastIO_init(); // Must be called before using fast io macros
#define _READ(IO) bool(READ_BIT(FastIOPortMap[STM_PORT(digitalPinToPinName(IO))]->IDR, _BV32(STM_PIN(digitalPinToPinName(IO)))))
#define _TOGGLE(IO) TBI32(FastIOPortMap[STM_PORT(digitalPinToPinName(IO))]->ODR, STM_PIN(digitalPinToPinName(IO)))

#define READ_OUT(IO) bool(READ_BIT(FastIOPortMap[STM_PORT(digitalPinToPinName(IO))]->ODR, _BV32(STM_PIN(digitalPinToPinName(IO)))))

#define _GET_MODE(IO)
#define _SET_MODE(IO,M) pinMode(IO, M)
#define _SET_OUTPUT(IO) pinMode(IO, OUTPUT) //!< Output Push Pull Mode & GPIO_NOPULL
Expand Down
54 changes: 45 additions & 9 deletions release_marlin2.0/maincode/Marlin/src/MarlinCore.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -276,6 +276,10 @@
#include "feature/anker/anker_homing.h"
#endif

#if ADAPT_DETACHED_NOZZLE
#include "feature/interactive/uart_nozzle_rx.h"
#include "feature/interactive/oci.h"
#endif

PGMSTR(M112_KILL_STR, "M112 Shutdown");

Expand Down Expand Up @@ -352,6 +356,8 @@ void enable_e_steppers() {

void enable_all_steppers() {
TERN_(AUTO_POWER_CONTROL, powerManager.power_on());
OUT_WRITE(MOTOR_EN_PIN, HIGH);
safe_delay(100);
ENABLE_AXIS_X();
ENABLE_AXIS_Y();
ENABLE_AXIS_Z();
Expand Down Expand Up @@ -384,6 +390,8 @@ void disable_all_steppers() {
DISABLE_AXIS_K();
disable_e_steppers();

safe_delay(100);
OUT_WRITE(MOTOR_EN_PIN, LOW);
TERN_(EXTENSIBLE_UI, ExtUI::onSteppersDisabled());
}

Expand Down Expand Up @@ -936,10 +944,20 @@ void idle(bool no_stepper_sleep/*=false*/) {
anker_homing.anker_disable_motton_before_check();
#endif

#if ENABLED(PROVE_CONTROL) && ENABLED(ANKER_NOZZLE_BOARD)
get_anker_nozzle_board_info()->nozzle_board_deal();
#endif

if (nozzle_board_type == NOZZLE_TYPE_OLD)
{
#if ENABLED(PROVE_CONTROL) && ENABLED(ANKER_NOZZLE_BOARD)
get_anker_nozzle_board_info()->nozzle_board_deal();
#endif
}
else
{
#if ADAPT_DETACHED_NOZZLE
uart_nozzle_polling();
#endif
}


IDLE_DONE:
TERN_(MARLIN_DEV_MODE, idle_depth--);
return;
Expand Down Expand Up @@ -1215,16 +1233,22 @@ void setup() {
#define SETUP_RUN(C) do{ SETUP_LOG(STRINGIFY(C)); C; }while(0)

MYSERIAL1.begin(BAUDRATE);
millis_t serial_connect_timeout = millis() + 1000UL;
while (!MYSERIAL1.connected() && PENDING(millis(), serial_connect_timeout)) { /*nada*/ }
// millis_t serial_connect_timeout = millis() + 1000UL;
// while (!MYSERIAL1.connected() && PENDING(millis(), serial_connect_timeout)) { /*nada*/ }

#if ENABLED(ANKERUI)
LCD_SERIAL.begin(LCD_BAUDRATE);
serial_connect_timeout = millis() + 1000UL;
while (!LCD_SERIAL.connected() && PENDING(millis(), serial_connect_timeout)) { /*nada*/ }
#endif

#if HAS_MULTI_SERIAL && !HAS_ETHERNET
#ifndef BAUDRATE_2
#define BAUDRATE_2 BAUDRATE
#endif
MYSERIAL2.begin(BAUDRATE_2);
serial_connect_timeout = millis() + 1000UL;
while (!MYSERIAL2.connected() && PENDING(millis(), serial_connect_timeout)) { /*nada*/ }
// serial_connect_timeout = millis() + 1000UL;
// while (!MYSERIAL2.connected() && PENDING(millis(), serial_connect_timeout)) { /*nada*/ }
#if DISABLED(PROVE_CONTROL) && DISABLED(ANKER_NOZZLE_BOARD)
#ifdef SERIAL_PORT_3
#ifndef BAUDRATE_3
Expand Down Expand Up @@ -1277,6 +1301,11 @@ void setup() {
#endif
#endif

#if ADAPT_DETACHED_NOZZLE
oci_latch_clear();
hw_select();
#endif

TERN_(DYNAMIC_VECTORTABLE, hook_cpu_exceptions()); // If supported, install Marlin exception handlers at runtime

SETUP_RUN(HAL_init());
Expand Down Expand Up @@ -1696,6 +1725,8 @@ void setup() {
ui.check_touch_calibration();
#endif

TERN_(ANKERUI,module_task_init());

marlin_state = MF_RUNNING;

#if ENABLED(PROVE_CONTROL) && ENABLED(ANKER_NOZZLE_BOARD)
Expand All @@ -1708,7 +1739,7 @@ void setup() {

#if ENABLED(MOTOR_EN_CONTROL)
pinMode(MOTOR_EN_PIN,OUTPUT);
digitalWrite(MOTOR_EN_PIN,MOTOR_EN_STATE);
digitalWrite(MOTOR_EN_PIN,!MOTOR_EN_STATE);
#endif

#if HEATER_EN_CONTROL&&HANDSHAKE==0
Expand Down Expand Up @@ -1741,6 +1772,11 @@ void setup() {
#endif

SETUP_LOG("setup() completed.");

#if ADAPT_DETACHED_NOZZLE
uart_nozzle_init();
oci_init();
#endif
}

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,9 @@
#include "../../module/probe.h"
#include "../../gcode/gcode.h"
#include "../../module/temperature.h"
#if ENABLED(ADAPT_DETACHED_NOZZLE)
#include "../interactive/uart_nozzle_rx.h"
#endif

Anker_Align anker_align;

Expand Down Expand Up @@ -86,6 +89,7 @@
uint16_t num=0;
is_g36_cmd_executing = true;
const ProbePtRaise raise_after = PROBE_PT_RAISE;
const float __align_allowed = TERN(ADAPT_DETACHED_NOZZLE, IS_new_nozzle_board() ? NOZZLE_TYPE_NEW_ANLIGN_ALLOWED : ANLIGN_ALLOWED, ANLIGN_ALLOWED);
anker_align.init();
gcode.process_subcommands_now_P(PSTR("G28"));
for(num=0;num<ANLIGN_NUM;num++)
Expand Down Expand Up @@ -123,7 +127,7 @@
SERIAL_ERROR_MSG(STR_ERR_PROBING_FAILED);
kill();
}
if(ABS(z1-z2)<=ANLIGN_ALLOWED)
if(ABS(z1-z2) <= __align_allowed)
{
anker_align.eeprom_z1_value = anker_align.z1_value;
anker_align.eeprom_z2_value = anker_align.z2_value;
Expand All @@ -150,7 +154,7 @@

if(num==(ANLIGN_NUM-1))
{
if(ABS(z1-z2)>ANLIGN_ALLOWED)
if(ABS(z1-z2) > __align_allowed)
{
SERIAL_ECHO("echo:Please check the Z-axis limit!\r\n");
anker_align.reset();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,10 @@
*/
#include "anker_homing.h"
#include "../bedlevel/bedlevel.h"
#if ADAPT_DETACHED_NOZZLE
#include "../interactive/uart_nozzle_tx.h"
#include "../interactive/uart_nozzle_rx.h"
#endif
#if ENABLED(EVT_HOMING_5X)

Anker_Homing anker_homing;
Expand Down Expand Up @@ -64,11 +68,17 @@
do_blocking_move_to(first_z2_pos, feedRate_t(XY_PROBE_FEEDRATE_MM_S));
}

set_anker_z_sensorless_probe_value(800);
if (nozzle_board_type == NOZZLE_TYPE_OLD)
set_anker_z_sensorless_probe_value(800);
else
uart_nozzle_tx_probe_val(800);

#if ENABLED(PROVE_CONTROL)
digitalWrite(PROVE_CONTROL_PIN, !PROVE_CONTROL_STATE);
if (!IS_new_nozzle_board())
digitalWrite(PROVE_CONTROL_PIN, !PROVE_CONTROL_STATE);
probe.anker_level_set_probing_paused(true,ANKER_LEVEING_DELAY_BEFORE_PROBING);
digitalWrite(PROVE_CONTROL_PIN, PROVE_CONTROL_STATE);
if (!IS_new_nozzle_board())
digitalWrite(PROVE_CONTROL_PIN, PROVE_CONTROL_STATE);
#endif
for(u_int16_t i=0;i<(DUAL_Z_NOZZLE_BELOW_BED_MM/DUAL_Z_NOZZLE_BELOW_BED_STEP_MM);i++)
{
Expand Down Expand Up @@ -111,7 +121,8 @@


#if ENABLED(PROVE_CONTROL)
digitalWrite(PROVE_CONTROL_PIN, !PROVE_CONTROL_STATE);
if (!IS_new_nozzle_board())
digitalWrite(PROVE_CONTROL_PIN, !PROVE_CONTROL_STATE);
#endif
reset_anker_z_sensorless_probe_value();
}
Expand Down
137 changes: 137 additions & 0 deletions release_marlin2.0/maincode/Marlin/src/feature/anker/anker_z_offset.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,137 @@
/*
* @Author : winter
* @Date : 2022-08-23 11:42:50
* @LastEditors : winter
* @LastEditTime : 2022-08-25 15:10:45
* @Description :
*/
#include "anker_z_offset.h"

#if ENABLED(ANKER_MAKE_API)

#include "../../gcode/gcode.h"
#include "../../module/probe.h"
#include "../interactive/uart_nozzle_rx.h"

Anker_Probe_set anker_probe_set;
int16_t Anker_Probe_set::homing_value = HOMING_PROBE_VALUE;
int16_t Anker_Probe_set::leveing_value = LEVEING_PROBE_VALUE;
uint16_t Anker_Probe_set::delay = LEVEING_PROBE_DELAY;
uint8_t Anker_Probe_set::run_step = 0;
bool Anker_Probe_set::auto_run_flag = false;
bool Anker_Probe_set::point_test_flag = false;
xy_pos_t Anker_Probe_set::xy[5];

void Anker_Probe_set::probe_start(uint16_t value)
{
#if ADAPT_DETACHED_NOZZLE
safe_delay(anker_probe_set.delay);
uart_nozzle_tx_probe_val(value);
SERIAL_ECHO("probe_start\r\n");
#else
MYSERIAL1.printf("M2012 S%d\n", value);
#endif
}

void Anker_Probe_set::reset_value()
{
anker_probe_set.homing_value = HOMING_PROBE_VALUE;
anker_probe_set.leveing_value = LEVEING_PROBE_VALUE;
}

void Anker_Probe_set::report_value()
{
SERIAL_ECHO("anker probe homing value: ");
SERIAL_ECHO(anker_probe_set.homing_value);
SERIAL_ECHO("\r\nanker probe leveing value: ");
SERIAL_ECHO(anker_probe_set.leveing_value);
SERIAL_ECHO("\r\n");
}

void Anker_Probe_set::get_probe_value()
{
uart_nozzle_tx_probe_val_get();
}

void Anker_Probe_set::show_adc_value(bool show_adc)
{
if (show_adc)
{
uart_nozzle_tx_show_adc_value_on();
}
else
{
uart_nozzle_tx_show_adc_value_off();
}
}

void Anker_Probe_set::pid_autotune(uint16_t temp, uint16_t ncyclesc)
{
uart_nozzle_tx_pid_autotune(temp, ncyclesc);
SERIAL_ECHO("PID AUTOTUNE START \r\n");
}

void Anker_Probe_set::run()
{
switch (anker_probe_set.run_step)
{
case 0:
gcode.process_subcommands_now_P(PSTR("M104 S230\nM109 S230\n"));
gcode.process_subcommands_now_P(PSTR("G28\n"));
gcode.process_subcommands_now_P(PSTR("G1 Z80 F900\n"));
gcode.process_subcommands_now_P(PSTR("G1 X110 Y110 F6000\n"));
anker_probe_set.run_step = 1;
break;
case 1:
gcode.process_subcommands_now_P(PSTR("G2001\n"));
break;
default:
break;
}
}

void Anker_Probe_set::home_delay()
{
safe_delay(PROBE_READ_NUM_DELAY);
}

void Anker_Probe_set::auto_run()
{
gcode.process_subcommands_now_P(PSTR("M104 S230\nM109 S230\n"));
anker_probe_set.auto_run_flag = true;
gcode.process_subcommands_now_P(PSTR("G28\n"));
}

void Anker_Probe_set::auto_run_send_start_info()
{
safe_delay(anker_probe_set.delay);
uart_nozzle_tx_auto_offset_start();
SERIAL_ECHO("auto_run_send_start_info\r\n");
}

void Anker_Probe_set::point_test_ready()
{
anker_probe_set.xy[0].x = 0;
anker_probe_set.xy[0].y = 110;
anker_probe_set.xy[1].x = 55;
anker_probe_set.xy[1].y = 110;
anker_probe_set.xy[2].x = 110;
anker_probe_set.xy[2].y = 110;
anker_probe_set.xy[3].x = 165;
anker_probe_set.xy[3].y = 110;
anker_probe_set.xy[4].x = 220;
anker_probe_set.xy[4].y = 110;

gcode.process_subcommands_now_P(PSTR("M104 S230\nM109 S230\n"));
gcode.process_subcommands_now_P(PSTR("G28\n"));
gcode.process_subcommands_now_P(PSTR("G1 Z80 F900\n"));
gcode.process_subcommands_now_P(PSTR("G1 X110 Y110 F6000\n"));
anker_probe_set.point_test_flag = true;
}

void Anker_Probe_set::point_test(uint8_t point)
{
probe.probe_at_point(anker_probe_set.xy[point], PROBE_PT_RAISE, 0, true, false);
}

#endif /* ANKER_PROBE_SET */
Loading

0 comments on commit 0a35bdc

Please sign in to comment.