AlexShkarin / pyLabLib

Python package for device control and experiment automation
http://pylablib.readthedocs.io
GNU General Public License v3.0
130 stars 30 forks source link

Picomotor controller model 8743-CL #89

Open alexkish opened 2 months ago

alexkish commented 2 months ago

What can I try to modify in the code to make it work with the 2-axis controller model 8743-CL?

These are the commands that work and the responce to them:

Newport.get_usb_devices_number_picomotor() 1 print(comm_backend.PyUSBDeviceBackend.list_resources(idVendor=0x104d)) [(4173, 16384, 0)]

alexkish commented 2 months ago

If I execute this command: stage1 = Newport.Picomotor8742(), I get the following errors:

KeyError Traceback (most recent call last) File /Applications/xapps/miniconda3/envs/scipy/lib/python3.9/site-packages/usb/core.py:236, in _ResourceManager.get_interface_and_endpoint(self, device, endpoint_address) 235 try: --> 236 return self._ep_info[endpoint_address] 237 except KeyError:

KeyError: 2

During handling of the above exception, another exception occurred:

USBError Traceback (most recent call last) File /Applications/xapps/miniconda3/envs/scipy/lib/python3.9/site-packages/pylablib/core/devio/comm_backend.py:34, in reraise..wrapped(self, *args, *kwargs) 33 try: ---> 34 return func(self,args,**kwargs) 35 except self.BackendError as exc:

File /Applications/xapps/miniconda3/envs/scipy/lib/python3.9/site-packages/pylablib/core/devio/comm_backend.py:1349, in PyUSBDeviceBackend.write(self, data, flush, read_echo, read_echo_delay, read_echo_lines) 1348 data=data+py3.as_builtin_bytes(self.term_write) -> 1349 self.instr.write(self.ep_write,data,timeout=self._timeout()) 1350 self.cooldown("write")

File /Applications/xapps/miniconda3/envs/scipy/lib/python3.9/site-packages/usb/core.py:986, in Device.write(self, endpoint, data, timeout) 980 fn_map = { 981 util.ENDPOINT_TYPE_BULK:backend.bulk_write, 982 util.ENDPOINT_TYPE_INTR:backend.intr_write, 983 util.ENDPOINT_TYPE_ISO:backend.iso_write 984 } --> 986 intf, ep = self._ctx.setup_request(self, endpoint) 987 fn = fn_map[util.endpoint_type(ep.bmAttributes)]

File /Applications/xapps/miniconda3/envs/scipy/lib/python3.9/site-packages/usb/core.py:113, in synchronized..wrapper(self, *args, *kwargs) 112 self.lock.acquire() --> 113 return f(self, args, **kwargs) 114 finally:

File /Applications/xapps/miniconda3/envs/scipy/lib/python3.9/site-packages/usb/core.py:228, in _ResourceManager.setup_request(self, device, endpoint) 226 endpoint_address = endpoint --> 228 intf, ep = self.get_interface_and_endpoint(device, endpoint_address) 229 self.managed_claim_interface(device, intf)

File /Applications/xapps/miniconda3/envs/scipy/lib/python3.9/site-packages/usb/core.py:113, in synchronized..wrapper(self, *args, *kwargs) 112 self.lock.acquire() --> 113 return f(self, args, **kwargs) 114 finally:

File /Applications/xapps/miniconda3/envs/scipy/lib/python3.9/site-packages/usb/core.py:238, in _ResourceManager.get_interface_and_endpoint(self, device, endpoint_address) 237 except KeyError: --> 238 for intf in self.get_active_configuration(device): 239 ep = util.find_descriptor(intf, bEndpointAddress=endpoint_address)

File /Applications/xapps/miniconda3/envs/scipy/lib/python3.9/site-packages/usb/core.py:113, in synchronized..wrapper(self, *args, *kwargs) 112 self.lock.acquire() --> 113 return f(self, args, **kwargs) 114 finally:

File /Applications/xapps/miniconda3/envs/scipy/lib/python3.9/site-packages/usb/core.py:255, in _ResourceManager.get_active_configuration(self, device) 254 if cfg is None: --> 255 raise USBError('Configuration not set') 256 self._active_cfg_index = cfg.index

USBError: [Errno None] Configuration not set

The above exception was the direct cause of the following exception:

NewportBackendError Traceback (most recent call last) File /Applications/xapps/miniconda3/envs/scipy/lib/python3.9/site-packages/pylablib/devices/Newport/picomotor.py:55, in Picomotor8742.init(self, conn, backend, timeout, multiaddr, scan) 54 try: ---> 55 self.get_id() 56 except instr.Error:

File /Applications/xapps/miniconda3/envs/scipy/lib/python3.9/site-packages/pylablib/core/utils/general.py:1120, in muxcall..wrapper..wrapped(*args, kwargs) 1119 all_args[argname]=marg -> 1120 res=func(all_args) 1121 return res

File /Applications/xapps/miniconda3/envs/scipy/lib/python3.9/site-packages/pylablib/devices/Newport/picomotor.py:91, in Picomotor8742.get_id(self, addr) 90 """Get the device identification string""" ---> 91 return self.query("*IDN?",addr=addr)

File /Applications/xapps/miniconda3/envs/scipy/lib/python3.9/site-packages/pylablib/devices/Newport/picomotor.py:77, in Picomotor8742.query(self, comm, axis, addr, read_reply) 76 comm=addr_header+comm ---> 77 self.instr.write(comm) 78 if read_reply is None:

File /Applications/xapps/miniconda3/envs/scipy/lib/python3.9/site-packages/pylablib/core/devio/comm_backend.py:45, in logerror..wrapped(self, *args, *kwargs) 44 try: ---> 45 return func(self,args,**kwargs) 46 except self.Error as exc:

File /Applications/xapps/miniconda3/envs/scipy/lib/python3.9/site-packages/pylablib/core/devio/comm_backend.py:37, in reraise..wrapped(self, *args, **kwargs) 36 ReraiseError=getattr(self,"ReraiseError",self.Error) ---> 37 raise ReraiseError(exc) from exc

NewportBackendError: backend exception: USBError(None, 'Configuration not set') ('[Errno None] Configuration not set')

During handling of the above exception, another exception occurred:

NewportError Traceback (most recent call last) Cell In [7], line 1 ----> 1 stage1 = Newport.Picomotor8742()

File /Applications/xapps/miniconda3/envs/scipy/lib/python3.9/site-packages/pylablib/devices/Newport/picomotor.py:58, in Picomotor8742.init(self, conn, backend, timeout, multiaddr, scan) 56 except instr.Error: 57 self.close() ---> 58 raise NewportError("error connecting to the Picomotor controller") 59 if multiaddr: 60 if scan:

NewportError: error connecting to the Picomotor controller