mabuchilab / Instrumental

Python-based instrumentation library from the Mabuchi Lab.
http://instrumental-lib.readthedocs.org/
GNU General Public License v3.0
117 stars 77 forks source link

Thor Labs CCS200 - Constantly Timing Out (Ive seen the other closed thread on this) #134

Closed TannerZachem closed 3 years ago

TannerZachem commented 3 years ago

Hi there, using an anaconda dist with everything installed and constantly receiving the ThorLabsCCSError: b'Timeout expired before operation completed" even when I choose incredibly fast integration times the timeout still occurs.

def __init__(self): 
        params = inst.list_instruments()
        self.ccs = inst.instrument(params[0])

Then to collect the data:

data_array, wavelengths = self.ccs.take_data(integration_time)

Where integration_time is the pint appropriate value (usually '.1s'). This is the error message I receive:

Exception in Tkinter callback
Traceback (most recent call last):
  File "C:\Users\Tanner Zachem\Anaconda3\envs\TUMORIDFLOW\lib\tkinter\__init__.py", line 1883, in __call__
    return self.func(*args)
  File "C:/Users/Tanner Zachem/Desktop/TUMORIDFLOW/gui.py", line 146, in CollectSpectra
    wavelengths, data_array = self.ccs.take_data(integration_time)  # integration time on spectrometer
  File "C:\Users\Tanner Zachem\Anaconda3\envs\TUMORIDFLOW\lib\site-packages\instrumental\drivers\spectrometers\thorlabs_ccs.py", line 365, in take_data
    self.stop_and_clear(max_attempts)
  File "C:\Users\Tanner Zachem\Anaconda3\envs\TUMORIDFLOW\lib\site-packages\instrumental\drivers\spectrometers\thorlabs_ccs.py", line 335, in stop_and_clear
    self.get_scan_data()
  File "C:\Users\Tanner Zachem\Anaconda3\envs\TUMORIDFLOW\lib\site-packages\instrumental\drivers\spectrometers\thorlabs_ccs.py", line 295, in get_scan_data
    data = self._NiceCCS.getScanData()
  File "C:\Users\Tanner Zachem\Anaconda3\envs\TUMORIDFLOW\lib\site-packages\nicelib\nicelib.py", line 700, in __call__
    return self._libfunc._call(args, kwds, niceobj=self._niceobj)
  File "C:\Users\Tanner Zachem\Anaconda3\envs\TUMORIDFLOW\lib\site-packages\nicelib\nicelib.py", line 1170, in _call
    return self.sig.extract_outputs(c_args, retval, ret_handler_args)
  File "C:\Users\Tanner Zachem\Anaconda3\envs\TUMORIDFLOW\lib\site-packages\nicelib\nicelib.py", line 219, in extract_outputs
    retval = self.ret_handler.handle(retval, ret_handler_kwargs)
  File "C:\Users\Tanner Zachem\Anaconda3\envs\TUMORIDFLOW\lib\site-packages\nicelib\nicelib.py", line 542, in handle
    return self.__func__(retval, **kwargs)
  File "C:\Users\Tanner Zachem\Anaconda3\envs\TUMORIDFLOW\lib\site-packages\instrumental\drivers\spectrometers\thorlabs_ccs.py", line 64, in ccs_errcheck
    raise ThorlabsCCSError(niceobj.error_message(error_code))
instrumental.drivers.spectrometers.thorlabs_ccs.ThorlabsCCSError: b'Timeout expired before operation completed.'

Any ideas on how to fix this, using the git dev version of both Instrumental & NiceLib, but this occurred even with a regular pip install.

natezb commented 3 years ago

Hi, thanks for the report. I'm not sure specifically which issue you're referring to, but have you seen #120? By the end of the thread, @LewisBarltrop came up with a theory of what the problem might be, related to a low-power USB state.

TannerZachem commented 3 years ago

Thank you for the reply! I have seen #120 as well as #93, have tried many USB cables and both desktop/laptop. Seems to be timing out no matter what, working maybe 1/100 times? Thank you for making all of this, super helpful!!

TannerZachem commented 3 years ago

Just investigated the USB power, and the spectrometer stays at USB D0, full power, the entire time.

TannerZachem commented 3 years ago

Could not fix this issue, was able to successfully collect data reliably with pythonNET. ThorLabsCCS200

natezb commented 3 years ago

Sorry I couldn't be of more help, I don't have much experience with this instrument. Thanks for posting about pythonNET, we could perhaps create a .NET-based driver if other people continue to have issues and the .NET lib seems to be more reliable. We'd probably want to keep this driver too though, for cross-platform support.

TannerZachem commented 3 years ago

No worries, it was a tricky workaround with lots of time spent talking to ThorLabs. Thank you for making this entire library, it is amazing. Happy to help however I can!