Skip to content

Commit

Permalink
Merge branch 'main' into add_siboor_14sth20-1004a
Browse files Browse the repository at this point in the history
  • Loading branch information
andrewmcgr authored Aug 28, 2024
2 parents 197e4ed + bf6a30a commit 2fb2eee
Show file tree
Hide file tree
Showing 2 changed files with 140 additions and 24 deletions.
28 changes: 23 additions & 5 deletions autotune_tmc.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import math, logging, os
from enum import Enum
from inspect import signature
from . import tmc

# Autotune config parameters
Expand Down Expand Up @@ -32,10 +33,10 @@
FAST_STANDSTILL = True
SMALL_HYSTERESIS = False
SEMIN = 2
SEMAX = 2
SEMAX = 4
SEUP = 3
SEDN = 2
SEIMIN = 0 # If we drop to 1/4 current, high accels don't work right
SEIMIN = 1 # If we drop to 1/4 current, high accels don't work right
SFILT = 0
IHOLDDELAY = 12
IRUNDELAY = 0
Expand Down Expand Up @@ -87,7 +88,11 @@ def __init__(self, config):
raise config.error(
"Could not find any TMC driver config section for '%s' required by TMC autotuning"
% (self.name))

# TMCtstepHelper may have two signatures, let's pick an implementation
if 'pstepper' in signature(tmc.TMCtstepHelper).parameters:
self._set_driver_velocity_field = self._set_driver_velocity_field_new
else:
self._set_driver_velocity_field = self._set_driver_velocity_field_old
# AutotuneTMC config parameters
self.motor = config.get('motor')
self.motor_name = "motor_constants " + self.motor
Expand Down Expand Up @@ -235,7 +240,19 @@ def _set_driver_field(self, field, arg):
val = tmco.fields.set_field(field, arg)
tmco.mcu_tmc.set_register(register, val, None)

def _set_driver_velocity_field(self, field, velocity):
def _set_driver_velocity_field_new(self, field, velocity):
tmco = self.tmc_object
register = tmco.fields.lookup_register(field, None)
# Just bail if the field doesn't exist.
if register is None:
return
arg = tmc.TMCtstepHelper(tmco.mcu_tmc, velocity,
pstepper=self.tmc_cmdhelper.stepper)
logging.info("autotune_tmc set %s %s=%s(%s)",
self.name, field, repr(arg), repr(velocity))
tmco.fields.set_field(field, arg)

def _set_driver_velocity_field_old(self, field, velocity):
tmco = self.tmc_object
register = tmco.fields.lookup_register(field, None)
# Just bail if the field doesn't exist.
Expand Down Expand Up @@ -294,7 +311,8 @@ def _pwmthrs(self, vmaxpwm, coolthrs):
else:
# We do not have SG4, so this makes the world safe for
# sensorless homing in the presence of CoolStep
return 0.5 * coolthrs
# return 0.5 * coolthrs
return 0.5 * vmaxpwm

def _setup_pwm(self, tgoal, pwmthrs):
motor = self.motor_object
Expand Down
136 changes: 117 additions & 19 deletions motor_database.cfg
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,13 @@ holding_torque: 0.10
max_current: 1.0
steps_per_revolution: 200

[motor_constants ldo-36sth20-1004ahg-9T]
resistance: 2.4
inductance: 0.0014
holding_torque: 0.10
max_current: 1.0
steps_per_revolution: 200

[motor_constants ldo-36sth20-1004ahg]
resistance: 2.1
inductance: 0.0016
Expand Down Expand Up @@ -46,6 +53,14 @@ holding_torque: 0.4
max_current: 1.68
steps_per_revolution: 200

[motor_constants ldo-36sth17-0354ahg]
# Basically a LDO-36STH17-1004AHG but 0.35A rated
resistance: 10.8
inductance: 0.006
holding_torque: 0.06
max_current: 0.35
steps_per_revolution: 200

## NEMA 17

[motor_constants ldo-42sth40-1684l300e]
Expand Down Expand Up @@ -113,13 +128,6 @@ holding_torque: 0.44
max_current: 2.0
steps_per_revolution: 400

[motor_constants ldo-42sth48-2004ac]
resistance: 1.6
inductance: 0.003
holding_torque: 0.59
max_current: 2.0
steps_per_revolution: 200

[motor_constants ldo-42sth40-1004a]
#Prusa Mk3 steppers XYE axis
#https://cfl.prusa3d.com/display/PI3M3/Stepper+motors
Expand All @@ -129,19 +137,21 @@ holding_torque: 0.49
max_current: 1
steps_per_revolution: 200

[motor_constants ldo-42sth34-1004l321e]
# Prusa Mk3 steppers Z axis
resistance: 8.00
inductance: 0.0095
holding_torque: 107.7
max_current: 1.00
steps_per_revolution: 200

[motor_constants ldo-42sth40-1004mah]
resistance: 4.1
inductance: 0.0115
holding_torque: 0.39
max_current: 1
steps_per_revolution: 400

