mirror of
https://github.com/nqrduck/nqrduck-autotm.git
synced 2024-12-30 11:28:07 +00:00
Implemented relative stepper movement.
This commit is contained in:
parent
67b21d27b7
commit
487f7ce0c7
3 changed files with 42 additions and 2 deletions
|
@ -634,6 +634,34 @@ class AutoTMController(ModuleController):
|
||||||
self.module.model.active_stepper = self.module.model.tuning_stepper
|
self.module.model.active_stepper = self.module.model.tuning_stepper
|
||||||
elif stepper == "matching":
|
elif stepper == "matching":
|
||||||
self.module.model.active_stepper = self.module.model.matching_stepper
|
self.module.model.active_stepper = self.module.model.matching_stepper
|
||||||
|
|
||||||
|
def on_relative_move(self, steps : str) -> None:
|
||||||
|
"""This method is called when the relative move button is pressed.
|
||||||
|
|
||||||
|
Args:
|
||||||
|
steps (str): The number of steps to move the stepper.
|
||||||
|
"""
|
||||||
|
|
||||||
|
# First char is the stepper identifier, m for matching and t for tuning
|
||||||
|
motor_identifier = self.module.model.active_stepper.TYPE.lower()[0]
|
||||||
|
|
||||||
|
# We check if the steps are valid
|
||||||
|
stepper_current_position = self.module.model.active_stepper.position
|
||||||
|
|
||||||
|
future_position = stepper_current_position + int(steps)
|
||||||
|
|
||||||
|
if future_position < 0:
|
||||||
|
error = "Could not move stepper. Stepper position cannot be negative"
|
||||||
|
self.module.view.add_info_text(error)
|
||||||
|
return
|
||||||
|
|
||||||
|
if future_position > self.module.model.active_stepper.MAX_STEPS:
|
||||||
|
error = f"Could not move stepper. Stepper position cannot be larger than {self.module.model.active_stepper.MAX_STEPS}"
|
||||||
|
self.module.view.add_info_text(error)
|
||||||
|
return
|
||||||
|
|
||||||
|
# We send the command to the atm system, the first m identifies this is a move command
|
||||||
|
command = f"m{motor_identifier}{steps}"
|
||||||
|
self.send_command(command)
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -223,6 +223,14 @@ class Stepper:
|
||||||
self.homed = False
|
self.homed = False
|
||||||
self.position = 0
|
self.position = 0
|
||||||
|
|
||||||
|
class TuningStepper(Stepper):
|
||||||
|
TYPE = "Tuning"
|
||||||
|
MAX_STEPS = 1e6
|
||||||
|
|
||||||
|
class MatchingStepper(Stepper):
|
||||||
|
TYPE = "Matching"
|
||||||
|
MAX_STEPS = 1e6
|
||||||
|
|
||||||
class ElectricalLookupTable(LookupTable):
|
class ElectricalLookupTable(LookupTable):
|
||||||
TYPE = "Electrical"
|
TYPE = "Electrical"
|
||||||
|
|
||||||
|
@ -280,8 +288,8 @@ class AutoTMModel(ModuleModel):
|
||||||
self.calibration = None
|
self.calibration = None
|
||||||
self.serial = None
|
self.serial = None
|
||||||
|
|
||||||
self.tuning_stepper = Stepper()
|
self.tuning_stepper = TuningStepper()
|
||||||
self.matching_stepper = Stepper()
|
self.matching_stepper = MatchingStepper()
|
||||||
self.active_stepper = self.tuning_stepper
|
self.active_stepper = self.tuning_stepper
|
||||||
|
|
||||||
@property
|
@property
|
||||||
|
|
|
@ -116,6 +116,10 @@ class AutoTMView(ModuleView):
|
||||||
|
|
||||||
# Stepper selection
|
# Stepper selection
|
||||||
self._ui_form.stepperselectBox.currentIndexChanged.connect(lambda: self.module.controller.on_stepper_changed(self._ui_form.stepperselectBox.currentText()))
|
self._ui_form.stepperselectBox.currentIndexChanged.connect(lambda: self.module.controller.on_stepper_changed(self._ui_form.stepperselectBox.currentText()))
|
||||||
|
self._ui_form.increaseButton.clicked.connect(lambda: self.module.controller.on_relative_move(self._ui_form.stepsizeBox.text()))
|
||||||
|
self._ui_form.decreaseButton.clicked.connect(lambda: self.module.controller.on_relative_move("-" + self._ui_form.stepsizeBox.text()))
|
||||||
|
|
||||||
|
self._ui_form.absoluteGoButton.clicked.connect(lambda: self.module.controller.on_absolute_move(self._ui_form.absoluteposBox.text()))
|
||||||
|
|
||||||
# Active stepper changed
|
# Active stepper changed
|
||||||
self.module.model.active_stepper_changed.connect(self.on_active_stepper_changed)
|
self.module.model.active_stepper_changed.connect(self.on_active_stepper_changed)
|
||||||
|
|
Loading…
Reference in a new issue