Update backlash code

This commit is contained in:
Scott Lahteine
2019-05-20 21:34:08 -05:00
parent 7b4c3bd92a
commit aeec9ef76b
4 changed files with 30 additions and 23 deletions

View File

@@ -20,11 +20,13 @@
*
*/
#include "../Marlin.h"
#include "../inc/MarlinConfigPre.h"
#if ENABLED(BACKLASH_COMPENSATION)
#include "backlash.h"
#include "../module/motion.h"
#include "../module/planner.h"
#if ENABLED(BACKLASH_GCODE)
@@ -75,10 +77,10 @@ void Backlash::add_correction_steps(const int32_t &da, const int32_t &db, const
// to segments where there is no direction change.
static int32_t residual_error[XYZ] = { 0 };
#else
// No leftover residual error from segment to segment
int32_t residual_error[XYZ] = { 0 };
// No direction change, no correction.
if (!changed_dir) return;
// No leftover residual error from segment to segment
int32_t residual_error[XYZ] = { 0 };
#endif
const float f_corr = float(correction) / 255.0f;
@@ -100,7 +102,7 @@ void Backlash::add_correction_steps(const int32_t &da, const int32_t &db, const
if (reversing == (error_correction < 0)) {
if (segment_proportion == 0)
segment_proportion = MIN(1.0f, block->millimeters / smoothing_mm);
error_correction = ceil(segment_proportion * error_correction);
error_correction = CEIL(segment_proportion * error_correction);
}
else
error_correction = 0; // Don't take up any backlash in this segment, as it would subtract steps