LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Ocean Optics USB4000 Spectrometer

Hi Sundar,

 

In the end, I just wasn't able to find a way to run two spectrometers at different rates with the COM objects.  I went ahead and created NI-VISA drivers for the 2000, 2000+, and 4000 spectrometers.  With the new drivers, I've been able to run three different spectrometers off the same computer simultaneously, each with a different integration time.  All I had to do to make this work was to make my "Get Spectrum" subvi reentrant.  In addition, with the VISA error codes I've been able to safely unplug a spectrometer in mid-acquisiton.  I have my code set up to handle the errors this generates and then re-detect the spectrometer and continue with acquisitions as soon as it is plugged back in.  This is a bit more robust than the wrapper functions provided with the OmniDriver.

 

The author of the post I referenced above was right - creating VISA drivers is actually VERY simple.  I am a complete newbie to USB communications, and yet was still able to have it all running with a few hours of effort.  The procedure is:

 

1) Use the VISA Driver Wizard to create drivers for each spectrometer

2) Install the drivers, then plug in your spectrometers - verify you can see/interact with them in MAX

3) Build subVIs using the VISA Read and Write functions to communicate with the spectrometers

 

The format is simple - send a command (hex code) to the spectrometer, then read a string off the appropriate endpoint(s) to get the data.  You'll need the spectrometer data sheets to know the commands and the format of the returned data - it varies quite a bit by spectrometer type.  The data sheets are available on Ocean Optics website.   

 

Jason

 

 

Message 61 of 277
(5,778 Views)

Hi, Jason, I am also trying to use three spectrometers simultaneously and sufferred from the same problem as yours, i.e. no able to set different integration times. Could you please send me some example vi using VISA as the tool to communicate with the spectrometers? Many thanks!!

 

Best wishes,

 

Bin (bo237@cam.ac.uk)

0 Kudos
Message 62 of 277
(5,740 Views)

Hi Bin,

 

I really wish I could send you my VIs, but I developed the VIs while at work and I am not allowed share them here.  But I really meant it when I said it was easy.  The following document is a step by step tutorial containing almost everything you need to make your own drivers:

 

http://zone.ni.com/devzone/cda/tut/p/id/4478

 

Once you've read that, check out gharris's VIs as a working example:

 

http://forums.ni.com/ni/board/message?board.id=170&message.id=405281#M405281

 

Depending on which spectrometer you have, the exact commands you need to send to the spectrometer may be slightly different.  Here is a link to Ocean Optics's page - just download the datasheet that deals with your spectrometer.

 

http://www.oceanoptics.com/technical/engineeringdocs.asp

 

After you've read all that, try creating your own drivers.  If you are still having problems, post what you've done and I may be able to guide you in the right direction.

 

Jason

 

Message 63 of 277
(5,726 Views)

Hi Jason,

 

Thanks for providing the links. At the current stage I am trying to set up the TEC feature of the QE65000 Ocean Optics spectrometer. I followed the links you gave and can talk to the spectrometer using the USB port. Everything is fine up to this stage. I then build a VI to write strings to the spectrometer to set up, say the TEC setpoint temperature, and then using the VISA Read to read the sensor's most updated temperature (see VI attached). However it does not work.

 

A do-while loop was used to include the 3, 4 and 5 steps of the VI. I have also tried to work without it but it does not work either.

 

Thanks for your kind helps.

 

Bin

0 Kudos
Message 64 of 277
(5,707 Views)

Hi Bin,

 

A couple of thoughts - first, you may want to clean up your code a bit.  I know this probably isn't your final version, but you had wires (and I assume controls) hidden under your while loop.  I have no way of knowing what is under there or if it is a problem.

 

Second, what do you mean when you say it doesn't work?  Do you get an error code, a response that doesn't make sense, or no response at all?  I'm not familiar with your particular spectrometer, so I'll have to assume you are sending the proper codes.  But make certain you are following the correct byte order (little endian or big endian) in your words.  I often had to reverse the order of the bytes when doing VISA Reads to correctly interpret the data.

 

Jason

Message 65 of 277
(5,702 Views)

Hi Jason,

 

Sorry for the bad look of the VI, I have moved the while loop a bit so that there is no wire under it this time. The vi itself is attached so that you can have a better check.

 

The VI connects to the spectrometer and returns no error, but it is not giving any outputs which in my case is the temperature of the sensor.

 

I am most uncertain about the heximal code I should send to activate the TEC (Step 3 in the VI). Have you done similar things to your spectrometer? The data sheet for QE65000 says it should be 0x6A-0x10- followed by Data Byte being 0 (Disabled) or 1 (Enabled), see page 21 in http://www.oceanoptics.com/technical/engineering/OEM%20Data%20Sheet%20--%20QE65000.pdf).

 

I am also confused by the "Read current TEC temperature" in the data sheet, and am not sure whether there should be any Data Byte following the 0x02 Register value.

 

Thanks a lot for your time and patience.

 

Best wishes,

 

Bin

0 Kudos
Message 66 of 277
(5,693 Views)

OK, I've cleaned it up and added some features - look at my comments.  Not sure if it will fix your problems, but it might.  The only part I am unsure about is the number of bytes to read for the temperature.  Either do some more research about the communications format, or just experiment with different values until you get what you need.

 

Let me know if this helps,

Jason

0 Kudos
Message 67 of 277
(5,689 Views)

Hi Jason,

 

Thanks a lot for your help. Tried your version but still not working. I then did the following,

 

(1) Since all commands should be sent to End Point 1 out (Page 13 on the data sheet for QE65000), rather than End Point 1 in, I changed your version accordingly but no effect.

 

(2) Before the VISA read node, I add another property node and set the Bulk in Pipe to be 0x81 (Page 13 on the data sheet). No effect.

 

Very strange.

 

I am sure that the spectrometer is connected with the computer using the USB port USB0::0x2457::0x1018::NI-VISA-0::RAW, and the driver created from VISA driver wizard is correctly installed.

0 Kudos
Message 68 of 277
(5,679 Views)

Also as I found out, if the number of byte read for temperature was set to 1, an error will be returned from VISA read.

 

 

0 Kudos
Message 69 of 277
(5,674 Views)

OK - let's back up and try something easier.  Open MAX and select your spectrometer.  You should be able to see the manufacturer and model names.  If you can get this far, open the VISA test panel.  Select the "Property Node (Get) tab, and see if you can view any of the property values.  If this works, then we know we're at least talking to the spectrometer.

 

At this point, create a new VI that does nothing but initialize your spectrometer and execute the Query Information command.  This is an easy one because the command string is simple (0x05 and and index), and the response will be 18 bytes long.  Query for the 0 index and see if you can get the serial number off your spectrometer.  Make sure you are sending to/receiving from the proper endpoints.  Let me know if this works and if you get any errors.

 

Jason

0 Kudos
Message 70 of 277
(5,669 Views)