def Connect(self, portName: str): self.Disconnect() if portName not in [p[0] for p in self.GetDeviceList()]: self.settings.portName = "" return else: self.settings.portName = portName self._activeConnection = Connection.open_serial_port( self.settings.portName) self._activeConnection.disconnected.subscribe( lambda alert: self.OnDisconnect.Invoke()) try: self._axisList = [ device.get_axis(1) for device in self._activeConnection.detect_devices() ] except: self._activeConnection = None self.settings.portName = "" return devices = self._activeConnection.detect_devices() for d in devices: d.all_axes.unpark() self.FlushSettings(self.xSettings) self.FlushSettings(self.ySettings) self.FlushSettings(self.zSettings)
def home2(): with Connection.open_serial_port("/dev/ttyUSB0") as connection: device_list = connection.detect_devices() device1 = device_list[0] device2 = device_list[1] axis1 = device1.get_axis(1) axis2 = device2.get_axis(1) axis2.home() return ("nothing")
def upstep(): with Connection.open_serial_port("/dev/ttyUSB0") as connection: device_list = connection.detect_devices() device1 = device_list[0] device2 = device_list[1] axis1 = device1.get_axis(1) axis2 = device2.get_axis(1) axis2.move_relative(5, Units.LENGTH_MILLIMETRES) #all_axes.stop(wait_until_idle = True) return ("nothing")
def rightstep(): with Connection.open_serial_port("/dev/ttyUSB0") as connection: device_list = connection.detect_devices() device1 = device_list[0] device2 = device_list[1] axis1 = device1.get_axis(1) axis2 = device2.get_axis(1) axis1.move_relative(-5, Units.LENGTH_MILLIMETRES) return ("nothing")
def upcont(): with Connection.open_serial_port("/dev/ttyUSB0") as connection: device_list = connection.detect_devices() device1 = device_list[0] device2 = device_list[1] axis1 = device1.get_axis(1) axis2 = device2.get_axis(1) velocity = 10 # update if with - & + shortly axis2.move_velocity(velocity, Units.VELOCITY_MILLIMETRES_PER_SECOND) axis2.move_absolute(100, Units.LENGTH_MILLIMETRES) return ("nothing")
def __init__(self): # The next time the library needs the database it will contact the web-service and save # the obtained data to the file system. When the library requires data later on, it uses the # saved files instead of the web-service. Library.toggle_device_db_store(True) print("Initializing connection at " + constants.SERIAL_PORT) self.conn = Connection.open_serial_port(constants.SERIAL_PORT) self.device = self.conn.detect_devices()[-1] print("Found {} controller with id {}".format( self.device.name, self.device.serial_number)) print("Homing all axes of {} peripheral device.. ".format( self.device.get_axis(1).peripheral_name)) self.device.all_axes.home()
def __init__(self): self.window = Tk() self.window.title('Gantry Motion Control') self.connected_text = Label(self.window, text="Connecting...") self.connected_text.pack() self.check_connection() self.canvas_create() self.rotaryStage.set_velocity_params(20, acceleration=None) with Connection.open_serial_port(self.zaberport) as connection: self.device_list = connection.detect_devices() self.connected_text.configure( text="Found {} devices".format(len(self.device_list))) #Error checking to ensure all zaber products are connected if len(self.device_list) == 2: pass elif len(self.device_list) == 1: messagebox.showerror( 'Error', 'Only one stage controllers is connected.' '\nCheck the connection then reopen') quit() else: messagebox.showerror( 'Error', 'More than 2 Zaber controllers are connected. ' '\nEnsure only two controllers are connected') quit() self.xyController = self.device_list[0] self.zController = self.device_list[1] self.Xaxis = self.xyController.get_axis(1) self.Yaxis = self.xyController.get_axis(2) self.Zaxis = self.zController.get_axis(1) menu = Menu(self.window) self.window.config(menu=menu) filemenu = Menu(menu) menu.add_cascade(label='File', menu=filemenu) filemenu.add_command(label='Home', command=self.zaber_home) filemenu.add_command( label='Help', command=lambda: webbrowser.open( 'https://iastate.box.com/s/huwdeysldcoheqrfgy4wmlfk6vyvoyvu' )) filemenu.add_command(label='Quit', command=quit) self.window.mainloop()
def background(): with Connection.open_serial_port("/dev/ttyUSB0") as connection: device_list = connection.detect_devices() print("Found {} devices".format(len(device_list))) device1 = device_list[0] device2 = device_list[1] axis1 = device1.get_axis(1) axis2 = device2.get_axis(1) axis1.move_absolute(10, Units.LENGTH_MILLIMETRES) axis2.move_absolute(10, Units.LENGTH_MILLIMETRES) axis1.home() axis2.home() return ("nothing")
def __init__(self, comp_port=None, position_start=0, offset=10): if comp_port is None: # COM port if os.name == 'nt': com_port = 'COM4' elif os.uname()[4][:3] == 'arm': com_port = '/dev/ttyUSB0' else: raise Exception('', 'Need to specify port') self.offset = offset self.position_whiskers = 0 self.current_position = 0 self.status = 'Standby' Library.enable_device_db_store() self.connection = Connection.open_serial_port(com_port) self.init_device()
from zaber_motion.ascii import Connection from zaber_motion import Units from zaber_motion.ascii import Lockstep import time with Connection.open_serial_port("/dev/ttyUSB0") as connection: device_list = connection.detect_devices() print("Found {} devices".format(len(device_list))) device1 = device_list[0] device2 = device_list[1] axis1 = device1.get_axis(1) axis2 = device2.get_axis(1) axis1.move_velocity(-2.0, unit = Units.VELOCITY_MILLIMETRES_PER_SECOND) axis2.move_velocity(-2.0, unit = Units.VELOCITY_MILLIMETRES_PER_SECOND) axis1.home() axis2.home() axis1.move_absolute(30, Units.LENGTH_MILLIMETRES, wait_until_idle=False) axis2.move_absolute(30, Units.LENGTH_MILLIMETRES, wait_until_idle=False) axis1.wait_until_idle() axis2.wait_until_idle()