Skip to content

Commit

Permalink
Update Aerotech motor for waiting mechanism
Browse files Browse the repository at this point in the history
  • Loading branch information
tfarago committed May 31, 2014
1 parent c993e3c commit f5e0732
Showing 1 changed file with 12 additions and 9 deletions.
21 changes: 12 additions & 9 deletions concert/devices/motors/aerotech.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
"""Aerotech"""
import time
from concert.helpers import wait_until
from concert.quantities import q
from concert.networking.aerotech import Connection
from concert.devices.motors.base import ContinuousRotationMotor
Expand Down Expand Up @@ -46,17 +46,16 @@ def _get_position(self):
def _set_position(self, position):
self._connection.execute("MOVEABS %s %f" % (Aerorot.AXIS, position.magnitude))

while not self._query_state() >> Aerorot.AXISSTATUS_IN_POSITION & 1:
time.sleep(Aerorot.SLEEP_TIME)
condition = lambda: self._query_state() >> Aerorot.AXISSTATUS_IN_POSITION & 1
wait_until(condition, sleep_time=Aerorot.SLEEP_TIME)

def _get_velocity(self):
return float(self._connection.execute("VFBK(%s)" % (Aerorot.AXIS))) * q.deg / q.s

def _set_velocity(self, velocity):
self._connection.execute("FREERUN %s %f" % (Aerorot.AXIS, velocity.magnitude))

while self._query_state() >> Aerorot.AXISSTATUS_ACCEL_PHASE & 1:
time.sleep(Aerorot.SLEEP_TIME)
wait_until(self._is_velocity_stable, sleep_time=Aerorot.SLEEP_TIME)

def check_state(self):
res = self._query_state()
Expand All @@ -74,11 +73,15 @@ def _stop(self):
if self.check_state() == 'moving':
self._connection.execute("ABORT %s" % (Aerorot.AXIS))

while self.check_state() == 'moving':
time.sleep(Aerorot.SLEEP_TIME)
wait_until(lambda: self.check_state() == 'moving', sleep_time=Aerorot.SLEEP_TIME)

def _home(self):
self._connection.execute("HOME %s" % (Aerorot.AXIS))

while self.check_state() == 'moving':
time.sleep(Aerorot.SLEEP_TIME)
wait_until(lambda: self.check_state() == 'moving', sleep_time=Aerorot.SLEEP_TIME)

def _is_velocity_stable(self):
accel = self._query_state() >> Aerorot.AXISSTATUS_ACCEL_PHASE & 1
decel = self._query_state() >> Aerorot.AXISSTATUS_DECEL_PHASE & 1

return not (accel or decel)

0 comments on commit f5e0732

Please sign in to comment.