Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Experimental kinematics #1023

Merged
merged 3 commits into from
Dec 24, 2018
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
86 changes: 86 additions & 0 deletions config/example-polar.cfg
Original file line number Diff line number Diff line change
@@ -0,0 +1,86 @@
# This file serves as documentation for config parameters of "polar"
# style printers. One may copy and edit this file to configure a new
# polar printer.

# POLAR KINEMATICS ARE A WORK IN PROGRESS. Moves around the 0,0
# position are known to not work properly. Moves to a negative Y
# coordinate from a positive Y coordinate (and vice-versa) when the
# head is at a negative X coordinate also do not work properly.

# Only parameters unique to polar printers are described here - see
# the "example.cfg" file for description of common config parameters.

# The stepper_bed section is used to describe the stepper controlling
# the bed.
[stepper_bed]
step_pin: ar54
dir_pin: ar55
enable_pin: !ar38
step_distance: 0.000981748
# On a polar printer the step_distance is the amount each step pulse
# moves the bed in radians (for example, a 1.8 degree stepper with
# 16 micro-steps would be 1.8 / 360 * pi / 16 == 0.000981748). This
# parameter must be provided.

# The stepper_arm section is used to describe the stepper controlling
# the carriage on the arm.
[stepper_arm]
step_pin: ar60
dir_pin: ar61
enable_pin: !ar56
step_distance: .01
endstop_pin: ^ar14
position_endstop: 300
position_max: 300
homing_speed: 50

# The stepper_z section is used to describe the stepper controlling
# the Z axis.
[stepper_z]
step_pin: ar46
dir_pin: ar48
enable_pin: !ar62
step_distance: .0025
endstop_pin: ^ar18
position_endstop: 0.5
position_max: 200

[extruder]
step_pin: ar26
dir_pin: ar28
enable_pin: !ar24
step_distance: .0022
nozzle_diameter: 0.400
filament_diameter: 1.750
heater_pin: ar10
sensor_type: ATC Semitec 104GT-2
sensor_pin: analog13
control: pid
pid_Kp: 22.2
pid_Ki: 1.08
pid_Kd: 114
min_temp: 0
max_temp: 250

[heater_bed]
heater_pin: ar8
sensor_type: EPCOS 100K B57560G104F
sensor_pin: analog14
control: watermark
min_temp: 0
max_temp: 130

[fan]
pin: ar9

[mcu]
serial: /dev/ttyACM0
pin_map: arduino

[printer]
kinematics: polar
# This option must be "polar" for polar printers.
max_velocity: 300
max_accel: 3000
max_z_velocity: 25
max_z_accel: 30
96 changes: 96 additions & 0 deletions config/example-winch.cfg
Original file line number Diff line number Diff line change
@@ -0,0 +1,96 @@
# This file serves as documentation for config parameters of cable
# winch style printers. One may copy and edit this file to configure a
# new cable winch printer.

# CABLE WINCH SUPPORT IS EXPERIMENTAL - PROCEED WITH CAUTION!

# Homing is not implemented on cable winch kinematics. In order to
# home the printer, manually send movement commands until the toolhead
# is at 0,0,0 and then issue a G28 command.

# Only parameters unique to cable winch printers are described here -
# see the "example.cfg" file for description of common config
# parameters.

# The stepper_a section describes the stepper connected to the first
# cable winch. A minimum of 3 and a maximum of 26 cable winches may be
# defined (stepper_a to stepper_z) though it is common to define 4.
[stepper_a]
step_pin: ar54
dir_pin: ar55
enable_pin: !ar38
step_distance: .01
# The step_distance is the nominal distance (in mm) the toolhead
# moves towards the cable winch on each step pulse. This parameter
# must be provided.
anchor_x: 0
anchor_y: -2000
anchor_z: -100
# The x, y, and z position of the cable winch in cartesian space.
# These parameters must be provided.

[stepper_b]
step_pin: ar60
dir_pin: ar61
enable_pin: !ar56
step_distance: .01
anchor_x: 2000
anchor_y: 1000
anchor_z: -100

[stepper_c]
step_pin: ar46
dir_pin: ar48
enable_pin: !ar62
step_distance: .01
anchor_x: -2000
anchor_y: 1000
anchor_z: -100

[stepper_d]
step_pin: ar36
dir_pin: ar34
enable_pin: !ar30
step_distance: .01
anchor_x: 0
anchor_y: 0
anchor_z: 3000

[extruder]
step_pin: ar26
dir_pin: ar28
enable_pin: !ar24
step_distance: .0022
nozzle_diameter: 0.400
filament_diameter: 1.750
heater_pin: ar10
sensor_type: ATC Semitec 104GT-2
sensor_pin: analog13
control: pid
pid_Kp: 22.2
pid_Ki: 1.08
pid_Kd: 114
min_temp: 0
max_temp: 250

[heater_bed]
heater_pin: ar8
sensor_type: EPCOS 100K B57560G104F
sensor_pin: analog14
control: watermark
min_temp: 0
max_temp: 130

# Print cooling fan (omit section if fan not present).
#[fan]
#pin: ar9

[mcu]
serial: /dev/ttyACM0
pin_map: arduino

