Example #1
0
class HLe(base.IO):
    """Aerotech HLe controller IO board."""
    def __init__(self, host, port=8001):
        super(HLe, self).__init__()
        self._connection = Connection(host, port)
        # Three groups, first 0-5, the rest 0-7
        self._ports = _make_ids(0, 6) + _make_ids(1, 8) + _make_ids(2, 8)

    def _read_port(self, port):
        return int(
            self._connection.execute("DIN(X,%d,%d)" % (port[0], port[1])))

    def _write_port(self, port, value):
        self._connection.execute("DOUT(X,%d,%d:%d)" %
                                 (port[0], port[1], value))
Example #2
0
class HLe(base.IO):

    """Aerotech HLe controller IO board."""

    def __init__(self, host, port=8001):
        super(HLe, self).__init__()
        self._connection = Connection(host, port)
        # Three groups, first 0-5, the rest 0-7
        self._ports = _make_ids(0, 6) + _make_ids(1, 8) + _make_ids(2, 8)

    def _read_port(self, port):
        return int(self._connection.execute("DIN(X,%d,%d)" % (port[0], port[1])))

    def _write_port(self, port, value):
        self._connection.execute("DOUT(X,%d,%d:%d)" % (port[0], port[1], value))
Example #3
0
class Aerorot(ContinuousRotationMotor):
    """Aerorot ContinuousRotationMotor class implementation."""
    AXIS = "X"

    # status constants (bits of the AXISSTATUS output (see HLe docs))
    AXISSTATUS_ENABLED = 0
    AXISSTATUS_HOMED = 1
    AXISSTATUS_IN_POSITION = 2
    AXISSTATUS_MOVE_ACTIVE = 3
    AXISSTATUS_ACCEL_PHASE = 4
    AXISSTATUS_DECEL_PHASE = 5
    AXISSTATUS_POSITION_CAPTURE = 6
    AXISSTATUS_HOMING = 14

    SLEEP_TIME = 0.01 * q.s

    def __init__(self, host, port=8001, enable=True):
        super(Aerorot, self).__init__()

        self._host = host
        self._port = port
        self.connect()
        if enable:
            self.enable()

    def enable(self):
        """Enable the motor."""
        self._connection.execute("ENABLE %s" % (Aerorot.AXIS))

    def disable(self):
        """Disable the motor."""
        self._connection.execute("DISABLE %s" % (Aerorot.AXIS))

    def connect(self):
        """Reconnect in case the connection fails or is closed by the motor controller."""
        self._connection = Connection(self._host, self._port)

    def _query_state(self):
        return int(self._connection.execute("AXISSTATUS(%s)" % (Aerorot.AXIS)))

    def _get_position(self):
        return float(self._connection.execute("PFBK(%s)" %
                                              (Aerorot.AXIS))) * q.deg

    def _set_position(self, position):
        self._connection.execute("MOVEABS %s %f" %
                                 (Aerorot.AXIS, position.magnitude))

        # If this is not precise enough one can try the IN_POSITION
        self['state'].wait('standby', sleep_time=Aerorot.SLEEP_TIME)

    def _cancel_position(self):
        self._abort()

    def _cancel_velocity(self):
        self._abort()

    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))

        busy_wait(self._is_velocity_stable, sleep_time=Aerorot.SLEEP_TIME)

    def _get_state(self):
        res = self._query_state()

        # Simplified behavior because of unstable motor states, i.e.
        # error after long-homing etx. TODO:investigate
        state = 'standby'

        if res >> Aerorot.AXISSTATUS_MOVE_ACTIVE & 1:
            state = 'moving'

        return state

    def _stop(self):
        if self.state == 'moving':
            self.velocity = 0 * q.deg / q.s

        self['state'].wait('standby', sleep_time=Aerorot.SLEEP_TIME)

    def _abort(self):
        self._connection.execute("ABORT %s" % (Aerorot.AXIS))

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

        self['state'].wait('standby', 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)
Example #4
0
 def connect(self):
     """Reconnect in case the connection fails or is closed by the motor controller."""
     self._connection = Connection(self._host, self._port)
Example #5
0
class Aerorot(ContinuousRotationMotor):

    """Aerorot ContinuousRotationMotor class implementation."""
    AXIS = "X"

    # status constants (bits of the AXISSTATUS output (see HLe docs))
    AXISSTATUS_ENABLED = 0
    AXISSTATUS_HOMED = 1
    AXISSTATUS_IN_POSITION = 2
    AXISSTATUS_MOVE_ACTIVE = 3
    AXISSTATUS_ACCEL_PHASE = 4
    AXISSTATUS_DECEL_PHASE = 5
    AXISSTATUS_POSITION_CAPTURE = 6
    AXISSTATUS_HOMING = 14

    SLEEP_TIME = 0.01 * q.s

    def __init__(self, host, port=8001, enable=True):
        super(Aerorot, self).__init__()

        self._host = host
        self._port = port
        self.connect()
        if enable:
            self.enable()

    def enable(self):
        """Enable the motor."""
        self._connection.execute("ENABLE %s" % (Aerorot.AXIS))

    def disable(self):
        """Disable the motor."""
        self._connection.execute("DISABLE %s" % (Aerorot.AXIS))

    def connect(self):
        """Reconnect in case the connection fails or is closed by the motor controller."""
        self._connection = Connection(self._host, self._port)

    def faultack(self):
        """Clear errors."""
        return self._connection.execute("FAULTACK %s" % (Aerorot.AXIS))

    def _query_state(self):
        return int(self._connection.execute("AXISSTATUS(%s)" % (Aerorot.AXIS)))

    def _get_position(self):
        return float(self._connection.execute("PFBK(%s)" % (Aerorot.AXIS))) * q.deg

    def _set_position(self, position):
        self._connection.execute("MOVEABS %s %f" % (Aerorot.AXIS, position.magnitude))

        # If this is not precise enough one can try the IN_POSITION
        self['state'].wait('standby', sleep_time=Aerorot.SLEEP_TIME)

    def _cancel_position(self):
        self._abort()

    def _cancel_velocity(self):
        self._abort()

    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))

        busy_wait(self._is_velocity_stable, sleep_time=Aerorot.SLEEP_TIME)

    def _get_state(self):
        res = self._query_state()

        # Simplified behavior because of unstable motor states, i.e.
        # error after long-homing etx. TODO:investigate
        state = 'standby'

        if res >> Aerorot.AXISSTATUS_MOVE_ACTIVE & 1:
            state = 'moving'

        return state

    def _stop(self):
        if self.state == 'moving':
            self.velocity = 0 * q.deg / q.s

        self['state'].wait('standby', sleep_time=Aerorot.SLEEP_TIME)

    def _abort(self):
        self._connection.execute("ABORT %s" % (Aerorot.AXIS))

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

        self['state'].wait('standby', 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)
Example #6
0
 def connect(self):
     """Reconnect in case the connection fails or is closed by the motor controller."""
     self._connection = Connection(self._host, self._port)
Example #7
0
 def __init__(self, host, port=8001):
     super(HLe, self).__init__()
     self._connection = Connection(host, port)
     # Three groups, first 0-5, the rest 0-7
     self._ports = _make_ids(0, 6) + _make_ids(1, 8) + _make_ids(2, 8)
Example #8
0
 def __init__(self, host, port=8001):
     super(HLe, self).__init__()
     self._connection = Connection(host, port)
     # Three groups, first 0-5, the rest 0-7
     self._ports = _make_ids(0, 6) + _make_ids(1, 8) + _make_ids(2, 8)