|
20 | 20 | StackerInfo,
|
21 | 21 | HardwareRevision,
|
22 | 22 | MoveParams,
|
| 23 | + AxisParams, |
23 | 24 | LimitSwitchStatus,
|
24 | 25 | LEDColor,
|
25 | 26 | StallGuardParams,
|
|
57 | 58 | STALLGUARD_CONFIG = {
|
58 | 59 | StackerAxis.X: StallGuardParams(StackerAxis.X, True, 2),
|
59 | 60 | StackerAxis.Z: StallGuardParams(StackerAxis.Z, True, 2),
|
60 |
| - StackerAxis.L: StallGuardParams(StackerAxis.L, True, 2), |
61 | 61 | }
|
62 | 62 |
|
63 | 63 | STACKER_MOTION_CONFIG = {
|
64 | 64 | StackerAxis.X: {
|
65 |
| - "home": MoveParams( |
66 |
| - StackerAxis.X, |
67 |
| - max_speed=10.0, # mm/s |
68 |
| - acceleration=100.0, # mm/s^2 |
69 |
| - max_speed_discont=40, # mm/s |
70 |
| - current=1.5, # mAmps |
| 65 | + "home": AxisParams( |
| 66 | + run_current=1.5, # mAmps |
| 67 | + hold_current=0.75, |
| 68 | + move_params=MoveParams( |
| 69 | + max_speed=10.0, # mm/s |
| 70 | + acceleration=100.0, # mm/s^2 |
| 71 | + max_speed_discont=40.0, # mm/s |
| 72 | + ), |
71 | 73 | ),
|
72 |
| - "move": MoveParams( |
73 |
| - StackerAxis.X, |
74 |
| - max_speed=200.0, |
75 |
| - acceleration=1500.0, |
76 |
| - max_speed_discont=40, |
77 |
| - current=1.0, |
| 74 | + "move": AxisParams( |
| 75 | + run_current=1.0, |
| 76 | + hold_current=0.75, |
| 77 | + move_params=MoveParams( |
| 78 | + max_speed=200.0, |
| 79 | + acceleration=1500.0, |
| 80 | + max_speed_discont=40.0, |
| 81 | + ), |
78 | 82 | ),
|
79 | 83 | },
|
80 | 84 | StackerAxis.Z: {
|
81 |
| - "home": MoveParams( |
82 |
| - StackerAxis.Z, |
83 |
| - max_speed=10.0, |
84 |
| - acceleration=100.0, |
85 |
| - max_speed_discont=40, |
86 |
| - current=1.5, |
| 85 | + "home": AxisParams( |
| 86 | + run_current=1.5, |
| 87 | + hold_current=1.8, |
| 88 | + move_params=MoveParams( |
| 89 | + max_speed=10.0, |
| 90 | + acceleration=100.0, |
| 91 | + max_speed_discont=25.0, |
| 92 | + ), |
87 | 93 | ),
|
88 |
| - "move": MoveParams( |
89 |
| - StackerAxis.Z, |
90 |
| - max_speed=200.0, |
91 |
| - acceleration=500.0, |
92 |
| - max_speed_discont=40, |
93 |
| - current=1.5, |
| 94 | + "move": AxisParams( |
| 95 | + run_current=1.5, |
| 96 | + hold_current=0.5, |
| 97 | + move_params=MoveParams( |
| 98 | + max_speed=150.0, |
| 99 | + acceleration=500.0, |
| 100 | + max_speed_discont=25.0, |
| 101 | + ), |
94 | 102 | ),
|
95 | 103 | },
|
96 | 104 | StackerAxis.L: {
|
97 |
| - "home": MoveParams( |
98 |
| - StackerAxis.L, |
99 |
| - max_speed=100.0, |
100 |
| - acceleration=800.0, |
101 |
| - max_speed_discont=40, |
102 |
| - current=0.8, |
| 105 | + "home": AxisParams( |
| 106 | + run_current=0.8, |
| 107 | + hold_current=0.15, |
| 108 | + move_params=MoveParams( |
| 109 | + max_speed=100.0, |
| 110 | + acceleration=800.0, |
| 111 | + max_speed_discont=40.0, |
| 112 | + ), |
103 | 113 | ),
|
104 |
| - "move": MoveParams( |
105 |
| - StackerAxis.L, |
106 |
| - max_speed=100.0, |
107 |
| - acceleration=800.0, |
108 |
| - max_speed_discont=40, |
109 |
| - current=0.6, |
| 114 | + "move": AxisParams( |
| 115 | + run_current=0.6, |
| 116 | + hold_current=0.15, |
| 117 | + move_params=MoveParams( |
| 118 | + max_speed=100.0, |
| 119 | + acceleration=800.0, |
| 120 | + max_speed_discont=40.0, |
| 121 | + ), |
110 | 122 | ),
|
111 | 123 | },
|
112 | 124 | }
|
@@ -183,18 +195,12 @@ def parse_installation_detected(cls, response: str) -> bool:
|
183 | 195 | def parse_move_params(cls, response: str) -> MoveParams:
|
184 | 196 | """Parse move params."""
|
185 | 197 | field_names = MoveParams.get_fields()
|
186 |
| - pattern = r"\s".join( |
187 |
| - [ |
188 |
| - rf"{f}:(?P<{f}>(\d*\.)?\d+)" if f != "M" else rf"{f}:(?P<{f}>[XZL])" |
189 |
| - for f in field_names |
190 |
| - ] |
191 |
| - ) |
192 |
| - _RE = re.compile(f"^{GCODE.GET_MOVE_PARAMS} {pattern}$") |
| 198 | + pattern = r"\s".join(rf"{f}:(?P<{f}>(\d*\.)?\d+)" for f in field_names) |
| 199 | + _RE = re.compile(rf"^{GCODE.GET_MOVE_PARAMS} M:([XZL]) {pattern}$") |
193 | 200 | m = _RE.match(response)
|
194 | 201 | if not m:
|
195 | 202 | raise ValueError(f"Incorrect Response for move params: {response}")
|
196 | 203 | return MoveParams(
|
197 |
| - axis=StackerAxis(m.group("M")), |
198 | 204 | max_speed=float(m.group("V")),
|
199 | 205 | acceleration=float(m.group("A")),
|
200 | 206 | max_speed_discont=float(m.group("D")),
|
@@ -294,14 +300,9 @@ def append_move_params(
|
294 | 300 | ) -> CommandBuilder:
|
295 | 301 | """Append move params."""
|
296 | 302 | if params is not None:
|
297 |
| - if params.max_speed is not None: |
298 |
| - command.add_float("V", params.max_speed, GCODE_ROUNDING_PRECISION) |
299 |
| - if params.acceleration is not None: |
300 |
| - command.add_float("A", params.acceleration, GCODE_ROUNDING_PRECISION) |
301 |
| - if params.max_speed_discont is not None: |
302 |
| - command.add_float( |
303 |
| - "D", params.max_speed_discont, GCODE_ROUNDING_PRECISION |
304 |
| - ) |
| 303 | + command.add_float("V", params.max_speed, GCODE_ROUNDING_PRECISION) |
| 304 | + command.add_float("A", params.acceleration, GCODE_ROUNDING_PRECISION) |
| 305 | + command.add_float("D", params.max_speed_discont, GCODE_ROUNDING_PRECISION) |
305 | 306 | return command
|
306 | 307 |
|
307 | 308 | @classmethod
|
@@ -410,6 +411,7 @@ async def set_stallguard_threshold(
|
410 | 411 | self, axis: StackerAxis, enable: bool, threshold: int
|
411 | 412 | ) -> bool:
|
412 | 413 | """Enables and sets the stallguard threshold for the given axis motor."""
|
| 414 | + assert axis != StackerAxis.L, "Stallguard not supported for L axis" |
413 | 415 | if not -64 < threshold < 63:
|
414 | 416 | raise ValueError(
|
415 | 417 | f"Threshold value ({threshold}) should be between -64 and 63."
|
|
0 commit comments