-
-
Notifications
You must be signed in to change notification settings - Fork 83
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
RedTide 650 support not working #47
Comments
With the new conda packages python-seabreeze defaults to the cseabreeze backend. In the meantime try installing python-seabreeze and pyUSB in conda: conda install -c poehlmann python-seabreeze
pip install pyusb (Note: the akode channel that we used before to install pyusb only ships it for 2.7. So we'll just install pyusb in conda via pip from pypi) To check if pyusb was installed correctly run (it should not raise an exception): import usb.core
usb.core.find() and then: import seabreeze
seabreeze.use("pyseabreeze")
import seabreeze.spectrometers as sb
devices = sb.list_devices()
print(devices) I hope it'll work. I'll check in the meantime why the 650 isn't working with cseabreeze. |
I will try this when I get back in the lab, but one quick question, is there a way to properly check if the cseabreeze interface works (for example, if devices = sb.list_devices() returns no devices) and then switch the interface to pyusb? I'm going to try an approach, but I suspect I can't simply re-import seabreeze.spectrometers. |
Hmm. I think this might work on OSX and Linux: # There is definitely a spectrometer connected, and the code
# should first try to connect via cseabreeze, and switch to
# pyseabreeze if it can't find the spectrometer
from seabreeze.backends import _use_cseabreeze
_lib = _use_cseabreeze()
if _lib is not None and _lib.device_list_devices():
pass # cseabreeze import works and it finds a spectrometer
else:
# cseabreeze import failed or it didn't find a spectrometer
import seabreeze
seabreeze.use("pyseabreeze")
# continue normally
import seabreeze.spectrometers as sb
... |
So as additional info: I think reimporting but |
Note to self: Maybe this should be default behavior... |
Using your 'auto selection' code I was able to see the USB650, but I am getting errors when attempting to take a spectrum, even turning off dark and non-linearity corrections. The errors don't occur during every exposure, but happen about 80% of the time. Looks to be ultimately a USB overflow problem (based on reviewing error messages). Juan
|
Does this also occur when you don't use the "auto-select" code? So just: import seabreeze
seabreeze.use("pyseabreeze")
import seabreeze.spectrometers as sb And possible ways to proceed are:
Anyways, it would be good to have a datasheet with the full usb command set and compare it in detail with the one for the USB2000 (Because I think it's almost identical to that one) |
Not using the auto-select does in fact stabilize things. I can now perform exposures on the USB650 without issue. I am comfortable with C (its been a few years, but it dominated my grad school days), less so with C++. Feel free to provide me with guidance on how to fix this if by fix you mean allowing auto-select to function. I think I should file an issue with seabreeze as well, but do you have a specific error to report other than USB 650 support is not functional? |
To just fix the auto-select, I think we don't need to touch any of the C/C++ stuff... I think my previous approach doesn't work because the cseabreeze backend is not unloaded correctly. Maybe try: import usb.core
import seabreeze
if usb.core.find(idVendor=0x2457, idProduct=0x1014):
# If we find a connected USB650
seabreeze.use("pyseabreeze")
else:
seabreeze.use("cseabreeze")
import seabreeze.spectrometers as sb But: Why don't you just use the pyseabreeze backend for all spectrometers? And regarding the upstream ticket: it's just that USB650 support is missing. |
I didn't want to try the new backend because I am in the middle of an experiment and my mentality is to keep everything the same. That said, I can't imagine there should be a difference, so that may be the easier solution here. I'll try your solution to the auto-switching shortly and if that fails I will just switch to using pyusb. |
FYI, I posted a trouble ticket for seabreeze, response was that they intentionally left out RedTide USB650 support. See https://sourceforge.net/p/seabreeze/tickets/32/ |
On a positive note, your "switching" code above does seem to do the trick. |
I take it back, I am still getting USB overflow errors with the RedTide USB650, even when switching to using pyUSB exclusively. :/ And I have also discovered when I do manage to access the RedTide USB650, I often get a uniform 2409.00 (2417.15893453) counts in every channel with non-linearity corrections turned off (on). Clearly not real data. This only appears to occur with the RedTide USB650, my Ocean Optics USB2000 appears to be behaving OK, even when accessed via pyUSB. Something strange is going on here. Could there be some issue with how python-seabreeze communicates with the RedTide USB650? I was initially getting "real" looking data, but now its either overflowing or clearly bogus data. |
Regarding the sourceforge ticket: Well I guess that explains why I can't find a USB-communication datasheet for the USB650... Weird though that they intentionally leave out support for it... Regarding the overflow issue: Without the hardware or a datasheet it's hard for me to help with this. Is your measuring protocol doing some asynchronous stuff? Or something else that might cause the sporadic failures? |
I'm not doing anything asynchronous. Just attaching the spectrometer, taking a reading, and detaching the spectrometer. And as I said, it works with the Ocean Optics USB2000 even when accessing via pyusb. I am doing this in iPython, so maybe iPython doesn't close something it should. |
And one last idea: import seabreeze
seabreeze.use("pyseabreeze")
# Monkey patch the USB650 to use the USB4000 protocol
from seabreeze.pyseabreeze.interfaces import USBInterfaces, USB4000
USBInterfaces[0x1014] = USB4000
import seabreeze.spectrometers as sb
... No idea if this will work. But I guess it's worth one last try... |
Pretty sure the USB650 is a rebranded USB2000, it has a sticker on the bottom indicating it is a USB2000. |
Okay... Then I am out of ideas. Sorry. |
The USB650 seems to return the spectrum in a different format. So for each 64 block one has to do: (j contains the offset in the raw data, i the spectrum point)
And timeconst is actually 1000 less than for an USB2000+ ff and returns for maximum value 4095. |
Hi @prissi The current device implementation in the python-seabreeze/src/seabreeze/pyseabreeze/devices.py Lines 652 to 678 in ff806a8
which uses the millisecond timescale the smaller max value and the following raw spectrum formatting: python-seabreeze/src/seabreeze/pyseabreeze/features/spectrometer.py Lines 164 to 175 in ff806a8
does this agree with your comment? Cheers, P.S.: Although I still am not entirely certain that the USB650 works with python-seabreeze, I believe that some USB650 require a firmware update to be supported. See: https://github.com/ap--/python-seabreeze/issues/48 |
My knowledge of python and numpy is not good enough to answer that. But it seems similar. Seabreeze does not install on this machine, neither from Mingw python (where already numpy does not work) or it installs but does not work from anaconda. But I am not python specialist. The USB650 is a recent model. OceanView does not report a firmware version, so I am not sure how to check for the firmware version. It does not work with the command for USB2000+, which I have. Since the target computer is an Win7 machine without network access (due to old custom hardware ...), I am using the USB650 with the libusb from C directly and it works like an existing USB2000+, but with the different byte order as above. I arrived (at the old repo), because this is one of the very few places that had any info on the USB650, and the documentation here was enough to get it working. |
spectrometer and system information
current problem
In a nutshell, the same code I have that works with an Ocean Optics USB2000 when applied to a RedTide 650 (which appears to be listed on the list of compatible devices) doesn't work due to a failure to connect to the spectrometer. The specific steps are below:
steps to reproduce
Specifically, although Apple's System Profiler clearly shows the RedTide connected (and I can access it via Vernier's Logger Pro software), when I do
I get a blank list.
The text was updated successfully, but these errors were encountered: