LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Ocean Optics USB4000 Spectrometer

Hello NathanT

 

first of all I must excuse for not responding so long- had to complete (+invoice !!) a couple of minor projects ... there's no point writing the most ingenious software under the sun, while going bankrupt in the meantime 😉

 

Thank you for all your suggestions plus the updated application example. Unfortunately none of it really helps in my case because my update rates aren't all that high: I am acquiring approx. 10 spectra per second ... thats something the LabVIEW graph can very well cope with.

 

So I got down into the code of the driver today and fortunately the performance issue was very easy to find: there is one very inefficient for-loop inside the Read Spectra.vi. I replaced this with more sensible code ...et voilà: the loop now is on the order of 3000 times faster and the CPU consumption is down near 5%, which is what I had hoped for.

 

I attach the modified VI so everybody can enjoy the performance benefit.

 

Regards HU

 

btw.: I am seriously considering writing a similar VISA driver for the Zeiss (Germany) line of spectrometers which we also use frequently, so if anybody is interested in this, just let me know.

 

Message 121 of 286
(3,169 Views)

Hello HU,

       That is a huge improvement!  It is also implemented in a very elegant manner.  Thank you for doing that.  I will try to get the driver updated at the updated version released to IDNet by the end of next week.  We would certainly like to give you credit in the Readme, so please just let me know if "Hu" is enough or if you would like your company name also.  Whenever I update drivers, I just do it as "Nathan T."

 

       Shipping the source code really does give the end users much more control, and I am glad that you took the time to improve this one.

 

Thanks,

 

NathanT

Message 122 of 286
(3,137 Views)

Hello again NathanT,

 

Thanks for the suggestions. I've started with a new laptop that's been wiped with everything reinstalled (except for the OO software), and I still get the same issue I mentioned above. Could you link to the readme that you mention? I assumed that you were talking about the driver creation page linked to by JasonP earlier in the thread. I followed those instructions as far as I can tell. 

 

Are setting changes saved in the USB4000 firmware? I'm wondering if there is some setting that may have been changed while it was used with the OO software that is preventing it from sending/receiving the synch packet?

 

Also, could you recompile the read spectra.vi posted by hurban for LV7.1? I'm interested in seeing if his improvements would have any effect on my problem, as it's definitely occuring in the read spectra.vis that I've used.

 

Thanks!

~Dave

0 Kudos
Message 123 of 286
(3,059 Views)

One thing that I've also noticed is that when I look at the Device Manager -> NI-VISA USB Devices -> USB4000 -> Properties -> 'Driver' tab -> Driver Details...   the only Driver file it lists is C:\\Windows\System32\Drivers\NIVIUSBK.sys.  I've tried to manually Update Driver... several times to point to the .inf file that I created using the instructions on ni.com ( http://zone.ni.com/devzone/cda/tut/p/id/4478 ), but it always still shows the NIVIUSBK.sys. Is this normal?

 

Thanks,

~Dave

0 Kudos
Message 124 of 286
(3,040 Views)

Hello again,

 

Now I'm not convinced that it's a driver issue that's causing my trouble.

 

I've been playing with the read out of a single spectrum using the Read Spectra.vi (called from the Acquire Multiple Waveform.vi with # of Meas. = 1). I'm using USB 2.0, so 2k of the bytes are going through the EP6In in four packets and the rest are going through EP2In. The vi reads each packet in sequence using two FOR loops:first, four 512-byte packets, and then eleven 512-byte packets. There is also a single byte sync packet at that's read last. When the byte counts in the loops are set to 512, the first loop times out during the 3rd iteration. When I set the byte count in the first for loop to 511, that loop completes with no errors and the second FOR loop (with byte count = 512) times out during the 10th iteration. When I set the second loop's byte count to 511, both loops complete and no errors are reported until after the Total Byte check (which, of course, fails). I can change the first for loop to iterate once (N=1) while reading 2047 bytes without error, but with a timeout when set to 2048. Similarly, the second loop runs without timing out if I change it to run once with byte count = 5631 (11*512 -1), but times out when I set the byte count equal to 5632.

 

So, I gues my problem lies more with incomplete VISA reads. Any ideas why the last byte causes a timeout? I've been looking at some past posts discussing termination characters and played with the Supress End Enable property node, but those don't seem to change anything in my code.

 

Thanks for any input you might have.

~Dave 

0 Kudos
Message 125 of 286
(2,999 Views)

Hello Dave,

       The readme that I was mentioning can be found in the LabVIEW Instrument Driver (C:\Program Files\National Instruments\LabVIEW XX\instr.lib\Ocean Optics 2000 4000\Ocean Optics 2000 4000 Readme.html).  I will also attach the current version of the readme to this post for your reference.  It has specific instructions about how to switch between inf files.  Please let us know if those steps help resolve the issues that you are seeing.

 

Cheers,

 

NathanT

0 Kudos
Message 126 of 286
(2,984 Views)

Hello Dave,

       I saved the modified VI back to 8.0 and then 7.1 and have attached it to this post.

 

Cheers,

 

NathanT

0 Kudos
Message 127 of 286
(2,963 Views)

Thanks for all your help NathanT.

 

Right now I'm upgrading as far as I can (was using LV7.1 and NIVISA 3.1) to see if that helps. I think I can only go up to LV7.1.1 and NVISA 4.5 here on this Windows XP machine before I'd have to purchase an upgrade. If that doesn't work, I might download the trial of 2009 and see if that does anything.

 

 

BTW, HU: That modification to the Read Spectra.vi is very cool. Nice work.

 

Thanks,

~Dave

0 Kudos
Message 128 of 286
(2,952 Views)

Sweet, upgrading to LV 7.1.1 and NIVISA 4.5 seems to have fixed it! I went from NIVISA 3.1 to 3.3.1 to 4.5. Each time I upgraded, I deleted the drivers made with the older VISA driver wizard and made a new one with the new wizard. I don't know what changed between revisions that finally allowed my USB4000 to work. I'm just glad it finally does. I hope anybody having trouble with their spec remembers to upgrade as much as they can.

 

Thanks to everyone for their informative posts,

~Dave

0 Kudos
Message 129 of 286
(2,942 Views)

If I set the integration time to 1 ms with a USB2000+, Even using Hurban's new code, I get at max 1 spectrum every 4.xx ms.  Using the previous labview driver based on Omnidriver I get a spectrum every 2.xx ms.

 

This is very surprising since the Omnidriver driver is a dll which wraps call to a JVM which calls into a usb driver.  I expected the all labview implementation to be faster than dealing with Java layer.

 

It seems to be the VISA driver, is there some way to make it faster?

 

 

0 Kudos
Message 130 of 286
(2,931 Views)