Quiet M906/M913/M914 with axes. Patch for DISTINCT_E_FACTORS.

This commit is contained in:
Scott Lahteine 2018-03-14 05:43:18 -05:00
parent c95450016b
commit cfc13ed7f3
4 changed files with 247 additions and 106 deletions

View file

@ -331,6 +331,7 @@ void _tmc_say_sgt(const TMC_AxisEnum axis, const int8_t sgt) {
}
}
#endif
#if ENABLED(HAVE_TMC2208)
static void tmc_status(TMC2208Stepper &st, const TMC_debug_enum i) {
switch (i) {

View file

@ -55,7 +55,6 @@ void tmc_get_current(TMC &st, const TMC_AxisEnum axis) {
template<typename TMC>
void tmc_set_current(TMC &st, const TMC_AxisEnum axis, const int mA) {
st.setCurrent(mA, R_SENSE, HOLD_MULTIPLIER);
tmc_get_current(st, axis);
}
template<typename TMC>
void tmc_report_otpw(TMC &st, const TMC_AxisEnum axis) {
@ -73,7 +72,6 @@ void tmc_get_pwmthrs(TMC &st, const TMC_AxisEnum axis, const uint16_t spmm) {
template<typename TMC>
void tmc_set_pwmthrs(TMC &st, const TMC_AxisEnum axis, const int32_t thrs, const uint32_t spmm) {
st.TPWMTHRS(_tmc_thrs(st.microsteps(), thrs, spmm));
tmc_get_pwmthrs(st, axis, spmm);
}
template<typename TMC>
void tmc_get_sgt(TMC &st, const TMC_AxisEnum axis) {
@ -82,7 +80,6 @@ void tmc_get_sgt(TMC &st, const TMC_AxisEnum axis) {
template<typename TMC>
void tmc_set_sgt(TMC &st, const TMC_AxisEnum axis, const int8_t sgt_val) {
st.sgt(sgt_val);
tmc_get_sgt(st, axis);
}
void monitor_tmc_driver();

View file

@ -33,46 +33,100 @@
* Report driver currents when no axis specified
*/
void GcodeSuite::M906() {
uint16_t values[XYZE];
LOOP_XYZE(i) values[i] = parser.intval(axis_codes[i]);
#define TMC_SET_GET_CURRENT(P,Q) do { \
if (values[P##_AXIS]) tmc_set_current(stepper##Q, TMC_##Q, values[P##_AXIS]); \
else tmc_get_current(stepper##Q, TMC_##Q); } while(0)
#define TMC_SAY_CURRENT(Q) tmc_get_current(stepper##Q, TMC_##Q)
#define TMC_SET_CURRENT(Q) tmc_set_current(stepper##Q, TMC_##Q, value)
bool report = true;
LOOP_XYZE(i) if (uint16_t value = parser.intval(axis_codes[i])) {
report = false;
switch (i) {
case X_AXIS:
#if X_IS_TRINAMIC
TMC_SET_GET_CURRENT(X,X);
TMC_SET_CURRENT(X);
#endif
#if X2_IS_TRINAMIC
TMC_SET_GET_CURRENT(X,X2);
TMC_SET_CURRENT(X2);
#endif
break;
case Y_AXIS:
#if Y_IS_TRINAMIC
TMC_SET_GET_CURRENT(Y,Y);
TMC_SET_CURRENT(Y);
#endif
#if Y2_IS_TRINAMIC
TMC_SET_GET_CURRENT(Y,Y2);
TMC_SET_CURRENT(Y2);
#endif
break;
case Z_AXIS:
#if Z_IS_TRINAMIC
TMC_SET_GET_CURRENT(Z,Z);
TMC_SET_CURRENT(Z);
#endif
#if Z2_IS_TRINAMIC
TMC_SET_GET_CURRENT(Z,Z2);
TMC_SET_CURRENT(Z2);
#endif
break;
case E_AXIS:
#if E0_IS_TRINAMIC
TMC_SET_GET_CURRENT(E,E0);
TMC_SET_CURRENT(E0);
#endif
#if E1_IS_TRINAMIC
TMC_SET_GET_CURRENT(E,E1);
TMC_SET_CURRENT(E1);
#endif
#if E2_IS_TRINAMIC
TMC_SET_GET_CURRENT(E,E2);
TMC_SET_CURRENT(E2);
#endif
#if E3_IS_TRINAMIC
TMC_SET_GET_CURRENT(E,E3);
TMC_SET_CURRENT(E3);
#endif
#if E4_IS_TRINAMIC
TMC_SET_GET_CURRENT(E,E4);
TMC_SET_CURRENT(E4);
#endif
break;
}
}
if (report) LOOP_XYZE(i) switch (i) {
case X_AXIS:
#if X_IS_TRINAMIC
TMC_SAY_CURRENT(X);
#endif
#if X2_IS_TRINAMIC
TMC_SAY_CURRENT(X2);
#endif
break;
case Y_AXIS:
#if Y_IS_TRINAMIC
TMC_SAY_CURRENT(Y);
#endif
#if Y2_IS_TRINAMIC
TMC_SAY_CURRENT(Y2);
#endif
break;
case Z_AXIS:
#if Z_IS_TRINAMIC
TMC_SAY_CURRENT(Z);
#endif
#if Z2_IS_TRINAMIC
TMC_SAY_CURRENT(Z2);
#endif
break;
case E_AXIS:
#if E0_IS_TRINAMIC
TMC_SAY_CURRENT(E0);
#endif
#if E1_IS_TRINAMIC
TMC_SAY_CURRENT(E1);
#endif
#if E2_IS_TRINAMIC
TMC_SAY_CURRENT(E2);
#endif
#if E3_IS_TRINAMIC
TMC_SAY_CURRENT(E3);
#endif
#if E4_IS_TRINAMIC
TMC_SAY_CURRENT(E4);
#endif
break;
}
}
#endif // HAS_TRINAMIC

View file

@ -80,46 +80,102 @@ void GcodeSuite::M912() {
*/
#if ENABLED(HYBRID_THRESHOLD)
void GcodeSuite::M913() {
uint16_t values[XYZE];
LOOP_XYZE(i) values[i] = parser.intval(axis_codes[i]);
#define TMC_SET_GET_PWMTHRS(P,Q) do { \
if (values[P##_AXIS]) tmc_set_pwmthrs(stepper##Q, TMC_##Q, values[P##_AXIS], planner.axis_steps_per_mm[P##_AXIS]); \
else tmc_get_pwmthrs(stepper##Q, TMC_##Q, planner.axis_steps_per_mm[P##_AXIS]); } while(0)
#define TMC_SAY_PWMTHRS(P,Q) tmc_get_pwmthrs(stepper##Q, TMC_##Q, planner.axis_steps_per_mm[P##_AXIS])
#define TMC_SET_PWMTHRS(P,Q) tmc_set_pwmthrs(stepper##Q, TMC_##Q, value, planner.axis_steps_per_mm[P##_AXIS])
#define TMC_SAY_PWMTHRS_E(E) do{ const uint8_t extruder = E; tmc_get_pwmthrs(stepperE##E, TMC_E##E, planner.axis_steps_per_mm[E_AXIS_N]); }while(0)
#define TMC_SET_PWMTHRS_E(E) do{ const uint8_t extruder = E; tmc_set_pwmthrs(stepperE##E, TMC_E##E, value, planner.axis_steps_per_mm[E_AXIS_N]); }while(0)
bool report = true;
LOOP_XYZE(i) if (int32_t value = parser.longval(axis_codes[i])) {
report = false;
switch (i) {
case X_AXIS:
#if X_IS_TRINAMIC
TMC_SET_GET_PWMTHRS(X,X);
TMC_SET_PWMTHRS(X,X);
#endif
#if X2_IS_TRINAMIC
TMC_SET_GET_PWMTHRS(X,X2);
TMC_SET_PWMTHRS(X,X2);
#endif
break;
case Y_AXIS:
#if Y_IS_TRINAMIC
TMC_SET_GET_PWMTHRS(Y,Y);
TMC_SET_PWMTHRS(Y,Y);
#endif
#if Y2_IS_TRINAMIC
TMC_SET_GET_PWMTHRS(Y,Y2);
TMC_SET_PWMTHRS(Y,Y2);
#endif
break;
case Z_AXIS:
#if Z_IS_TRINAMIC
TMC_SET_GET_PWMTHRS(Z,Z);
TMC_SET_PWMTHRS(Z,Z);
#endif
#if Z2_IS_TRINAMIC
TMC_SET_GET_PWMTHRS(Z,Z2);
TMC_SET_PWMTHRS(Z,Z2);
#endif
break;
case E_AXIS:
#if E0_IS_TRINAMIC
TMC_SET_GET_PWMTHRS(E,E0);
TMC_SET_PWMTHRS_E(0);
#endif
#if E1_IS_TRINAMIC
TMC_SET_GET_PWMTHRS(E,E1);
TMC_SET_PWMTHRS_E(1);
#endif
#if E2_IS_TRINAMIC
TMC_SET_GET_PWMTHRS(E,E2);
TMC_SET_PWMTHRS_E(2);
#endif
#if E3_IS_TRINAMIC
TMC_SET_GET_PWMTHRS(E,E3);
TMC_SET_PWMTHRS_E(3);
#endif
#if E4_IS_TRINAMIC
TMC_SET_GET_PWMTHRS(E,E4);
TMC_SET_PWMTHRS_E(4);
#endif
break;
}
}
if (report) LOOP_XYZE(i) switch (i) {
case X_AXIS:
#if X_IS_TRINAMIC
TMC_SAY_PWMTHRS(X,X);
#endif
#if X2_IS_TRINAMIC
TMC_SAY_PWMTHRS(X,X2);
#endif
break;
case Y_AXIS:
#if Y_IS_TRINAMIC
TMC_SAY_PWMTHRS(Y,Y);
#endif
#if Y2_IS_TRINAMIC
TMC_SAY_PWMTHRS(Y,Y2);
#endif
break;
case Z_AXIS:
#if Z_IS_TRINAMIC
TMC_SAY_PWMTHRS(Z,Z);
#endif
#if Z2_IS_TRINAMIC
TMC_SAY_PWMTHRS(Z,Z2);
#endif
break;
case E_AXIS:
#if E0_IS_TRINAMIC
TMC_SAY_PWMTHRS_E(0);
#endif
#if E1_IS_TRINAMIC
TMC_SAY_PWMTHRS_E(1);
#endif
#if E2_IS_TRINAMIC
TMC_SAY_PWMTHRS_E(2);
#endif
#if E3_IS_TRINAMIC
TMC_SAY_PWMTHRS_E(3);
#endif
#if E4_IS_TRINAMIC
TMC_SAY_PWMTHRS_E(4);
#endif
break;
}
}
#endif // HYBRID_THRESHOLD
@ -128,34 +184,67 @@ void GcodeSuite::M912() {
*/
#if ENABLED(SENSORLESS_HOMING)
void GcodeSuite::M914() {
#define TMC_SET_GET_SGT(P,Q) do { \
if (parser.seen(axis_codes[P##_AXIS])) tmc_set_sgt(stepper##Q, TMC_##Q, parser.value_int()); \
else tmc_get_sgt(stepper##Q, TMC_##Q); } while(0)
#define TMC_SAY_SGT(Q) tmc_get_sgt(stepper##Q, TMC_##Q)
#define TMC_SET_SGT(Q) tmc_set_sgt(stepper##Q, TMC_##Q, value)
#ifdef X_HOMING_SENSITIVITY
bool report = true;
LOOP_XYZ(i) if (parser.seen(axis_codes[i])) {
const int8_t value = (int8_t)constrain(parser.value_int(), -63, 64);
report = false;
switch (i) {
case X_AXIS:
#if ENABLED(X_IS_TMC2130) || ENABLED(IS_TRAMS)
TMC_SET_GET_SGT(X,X);
TMC_SET_SGT(X);
#endif
#if ENABLED(X2_IS_TMC2130)
TMC_SET_GET_SGT(X,X2);
TMC_SET_SGT(X2);
#endif
#endif
#ifdef Y_HOMING_SENSITIVITY
break;
case Y_AXIS:
#if ENABLED(Y_IS_TMC2130) || ENABLED(IS_TRAMS)
TMC_SET_GET_SGT(Y,Y);
TMC_SET_SGT(Y);
#endif
#if ENABLED(Y2_IS_TMC2130)
TMC_SET_GET_SGT(Y,Y2);
TMC_SET_SGT(Y2);
#endif
#endif
#ifdef Z_HOMING_SENSITIVITY
break;
case Z_AXIS:
#if ENABLED(Z_IS_TMC2130) || ENABLED(IS_TRAMS)
TMC_SET_GET_SGT(Z,Z);
TMC_SET_SGT(Z);
#endif
#if ENABLED(Z2_IS_TMC2130)
TMC_SET_GET_SGT(Z,Z2);
TMC_SET_SGT(Z2);
#endif
break;
}
}
if (report) LOOP_XYZ(i) switch (i) {
case X_AXIS:
#if ENABLED(X_IS_TMC2130) || ENABLED(IS_TRAMS)
TMC_SAY_SGT(X);
#endif
#if ENABLED(X2_IS_TMC2130)
TMC_SAY_SGT(X2);
#endif
break;
case Y_AXIS:
#if ENABLED(Y_IS_TMC2130) || ENABLED(IS_TRAMS)
TMC_SAY_SGT(Y);
#endif
#if ENABLED(Y2_IS_TMC2130)
TMC_SAY_SGT(Y2);
#endif
break;
case Z_AXIS:
#if ENABLED(Z_IS_TMC2130) || ENABLED(IS_TRAMS)
TMC_SAY_SGT(Z);
#endif
#if ENABLED(Z2_IS_TMC2130)
TMC_SAY_SGT(Z2);
#endif
break;
}
}
#endif // SENSORLESS_HOMING