diff options
author | Kevin O'Connor <kevin@koconnor.net> | 2017-04-07 11:47:24 -0400 |
---|---|---|
committer | Kevin O'Connor <kevin@koconnor.net> | 2017-04-07 15:05:41 -0400 |
commit | 33b809714f8f0b018024f1636c76cc4c85648fd0 (patch) | |
tree | b63445fd491fe537ce6f20b90037758512fb3ac4 /klippy/stepcompress.c | |
parent | b915a2ad7d6eec6f7ef31fc5f13397029b927351 (diff) | |
download | kutter-33b809714f8f0b018024f1636c76cc4c85648fd0.tar.gz kutter-33b809714f8f0b018024f1636c76cc4c85648fd0.tar.xz kutter-33b809714f8f0b018024f1636c76cc4c85648fd0.zip |
delta: Do reverse direction checking in C code
Calculate where a tower must reverse direction during a move in the C
code instead of the delta.py kinematic code. This simplifies the
python code.
Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
Diffstat (limited to 'klippy/stepcompress.c')
-rw-r--r-- | klippy/stepcompress.c | 38 |
1 files changed, 35 insertions, 3 deletions
diff --git a/klippy/stepcompress.c b/klippy/stepcompress.c index d9eeefc3..761c16c2 100644 --- a/klippy/stepcompress.c +++ b/klippy/stepcompress.c @@ -1,6 +1,6 @@ // Stepper pulse schedule compression // -// Copyright (C) 2016 Kevin O'Connor <kevin@koconnor.net> +// Copyright (C) 2016,2017 Kevin O'Connor <kevin@koconnor.net> // // This file may be distributed under the terms of the GNU GPLv3 license. // @@ -531,8 +531,8 @@ stepcompress_push_const( } // Schedule steps using delta kinematics -int32_t -stepcompress_push_delta( +static int32_t +_stepcompress_push_delta( struct stepcompress *sc, double clock_offset, double move_sd , double start_sv, double accel , double height, double startxy_sd, double arm_sd, double movez_r) @@ -627,6 +627,38 @@ stepcompress_push_delta( return res; } +int32_t +stepcompress_push_delta( + struct stepcompress *sc, double clock_offset, double move_sd + , double start_sv, double accel + , double height, double startxy_sd, double arm_sd, double movez_r) +{ + double reversexy_sd = startxy_sd + arm_sd*movez_r; + if (reversexy_sd <= 0.) + // All steps are in down direction + return _stepcompress_push_delta( + sc, clock_offset, -move_sd, start_sv, accel + , height, startxy_sd, arm_sd, movez_r); + double movexy_r = movez_r ? sqrt(1. - movez_r*movez_r) : 1.; + if (reversexy_sd >= move_sd * movexy_r) + // All steps are in up direction + return _stepcompress_push_delta( + sc, clock_offset, move_sd, start_sv, accel + , height, startxy_sd, arm_sd, movez_r); + // Steps in both up and down direction + int res1 = _stepcompress_push_delta( + sc, clock_offset, reversexy_sd / movexy_r, start_sv, accel + , height, startxy_sd, arm_sd, movez_r); + if (res1 == ERROR_RET) + return res1; + int res2 = _stepcompress_push_delta( + sc, clock_offset, -move_sd, start_sv, accel + , height + res1, startxy_sd, arm_sd, movez_r); + if (res2 == ERROR_RET) + return res2; + return res1 + res2; +} + /**************************************************************** * Step compress synchronization |