class MotorController(object): ''' classdocs ''' def __init__(self): ''' Constructor correct serial number: old 83863559 83815746 ''' self.connectFailed = False try: self.Motor1 = APTMotor(83863559, HWTYPE=31) print self.Motor1.getHardwareInformation() print self.Motor1.getStageAxisInformation() print self.Motor1.getVelocityParameters() # self.degreeConv = 15.0156077 self.degreeConv = 1 self.Motor1.setVelocityParameters(0.0, 5.0, 5.99976) print self.Motor1.getVelocityParameters() except Exception as e: import ThreadedGUI self.connectFailed = True title = "Motor Connection Error" text = "Motor connection failed, make sure it is connected" p = mp.Process(target = ThreadedGUI.displayError, args =(title, text) ) p.start() p.join() def moveMotor(self, ang): self.Motor1.mcRel(ang/self.degreeConv,5.99976) # ans = self.Motor1.getPos()*self.degreeConv # return ans return 1 def Home(self): self.Motor1.go_home() return True def BlinkSomeLights(self): self.Motor1.identify() return True def getPosition(self): return self.Motor1.getPos()*self.degreeConv def moveTo(self, ang): return self.Motor1.mAbs(ang/self.degreeConv)*self.degreeConv
class BBD103(): """ Thorlabs USB interface to BBD103 controller for a MLS203 stage """ def __init__(self, sn_motor1=94832870, sn_motor2=94832869, **kwds): """ Connect to the thorlabs stage at the specified port. """ self.live = True self.unit_to_um = 1000.0 # units are mm self.um_to_unit = 1.0 / self.unit_to_um self.x = 0.0 self.y = 0.0 # sn_motor1 = 94832870 # sn_motor2 = 94832869 self.Motor1 = APTMotor(sn_motor1, HWTYPE=44) # initialize motor 1 "x" self.Motor2 = APTMotor(sn_motor2, HWTYPE=44) # initizalize motor 2 "y" ## getStatus # # @return True/False if we are actually connected to the stage. # def getStatus(self): return self.live def goAbsolute(self, x, y): x = x * self.um_to_unit y = y * self.um_to_unit self.Motor1.mAbs(x) # self.Motor2.mAbs(y) # def goRelative(self, x, y): x = x * self.um_to_unit y = y * self.um_to_unit self.Motor1.mRel(x) # self.Motor2.mRel(y) # def jog(self, x_speed, y_speed): # shouldn't this also specify a relative position vx = x_speed * self.um_to_unit vy = y_speed * self.um_to_unit self.Motor1.setVel(x_speed) self.Motor2.setVel(y_speed) def joystickOnOff(self, on): if on: self.writeline("!joy 2") else: self.writeline("!joy 0") ## lockout # # Calls joystickOnOff. # # @param flag True/False. # def lockout(self, flag): self.joystickOnOff(not flag) ## position # # @return [stage x (um), stage y (um), stage z (um)] # def position(self): if self.live: x0 = self.Motor1.getPos() # query single axis y0 = self.Motor2.getPos() # query single axis return {"x": x0, "y": y0} def serialNumber(self): """ Return the stages serial number. """ return self.Motor1.getHardwareInformation() def setVelocity(self, x_vel, y_vel): """ x_vel - The maximum stage velocity allowed in x. y_vel - The maximum stage velocity allowed in y. I'm not sure this should be allowed to change the max velocity here. """ pass ## shutDown # # Disconnect from the stage. # def shutDown(self): # Disconnect from the stage (not sure this is correct) if self.live: self.Motor1.cleanUpAPT() self.Motor2.cleanUpAPT() def zero(self): pass