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) {

View File

@ -43,7 +43,7 @@
#endif
#ifdef PHOTO_RETRACT_MM
inline void e_move_m240(const float length, const float fr_mm_s) {
inline void e_move_m240(const float length, const feedRate_t &fr_mm_s) {
if (length && thermalManager.hotEnoughToExtrude(active_extruder)) {
#if ENABLED(ADVANCED_PAUSE_FEATURE)
do_pause_e_move(length, fr_mm_s);
@ -104,7 +104,8 @@ void GcodeSuite::M240() {
};
#ifdef PHOTO_RETRACT_MM
constexpr float rfr = (MMS_TO_MMM(
const float rval = parser.seenval('R') ? parser.value_linear_units() : _PHOTO_RETRACT_MM;
feedRate_t sval = (
#if ENABLED(ADVANCED_PAUSE_FEATURE)
PAUSE_PARK_RETRACT_FEEDRATE
#elif ENABLED(FWRETRACT)
@ -112,13 +113,12 @@ void GcodeSuite::M240() {
#else
45
#endif
));
const float rval = parser.seenval('R') ? parser.value_linear_units() : _PHOTO_RETRACT_MM,
sval = parser.seenval('S') ? MMM_TO_MMS(parser.value_feedrate()) : rfr;
);
if (parser.seenval('S')) sval = parser.value_feedrate();
e_move_m240(-rval, sval);
#endif
float fr_mm_s = MMM_TO_MMS(parser.linearval('F'));
feedRate_t fr_mm_s = MMM_TO_MMS(parser.linearval('F'));
if (fr_mm_s) NOLESS(fr_mm_s, 10.0f);
constexpr float photo_position[XYZ] = PHOTO_POSITION;

View File

@ -97,7 +97,7 @@ void GcodeSuite::M701() {
// Lift Z axis
if (park_point.z > 0)
do_blocking_move_to_z(_MIN(current_position[Z_AXIS] + park_point.z, Z_MAX_POS), NOZZLE_PARK_Z_FEEDRATE);
do_blocking_move_to_z(_MIN(current_position[Z_AXIS] + park_point.z, Z_MAX_POS), feedRate_t(NOZZLE_PARK_Z_FEEDRATE));
// Load filament
#if ENABLED(PRUSA_MMU2)
@ -116,7 +116,7 @@ void GcodeSuite::M701() {
// Restore Z axis
if (park_point.z > 0)
do_blocking_move_to_z(_MAX(current_position[Z_AXIS] - park_point.z, 0), NOZZLE_PARK_Z_FEEDRATE);
do_blocking_move_to_z(_MAX(current_position[Z_AXIS] - park_point.z, 0), feedRate_t(NOZZLE_PARK_Z_FEEDRATE));
#if EXTRUDERS > 1 && DISABLED(PRUSA_MMU2)
// Restore toolhead if it was changed
@ -196,7 +196,7 @@ void GcodeSuite::M702() {
// Lift Z axis
if (park_point.z > 0)
do_blocking_move_to_z(_MIN(current_position[Z_AXIS] + park_point.z, Z_MAX_POS), NOZZLE_PARK_Z_FEEDRATE);
do_blocking_move_to_z(_MIN(current_position[Z_AXIS] + park_point.z, Z_MAX_POS), feedRate_t(NOZZLE_PARK_Z_FEEDRATE));
// Unload filament
#if ENABLED(PRUSA_MMU2)
@ -226,7 +226,7 @@ void GcodeSuite::M702() {
// Restore Z axis
if (park_point.z > 0)
do_blocking_move_to_z(_MAX(current_position[Z_AXIS] - park_point.z, 0), NOZZLE_PARK_Z_FEEDRATE);
do_blocking_move_to_z(_MAX(current_position[Z_AXIS] - park_point.z, 0), feedRate_t(NOZZLE_PARK_Z_FEEDRATE));
#if EXTRUDERS > 1 && DISABLED(PRUSA_MMU2)
// Restore toolhead if it was changed