From d47363d85a5a813e86af8458bacc0f4970904615 Mon Sep 17 00:00:00 2001 From: Yuri D'Elia Date: Wed, 5 Feb 2020 14:23:41 +0100 Subject: [PATCH] Update the filament axis resolution when E resolution is changed The filament sensor "chunk lenght" needs to be updated every time the E axis resolution is changed in order to trigger at the same distance. Introduce a new function fsensor_set_axis_steps_per_unit() and use it consistent during init, in M92 and M350. --- Firmware/Marlin_main.cpp | 6 ++++-- Firmware/fsensor.cpp | 7 ++++++- Firmware/fsensor.h | 3 +++ 3 files changed, 13 insertions(+), 3 deletions(-) diff --git a/Firmware/Marlin_main.cpp b/Firmware/Marlin_main.cpp index 0a1e5439..047b7082 100755 --- a/Firmware/Marlin_main.cpp +++ b/Firmware/Marlin_main.cpp @@ -6673,7 +6673,7 @@ Sigma_Exit: { if(code_seen(axis_codes[i])) { - if(i == 3) { // E + if(i == E_AXIS) { // E float value = code_value(); if(value < 20.0) { float factor = cs.axis_steps_per_unit[i] / value; // increase e constants if M92 E14 is given for netfab. @@ -6682,6 +6682,7 @@ Sigma_Exit: axis_steps_per_sqr_second[i] *= factor; } cs.axis_steps_per_unit[i] = value; + fsensor_set_axis_steps_per_unit(value); } else { cs.axis_steps_per_unit[i] = code_value(); @@ -8429,7 +8430,6 @@ Sigma_Exit: res_valid |= (i == E_AXIS) && ((res_new == 64) || (res_new == 128)); // resolutions valid for E only if (res_valid) { - st_synchronize(); uint16_t res = tmc2130_get_res(i); tmc2130_set_res(i, res_new); @@ -8446,6 +8446,8 @@ Sigma_Exit: cs.axis_steps_per_unit[i] /= fac; position[i] /= fac; } + if (i == E_AXIS) + fsensor_set_axis_steps_per_unit(cs.axis_steps_per_unit[i]); } } } diff --git a/Firmware/fsensor.cpp b/Firmware/fsensor.cpp index 7daea8da..297460d6 100755 --- a/Firmware/fsensor.cpp +++ b/Firmware/fsensor.cpp @@ -149,6 +149,11 @@ void fsensor_checkpoint_print(void) restore_print_from_ram_and_continue(0); } +void fsensor_set_axis_steps_per_unit(float u) +{ + fsensor_chunk_len = (int16_t)(FSENSOR_CHUNK_LEN * u); +} + void fsensor_init(void) { #ifdef PAT9125 @@ -161,7 +166,7 @@ void fsensor_init(void) #ifdef PAT9125 uint8_t oq_meassure_enabled = eeprom_read_byte((uint8_t*)EEPROM_FSENS_OQ_MEASS_ENABLED); fsensor_oq_meassure_enabled = (oq_meassure_enabled == 1)?true:false; - fsensor_chunk_len = (int16_t)(FSENSOR_CHUNK_LEN * cs.axis_steps_per_unit[E_AXIS]); + fsensor_set_axis_steps_per_unit(cs.axis_steps_per_unit[E_AXIS]); if (!pat9125) { diff --git a/Firmware/fsensor.h b/Firmware/fsensor.h index fba131db..0c791d41 100755 --- a/Firmware/fsensor.h +++ b/Firmware/fsensor.h @@ -29,6 +29,9 @@ extern void fsensor_checkpoint_print(void); //! initialize extern void fsensor_init(void); +//! update axis resolution +extern void fsensor_set_axis_steps_per_unit(float u); + //! @name enable/disable //! @{ extern bool fsensor_enable(bool bUpdateEEPROM=true);