[printer]
kinematics: winch
# This option must be "winch" for cable winch printers.
max_velocity: 300
max_accel: 3000
15 changes: 13 additions & 2 deletions klippy/chelper/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,8 @@
" -o %s %s")
SOURCE_FILES = [
'pyhelper.c', 'serialqueue.c', 'stepcompress.c', 'itersolve.c',
'kin_cartesian.c', 'kin_corexy.c', 'kin_delta.c', 'kin_extruder.c'
'kin_cartesian.c', 'kin_corexy.c', 'kin_delta.c', 'kin_polar.c',
'kin_winch.c', 'kin_extruder.c',
]
DEST_LIB = "c_helper.so"
OTHER_FILES = [
Expand Down Expand Up @@ -70,6 +71,15 @@
, double tower_x, double tower_y);
"""

defs_kin_polar = """
struct stepper_kinematics *polar_stepper_alloc(char type);
"""

defs_kin_winch = """
struct stepper_kinematics *winch_stepper_alloc(double anchor_x
, double anchor_y, double anchor_z);
"""

defs_kin_extruder = """
struct stepper_kinematics *extruder_stepper_alloc(void);
void extruder_move_fill(struct move *m, double print_time
Expand Down Expand Up @@ -116,7 +126,8 @@

defs_all = [
defs_pyhelper, defs_serialqueue, defs_std, defs_stepcompress, defs_itersolve,
defs_kin_cartesian, defs_kin_corexy, defs_kin_delta, defs_kin_extruder
defs_kin_cartesian, defs_kin_corexy, defs_kin_delta, defs_kin_polar,
defs_kin_winch, defs_kin_extruder
]

# Return the list of file modification times
Expand Down
41 changes: 41 additions & 0 deletions klippy/chelper/kin_polar.c
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
// Polar 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 <math.h> // sqrt
#include <stdlib.h> // malloc
#include <string.h> // memset
#include "compiler.h" // __visible
#include "itersolve.h" // struct stepper_kinematics

static double
polar_stepper_radius_calc_position(struct stepper_kinematics *sk, struct move *m
, double move_time)
{
struct coord c = move_get_coord(m, move_time);
return sqrt(c.x*c.x + c.y*c.y);
}

static double
polar_stepper_angle_calc_position(struct stepper_kinematics *sk, struct move *m
, double move_time)
{
struct coord c = move_get_coord(m, move_time);
// XXX - handle x==y==0
// XXX - handle angle wrapping
return atan2(c.y, c.x);
}

struct stepper_kinematics * __visible
polar_stepper_alloc(char type)
{
struct stepper_kinematics *sk = malloc(sizeof(*sk));
memset(sk, 0, sizeof(*sk));
if (type == 'r')
sk->calc_position = polar_stepper_radius_calc_position;
else if (type == 'a')
sk->calc_position = polar_stepper_angle_calc_position;
return sk;
}
40 changes: 40 additions & 0 deletions klippy/chelper/kin_winch.c
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
// Cable winch stepper kinematics
//
// Copyright (C) 2018 Kevin O'Connor <kevin@koconnor.net>
//
// This file may be distributed under the terms of the GNU GPLv3 license.

#include <math.h> // sqrt
#include <stddef.h> // offsetof
#include <stdlib.h> // malloc
#include <string.h> // memset
#include "compiler.h" // __visible
#include "itersolve.h" // struct stepper_kinematics

struct winch_stepper {
struct stepper_kinematics sk;
struct coord anchor;
};

static double
winch_stepper_calc_position(struct stepper_kinematics *sk, struct move *m
, double move_time)
{
struct winch_stepper *hs = container_of(sk, struct winch_stepper, sk);
struct coord c = move_get_coord(m, move_time);
double dx = hs->anchor.x - c.x, dy = hs->anchor.y - c.y;
double dz = hs->anchor.z - c.z;
return sqrt(dx*dx + dy*dy + dz*dz);
}

struct stepper_kinematics * __visible
winch_stepper_alloc(double anchor_x, double anchor_y, double anchor_z)
{
struct winch_stepper *hs = malloc(sizeof(*hs));
memset(hs, 0, sizeof(*hs));
hs->anchor.x = anchor_x;
hs->anchor.y = anchor_y;
hs->anchor.z = anchor_z;
hs->sk.calc_position = winch_stepper_calc_position;
return &hs->sk;
}
26 changes: 26 additions & 0 deletions klippy/kinematics/none.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
# Dummy "none" kinematics support (for developer testing)
#
# Copyright (C) 2018 Kevin O'Connor <kevin@koconnor.net>
#
# This file may be distributed under the terms of the GNU GPLv3 license.

class NoneKinematics:
def __init__(self, toolhead, config):
pass
def get_steppers(self, flags=""):
return []
def calc_position(self):
return [0, 0, 0]
def set_position(self, newpos, homing_axes):
pass
def home(self, homing_state):
pass
def motor_off(self, print_time):
pass
def check_move(self, move):
pass
def move(self, print_time, move):
pass

def load_kinematics(toolhead, config):
return NoneKinematics(toolhead, config)
Loading