aboutsummaryrefslogtreecommitdiffstats
path: root/klippy/chelper
diff options
context:
space:
mode:
authorKevin O'Connor <kevin@koconnor.net>2020-02-26 11:28:36 -0500
committerKevin O'Connor <kevin@koconnor.net>2020-03-04 19:43:47 -0500
commit8f8c1e2c587a8e4bc88524774ea6fd49139fd08a (patch)
treed0ccdc815d57f746e3277311cc2d86591cc4b56b /klippy/chelper
parent271e412ae6b713a71431bc6f75fcc3ada3af41c3 (diff)
downloadkutter-8f8c1e2c587a8e4bc88524774ea6fd49139fd08a.tar.gz
kutter-8f8c1e2c587a8e4bc88524774ea6fd49139fd08a.tar.xz
kutter-8f8c1e2c587a8e4bc88524774ea6fd49139fd08a.zip
itersolve: Reset bounds search on a direction change
If the stepper changes direction then the average velocity since the last step pulse isn't a good indicator of the next step pulse. Instead, reset the bounds checking to use a low starting guess. Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
Diffstat (limited to 'klippy/chelper')
-rw-r--r--klippy/chelper/itersolve.c12
1 files changed, 10 insertions, 2 deletions
diff --git a/klippy/chelper/itersolve.c b/klippy/chelper/itersolve.c
index 918c44d0..1094e5f3 100644
--- a/klippy/chelper/itersolve.c
+++ b/klippy/chelper/itersolve.c
@@ -54,6 +54,8 @@ itersolve_find_step(struct stepper_kinematics *sk, struct move *m
return best_guess;
}
+#define SEEK_TIME_RESET 0.000100
+
// Generate step times for a portion of a move
static int32_t
itersolve_gen_steps_range(struct stepper_kinematics *sk, struct move *m
@@ -63,8 +65,8 @@ itersolve_gen_steps_range(struct stepper_kinematics *sk, struct move *m
double half_step = .5 * sk->step_dist;
double start = move_start - m->print_time, end = move_end - m->print_time;
struct timepos last = { start, sk->commanded_pos }, low = last, high = last;
- double seek_time_delta = 0.000100;
- int sdir = !!stepcompress_get_step_dir(sk->sc);
+ double seek_time_delta = SEEK_TIME_RESET;
+ int sdir = !!stepcompress_get_step_dir(sk->sc), is_dir_change = 0;
for (;;) {
double diff = high.position - last.position, dist = sdir ? diff : -diff;
if (dist >= half_step) {
@@ -79,6 +81,9 @@ itersolve_gen_steps_range(struct stepper_kinematics *sk, struct move *m
seek_time_delta = next.time - last.time;
if (seek_time_delta < .000000001)
seek_time_delta = .000000001;
+ if (is_dir_change && seek_time_delta > SEEK_TIME_RESET)
+ seek_time_delta = SEEK_TIME_RESET;
+ is_dir_change = 0;
last.position = target + (sdir ? half_step : -half_step);
last.time = next.time;
low = next;
@@ -87,6 +92,9 @@ itersolve_gen_steps_range(struct stepper_kinematics *sk, struct move *m
continue;
} else if (unlikely(dist < -(half_step + .000000001))) {
// Found direction change
+ is_dir_change = 1;
+ if (seek_time_delta > SEEK_TIME_RESET)
+ seek_time_delta = SEEK_TIME_RESET;
if (low.time > last.time) {
// Update direction and retry
sdir = !sdir;