-
-
Notifications
You must be signed in to change notification settings - Fork 5.5k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
winch: Add experimental support for cable winch kinematics
Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
- Loading branch information
1 parent
ec9cb3a
commit 5dc74f3
Showing
6 changed files
with
209 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,62 @@ | ||
# Code for handling the kinematics of cable winch robots | ||
# | ||
# Copyright (C) 2018 Kevin O'Connor <kevin@koconnor.net> | ||
# | ||
# This file may be distributed under the terms of the GNU GPLv3 license. | ||
import stepper, mathutil | ||
|
||
class WinchKinematics: | ||
def __init__(self, toolhead, config): | ||
# Setup steppers at each anchor | ||
self.steppers = [] | ||
self.anchors = [] | ||
for i in range(26): | ||
name = 'stepper_' + chr(ord('a') + i) | ||
if i >= 3 and not config.has_section(name): | ||
break | ||
stepper_config = config.getsection(name) | ||
s = stepper.PrinterStepper(stepper_config) | ||
self.steppers.append(s) | ||
a = tuple([stepper_config.getfloat('anchor_' + n) for n in 'xyz']) | ||
self.anchors.append(a) | ||
s.setup_itersolve('winch_stepper_alloc', *a) | ||
# Setup stepper max halt velocity | ||
max_velocity, max_accel = toolhead.get_max_velocity() | ||
max_halt_velocity = toolhead.get_max_axis_halt() | ||
for s in self.steppers: | ||
s.set_max_jerk(max_halt_velocity, max_accel) | ||
# Setup boundary checks | ||
self.need_motor_enable = True | ||
self.set_position([0., 0., 0.], ()) | ||
def get_steppers(self, flags=""): | ||
return list(self.steppers) | ||
def calc_position(self): | ||
# Use only first three steppers to calculate cartesian position | ||
spos = [s.get_commanded_position() for s in self.steppers[:3]] | ||
return mathutil.trilateration(self.anchors[:3], [sp*sp for sp in spos]) | ||
def set_position(self, newpos, homing_axes): | ||
for s in self.steppers: | ||
s.set_position(newpos) | ||
def home(self, homing_state): | ||
# XXX - homing not implemented | ||
homing_state.set_axes([0, 1, 2]) | ||
homing_state.set_homed_position([0., 0., 0.]) | ||
def motor_off(self, print_time): | ||
for s in self.steppers: | ||
s.motor_enable(print_time, 0) | ||
self.need_motor_enable = True | ||
def _check_motor_enable(self, print_time): | ||
for s in self.steppers: | ||
s.motor_enable(print_time, 1) | ||
self.need_motor_enable = False | ||
def check_move(self, move): | ||
# XXX - boundary checks and speed limits not implemented | ||
pass | ||
def move(self, print_time, move): | ||
if self.need_motor_enable: | ||
self._check_motor_enable(print_time) | ||
for s in self.steppers: | ||
s.step_itersolve(move.cmove) | ||
|
||
def load_kinematics(toolhead, config): | ||
return WinchKinematics(toolhead, config) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters