From bac2af236f4e799ad9f732ca85ccbe4432a2e9bb Mon Sep 17 00:00:00 2001 From: silab Date: Fri, 10 May 2024 12:00:57 +0200 Subject: [PATCH] changes according to comments --- basil/HL/mercury.py | 24 ++++++++++++------------ examples/lab_devices/MotorStage.py | 4 ++-- 2 files changed, 14 insertions(+), 14 deletions(-) diff --git a/basil/HL/mercury.py b/basil/HL/mercury.py index c5f2c6fc..8623080a 100644 --- a/basil/HL/mercury.py +++ b/basil/HL/mercury.py @@ -73,35 +73,35 @@ def get_channel(self, address=None): self._write_command("TS", address) return self.read() - def set_position(self, value, precision=500, address=None, wait=True): + def set_position(self, value, precision=100, address=None, wait=False): self._write_command("MA%d" % value, address) if wait is True: - pos = self._wait_FE(address) + pos = self._wait(address) if abs(pos - value) <= precision: - print("At position", pos, "Traget at", value) + print("At position {pos}, Target at {target}".format(pos = pos, target = value)) else: - print("Warning: Precision not reached") + print("Warning: Target not reached! Target: {target}, actual position: {pos}, precision: {pre}".format(target = value, pos = pos, pre = precision)) - def move_relative(self, value, precision=500, address=None, wait=True): + def move_relative(self, value, precision=100, address=None, wait=False): target = self.get_position(address=1) + value self._write_command("MR%d" % value, address) if wait is True: - pos = self._wait_FE(address) + pos = self._wait(address) if abs(pos - target) <= precision: - print("At position", pos, "Traget at", target) + print("At position {pos}, Target at {target}".format(pos = pos, target = target)) else: - print("Warning: Precision not reached") + print("Warning: Target not reached! Target: {target}, actual position: {pos}, precision: {pre}".format(target = target, pos = pos, pre = precision)) def abort(self, address=None): self._write_command("AB", address) def find_edge(self, n, address=None): self._write_command("FE%d" % n, address) - pos = self._wait_FE(address) - print("Edge found, position:", pos) + pos = self._wait(address) + print("Edge found at position: {pos}".format(pos = pos)) - def _wait_FE(self, address=None): # waits until motor stops moving - print(self.get_position(address), "Moving") + def _wait(self, address=None): # waits until motor stops moving + print("Moving! Starting position: {pos}".format(pos = self.get_position(address))) done = False while done is False: a = self.get_position(address) diff --git a/examples/lab_devices/MotorStage.py b/examples/lab_devices/MotorStage.py index 54c4ce70..c02832dd 100644 --- a/examples/lab_devices/MotorStage.py +++ b/examples/lab_devices/MotorStage.py @@ -25,13 +25,13 @@ time.sleep(0.1) # move to absolute position 10000: -# dut["MotorStage"].set_position(10000, address=1) +# dut["MotorStage"].set_position(10000, address=1, wait=True) # get position: # print(dut["MotorStage"].get_position(address=1)) # move relative 10000: -dut["MotorStage"].move_relative(10000, address=1, wait=False) +dut["MotorStage"].move_relative(10000, address=1, wait=True) # finding edge example: # dut["MotorStage"].find_edge(1,address=1) # 0 or 1 indicates direction of movement