Unify debugging output with debug_out.h (#13388)

This commit is contained in:
Scott Lahteine
2019-03-14 02:25:42 -05:00
committed by GitHub
parent cc8a871705
commit f5bcc00570
25 changed files with 627 additions and 904 deletions

View File

@ -48,6 +48,9 @@
#include "../../../libs/vector_3.h"
#endif
#define DEBUG_OUT ENABLED(DEBUG_LEVELING_FEATURE)
#include "../../../core/debug_out.h"
#if ABL_GRID
#if ENABLED(PROBE_Y_FIRST)
#define PR_OUTER_VAR xCount
@ -187,12 +190,7 @@ G29_TYPE GcodeSuite::G29() {
if (axis_unhomed_error()) G29_RETURN(false);
if (!no_action && planner.leveling_active && parser.boolval('O')) { // Auto-level only if needed
#if ENABLED(DEBUG_LEVELING_FEATURE)
if (DEBUGGING(LEVELING)) {
SERIAL_ECHOLNPGM("> Auto-level not needed, skip");
SERIAL_ECHOLNPGM("<<< G29");
}
#endif
if (DEBUGGING(LEVELING)) DEBUG_ECHOLNPGM("> Auto-level not needed, skip\n<<< G29");
G29_RETURN(false);
}
@ -470,9 +468,7 @@ G29_TYPE GcodeSuite::G29() {
#if ENABLED(AUTO_BED_LEVELING_3POINT)
#if ENABLED(DEBUG_LEVELING_FEATURE)
if (DEBUGGING(LEVELING)) SERIAL_ECHOLNPGM("> 3-point Leveling");
#endif
if (DEBUGGING(LEVELING)) DEBUG_ECHOLNPGM("> 3-point Leveling");
// Probe at 3 arbitrary points
points[0].z = points[1].z = points[2].z = 0;
@ -555,13 +551,7 @@ G29_TYPE GcodeSuite::G29() {
ExtUI::onMeshUpdate(xCount, yCount, z_values[xCount][yCount]);
#endif
#if ENABLED(DEBUG_LEVELING_FEATURE)
if (DEBUGGING(LEVELING)) {
SERIAL_ECHOPAIR("Save X", xCount);
SERIAL_ECHOPAIR(" Y", yCount);
SERIAL_ECHOLNPAIR(" Z", measured_z + zoffset);
}
#endif
if (DEBUGGING(LEVELING)) DEBUG_ECHOLNPAIR("Save X", xCount, " Y", yCount, " Z", measured_z + zoffset);
#endif
}
@ -790,9 +780,7 @@ G29_TYPE GcodeSuite::G29() {
// return or loop before this point.
//
#if ENABLED(DEBUG_LEVELING_FEATURE)
if (DEBUGGING(LEVELING)) DEBUG_POS("> probing complete", current_position);
#endif
if (DEBUGGING(LEVELING)) DEBUG_POS("> probing complete", current_position);
#if ENABLED(PROBE_MANUALLY)
g29_in_progress = false;
@ -929,9 +917,7 @@ G29_TYPE GcodeSuite::G29() {
// Correct the current XYZ position based on the tilted plane.
//
#if ENABLED(DEBUG_LEVELING_FEATURE)
if (DEBUGGING(LEVELING)) DEBUG_POS("G29 uncorrected XYZ", current_position);
#endif
if (DEBUGGING(LEVELING)) DEBUG_POS("G29 uncorrected XYZ", current_position);
float converted[XYZ];
COPY(converted, current_position);
@ -945,46 +931,32 @@ G29_TYPE GcodeSuite::G29() {
&& NEAR(current_position[Y_AXIS], yProbe - (Y_PROBE_OFFSET_FROM_EXTRUDER))
) {
const float simple_z = current_position[Z_AXIS] - measured_z;
#if ENABLED(DEBUG_LEVELING_FEATURE)
if (DEBUGGING(LEVELING)) {
SERIAL_ECHOPAIR("Z from Probe:", simple_z);
SERIAL_ECHOPAIR(" Matrix:", converted[Z_AXIS]);
SERIAL_ECHOLNPAIR(" Discrepancy:", simple_z - converted[Z_AXIS]);
}
#endif
if (DEBUGGING(LEVELING)) DEBUG_ECHOLNPAIR("Probed Z", simple_z, " Matrix Z", converted[Z_AXIS], " Discrepancy ", simple_z - converted[Z_AXIS]);
converted[Z_AXIS] = simple_z;
}
// The rotated XY and corrected Z are now current_position
COPY(current_position, converted);
#if ENABLED(DEBUG_LEVELING_FEATURE)
if (DEBUGGING(LEVELING)) DEBUG_POS("G29 corrected XYZ", current_position);
#endif
if (DEBUGGING(LEVELING)) DEBUG_POS("G29 corrected XYZ", current_position);
}
#elif ENABLED(AUTO_BED_LEVELING_BILINEAR)
if (!dryrun) {
#if ENABLED(DEBUG_LEVELING_FEATURE)
if (DEBUGGING(LEVELING)) SERIAL_ECHOLNPAIR("G29 uncorrected Z:", current_position[Z_AXIS]);
#endif
if (DEBUGGING(LEVELING)) DEBUG_ECHOLNPAIR("G29 uncorrected Z:", current_position[Z_AXIS]);
// Unapply the offset because it is going to be immediately applied
// and cause compensation movement in Z
current_position[Z_AXIS] -= bilinear_z_offset(current_position);
#if ENABLED(DEBUG_LEVELING_FEATURE)
if (DEBUGGING(LEVELING)) SERIAL_ECHOLNPAIR(" corrected Z:", current_position[Z_AXIS]);
#endif
if (DEBUGGING(LEVELING)) DEBUG_ECHOLNPAIR(" corrected Z:", current_position[Z_AXIS]);
}
#endif // ABL_PLANAR
#ifdef Z_PROBE_END_SCRIPT
#if ENABLED(DEBUG_LEVELING_FEATURE)
if (DEBUGGING(LEVELING)) SERIAL_ECHOLNPAIR("Z Probe End Script: ", Z_PROBE_END_SCRIPT);
#endif
if (DEBUGGING(LEVELING)) DEBUG_ECHOLNPAIR("Z Probe End Script: ", Z_PROBE_END_SCRIPT);
planner.synchronize();
enqueue_and_echo_commands_P(PSTR(Z_PROBE_END_SCRIPT));
#endif
@ -996,9 +968,7 @@ G29_TYPE GcodeSuite::G29() {
// Restore state after probing
if (!faux) clean_up_after_endstop_or_probe_move();
#if ENABLED(DEBUG_LEVELING_FEATURE)
if (DEBUGGING(LEVELING)) SERIAL_ECHOLNPGM("<<< G29");
#endif
if (DEBUGGING(LEVELING)) DEBUG_ECHOLNPGM("<<< G29");
KEEPALIVE_STATE(IN_HANDLER);

View File

@ -49,6 +49,9 @@
#include "../../libs/L6470/L6470_Marlin.h"
#endif
#define DEBUG_OUT ENABLED(DEBUG_LEVELING_FEATURE)
#include "../../core/debug_out.h"
#if ENABLED(QUICK_HOME)
static void quick_home_xy() {
@ -113,9 +116,7 @@
return;
}
#if ENABLED(DEBUG_LEVELING_FEATURE)
if (DEBUGGING(LEVELING)) SERIAL_ECHOLNPGM("Z_SAFE_HOMING >>>");
#endif
if (DEBUGGING(LEVELING)) DEBUG_ECHOLNPGM("Z_SAFE_HOMING >>>");
sync_plan_position();
@ -133,9 +134,7 @@
if (position_is_reachable(destination[X_AXIS], destination[Y_AXIS])) {
#if ENABLED(DEBUG_LEVELING_FEATURE)
if (DEBUGGING(LEVELING)) DEBUG_POS("Z_SAFE_HOMING", destination);
#endif
if (DEBUGGING(LEVELING)) DEBUG_POS("Z_SAFE_HOMING", destination);
// This causes the carriage on Dual X to unpark
#if ENABLED(DUAL_X_CARRIAGE)
@ -154,9 +153,7 @@
SERIAL_ECHO_MSG(MSG_ZPROBE_OUT);
}
#if ENABLED(DEBUG_LEVELING_FEATURE)
if (DEBUGGING(LEVELING)) SERIAL_ECHOLNPGM("<<< Z_SAFE_HOMING");
#endif
if (DEBUGGING(LEVELING)) DEBUG_ECHOLNPGM("<<< Z_SAFE_HOMING");
}
#endif // Z_SAFE_HOMING
@ -182,12 +179,10 @@
*/
void GcodeSuite::G28(const bool always_home_all) {
#if ENABLED(DEBUG_LEVELING_FEATURE)
if (DEBUGGING(LEVELING)) {
SERIAL_ECHOLNPGM(">>> G28");
log_machine_info();
}
#endif
if (DEBUGGING(LEVELING)) {
DEBUG_ECHOLNPGM(">>> G28");
log_machine_info();
}
#if ENABLED(DUAL_X_CARRIAGE)
bool IDEX_saved_duplication_state = extruder_duplication_enabled;
@ -200,9 +195,7 @@ void GcodeSuite::G28(const bool always_home_all) {
sync_plan_position();
SERIAL_ECHOLNPGM("Simulated Homing");
report_current_position();
#if ENABLED(DEBUG_LEVELING_FEATURE)
if (DEBUGGING(LEVELING)) SERIAL_ECHOLNPGM("<<< G28");
#endif
if (DEBUGGING(LEVELING)) DEBUG_ECHOLNPGM("<<< G28");
return;
}
#endif
@ -215,12 +208,7 @@ void GcodeSuite::G28(const bool always_home_all) {
all_axes_homed() // homing needed only if never homed
#endif
) {
#if ENABLED(DEBUG_LEVELING_FEATURE)
if (DEBUGGING(LEVELING)) {
SERIAL_ECHOLNPGM("> homing not needed, skip");
SERIAL_ECHOLNPGM("<<< G28");
}
#endif
if (DEBUGGING(LEVELING)) DEBUG_ECHOLNPGM("> homing not needed, skip\n<<< G28");
return;
}
}
@ -297,12 +285,7 @@ void GcodeSuite::G28(const bool always_home_all) {
// Raise Z before homing any other axes and z is not already high enough (never lower z)
destination[Z_AXIS] = z_homing_height;
if (destination[Z_AXIS] > current_position[Z_AXIS]) {
#if ENABLED(DEBUG_LEVELING_FEATURE)
if (DEBUGGING(LEVELING))
SERIAL_ECHOLNPAIR("Raise Z (before homing) to ", destination[Z_AXIS]);
#endif
if (DEBUGGING(LEVELING)) DEBUG_ECHOLNPAIR("Raise Z (before homing) to ", destination[Z_AXIS]);
do_blocking_move_to_z(destination[Z_AXIS]);
}
}
@ -451,9 +434,7 @@ void GcodeSuite::G28(const bool always_home_all) {
SERIAL_ECHOLNPGM(MSG_Z_MOVE_COMP);
#endif
#if ENABLED(DEBUG_LEVELING_FEATURE)
if (DEBUGGING(LEVELING)) SERIAL_ECHOLNPGM("<<< G28");
#endif
if (DEBUGGING(LEVELING)) DEBUG_ECHOLNPGM("<<< G28");
#if HAS_DRIVER(L6470)
// Set L6470 absolute position registers to counts

View File

@ -42,6 +42,9 @@
#include "../../feature/bedlevel/bedlevel.h"
#endif
#define DEBUG_OUT ENABLED(DEBUG_LEVELING_FEATURE)
#include "../../core/debug_out.h"
float z_auto_align_xpos[Z_STEPPER_COUNT] = Z_STEPPER_ALIGN_X,
z_auto_align_ypos[Z_STEPPER_COUNT] = Z_STEPPER_ALIGN_Y;
@ -59,19 +62,15 @@ inline void set_all_z_lock(const bool lock) {
* Parameters: I<iterations> T<accuracy> A<amplification>
*/
void GcodeSuite::G34() {
#if ENABLED(DEBUG_LEVELING_FEATURE)
if (DEBUGGING(LEVELING)) {
SERIAL_ECHOLNPGM(">>> G34");
log_machine_info();
}
#endif
if (DEBUGGING(LEVELING)) {
DEBUG_ECHOLNPGM(">>> G34");
log_machine_info();
}
do { // break out on error
if (!TEST(axis_known_position, X_AXIS) || !TEST(axis_known_position, Y_AXIS)) {
#if ENABLED(DEBUG_LEVELING_FEATURE)
if (DEBUGGING(LEVELING)) SERIAL_ECHOLNPGM("> XY homing required.");
#endif
if (DEBUGGING(LEVELING)) DEBUG_ECHOLNPGM("> XY homing required.");
break;
}
@ -128,9 +127,7 @@ void GcodeSuite::G34() {
z_measured[Z_STEPPER_COUNT] = { 0 };
bool err_break = false;
for (uint8_t iteration = 0; iteration < z_auto_align_iterations; ++iteration) {
#if ENABLED(DEBUG_LEVELING_FEATURE)
if (DEBUGGING(LEVELING)) SERIAL_ECHOLNPGM("> probing all positions.");
#endif
if (DEBUGGING(LEVELING)) DEBUG_ECHOLNPGM("> probing all positions.");
// Reset minimum value
float z_measured_min = 100000.0f;
@ -141,19 +138,12 @@ void GcodeSuite::G34() {
// Stop on error
if (isnan(z_measured[zstepper])) {
#if ENABLED(DEBUG_LEVELING_FEATURE)
if (DEBUGGING(LEVELING)) SERIAL_ECHOLNPGM("> PROBING FAILED!");
#endif
if (DEBUGGING(LEVELING)) DEBUG_ECHOLNPGM("> PROBING FAILED!");
err_break = true;
break;
}
#if ENABLED(DEBUG_LEVELING_FEATURE)
if (DEBUGGING(LEVELING)) {
SERIAL_ECHOPAIR("> Z", int(zstepper + 1));
SERIAL_ECHOLNPAIR(" measured position is ", z_measured[zstepper]);
}
#endif
if (DEBUGGING(LEVELING)) DEBUG_ECHOLNPAIR("> Z", int(zstepper + 1), " measured position is ", z_measured[zstepper]);
// Remember the maximum position to calculate the correction
z_measured_min = MIN(z_measured_min, z_measured[zstepper]);
@ -178,9 +168,7 @@ void GcodeSuite::G34() {
// Check for lost accuracy compared to last move
if (last_z_align_move[zstepper] < z_align_abs - 1.0) {
// Stop here
#if ENABLED(DEBUG_LEVELING_FEATURE)
if (DEBUGGING(LEVELING)) SERIAL_ECHOLNPGM("> detected decreasing accuracy.");
#endif
if (DEBUGGING(LEVELING)) DEBUG_ECHOLNPGM("> detected decreasing accuracy.");
err_break = true;
break;
}
@ -190,12 +178,7 @@ void GcodeSuite::G34() {
// Only stop early if all measured points achieve accuracy target
if (z_align_abs > z_auto_align_accuracy) success_break = false;
#if ENABLED(DEBUG_LEVELING_FEATURE)
if (DEBUGGING(LEVELING)) {
SERIAL_ECHOPAIR("> Z", int(zstepper + 1));
SERIAL_ECHOLNPAIR(" corrected by ", z_align_move);
}
#endif
if (DEBUGGING(LEVELING)) DEBUG_ECHOLNPAIR("> Z", int(zstepper + 1), " corrected by ", z_align_move);
switch (zstepper) {
case 0: stepper.set_z_lock(false); break;
@ -219,9 +202,7 @@ void GcodeSuite::G34() {
stepper.set_separate_multi_axis(false);
if (success_break) {
#if ENABLED(DEBUG_LEVELING_FEATURE)
if (DEBUGGING(LEVELING)) SERIAL_ECHOLNPGM("> achieved target accuracy.");
#endif
if (DEBUGGING(LEVELING)) DEBUG_ECHOLNPGM("> achieved target accuracy.");
break;
}
}
@ -252,9 +233,7 @@ void GcodeSuite::G34() {
} while(0);
#if ENABLED(DEBUG_LEVELING_FEATURE)
if (DEBUGGING(LEVELING)) SERIAL_ECHOLNPGM("<<< G34");
#endif
if (DEBUGGING(LEVELING)) DEBUG_ECHOLNPGM("<<< G34");
}
/**

View File

@ -31,32 +31,22 @@
#include "../../module/delta.h"
#include "../../module/motion.h"
#define DEBUG_OUT ENABLED(DEBUG_LEVELING_FEATURE)
#include "../../core/debug_out.h"
/**
* M666: Set delta endstop adjustment
*/
void GcodeSuite::M666() {
#if ENABLED(DEBUG_LEVELING_FEATURE)
if (DEBUGGING(LEVELING)) {
SERIAL_ECHOLNPGM(">>> M666");
}
#endif
if (DEBUGGING(LEVELING)) DEBUG_ECHOLNPGM(">>> M666");
LOOP_XYZ(i) {
if (parser.seen(axis_codes[i])) {
const float v = parser.value_linear_units();
if (v * Z_HOME_DIR <= 0) delta_endstop_adj[i] = v;
#if ENABLED(DEBUG_LEVELING_FEATURE)
if (DEBUGGING(LEVELING)) {
SERIAL_ECHOPAIR("delta_endstop_adj[", axis_codes[i]);
SERIAL_ECHOLNPAIR("] = ", delta_endstop_adj[i]);
}
#endif
if (DEBUGGING(LEVELING)) DEBUG_ECHOLNPAIR("delta_endstop_adj[", axis_codes[i], "] = ", delta_endstop_adj[i]);
}
}
#if ENABLED(DEBUG_LEVELING_FEATURE)
if (DEBUGGING(LEVELING)) {
SERIAL_ECHOLNPGM("<<< M666");
}
#endif
if (DEBUGGING(LEVELING)) DEBUG_ECHOLNPGM("<<< M666");
}
#elif HAS_EXTRA_ENDSTOPS

View File

@ -34,14 +34,14 @@ void GcodeSuite::M111() {
str_debug_8[] PROGMEM = MSG_DEBUG_DRYRUN,
str_debug_16[] PROGMEM = MSG_DEBUG_COMMUNICATION
#if ENABLED(DEBUG_LEVELING_FEATURE)
, str_debug_32[] PROGMEM = MSG_DEBUG_LEVELING
, str_debug_lvl[] PROGMEM = MSG_DEBUG_LEVELING
#endif
;
static PGM_P const debug_strings[] PROGMEM = {
str_debug_1, str_debug_2, str_debug_4, str_debug_8, str_debug_16
#if ENABLED(DEBUG_LEVELING_FEATURE)
, str_debug_32
, str_debug_lvl
#endif
};

View File

@ -31,6 +31,9 @@
#include "../../feature/prusa_MMU2/mmu2.h"
#endif
#define DEBUG_OUT ENABLED(DEBUG_LEVELING_FEATURE)
#include "../../core/debug_out.h"
/**
* T0-T<n>: Switch tool, usually switching extruders
*
@ -45,14 +48,10 @@
*/
void GcodeSuite::T(const uint8_t tool_index) {
#if ENABLED(DEBUG_LEVELING_FEATURE)
if (DEBUGGING(LEVELING)) {
SERIAL_ECHOPAIR(">>> T(", tool_index);
SERIAL_CHAR(')');
SERIAL_EOL();
DEBUG_POS("BEFORE", current_position);
}
#endif
if (DEBUGGING(LEVELING)) {
DEBUG_ECHOLNPAIR(">>> T(", tool_index, ")");
DEBUG_POS("BEFORE", current_position);
}
#if ENABLED(PRUSA_MMU2)
if (parser.string_arg) {
@ -75,10 +74,8 @@ void GcodeSuite::T(const uint8_t tool_index) {
#endif
#if ENABLED(DEBUG_LEVELING_FEATURE)
if (DEBUGGING(LEVELING)) {
DEBUG_POS("AFTER", current_position);
SERIAL_ECHOLNPGM("<<< T()");
}
#endif
if (DEBUGGING(LEVELING)) {
DEBUG_POS("AFTER", current_position);
DEBUG_ECHOLNPGM("<<< T()");
}
}

View File

@ -29,6 +29,9 @@
#include "../../../module/stepper_indirection.h"
#include "../../../module/planner.h"
#define DEBUG_OUT ENABLED(L6470_CHITCHAT)
#include "../../../core/debug_out.h"
/**
*
* M906: report or set KVAL_HOLD which sets the maximum effective voltage provided by the
@ -93,7 +96,7 @@ void L6470_report_current(L6470 &motor, const uint8_t axis) {
L6470.say_axis(axis);
#if ENABLED(L6470_CHITCHAT)
sprintf_P(temp_buf, PSTR(" status: %4x "), status);
SERIAL_ECHO(temp_buf);
DEBUG_ECHO(temp_buf);
print_bin(status);
#endif
sprintf_P(temp_buf, PSTR("\n...OverCurrent Threshold: %2d (%4d mA)"), overcurrent_threshold, (overcurrent_threshold + 1) * 375);
@ -134,7 +137,7 @@ void L6470_report_current(L6470 &motor, const uint8_t axis) {
void GcodeSuite::M906() {
#define L6470_SET_KVAL_HOLD(Q) stepper##Q.SetParam(L6470_KVAL_HOLD, value)
L6470_ECHOLNPGM("M906");
DEBUG_ECHOLNPGM("M906");
bool report_current = true;

View File

@ -29,6 +29,9 @@
#include "../../../module/planner.h"
#include "../../../libs/L6470/L6470_Marlin.h"
#define DEBUG_OUT ENABLED(L6470_CHITCHAT)
#include "../../../core/debug_out.h"
/**
*
* M916: increase KVAL_HOLD until get thermal warning
@ -59,7 +62,7 @@
void GcodeSuite::M916() {
L6470_ECHOLNPGM("M916");
DEBUG_ECHOLNPGM("M916");
// Variables used by L6470_get_user_input function - some may not be used
char axis_mon[3][3] = { " ", " ", " " }; // list of Axes to be monitored
@ -80,7 +83,7 @@ void GcodeSuite::M916() {
if (L6470.get_user_input(driver_count, axis_index, axis_mon, position_max, position_min, final_feedrate, kval_hold, over_current_flag, ocd_th_val, stall_th_val, over_current_threshold))
return; // quit if invalid user input
L6470_ECHOLNPAIR("feedrate = ", final_feedrate);
DEBUG_ECHOLNPAIR("feedrate = ", final_feedrate);
planner.synchronize(); // wait for all current movement commands to complete
@ -92,11 +95,11 @@ void GcodeSuite::M916() {
char gcode_string[80];
uint16_t status_composite = 0;
L6470_ECHOLNPGM(".\n.");
DEBUG_ECHOLNPGM(".\n.");
do {
L6470_ECHOLNPAIR("kval_hold = ", kval_hold); // set & report KVAL_HOLD for this run
DEBUG_ECHOLNPAIR("kval_hold = ", kval_hold); // set & report KVAL_HOLD for this run
for (j = 0; j < driver_count; j++)
L6470.set_param(axis_index[j], L6470_KVAL_HOLD, kval_hold);
@ -119,9 +122,9 @@ void GcodeSuite::M916() {
}
if (status_composite && (status_composite & STATUS_UVLO)) {
L6470_ECHOLNPGM("Test aborted (Undervoltage lockout active)");
DEBUG_ECHOLNPGM("Test aborted (Undervoltage lockout active)");
for (j = 0; j < driver_count; j++) {
L6470_ECHOPGM("...");
DEBUG_ECHOPGM("...");
L6470.error_status_decode(axis_status[j], axis_index[j]);
}
return;
@ -133,18 +136,18 @@ void GcodeSuite::M916() {
} while (!(status_composite & (STATUS_TH_WRN | STATUS_TH_SD)) && kval_hold); // exit when kval_hold == 0 (rolls over)
L6470_ECHOPGM(".\n.\nThermal warning/shutdown ");
DEBUG_ECHOPGM(".\n.\nThermal warning/shutdown ");
if ((status_composite & (STATUS_TH_WRN | STATUS_TH_SD))) {
L6470_ECHOLNPGM("has occurred");
DEBUG_ECHOLNPGM("has occurred");
for (j = 0; j < driver_count; j++) {
L6470_ECHOPGM("...");
DEBUG_ECHOPGM("...");
L6470.error_status_decode(axis_status[j], axis_index[j]);
}
}
else
L6470_ECHOLNPGM("(Unable to get)");
DEBUG_ECHOLNPGM("(Unable to get)");
L6470_ECHOLNPGM(".");
DEBUG_ECHOLNPGM(".");
}
/**
@ -176,7 +179,7 @@ void GcodeSuite::M916() {
*/
void GcodeSuite::M917() {
L6470_ECHOLNPGM("M917");
DEBUG_ECHOLNPGM("M917");
char axis_mon[3][3] = { " ", " ", " " }; // list of axes to be monitored
uint8_t axis_index[3];
@ -196,7 +199,7 @@ void GcodeSuite::M917() {
if (L6470.get_user_input(driver_count, axis_index, axis_mon, position_max, position_min, final_feedrate, kval_hold, over_current_flag, ocd_th_val, stall_th_val, over_current_threshold))
return; // quit if invalid user input
L6470_ECHOLNPAIR("feedrate = ", final_feedrate);
DEBUG_ECHOLNPAIR("feedrate = ", final_feedrate);
planner.synchronize(); // wait for all current movement commands to complete
for (j = 0; j < driver_count; j++)
@ -211,16 +214,16 @@ void GcodeSuite::M917() {
// 2 - OCD finalized - decreasing STALL - exit when STALL warning happens
// 3 - OCD finalized - increasing STALL - exit when STALL warning stop
// 4 - all testing completed
L6470_ECHOPAIR(".\n.\n.\nover_current threshold : ", (ocd_th_val + 1) * 375); // first status display
L6470_ECHOPAIR(" (OCD_TH: : ", ocd_th_val);
L6470_ECHOPAIR(") Stall threshold: ", (stall_th_val + 1) * 31.25);
L6470_ECHOPAIR(" (STALL_TH: ", stall_th_val);
L6470_ECHOLNPGM(")");
DEBUG_ECHOPAIR(".\n.\n.\nover_current threshold : ", (ocd_th_val + 1) * 375); // first status display
DEBUG_ECHOPAIR(" (OCD_TH: : ", ocd_th_val);
DEBUG_ECHOPAIR(") Stall threshold: ", (stall_th_val + 1) * 31.25);
DEBUG_ECHOPAIR(" (STALL_TH: ", stall_th_val);
DEBUG_ECHOLNPGM(")");
do {
L6470_ECHOPAIR("STALL threshold : ", (stall_th_val + 1) * 31.25);
L6470_ECHOLNPAIR(" OCD threshold : ", (ocd_th_val + 1) * 375);
DEBUG_ECHOPAIR("STALL threshold : ", (stall_th_val + 1) * 31.25);
DEBUG_ECHOLNPAIR(" OCD threshold : ", (ocd_th_val + 1) * 375);
sprintf_P(gcode_string, PSTR("G0 %s%4.3f F%4.3f"), temp_axis_string, position_min, final_feedrate);
gcode.process_subcommands_now_P(gcode_string);
@ -238,16 +241,16 @@ void GcodeSuite::M917() {
}
if (status_composite && (status_composite & STATUS_UVLO)) {
L6470_ECHOLNPGM("Test aborted (Undervoltage lockout active)");
DEBUG_ECHOLNPGM("Test aborted (Undervoltage lockout active)");
for (j = 0; j < driver_count; j++) {
L6470_ECHOPGM("...");
DEBUG_ECHOPGM("...");
L6470.error_status_decode(axis_status[j], axis_index[j]);
}
return;
}
if (status_composite & (STATUS_TH_WRN | STATUS_TH_SD)) {
L6470_ECHOLNPGM("thermal problem - waiting for chip(s) to cool down ");
DEBUG_ECHOLNPGM("thermal problem - waiting for chip(s) to cool down ");
uint16_t status_composite_temp = 0;
uint8_t k = 0;
do {
@ -255,11 +258,11 @@ void GcodeSuite::M917() {
if (!(k % 4)) {
kval_hold *= 0.95;
L6470_EOL();
L6470_ECHOLNPAIR("Lowering KVAL_HOLD by about 5% to ", kval_hold);
DEBUG_ECHOLNPAIR("Lowering KVAL_HOLD by about 5% to ", kval_hold);
for (j = 0; j < driver_count; j++)
L6470.set_param(axis_index[j], L6470_KVAL_HOLD, kval_hold);
}
L6470_ECHOLNPGM(".");
DEBUG_ECHOLNPGM(".");
gcode.reset_stepper_timeout(); // reset_stepper_timeout to keep steppers powered
watchdog_reset(); // beat the dog
safe_delay(5000);
@ -281,22 +284,22 @@ void GcodeSuite::M917() {
if (ocd_th_val >=15) {
ocd_th_val = 15; // limit to max
test_phase = 2; // at highest value so skip phase 1
L6470_ECHOLNPGM("LOGIC E0A OCD at highest - skip to 2");
DEBUG_ECHOLNPGM("LOGIC E0A OCD at highest - skip to 2");
}
else {
ocd_th_val++; // normal exit to next phase
test_phase = 1; // setup for first pass of phase 1
L6470_ECHOLNPGM("LOGIC E0B - inc OCD & go to 1");
DEBUG_ECHOLNPGM("LOGIC E0B - inc OCD & go to 1");
}
}
else { // phase 0 without OCD warning - keep on decrementing if can
if (ocd_th_val) {
ocd_th_val--; // try lower value
L6470_ECHOLNPGM("LOGIC E0C - dec OCD");
DEBUG_ECHOLNPGM("LOGIC E0C - dec OCD");
}
else {
test_phase = 2; // at lowest value without warning so skip phase 1
L6470_ECHOLNPGM("LOGIC E0D - OCD at latest - go to 2");
DEBUG_ECHOLNPGM("LOGIC E0D - OCD at latest - go to 2");
}
}
} break;
@ -307,16 +310,16 @@ void GcodeSuite::M917() {
if (ocd_th_val >= 15) {
ocd_th_val = 15; // limit to max
test_phase = 2; // at highest value so go to next phase
L6470_ECHOLNPGM("LOGIC E1A - OCD at max - go to 2");
DEBUG_ECHOLNPGM("LOGIC E1A - OCD at max - go to 2");
}
else {
ocd_th_val++; // try a higher value
L6470_ECHOLNPGM("LOGIC E1B - inc OCD");
DEBUG_ECHOLNPGM("LOGIC E1B - inc OCD");
}
}
else { // phase 1 without OCD warning - normal exit to phase 2
test_phase = 2;
L6470_ECHOLNPGM("LOGIC E1C - no OCD warning - go to 1");
DEBUG_ECHOLNPGM("LOGIC E1C - no OCD warning - go to 1");
}
} break;
@ -325,25 +328,25 @@ void GcodeSuite::M917() {
// phase 2 with stall warning - time to go to next phase
if (stall_th_val >= 127) {
stall_th_val = 127; // limit to max
L6470_ECHOLNPGM("LOGIC E2A - STALL warning, STALL at max, quit");
L6470_ECHOLNPGM("finished - STALL at maximum value but still have stall warning");
DEBUG_ECHOLNPGM("LOGIC E2A - STALL warning, STALL at max, quit");
DEBUG_ECHOLNPGM("finished - STALL at maximum value but still have stall warning");
test_phase = 4;
}
else {
test_phase = 3; // normal exit to next phase (found failing value of STALL)
stall_th_val++; // setup for first pass of phase 3
L6470_ECHOLNPGM("LOGIC E2B - INC - STALL warning, inc Stall, go to 3");
DEBUG_ECHOLNPGM("LOGIC E2B - INC - STALL warning, inc Stall, go to 3");
}
}
else { // phase 2 without stall warning - decrement if can
if (stall_th_val) {
stall_th_val--; // try a lower value
L6470_ECHOLNPGM("LOGIC E2C - no STALL, dec STALL");
DEBUG_ECHOLNPGM("LOGIC E2C - no STALL, dec STALL");
}
else {
L6470_ECHOLNPGM("finished - STALL at lowest value but still do NOT have stall warning");
DEBUG_ECHOLNPGM("finished - STALL at lowest value but still do NOT have stall warning");
test_phase = 4;
L6470_ECHOLNPGM("LOGIC E2D - no STALL, at lowest so quit");
DEBUG_ECHOLNPGM("LOGIC E2D - no STALL, at lowest so quit");
}
}
} break;
@ -353,19 +356,19 @@ void GcodeSuite::M917() {
// phase 3 with stall warning - increment if can
if (stall_th_val >= 127) {
stall_th_val = 127; // limit to max
L6470_ECHOLNPGM("finished - STALL at maximum value but still have stall warning");
DEBUG_ECHOLNPGM("finished - STALL at maximum value but still have stall warning");
test_phase = 4;
L6470_ECHOLNPGM("LOGIC E3A - STALL, at max so quit");
DEBUG_ECHOLNPGM("LOGIC E3A - STALL, at max so quit");
}
else {
stall_th_val++; // still looking for passing value
L6470_ECHOLNPGM("LOGIC E3B - STALL, inc stall");
DEBUG_ECHOLNPGM("LOGIC E3B - STALL, inc stall");
}
}
else { //phase 3 without stall warning but have OCD warning
L6470_ECHOLNPGM("Hardware problem - OCD warning without STALL warning");
DEBUG_ECHOLNPGM("Hardware problem - OCD warning without STALL warning");
test_phase = 4;
L6470_ECHOLNPGM("LOGIC E3C - not STALLED, hardware problem (quit)");
DEBUG_ECHOLNPGM("LOGIC E3C - not STALLED, hardware problem (quit)");
}
} break;
@ -377,30 +380,30 @@ void GcodeSuite::M917() {
case 0: { // phase 0 without OCD warning - keep on decrementing if can
if (ocd_th_val) {
ocd_th_val--; // try lower value
L6470_ECHOLNPGM("LOGIC N0A - DEC OCD");
DEBUG_ECHOLNPGM("LOGIC N0A - DEC OCD");
}
else {
test_phase = 2; // at lowest value without warning so skip phase 1
L6470_ECHOLNPGM("LOGIC N0B - OCD at lowest (go to phase 2)");
DEBUG_ECHOLNPGM("LOGIC N0B - OCD at lowest (go to phase 2)");
}
} break;
case 1: L6470_ECHOLNPGM("LOGIC N1 (go directly to 2)"); // phase 1 without OCD warning - drop directly to phase 2
case 1: DEBUG_ECHOLNPGM("LOGIC N1 (go directly to 2)"); // phase 1 without OCD warning - drop directly to phase 2
case 2: { // phase 2 without stall warning - keep on decrementing if can
if (stall_th_val) {
stall_th_val--; // try a lower value (stay in phase 2)
L6470_ECHOLNPGM("LOGIC N2B - dec STALL");
DEBUG_ECHOLNPGM("LOGIC N2B - dec STALL");
}
else {
L6470_ECHOLNPGM("finished - STALL at lowest value but still no stall warning");
DEBUG_ECHOLNPGM("finished - STALL at lowest value but still no stall warning");
test_phase = 4;
L6470_ECHOLNPGM("LOGIC N2C - STALL at lowest (quit)");
DEBUG_ECHOLNPGM("LOGIC N2C - STALL at lowest (quit)");
}
} break;
case 3: { test_phase = 4;
L6470_ECHOLNPGM("LOGIC N3 - finished!");
DEBUG_ECHOLNPGM("LOGIC N3 - finished!");
} break; // phase 3 without any warnings - desired exit
} //
} // end of status checks
@ -409,22 +412,22 @@ void GcodeSuite::M917() {
for (j = 0; j < driver_count; j++) { // update threshold(s)
L6470.set_param(axis_index[j], L6470_OCD_TH, ocd_th_val);
L6470.set_param(axis_index[j], L6470_STALL_TH, stall_th_val);
if (L6470.get_param(axis_index[j], L6470_OCD_TH) != ocd_th_val) L6470_ECHOLNPGM("OCD mismatch");
if (L6470.get_param(axis_index[j], L6470_STALL_TH) != stall_th_val) L6470_ECHOLNPGM("STALL mismatch");
if (L6470.get_param(axis_index[j], L6470_OCD_TH) != ocd_th_val) DEBUG_ECHOLNPGM("OCD mismatch");
if (L6470.get_param(axis_index[j], L6470_STALL_TH) != stall_th_val) DEBUG_ECHOLNPGM("STALL mismatch");
}
}
} while (test_phase != 4);
if (status_composite) {
L6470_ECHOLNPGM("Completed with errors");
DEBUG_ECHOLNPGM("Completed with errors");
for (j = 0; j < driver_count; j++) {
L6470_ECHOPGM("...");
DEBUG_ECHOPGM("...");
L6470.error_status_decode(axis_status[j], axis_index[j]);
}
}
else
L6470_ECHOLNPGM("Completed with no errors");
DEBUG_ECHOLNPGM("Completed with no errors");
} // M917
@ -448,7 +451,7 @@ void GcodeSuite::M917() {
*/
void GcodeSuite::M918() {
L6470_ECHOLNPGM("M918");
DEBUG_ECHOLNPGM("M918");
char axis_mon[3][3] = { " ", " ", " " }; // List of axes to monitor
uint8_t axis_index[3];
@ -469,7 +472,7 @@ void GcodeSuite::M918() {
uint8_t m_steps = parser.byteval('M');
LIMIT(m_steps, 0, 128);
L6470_ECHOLNPAIR("M = ", m_steps);
DEBUG_ECHOLNPAIR("M = ", m_steps);
int8_t m_bits = -1;
if (m_steps > 85) m_bits = 7; // 128 (no synch output)
@ -484,15 +487,15 @@ void GcodeSuite::M918() {
if (m_bits >= 0) {
const int micros = _BV(m_bits);
if (micros < 100) { L6470_CHAR(' '); if (micros < 10) L6470_CHAR(' '); }
L6470_ECHO(micros);
L6470_ECHOPGM(" uSTEPS");
if (micros < 100) { DEBUG_CHAR(' '); if (micros < 10) DEBUG_CHAR(' '); }
DEBUG_ECHO(micros);
DEBUG_ECHOPGM(" uSTEPS");
}
for (j = 0; j < driver_count; j++)
L6470.set_param(axis_index[j], L6470_STEP_MODE, m_bits); // set microsteps
L6470_ECHOLNPAIR("target (maximum) feedrate = ",final_feedrate);
DEBUG_ECHOLNPAIR("target (maximum) feedrate = ",final_feedrate);
float feedrate_inc = final_feedrate / 10, // start at 1/10 of max & go up by 1/10 per step)
current_feedrate = 0;
@ -508,11 +511,11 @@ void GcodeSuite::M918() {
char gcode_string[80];
uint16_t status_composite = 0;
L6470_ECHOLNPGM(".\n.\n."); // make the feedrate prints easier to see
DEBUG_ECHOLNPGM(".\n.\n."); // make the feedrate prints easier to see
do {
current_feedrate += feedrate_inc;
L6470_ECHOLNPAIR("...feedrate = ", current_feedrate);
DEBUG_ECHOLNPAIR("...feedrate = ", current_feedrate);
sprintf_P(gcode_string, PSTR("G0 %s%4.3f F%4.3f"), temp_axis_string, position_min, current_feedrate);
gcode.process_subcommands_now_P(gcode_string);
@ -529,15 +532,16 @@ void GcodeSuite::M918() {
if (status_composite) break; // quit if any errors flags are raised
} while (current_feedrate < final_feedrate * 0.99);
DEBUG_ECHOPGM("Completed with errors");
if (status_composite) {
L6470_ECHOLNPGM("Completed with errors");
DEBUG_ECHOLNPGM("errors");
for (j = 0; j < driver_count; j++) {
L6470_ECHOPGM("...");
DEBUG_ECHOPGM("...");
L6470.error_status_decode(axis_status[j], axis_index[j]);
}
}
else
L6470_ECHOLNPGM("Completed with no errors");
DEBUG_ECHOLNPGM("no errors");
} // M918

View File

@ -32,6 +32,8 @@
//C:\Users\bobku\Documents\GitHub\Marlin-Bob-2\Marlin\src\gcode\host\M114.cpp
//C:\Users\bobku\Documents\GitHub\Marlin-Bob-2\Marlin\src\module\bob_L6470.cpp
#include "../../module/L6470/L6470_Marlin.h"
#define DEBUG_OUT ENABLED(L6470_CHITCHAT)
#include "../../core/debug_out.h"
#endif
void report_xyze(const float pos[], const uint8_t n = 4, const uint8_t precision = 3) {
@ -95,10 +97,10 @@
temp = L6470_GETPARAM(L6470_ABS_POS,Q); \
if (temp & ABS_POS_SIGN_MASK) temp |= ABS_POS_SIGN_MASK; \
sprintf_P(temp_buf, PSTR(":%8ld "), temp); \
L6470_ECHO(temp_buf); \
DEBUG_ECHO(temp_buf); \
}while(0)
L6470_ECHOPGM("\nL6470:");
DEBUG_ECHOPGM("\nL6470:");
#if AXIS_DRIVER_TYPE_X(L6470)
REPORT_ABSOLUTE_POS(X);
#endif