aboutsummaryrefslogtreecommitdiffstats
path: root/klippy/chelper
diff options
context:
space:
mode:
authorKevin O'Connor <kevin@koconnor.net>2018-06-09 14:30:22 -0400
committerKevin O'Connor <kevin@koconnor.net>2018-06-20 09:26:10 -0400
commitfc4a9e7564a51ab5275826f2a2398335ff9acc9a (patch)
tree0607a0f1b5bfef1ca99b06c167ee7902c84f0aec /klippy/chelper
parentca0d0135dc7c3c2a1bfb1cf49b97f039c97ca34d (diff)
downloadkutter-fc4a9e7564a51ab5275826f2a2398335ff9acc9a.tar.gz
kutter-fc4a9e7564a51ab5275826f2a2398335ff9acc9a.tar.xz
kutter-fc4a9e7564a51ab5275826f2a2398335ff9acc9a.zip
corexy: Convert corexy to use the iterative solver
Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
Diffstat (limited to 'klippy/chelper')
-rw-r--r--klippy/chelper/__init__.py13
-rw-r--r--klippy/chelper/kin_cartesian.c48
-rw-r--r--klippy/chelper/kin_corexy.c38
3 files changed, 95 insertions, 4 deletions
diff --git a/klippy/chelper/__init__.py b/klippy/chelper/__init__.py
index 36e32303..7366cc81 100644
--- a/klippy/chelper/__init__.py
+++ b/klippy/chelper/__init__.py
@@ -15,8 +15,8 @@ COMPILE_CMD = ("gcc -Wall -g -O2 -shared -fPIC"
" -flto -fwhole-program -fno-use-linker-plugin"
" -o %s %s")
SOURCE_FILES = [
- 'stepcompress.c', 'kin_cartesian.c', 'kin_delta.c', 'itersolve.c',
- 'serialqueue.c', 'pyhelper.c'
+ 'pyhelper.c', 'serialqueue.c', 'stepcompress.c', 'itersolve.c',
+ 'kin_cartesian.c', 'kin_corexy.c', 'kin_delta.c',
]
DEST_LIB = "c_helper.so"
OTHER_FILES = [
@@ -59,6 +59,11 @@ defs_kin_cartesian = """
, int32_t sdir);
int32_t stepcompress_push_const(struct stepcompress *sc, double clock_offset
, double step_offset, double steps, double start_sv, double accel);
+ struct stepper_kinematics *cartesian_stepper_alloc(char axis);
+"""
+
+defs_kin_corexy = """
+ struct stepper_kinematics *corexy_stepper_alloc(char type);
"""
defs_kin_delta = """
@@ -103,8 +108,8 @@ defs_std = """
"""
defs_all = [
- defs_stepcompress, defs_itersolve, defs_kin_cartesian, defs_kin_delta,
- defs_serialqueue, defs_pyhelper, defs_std
+ defs_pyhelper, defs_serialqueue, defs_std, defs_stepcompress, defs_itersolve,
+ defs_kin_cartesian, defs_kin_corexy, defs_kin_delta
]
# Return the list of file modification times
diff --git a/klippy/chelper/kin_cartesian.c b/klippy/chelper/kin_cartesian.c
index 5cefb119..c9d01e0a 100644
--- a/klippy/chelper/kin_cartesian.c
+++ b/klippy/chelper/kin_cartesian.c
@@ -5,10 +5,18 @@
// This file may be distributed under the terms of the GNU GPLv3 license.
#include <math.h> // sqrt
+#include <stdlib.h> // malloc
+#include <string.h> // memset
#include "compiler.h" // likely
+#include "itersolve.h" // move_get_coord
#include "pyhelper.h" // errorf
#include "stepcompress.h" // queue_append
+
+/****************************************************************
+ * Direct step generation
+ ****************************************************************/
+
// Common suffixes: _sd is step distance (a unit length the same
// distance the stepper moves on each step), _sv is step velocity (in
// units of step distance per time), _sd2 is step distance squared, _r
@@ -111,3 +119,43 @@ stepcompress_push_const(
}
return res;
}
+
+
+/****************************************************************
+ * Iterative solver
+ ****************************************************************/
+
+static double
+cart_stepper_x_calc_position(struct stepper_kinematics *sk, struct move *m
+ , double move_time)
+{
+ return move_get_coord(m, move_time).x;
+}
+
+static double
+cart_stepper_y_calc_position(struct stepper_kinematics *sk, struct move *m
+ , double move_time)
+{
+ return move_get_coord(m, move_time).y;
+}
+
+static double
+cart_stepper_z_calc_position(struct stepper_kinematics *sk, struct move *m
+ , double move_time)
+{
+ return move_get_coord(m, move_time).z;
+}
+
+struct stepper_kinematics * __visible
+cartesian_stepper_alloc(char axis)
+{
+ struct stepper_kinematics *sk = malloc(sizeof(*sk));
+ memset(sk, 0, sizeof(*sk));
+ if (axis == 'x')
+ sk->calc_position = cart_stepper_x_calc_position;
+ else if (axis == 'y')
+ sk->calc_position = cart_stepper_y_calc_position;
+ else if (axis == 'z')
+ sk->calc_position = cart_stepper_z_calc_position;
+ return sk;
+}
diff --git a/klippy/chelper/kin_corexy.c b/klippy/chelper/kin_corexy.c
new file mode 100644
index 00000000..2a097d91
--- /dev/null
+++ b/klippy/chelper/kin_corexy.c
@@ -0,0 +1,38 @@
+// CoreXY kinematics stepper pulse time generation
+//
+// Copyright (C) 2018 Kevin O'Connor <kevin@koconnor.net>
+//
+// This file may be distributed under the terms of the GNU GPLv3 license.
+
+#include <stdlib.h> // malloc
+#include <string.h> // memset
+#include "compiler.h" // __visible
+#include "itersolve.h" // struct stepper_kinematics
+
+static double
+corexy_stepper_plus_calc_position(struct stepper_kinematics *sk, struct move *m
+ , double move_time)
+{
+ struct coord c = move_get_coord(m, move_time);
+ return c.x + c.y;
+}
+
+static double
+corexy_stepper_minus_calc_position(struct stepper_kinematics *sk, struct move *m
+ , double move_time)
+{
+ struct coord c = move_get_coord(m, move_time);
+ return c.x - c.y;
+}
+
+struct stepper_kinematics * __visible
+corexy_stepper_alloc(char type)
+{
+ struct stepper_kinematics *sk = malloc(sizeof(*sk));
+ memset(sk, 0, sizeof(*sk));
+ if (type == '+')
+ sk->calc_position = corexy_stepper_plus_calc_position;
+ else if (type == '-')
+ sk->calc_position = corexy_stepper_minus_calc_position;
+ return sk;
+}