diff options
author | Kevin O'Connor <kevin@koconnor.net> | 2020-02-25 12:54:55 -0500 |
---|---|---|
committer | Kevin O'Connor <kevin@koconnor.net> | 2020-03-13 21:53:48 -0400 |
commit | acd165cbea2f48812b7fd96c28b81622e5c13665 (patch) | |
tree | 0496d4905d40c7cfe8a164a7c8cffd1eab53e8b1 /klippy/chelper/itersolve.c | |
parent | d86bf0b927b0a56bcef5a2fee98f610884c0d4a5 (diff) | |
download | kutter-acd165cbea2f48812b7fd96c28b81622e5c13665.tar.gz kutter-acd165cbea2f48812b7fd96c28b81622e5c13665.tar.xz kutter-acd165cbea2f48812b7fd96c28b81622e5c13665.zip |
stepcompress: Implement a step+dir+step filter
Some stepper motor drivers do not respond well to rapid "step +
direction change + step" events. In particular, it is believed this
can cause "over current" events on the tmc2208 drivers when they are
in "stealthchop" mode. Detect these events and remove them from the
generated step times.
Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
Diffstat (limited to 'klippy/chelper/itersolve.c')
-rw-r--r-- | klippy/chelper/itersolve.c | 15 |
1 files changed, 14 insertions, 1 deletions
diff --git a/klippy/chelper/itersolve.c b/klippy/chelper/itersolve.c index 1094e5f3..9cae55fd 100644 --- a/klippy/chelper/itersolve.c +++ b/klippy/chelper/itersolve.c @@ -13,6 +13,11 @@ #include "stepcompress.h" // queue_append_start #include "trapq.h" // struct move + +/**************************************************************** + * Main iterative solver + ****************************************************************/ + struct timepos { double time, position; }; @@ -66,7 +71,7 @@ itersolve_gen_steps_range(struct stepper_kinematics *sk, struct move *m 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 = SEEK_TIME_RESET; - int sdir = !!stepcompress_get_step_dir(sk->sc), is_dir_change = 0; + 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) { @@ -90,6 +95,9 @@ itersolve_gen_steps_range(struct stepper_kinematics *sk, struct move *m if (low.time < high.time) // The existing search range is still valid continue; + } else if (dist > 0.) { + // Avoid rollback if stepper fully reaches target position + stepcompress_commit(sk->sc); } else if (unlikely(dist < -(half_step + .000000001))) { // Found direction change is_dir_change = 1; @@ -127,6 +135,11 @@ itersolve_gen_steps_range(struct stepper_kinematics *sk, struct move *m return 0; } + +/**************************************************************** + * Interface functions + ****************************************************************/ + // Check if a move is likely to cause movement on a stepper static inline int check_active(struct stepper_kinematics *sk, struct move *m) |