Skip to content

Commit

Permalink
itersolve: Support step generation in lead up to and after stepper ac…
Browse files Browse the repository at this point in the history
…tivity

Add support for generating steps from kinematic functions that
calculate step times based on a range of the motion queue.  It
requires scanning for step generation during the lead up to stepper
activity (when the stepper would nominally be idle).  And it requires
scanning for step generation just after a stepper has nominally become
idle.

Signed-off-by: Kevin O'Connor <[email protected]>
  • Loading branch information
KevinOConnor committed Nov 21, 2019
1 parent 4dbe795 commit 56cd39f
Show file tree
Hide file tree
Showing 2 changed files with 28 additions and 6 deletions.
31 changes: 26 additions & 5 deletions klippy/chelper/itersolve.c
Original file line number Diff line number Diff line change
Expand Up @@ -150,21 +150,41 @@ itersolve_generate_steps(struct stepper_kinematics *sk, double flush_time)
struct move *m = list_first_entry(&sk->tq->moves, struct move, node);
while (last_flush_time >= m->print_time + m->move_t)
m = list_next_entry(m, node);
double force_steps_time = sk->last_move_time + sk->scan_past;
for (;;) {
if (last_flush_time >= flush_time)
return 0;
double start = m->print_time, end = start + m->move_t;
if (start < last_flush_time)
start = last_flush_time;
if (start >= flush_time)
return 0;
if (end > flush_time)
end = flush_time;
if (check_active(sk, m)) {
if (sk->scan_future && start > last_flush_time) {
// Must generate steps leading up to stepper activity
force_steps_time = start;
if (last_flush_time < start - sk->scan_future)
last_flush_time = start - sk->scan_future;
while (m->print_time > last_flush_time)
m = list_prev_entry(m, node);
continue;
}
// Generate steps for this move
int32_t ret = itersolve_gen_steps_range(sk, m, start, end);
if (ret)
return ret;
sk->last_move_time = last_flush_time = end;
force_steps_time = end + sk->scan_past;
} else if (start < force_steps_time) {
// Must generates steps just past stepper activity
if (end > force_steps_time)
end = force_steps_time;
int32_t ret = itersolve_gen_steps_range(sk, m, start, end);
if (ret)
return ret;
last_flush_time = end;
}
last_flush_time = end;
if (flush_time <= m->print_time + m->move_t)
if (flush_time + sk->scan_future <= m->print_time + m->move_t)
return 0;
m = list_next_entry(m, node);
}
Expand Down Expand Up @@ -212,7 +232,8 @@ itersolve_calc_position_from_coord(struct stepper_kinematics *sk
m.start_pos.x = x;
m.start_pos.y = y;
m.start_pos.z = z;
return sk->calc_position_cb(sk, &m, 0.);
m.move_t = 1000.;
return sk->calc_position_cb(sk, &m, 500.);
}

void __visible
Expand Down
3 changes: 2 additions & 1 deletion klippy/chelper/itersolve.h
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,8 @@ struct stepper_kinematics {
double step_dist, commanded_pos;
struct stepcompress *sc;

double last_flush_time;
double last_flush_time, last_move_time;
double scan_past, scan_future;
struct trapq *tq;
int active_flags;

Expand Down

0 comments on commit 56cd39f

Please sign in to comment.