Add a feedRate_t data type (#15349)

This commit is contained in:
Scott Lahteine
2019-09-26 01:28:09 -05:00
committed by GitHub
parent ee7558a622
commit 455dabb183
42 changed files with 384 additions and 377 deletions

View File

@ -32,7 +32,7 @@
#define DEBUG_OUT ENABLED(L6470_CHITCHAT)
#include "../../../core/debug_out.h"
static void jiggle_axis(const char axis_char, const float &min, const float &max, const float &rate) {
static void jiggle_axis(const char axis_char, const float &min, const float &max, const feedRate_t &fr_mm_m) {
char gcode_string[30], str1[11], str2[11];
// Turn the motor(s) both directions
@ -84,7 +84,7 @@ void GcodeSuite::M916() {
uint8_t driver_count = 1;
float position_max;
float position_min;
float final_feedrate;
feedRate_t final_fr_mm_m;
uint8_t kval_hold;
uint8_t ocd_th_val = 0;
uint8_t stall_th_val = 0;
@ -93,10 +93,10 @@ void GcodeSuite::M916() {
uint8_t j; // general purpose counter
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))
if (L6470.get_user_input(driver_count, axis_index, axis_mon, position_max, position_min, final_fr_mm_m, kval_hold, over_current_flag, ocd_th_val, stall_th_val, over_current_threshold))
return; // quit if invalid user input
DEBUG_ECHOLNPAIR("feedrate = ", final_feedrate);
DEBUG_ECHOLNPAIR("feedrate = ", final_fr_mm_m);
planner.synchronize(); // Wait for moves to finish
@ -115,7 +115,7 @@ void GcodeSuite::M916() {
L6470.set_param(axis_index[j], L6470_KVAL_HOLD, kval_hold);
// Turn the motor(s) both directions
jiggle_axis(axis_mon[0][0], position_min, position_max, final_feedrate);
jiggle_axis(axis_mon[0][0], position_min, position_max, final_fr_mm_m);
status_composite = 0; // clear out the old bits
@ -190,7 +190,7 @@ void GcodeSuite::M917() {
uint8_t driver_count = 1;
float position_max;
float position_min;
float final_feedrate;
feedRate_t final_fr_mm_m;
uint8_t kval_hold;
uint8_t ocd_th_val = 0;
uint8_t stall_th_val = 0;
@ -199,10 +199,10 @@ void GcodeSuite::M917() {
uint8_t j; // general purpose counter
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))
if (L6470.get_user_input(driver_count, axis_index, axis_mon, position_max, position_min, final_fr_mm_m, kval_hold, over_current_flag, ocd_th_val, stall_th_val, over_current_threshold))
return; // quit if invalid user input
DEBUG_ECHOLNPAIR("feedrate = ", final_feedrate);
DEBUG_ECHOLNPAIR("feedrate = ", final_fr_mm_m);
planner.synchronize(); // Wait for moves to finish
for (j = 0; j < driver_count; j++)
@ -225,7 +225,7 @@ void GcodeSuite::M917() {
DEBUG_ECHOPAIR("STALL threshold : ", (stall_th_val + 1) * 31.25);
DEBUG_ECHOLNPAIR(" OCD threshold : ", (ocd_th_val + 1) * 375);
jiggle_axis(axis_mon[0][0], position_min, position_max, final_feedrate);
jiggle_axis(axis_mon[0][0], position_min, position_max, final_fr_mm_m);
status_composite = 0; // clear out the old bits
@ -452,7 +452,7 @@ void GcodeSuite::M918() {
uint16_t axis_status[3];
uint8_t driver_count = 1;
float position_max, position_min;
float final_feedrate;
feedRate_t final_fr_mm_m;
uint8_t kval_hold;
uint8_t ocd_th_val = 0;
uint8_t stall_th_val = 0;
@ -461,7 +461,7 @@ void GcodeSuite::M918() {
uint8_t j; // general purpose counter
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))
if (L6470.get_user_input(driver_count, axis_index, axis_mon, position_max, position_min, final_fr_mm_m, kval_hold, over_current_flag, ocd_th_val, stall_th_val, over_current_threshold))
return; // quit if invalid user input
uint8_t m_steps = parser.byteval('M');
@ -489,10 +489,7 @@ void GcodeSuite::M918() {
for (j = 0; j < driver_count; j++)
L6470.set_param(axis_index[j], L6470_STEP_MODE, m_bits); // set microsteps
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;
DEBUG_ECHOLNPAIR("target (maximum) feedrate = ", final_fr_mm_m);
planner.synchronize(); // Wait for moves to finish
@ -502,18 +499,19 @@ void GcodeSuite::M918() {
uint16_t status_composite = 0;
DEBUG_ECHOLNPGM(".\n.\n."); // Make the feedrate prints easier to see
do {
current_feedrate += feedrate_inc;
DEBUG_ECHOLNPAIR("...feedrate = ", current_feedrate);
constexpr uint8_t iterations = 10;
for (uint8_t i = 1; i <= iterations; i++) {
const feedRate_t fr_mm_m = i * final_fr_mm_m / iterations;
DEBUG_ECHOLNPAIR("...feedrate = ", fr_mm_m);
jiggle_axis(axis_mon[0][0], position_min, position_max, current_feedrate);
jiggle_axis(axis_mon[0][0], position_min, position_max, fr_mm_m);
for (j = 0; j < driver_count; j++) {
axis_status[j] = (~L6470.get_status(axis_index[j])) & 0x0800; // bits of interest are all active low
status_composite |= axis_status[j];
}
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) {