M350 for E axis (8, 16, 32, 64, 128 microsteps)
This commit is contained in:
parent
79caf3d9c6
commit
57499dc6a0
6 changed files with 103 additions and 40 deletions
|
@ -446,6 +446,11 @@ void dcode_10()
|
||||||
calibration_status_store(CALIBRATION_STATUS_LIVE_ADJUST);
|
calibration_status_store(CALIBRATION_STATUS_LIVE_ADJUST);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void dcode_12()
|
||||||
|
{//Time
|
||||||
|
LOG("D12 - Time\n");
|
||||||
|
}
|
||||||
|
|
||||||
#include "tmc2130.h"
|
#include "tmc2130.h"
|
||||||
#include "Marlin.h"
|
#include "Marlin.h"
|
||||||
#include "planner.h"
|
#include "planner.h"
|
||||||
|
@ -495,7 +500,8 @@ void dcode_2130()
|
||||||
}
|
}
|
||||||
else if (strchr_pointer[1+5] == '?')
|
else if (strchr_pointer[1+5] == '?')
|
||||||
{
|
{
|
||||||
if (strcmp(strchr_pointer + 7, "step") == 0) printf_P(PSTR("%c step=%d\n"), ch_axis, tmc2130_rd_MSCNT(axis) >> tmc2130_mres[axis]);
|
if (strcmp(strchr_pointer + 7, "mres") == 0) printf_P(PSTR("%c mres=%d\n"), ch_axis, tmc2130_mres[axis]);
|
||||||
|
else if (strcmp(strchr_pointer + 7, "step") == 0) printf_P(PSTR("%c step=%d\n"), ch_axis, tmc2130_rd_MSCNT(axis) >> tmc2130_mres[axis]);
|
||||||
else if (strcmp(strchr_pointer + 7, "mscnt") == 0) printf_P(PSTR("%c MSCNT=%d\n"), ch_axis, tmc2130_rd_MSCNT(axis));
|
else if (strcmp(strchr_pointer + 7, "mscnt") == 0) printf_P(PSTR("%c MSCNT=%d\n"), ch_axis, tmc2130_rd_MSCNT(axis));
|
||||||
else if (strcmp(strchr_pointer + 7, "mscuract") == 0)
|
else if (strcmp(strchr_pointer + 7, "mscuract") == 0)
|
||||||
{
|
{
|
||||||
|
@ -519,6 +525,21 @@ void dcode_2130()
|
||||||
uint16_t res = tmc2130_get_res(axis);
|
uint16_t res = tmc2130_get_res(axis);
|
||||||
tmc2130_goto_step(axis, step & (4*res - 1), 2, 1000, res);
|
tmc2130_goto_step(axis, step & (4*res - 1), 2, 1000, res);
|
||||||
}
|
}
|
||||||
|
else if (strncmp(strchr_pointer + 7, "mres", 4) == 0)
|
||||||
|
{
|
||||||
|
uint8_t mres = strchr_pointer[11] - '0';
|
||||||
|
if ((mres >= 0) && (mres <= 8))
|
||||||
|
{
|
||||||
|
st_synchronize();
|
||||||
|
uint16_t res = tmc2130_get_res(axis);
|
||||||
|
uint16_t res_new = tmc2130_mres2usteps(mres);
|
||||||
|
tmc2130_set_res(axis, res_new);
|
||||||
|
if (res_new > res)
|
||||||
|
axis_steps_per_unit[axis] *= (res_new / res);
|
||||||
|
else
|
||||||
|
axis_steps_per_unit[axis] /= (res / res_new);
|
||||||
|
}
|
||||||
|
}
|
||||||
else if (strncmp(strchr_pointer + 7, "wave", 4) == 0)
|
else if (strncmp(strchr_pointer + 7, "wave", 4) == 0)
|
||||||
{
|
{
|
||||||
uint8_t fac200 = atoi(strchr_pointer + 11) & 0xfe;
|
uint8_t fac200 = atoi(strchr_pointer + 11) & 0xfe;
|
||||||
|
|
|
@ -6195,12 +6195,38 @@ case 404: //M404 Enter the nominal filament width (3mm, 1.75mm ) N<3.0> or disp
|
||||||
|
|
||||||
case 350: // M350 Set microstepping mode. Warning: Steps per unit remains unchanged. S code sets stepping mode for all drivers.
|
case 350: // M350 Set microstepping mode. Warning: Steps per unit remains unchanged. S code sets stepping mode for all drivers.
|
||||||
{
|
{
|
||||||
|
#ifdef TMC2130
|
||||||
|
if(code_seen('E'))
|
||||||
|
{
|
||||||
|
uint16_t res_new = code_value();
|
||||||
|
if ((res_new == 8) || (res_new == 16) || (res_new == 32) || (res_new == 64) || (res_new == 128))
|
||||||
|
{
|
||||||
|
st_synchronize();
|
||||||
|
uint8_t axis = E_AXIS;
|
||||||
|
uint16_t res = tmc2130_get_res(axis);
|
||||||
|
tmc2130_set_res(axis, res_new);
|
||||||
|
if (res_new > res)
|
||||||
|
{
|
||||||
|
uint16_t fac = (res_new / res);
|
||||||
|
axis_steps_per_unit[axis] *= fac;
|
||||||
|
position[E_AXIS] *= fac;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
uint16_t fac = (res / res_new);
|
||||||
|
axis_steps_per_unit[axis] /= fac;
|
||||||
|
position[E_AXIS] /= fac;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
#else //TMC2130
|
||||||
#if defined(X_MS1_PIN) && X_MS1_PIN > -1
|
#if defined(X_MS1_PIN) && X_MS1_PIN > -1
|
||||||
if(code_seen('S')) for(int i=0;i<=4;i++) microstep_mode(i,code_value());
|
if(code_seen('S')) for(int i=0;i<=4;i++) microstep_mode(i,code_value());
|
||||||
for(int i=0;i<NUM_AXIS;i++) if(code_seen(axis_codes[i])) microstep_mode(i,(uint8_t)code_value());
|
for(int i=0;i<NUM_AXIS;i++) if(code_seen(axis_codes[i])) microstep_mode(i,(uint8_t)code_value());
|
||||||
if(code_seen('B')) microstep_mode(4,code_value());
|
if(code_seen('B')) microstep_mode(4,code_value());
|
||||||
microstep_readings();
|
microstep_readings();
|
||||||
#endif
|
#endif
|
||||||
|
#endif //TMC2130
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
case 351: // M351 Toggle MS1 MS2 pins directly, S# determines MS1 or MS2, X# sets the pin high/low.
|
case 351: // M351 Toggle MS1 MS2 pins directly, S# determines MS1 or MS2, X# sets the pin high/low.
|
||||||
|
|
|
@ -148,6 +148,8 @@ extern float max_jerk[NUM_AXIS];
|
||||||
extern float mintravelfeedrate;
|
extern float mintravelfeedrate;
|
||||||
extern unsigned long axis_steps_per_sqr_second[NUM_AXIS];
|
extern unsigned long axis_steps_per_sqr_second[NUM_AXIS];
|
||||||
|
|
||||||
|
extern long position[NUM_AXIS];
|
||||||
|
|
||||||
#ifdef AUTOTEMP
|
#ifdef AUTOTEMP
|
||||||
extern bool autotemp_enabled;
|
extern bool autotemp_enabled;
|
||||||
extern float autotemp_max;
|
extern float autotemp_max;
|
||||||
|
|
|
@ -1433,6 +1433,9 @@ void microstep_init()
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
#ifndef TMC2130
|
||||||
|
|
||||||
void microstep_ms(uint8_t driver, int8_t ms1, int8_t ms2)
|
void microstep_ms(uint8_t driver, int8_t ms1, int8_t ms2)
|
||||||
{
|
{
|
||||||
if(ms1 > -1) switch(driver)
|
if(ms1 > -1) switch(driver)
|
||||||
|
@ -1490,3 +1493,4 @@ void microstep_readings()
|
||||||
SERIAL_PROTOCOLLN( digitalRead(E1_MS2_PIN));
|
SERIAL_PROTOCOLLN( digitalRead(E1_MS2_PIN));
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
#endif //TMC2130
|
||||||
|
|
|
@ -565,11 +565,11 @@ void tmc2130_wr_THIGH(uint8_t axis, uint32_t val32)
|
||||||
tmc2130_wr(axis, TMC2130_REG_THIGH, val32);
|
tmc2130_wr(axis, TMC2130_REG_THIGH, 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 (mres && (usteps >>= 1)) mres--;
|
||||||
return mres;
|
return mres;
|
||||||
}
|
}
|
||||||
|
|
||||||
uint8_t tmc2130_wr(uint8_t axis, uint8_t addr, uint32_t wval)
|
uint8_t tmc2130_wr(uint8_t axis, uint8_t addr, uint32_t wval)
|
||||||
{
|
{
|
||||||
|
@ -698,6 +698,15 @@ uint16_t tmc2130_get_res(uint8_t axis)
|
||||||
return tmc2130_mres2usteps(tmc2130_mres[axis]);
|
return tmc2130_mres2usteps(tmc2130_mres[axis]);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void tmc2130_set_res(uint8_t axis, uint16_t res)
|
||||||
|
{
|
||||||
|
tmc2130_mres[axis] = tmc2130_usteps2mres(res);
|
||||||
|
// uint32_t u = micros();
|
||||||
|
tmc2130_setup_chopper(axis, tmc2130_mres[axis], tmc2130_current_h[axis], tmc2130_current_r[axis]);
|
||||||
|
// u = micros() - u;
|
||||||
|
// printf_P(PSTR("tmc2130_setup_chopper %c %lu us"), "XYZE"[axis], u);
|
||||||
|
}
|
||||||
|
|
||||||
uint8_t tmc2130_get_pwr(uint8_t axis)
|
uint8_t tmc2130_get_pwr(uint8_t axis)
|
||||||
{
|
{
|
||||||
switch (axis)
|
switch (axis)
|
||||||
|
@ -872,26 +881,26 @@ void tmc2130_set_wave(uint8_t axis, uint8_t fac200)
|
||||||
break;*/
|
break;*/
|
||||||
case 216: //calculated wave 247/1.080
|
case 216: //calculated wave 247/1.080
|
||||||
tmc2130_wr_MSLUTSTART(axis, 0, 247);
|
tmc2130_wr_MSLUTSTART(axis, 0, 247);
|
||||||
tmc2130_wr_MSLUT(axis, 0, 0x9494911e);
|
tmc2130_wr_MSLUT(axis, 0, 0x9494911e);
|
||||||
tmc2130_wr_MSLUT(axis, 1, 0x4a94a94a);
|
tmc2130_wr_MSLUT(axis, 1, 0x4a94a94a);
|
||||||
tmc2130_wr_MSLUT(axis, 2, 0x92492929);
|
tmc2130_wr_MSLUT(axis, 2, 0x92492929);
|
||||||
tmc2130_wr_MSLUT(axis, 3, 0x41044444);
|
tmc2130_wr_MSLUT(axis, 3, 0x41044444);
|
||||||
tmc2130_wr_MSLUT(axis, 4, 0x00000040);
|
tmc2130_wr_MSLUT(axis, 4, 0x00000040);
|
||||||
tmc2130_wr_MSLUT(axis, 5, 0xaedddf7f);
|
tmc2130_wr_MSLUT(axis, 5, 0xaedddf7f);
|
||||||
tmc2130_wr_MSLUT(axis, 6, 0x94a956ad);
|
tmc2130_wr_MSLUT(axis, 6, 0x94a956ad);
|
||||||
tmc2130_wr_MSLUT(axis, 7, 0x00808448);
|
tmc2130_wr_MSLUT(axis, 7, 0x00808448);
|
||||||
tmc2130_wr_MSLUTSEL(axis, 4, 159, 255, 1, 2, 1, 1);
|
tmc2130_wr_MSLUTSEL(axis, 4, 159, 255, 1, 2, 1, 1);
|
||||||
break;
|
break;
|
||||||
case 218: //calculated wave 247/1.090
|
case 218: //calculated wave 247/1.090
|
||||||
tmc2130_wr_MSLUTSTART(axis, 0, 247);
|
tmc2130_wr_MSLUTSTART(axis, 0, 247);
|
||||||
tmc2130_wr_MSLUT(axis, 0, 0x4a49223e);
|
tmc2130_wr_MSLUT(axis, 0, 0x4a49223e);
|
||||||
tmc2130_wr_MSLUT(axis, 1, 0x4a52a529);
|
tmc2130_wr_MSLUT(axis, 1, 0x4a52a529);
|
||||||
tmc2130_wr_MSLUT(axis, 2, 0x49252529);
|
tmc2130_wr_MSLUT(axis, 2, 0x49252529);
|
||||||
tmc2130_wr_MSLUT(axis, 3, 0x08422224);
|
tmc2130_wr_MSLUT(axis, 3, 0x08422224);
|
||||||
tmc2130_wr_MSLUT(axis, 4, 0xfc008004);
|
tmc2130_wr_MSLUT(axis, 4, 0xfc008004);
|
||||||
tmc2130_wr_MSLUT(axis, 5, 0xb6eef7df);
|
tmc2130_wr_MSLUT(axis, 5, 0xb6eef7df);
|
||||||
tmc2130_wr_MSLUT(axis, 6, 0xa4aaaab5);
|
tmc2130_wr_MSLUT(axis, 6, 0xa4aaaab5);
|
||||||
tmc2130_wr_MSLUT(axis, 7, 0x00808448);
|
tmc2130_wr_MSLUT(axis, 7, 0x00808448);
|
||||||
tmc2130_wr_MSLUTSEL(axis, 5, 153, 255, 1, 2, 1, 1);
|
tmc2130_wr_MSLUTSEL(axis, 5, 153, 255, 1, 2, 1, 1);
|
||||||
break;
|
break;
|
||||||
case 220: //calculated wave 247/1.100
|
case 220: //calculated wave 247/1.100
|
||||||
|
@ -908,26 +917,26 @@ void tmc2130_set_wave(uint8_t axis, uint8_t fac200)
|
||||||
break;
|
break;
|
||||||
case 222: //calculated wave 247/1.110
|
case 222: //calculated wave 247/1.110
|
||||||
tmc2130_wr_MSLUTSTART(axis, 0, 247);
|
tmc2130_wr_MSLUTSTART(axis, 0, 247);
|
||||||
tmc2130_wr_MSLUT(axis, 0, 0x524910fe);
|
tmc2130_wr_MSLUT(axis, 0, 0x524910fe);
|
||||||
tmc2130_wr_MSLUT(axis, 1, 0xa5294a52);
|
tmc2130_wr_MSLUT(axis, 1, 0xa5294a52);
|
||||||
tmc2130_wr_MSLUT(axis, 2, 0x24929294);
|
tmc2130_wr_MSLUT(axis, 2, 0x24929294);
|
||||||
tmc2130_wr_MSLUT(axis, 3, 0x20844489);
|
tmc2130_wr_MSLUT(axis, 3, 0x20844489);
|
||||||
tmc2130_wr_MSLUT(axis, 4, 0xc0004008);
|
tmc2130_wr_MSLUT(axis, 4, 0xc0004008);
|
||||||
tmc2130_wr_MSLUT(axis, 5, 0xdbbbdf7f);
|
tmc2130_wr_MSLUT(axis, 5, 0xdbbbdf7f);
|
||||||
tmc2130_wr_MSLUT(axis, 6, 0x252aab5a);
|
tmc2130_wr_MSLUT(axis, 6, 0x252aab5a);
|
||||||
tmc2130_wr_MSLUT(axis, 7, 0x00808449);
|
tmc2130_wr_MSLUT(axis, 7, 0x00808449);
|
||||||
tmc2130_wr_MSLUTSEL(axis, 7, 157, 255, 1, 2, 1, 1);
|
tmc2130_wr_MSLUTSEL(axis, 7, 157, 255, 1, 2, 1, 1);
|
||||||
break;
|
break;
|
||||||
case 224: //calculated wave 247/1.120
|
case 224: //calculated wave 247/1.120
|
||||||
tmc2130_wr_MSLUTSTART(axis, 0, 247);
|
tmc2130_wr_MSLUTSTART(axis, 0, 247);
|
||||||
tmc2130_wr_MSLUT(axis, 0, 0x292223fe);
|
tmc2130_wr_MSLUT(axis, 0, 0x292223fe);
|
||||||
tmc2130_wr_MSLUT(axis, 1, 0x94a52949);
|
tmc2130_wr_MSLUT(axis, 1, 0x94a52949);
|
||||||
tmc2130_wr_MSLUT(axis, 2, 0x92524a52);
|
tmc2130_wr_MSLUT(axis, 2, 0x92524a52);
|
||||||
tmc2130_wr_MSLUT(axis, 3, 0x04222244);
|
tmc2130_wr_MSLUT(axis, 3, 0x04222244);
|
||||||
tmc2130_wr_MSLUT(axis, 4, 0x00000101);
|
tmc2130_wr_MSLUT(axis, 4, 0x00000101);
|
||||||
tmc2130_wr_MSLUT(axis, 5, 0x6dddefe0);
|
tmc2130_wr_MSLUT(axis, 5, 0x6dddefe0);
|
||||||
tmc2130_wr_MSLUT(axis, 6, 0x254aad5b);
|
tmc2130_wr_MSLUT(axis, 6, 0x254aad5b);
|
||||||
tmc2130_wr_MSLUT(axis, 7, 0x00810889);
|
tmc2130_wr_MSLUT(axis, 7, 0x00810889);
|
||||||
tmc2130_wr_MSLUTSEL(axis, 9, 164, 255, 1, 2, 1, 1);
|
tmc2130_wr_MSLUTSEL(axis, 9, 164, 255, 1, 2, 1, 1);
|
||||||
break;
|
break;
|
||||||
/* case 230: //calculated wave 247/1.150
|
/* case 230: //calculated wave 247/1.150
|
||||||
|
|
|
@ -70,8 +70,8 @@ extern void tmc2130_set_pwm_grad(uint8_t axis, uint8_t pwm_ampl);
|
||||||
extern uint16_t tmc2130_rd_MSCNT(uint8_t axis);
|
extern uint16_t tmc2130_rd_MSCNT(uint8_t axis);
|
||||||
extern uint32_t tmc2130_rd_MSCURACT(uint8_t axis);
|
extern uint32_t tmc2130_rd_MSCURACT(uint8_t axis);
|
||||||
|
|
||||||
extern uint8_t tmc2130_usteps2mres(uint16_t usteps);
|
extern uint8_t tmc2130_usteps2mres(uint16_t usteps);
|
||||||
#define tmc2130_mres2usteps(mres) ((uint16_t)256 >> mres)
|
#define tmc2130_mres2usteps(mres) ((uint16_t)256 >> mres)
|
||||||
|
|
||||||
extern bool tmc2130_wait_standstill_xy(int timeout);
|
extern bool tmc2130_wait_standstill_xy(int timeout);
|
||||||
|
|
||||||
|
@ -107,6 +107,7 @@ struct
|
||||||
#pragma pack(pop)
|
#pragma pack(pop)
|
||||||
|
|
||||||
extern uint16_t tmc2130_get_res(uint8_t axis);
|
extern uint16_t tmc2130_get_res(uint8_t axis);
|
||||||
|
extern void tmc2130_set_res(uint8_t axis, uint16_t res);
|
||||||
extern uint8_t tmc2130_get_pwr(uint8_t axis);
|
extern uint8_t tmc2130_get_pwr(uint8_t axis);
|
||||||
extern void tmc2130_set_pwr(uint8_t axis, uint8_t pwr);
|
extern void tmc2130_set_pwr(uint8_t axis, uint8_t pwr);
|
||||||
extern uint8_t tmc2130_get_inv(uint8_t axis);
|
extern uint8_t tmc2130_get_inv(uint8_t axis);
|
||||||
|
|
Loading…
Reference in a new issue