[motor_constants ldo-42sth40-2004mah]
resistance: 1.1
inductance: 0.0028
holding_torque: 0.35
max_current: 2
steps_per_revolution: 400

[motor_constants ldo-42sth20-1004ash]
resistance: 7.2
Expand Down Expand Up @@ -173,6 +183,14 @@ holding_torque: 0.85
max_current: 2
steps_per_revolution: 200

[motor_constants ldo-42sth25-1404ac]
# Microswiss NG extruder
resistance: 2.4
inductance: 0.0055
holding_torque: 0.23
max_current: 1.4
steps_per_revolution: 200

### Moons Motors ###

## NEMA 14
Expand Down Expand Up @@ -277,6 +295,13 @@ holding_torque: 0.4
max_current: 1.5
steps_per_revolution: 200

[motor_constants omc-14hr07-1004vrn]
resistance: 3.9
inductance: 0.002
holding_torque: 0.09
max_current: 1.00
steps_per_revolution: 400

# Adding the two stepper motors for the original V0 release:
# OMC 14HS17-0504S (A/B/Z)
# OMC 14HS10-0404S (Clockwork)
Expand Down Expand Up @@ -311,12 +336,6 @@ holding_torque: 0.42
max_current: 1.50
steps_per_revolution: 200

[motor_constants omc-17he19-2004s]
resistance: 1.30
inductance: 0.0024
holding_torque: 0.55
max_current: 2.0
steps_per_revolution: 200

[motor_constants omc-17hs15-1504s]
resistance: 2.30
Expand Down Expand Up @@ -435,6 +454,20 @@ holding_torque: 0.42
max_current: 1.5
steps_per_revolution: 200

[motor_constants fysetc-35hsh7402-24b-60b]
resistance: 2.8
inductance: 0.0055
holding_torque: 0.42
max_current: 1.5
steps_per_revolution: 200

[motor_constants fysetc-42hsc1433b-200n8]
resistance: 8
inductance: 0.01
holding_torque: 0.35
max_current: 1
steps_per_revolution: 200

#NEMA 17
[motor_constants fysetc-42hsc1404b-200n8]
resistance: 29
Expand Down Expand Up @@ -535,6 +568,14 @@ holding_torque: 0.12
max_current: 1.88
steps_per_revolution: 200

[motor_constants siboor-42sth28-0804a]
#Siboor BOM Voron 0.2 Z integrated leadscrew stepper (metal version)
resistance: 5.5
inductance: 0.0066
holding_torque: 0.26
max_current: 1.0
steps_per_revolution: 200

[motor_constants wantai-42byghw811]
# Wantai Stepper Motor 42BYGHW811 and 42BYGHW811-X11
resistance: 1.25
Expand All @@ -543,6 +584,32 @@ holding_torque: 0.48
max_current: 2.50
steps_per_revolution: 200

# QIDI motors

[motor_constants qidi-BJ42D29-28V07]
# used for X/Y-axis on QIDI X MAX 3
resistance: 1.4
inductance: 0.0026
holding_torque: 0.41
max_current: 1.5
steps_per_revolution: 200

[motor_constants qidi-BJ42D29-22V08]
# used for Z-Axis on QIDI X MAX 3
resistance: 4.7
inductance: 0.011
holding_torque: 0.6
max_current: 1.2
steps_per_revolution: 200

[motor_constants qidi-BJY36D12-04V13]
# used for extruder on QIDI X MAX 3
resistance: 2.0
inductance: 0.0012
holding_torque: 0.09
max_current: 1.0
steps_per_revolution: 200

# Creality motors

[motor_constants creality-42-34]
Expand All @@ -567,6 +634,14 @@ holding_torque: 0.57
max_current: 1.0
steps_per_revolution: 200

[motor_constants creality-42-60]
#Creality Ender 7 (X,Y) - RB Step Motor 17HDC8033-32B - https://14.23.50.34/en/biaozhunshihunheshibujindianji/41
resistance: 1.2
inductance: 0.0034
holding_torque: 0.76
max_current: 2.00
steps_per_revolution: 200

[motor_constants BJ42D09-20V02]
#Creality Sprite Pro https://user-images.githubusercontent.com/862951/235050029-79124b76-81d3-4f77-9501-6404f7c38336.png
resistance: 1.75
Expand Down Expand Up @@ -758,3 +833,26 @@ inductance: 0.0028
holding_torque: 0.65
max_current: 2
steps_per_revolution: 200


[motor_constants act-17hs4417]
resistance: 1.5
inductance: 0.0028
holding_torque: 0.40
max_current: 1.7
steps_per_revolution: 200

[motor_constants jkong-jk42hS40-1704]
resistance: 1.65
inductance: 0.0032
holding_torque: 0.4
max_current: 1.7
steps_per_revolution: 200

[motor_constants biqu-35BYGF0713-A-10HZT]
resistance: 2.3
inductance: 0.0020
holding_torque: 0.11
max_current: 1.5
steps_per_revolution: 200

0 comments on commit 2fb2eee

Please sign in to comment.