Skip to content

Commit

Permalink
changes wip. i broke something
Browse files Browse the repository at this point in the history
  • Loading branch information
lraithel15133 committed Jul 18, 2024
1 parent eb212a4 commit 76a9592
Show file tree
Hide file tree
Showing 6 changed files with 23 additions and 21 deletions.
7 changes: 4 additions & 3 deletions docs/Stepstick_Types.md
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,6 @@ Klipper behavior of using the TMC default value will be used (i.e. 0.075 for 516
| BTT EZ5160 RGB | BTT_EZ_5160_RGB | 0.05 | 4.7 |
| BTT EZ6609 | BTT_EZ_6609 | 0.11 | 2 |
| BTT TMC5160T Plus | BTT_EXT_5160 | 0.022 | 10.6 |
| FLY HV-TMC5160 Pro | MELLOW_FLY_HV_5160_Pro | 0.033 | 6 |
| COREVUS TMC2209 | COREVUS_2209 | 0.1 | 3 |
| COREVUS TMC2160 OLD | COREVUS_2160_OLD | 0.03 | 3 |
| COREVUS TMC2160 5A | COREVUS_2160_5A | 0.03 | 5 |
Expand All @@ -54,10 +53,12 @@ Klipper behavior of using the TMC default value will be used (i.e. 0.075 for 516
| FYSETC HV5160 | FYSETC_HV5160 | 0.075 | 3 |
| FYSETC QHV5160 | FYSETC_QHV5160 | 0.075 | 3 |
| FYSETC Silent5161 | FYSETC_5161 | 0.06 | 3.5 |
| MKS GC6609 | MKS_GC6609 | 0.11 | 2 |
| MKS 2130 | MKS_2130 | 0.11 | 2 |
| MKS 2208 | MKS_2208 | 0.11 | 2 |
| MKS 2209 | MKS_2209 | 0.11 | 2 |
| MKS 2225 | MKS_2225 | 0.11 | 2 |
| MKS 2226 | MKS_2226 | 0.17 | 2.5 |
| MKS 2240 | MKS_2240 | 0.11 | 2.1 |
| MKS 2240 | MKS_2240 | 0.11 | 2.1 |
| Mellow Fly 2209 | MELLOW_2209 | 0.11 | 2 |
| Mellow Fly 5160 | MELLOW_2209 | 0.11 | 3 |
| Mellow Fly HV-TMC5160 Pro | MELLOW_FLY_HV_5160_Pro | 0.033 | 6 |
5 changes: 3 additions & 2 deletions klippy/extras/stepstick_defs.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,6 @@
"BTT_EZ_5160_RGB": (0.05, 4.7),
"BTT_EZ_6609": (0.11, 2),
"BTT_5160T": (0.022, 10.6),
"MELLOW_FLY_HV_5160_Pro": (0.033, 6),
"COREVUS_2209": (0.1, 3),
"COREVUS_2160_OLD": (0.03, 3),
"COREVUS_2160_5A": (0.03, 5),
Expand All @@ -36,11 +35,13 @@
"FYSETC_HV5160": (0.075, 3),
"FYSETC_QHV5160": (0.075, 3),
"FYSETC_5161": (0.06, 3.5),
"MKS_GC6609": (0.11, 2),
"MKS_2130": (0.11, 2),
"MKS_2208": (0.11, 2),
"MKS_2209": (0.11, 2),
"MKS_2225": (0.11, 2),
"MKS_2226": (0.17, 2.5),
"MKS_2240": (0.11, 2.1),
"MELLOW_FLY_2209": (0.11, 2),
"MELLOW_FLY_5160": (0.11, 3),
"MELLOW_FLY_HV_5160_Pro": (0.033, 6),
}
9 changes: 5 additions & 4 deletions klippy/extras/tmc.py
Original file line number Diff line number Diff line change
Expand Up @@ -765,7 +765,7 @@ def TMCStealthchopHelper(config, mcu_tmc, tmc_freq):


class BaseTMCCurrentHelper:
def __init__(self, config, mcu_tmc, max_current):
def __init__(self, config, mcu_tmc):
self.printer = config.get_printer()
self.config_file = self.printer.lookup_object("configfile")
self.name = config.get_name().split()[-1]
Expand All @@ -792,7 +792,9 @@ def __init__(self, config, mcu_tmc, max_current):
self.sense_resistor = self.DEFAULT_SENSE_RESISTOR
self.config_file.warn(
"config",
f"[{self.name}] 'stepper_driver_type' or 'sense_resistor' is not defined, Using default value of {self.sense_resistor} ohm sense resistor. If this is incorrect, your drivers or board may be damaged.",
f"""Neither 'stepper_driver_type' or 'sense_resistor' is defined for [{self.name}].
Using default value of {self.sense_resistor} ohm sense resistor.
If this is incorrect, your drivers or board may be damaged.""",
"sense_resistor",
)

Expand All @@ -803,8 +805,7 @@ def __init__(self, config, mcu_tmc, max_current):

logging.warning(self.sense_resistor)

if step_driver_max_current is not None:
max_current = step_driver_max_current
max_current = step_driver_max_current or self.DEFAULT_MAX_CURRENT

# config_{run|hold|home}_current
# represents an initial value set via config file
Expand Down
9 changes: 4 additions & 5 deletions klippy/extras/tmc2130.py
Original file line number Diff line number Diff line change
Expand Up @@ -194,14 +194,13 @@
# TMC stepper current config helper
######################################################################

MAX_CURRENT = 2.000


class TMC2130CurrentHelper(tmc.BaseTMCCurrentHelper):
DEFAULT_SENSE_RESISTOR = 0.110
DEFAULT_MAX_CURRENT = 2.000

def __init__(self, config, mcu_tmc):
super().__init__(config, mcu_tmc, MAX_CURRENT)
super().__init__(config, mcu_tmc)

vsense, irun, ihold = self._calc_current(
self.req_run_current, self.req_hold_current
Expand Down Expand Up @@ -242,7 +241,7 @@ def _calc_current(self, run_current, hold_current):
ihold = self._calc_current_bits(min(hold_current, run_current), vsense)
return vsense, irun, ihold

def get_current(self):
def get_current(self, MAX_CURRENT):
irun = self.fields.get_field("irun")
ihold = self.fields.get_field("ihold")
vsense = self.fields.get_field("vsense")
Expand All @@ -252,7 +251,7 @@ def get_current(self):
run_current,
hold_current,
self.req_hold_current,
MAX_CURRENT,
self.MAX_CURRENT,
self.req_home_current,
)

Expand Down
8 changes: 4 additions & 4 deletions klippy/extras/tmc2660.py
Original file line number Diff line number Diff line change
Expand Up @@ -111,12 +111,12 @@
# TMC stepper current config helper
######################################################################

MAX_CURRENT = 2.400


class TMC2660CurrentHelper(tmc.BaseTMCCurrentHelper):
DEFAULT_MAX_CURRENT = 2.400

def __init__(self, config, mcu_tmc):
super().__init__(config, mcu_tmc, MAX_CURRENT)
super().__init__(config, mcu_tmc)

self.current = self.req_run_current

Expand Down Expand Up @@ -190,7 +190,7 @@ def get_current(self):
self.req_run_current,
None,
None,
MAX_CURRENT,
self.MAX_CURRENT,
self.req_home_current,
)

Expand Down
6 changes: 3 additions & 3 deletions klippy/extras/tmc5160.py
Original file line number Diff line number Diff line change
Expand Up @@ -248,14 +248,14 @@
######################################################################

VREF = 0.325
MAX_CURRENT = 10.000 # Maximum dependent on board, but 10 is safe sanity check


class TMC5160CurrentHelper(tmc.BaseTMCCurrentHelper):
DEFAULT_SENSE_RESISTOR = 0.075
DEFAULT_MAX_CURRENT = 10.000

def __init__(self, config, mcu_tmc):
super().__init__(config, mcu_tmc, MAX_CURRENT)
super().__init__(config, mcu_tmc)

self.sense_resistor = config.getfloat(
"sense_resistor", 0.075, above=0.0
Expand Down Expand Up @@ -313,7 +313,7 @@ def get_current(self):
run_current,
hold_current,
self.req_hold_current,
MAX_CURRENT,
self.MAX_CURRENT,
self.req_home_current,
)

Expand Down

0 comments on commit 76a9592

Please sign in to comment.