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.
This commit is contained in:
Yuri D'Elia 2020-02-05 14:23:41 +01:00
parent ce74b746f1
commit d47363d85a
3 changed files with 13 additions and 3 deletions

View File

@ -6673,7 +6673,7 @@ Sigma_Exit:
{ {
if(code_seen(axis_codes[i])) if(code_seen(axis_codes[i]))
{ {
if(i == 3) { // E if(i == E_AXIS) { // E
float value = code_value(); float value = code_value();
if(value < 20.0) { if(value < 20.0) {
float factor = cs.axis_steps_per_unit[i] / value; // increase e constants if M92 E14 is given for netfab. 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; axis_steps_per_sqr_second[i] *= factor;
} }
cs.axis_steps_per_unit[i] = value; cs.axis_steps_per_unit[i] = value;
fsensor_set_axis_steps_per_unit(value);
} }
else { else {
cs.axis_steps_per_unit[i] = code_value(); 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 res_valid |= (i == E_AXIS) && ((res_new == 64) || (res_new == 128)); // resolutions valid for E only
if (res_valid) if (res_valid)
{ {
st_synchronize(); st_synchronize();
uint16_t res = tmc2130_get_res(i); uint16_t res = tmc2130_get_res(i);
tmc2130_set_res(i, res_new); tmc2130_set_res(i, res_new);
@ -8446,6 +8446,8 @@ Sigma_Exit:
cs.axis_steps_per_unit[i] /= fac; cs.axis_steps_per_unit[i] /= fac;
position[i] /= fac; position[i] /= fac;
} }
if (i == E_AXIS)
fsensor_set_axis_steps_per_unit(cs.axis_steps_per_unit[i]);
} }
} }
} }

View File

@ -149,6 +149,11 @@ void fsensor_checkpoint_print(void)
restore_print_from_ram_and_continue(0); 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) void fsensor_init(void)
{ {
#ifdef PAT9125 #ifdef PAT9125
@ -161,7 +166,7 @@ void fsensor_init(void)
#ifdef PAT9125 #ifdef PAT9125
uint8_t oq_meassure_enabled = eeprom_read_byte((uint8_t*)EEPROM_FSENS_OQ_MEASS_ENABLED); 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_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) if (!pat9125)
{ {

View File

@ -29,6 +29,9 @@ extern void fsensor_checkpoint_print(void);
//! initialize //! initialize
extern void fsensor_init(void); extern void fsensor_init(void);
//! update axis resolution
extern void fsensor_set_axis_steps_per_unit(float u);
//! @name enable/disable //! @name enable/disable
//! @{ //! @{
extern bool fsensor_enable(bool bUpdateEEPROM=true); extern bool fsensor_enable(bool bUpdateEEPROM=true);