Merge pull request #2057 from leptun/MK3_fix_M350
M350 for all axis - MK3
This commit is contained in:
commit
4cf2f05d1d
|
|
@ -7641,27 +7641,33 @@ Sigma_Exit:
|
||||||
case 350:
|
case 350:
|
||||||
{
|
{
|
||||||
#ifdef TMC2130
|
#ifdef TMC2130
|
||||||
if(code_seen('E'))
|
for (int i=0; i<NUM_AXIS; i++)
|
||||||
{
|
{
|
||||||
uint16_t res_new = code_value();
|
if(code_seen(axis_codes[i]))
|
||||||
if ((res_new == 8) || (res_new == 16) || (res_new == 32) || (res_new == 64) || (res_new == 128))
|
|
||||||
{
|
{
|
||||||
st_synchronize();
|
uint16_t res_new = code_value();
|
||||||
uint8_t axis = E_AXIS;
|
bool res_valid = (res_new == 8) || (res_new == 16) || (res_new == 32); // resolutions valid for all axis
|
||||||
uint16_t res = tmc2130_get_res(axis);
|
res_valid |= (i != E_AXIS) && ((res_new == 1) || (res_new == 2) || (res_new == 4)); // resolutions valid for X Y Z only
|
||||||
tmc2130_set_res(axis, res_new);
|
res_valid |= (i == E_AXIS) && ((res_new == 64) || (res_new == 128)); // resolutions valid for E only
|
||||||
cs.axis_ustep_resolution[axis] = res_new;
|
if (res_valid)
|
||||||
if (res_new > res)
|
|
||||||
{
|
{
|
||||||
uint16_t fac = (res_new / res);
|
|
||||||
cs.axis_steps_per_unit[axis] *= fac;
|
st_synchronize();
|
||||||
position[E_AXIS] *= fac;
|
uint16_t res = tmc2130_get_res(i);
|
||||||
}
|
tmc2130_set_res(i, res_new);
|
||||||
else
|
cs.axis_ustep_resolution[i] = res_new;
|
||||||
{
|
if (res_new > res)
|
||||||
uint16_t fac = (res / res_new);
|
{
|
||||||
cs.axis_steps_per_unit[axis] /= fac;
|
uint16_t fac = (res_new / res);
|
||||||
position[E_AXIS] /= fac;
|
cs.axis_steps_per_unit[i] *= fac;
|
||||||
|
position[i] *= fac;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
uint16_t fac = (res / res_new);
|
||||||
|
cs.axis_steps_per_unit[i] /= fac;
|
||||||
|
position[i] /= fac;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -427,7 +427,7 @@ void tmc2130_check_overtemp()
|
||||||
|
|
||||||
void tmc2130_setup_chopper(uint8_t axis, uint8_t mres, uint8_t current_h, uint8_t current_r)
|
void tmc2130_setup_chopper(uint8_t axis, uint8_t mres, uint8_t current_h, uint8_t current_r)
|
||||||
{
|
{
|
||||||
uint8_t intpol = 1;
|
uint8_t intpol = (mres != 0); // intpol to 256 only if microsteps aren't 256
|
||||||
uint8_t toff = tmc2130_chopper_config[axis].toff; // toff = 3 (fchop = 27.778kHz)
|
uint8_t toff = tmc2130_chopper_config[axis].toff; // toff = 3 (fchop = 27.778kHz)
|
||||||
uint8_t hstrt = tmc2130_chopper_config[axis].hstr; //initial 4, modified to 5
|
uint8_t hstrt = tmc2130_chopper_config[axis].hstr; //initial 4, modified to 5
|
||||||
uint8_t hend = tmc2130_chopper_config[axis].hend; //original value = 1
|
uint8_t hend = tmc2130_chopper_config[axis].hend; //original value = 1
|
||||||
|
|
@ -600,7 +600,7 @@ void tmc2130_wr_THIGH(uint8_t axis, uint32_t val32)
|
||||||
|
|
||||||
uint8_t tmc2130_usteps2mres(uint16_t usteps)
|
uint8_t tmc2130_usteps2mres(uint16_t usteps)
|
||||||
{
|
{
|
||||||
uint8_t mres = 8; while (mres && (usteps >>= 1)) mres--;
|
uint8_t mres = 8; while (usteps >>= 1) mres--;
|
||||||
return mres;
|
return mres;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue