Skip to content

Commit

Permalink
changes according to comments
Browse files Browse the repository at this point in the history
  • Loading branch information
SilasM2001 committed May 10, 2024
1 parent d0a617d commit bac2af2
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 14 deletions.
24 changes: 12 additions & 12 deletions basil/HL/mercury.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
4 changes: 2 additions & 2 deletions examples/lab_devices/MotorStage.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit bac2af2

Please sign in to comment.