OmniDriver - Software Downloads

advertisement
Controlling Ocean Optics USB Spectrometers from MATLAB using
MacOS and OmniDriver
Installation and Configuration
OmniDriver
You can download the MacOS version of OmniDriver from the Ocean Optics
Software Downloads page:
http://www.oceanoptics.com/technical/softwaredownloads.asp
At writing, the MacOS OmniDriver .dmg can be found here:
OmniDriver-2.10-macosx-development-installer.dmg
After downloading and mounting the .dmg, simply drag the sole folder provided
("OmniDriver") to a location of your choice on your hard drive (i.e. $HOME, or
/Users/you).
Take note of where you placed OmniDriver on your computer, especially the
contained folder OOI_HOME (i.e. /Users/you/OmniDriver/OOI_HOME in the above
example). For the rest of this document, we shall refer to this directory as
$OOI_HOME, which you should replace with the actual path to
OmniDriver/OOI_HOME on your computer.
Unfortunately, the current version of OmniDriver for MacOS does not support 64-bit
Java, which MATLAB requires. Therefore, you will need to also download an
updated 64-bit version of libNatUSB.jnilib, and then copy it into $OOI_HOME
(overwriting the version you just installed). This file (encoded in a Zip archive) can
be found at our OEM download site:
http://downloads.oceanoptics.net/OEM/
At writing, the direct link for the necessary file is here:
libNatUSB.zip
MATLAB
MATLAB will need to know where to find OmniDriver's JNI interface to the MacOS
USB library (libusb). Current versions of MATLAB store that information using the
file matlabroot/toolbox/local/librarypath.txt (ref). You will need to add the full
path to $OOI_HOME to that file before launching MATLAB (there is no way to modify
the JNI library path from runtime):
$ sudo echo "/Users/you/OmniDriver/OOI_HOME" \
>> /Applications/MATLAB_R2012a.app/toolbox/local/librarypath.txt
Example
After installing OmniDriver, updating the libNatUSB.jnilib, then configuring MATLAB
to find OOI_HOME, then you should be able to launch MATLAB and type the
following short code snippet to test your system (assuming an Ocean Optics USB
spectrometer is connected to your computer):
Trial>>
Trial>>
Trial>>
Trial>>
Trial>>
Trial>>
javaaddpath('/Users/you/OmniDriver/OOI_HOME/OmniDriver.jar');
wrapper = com.oceanoptics.omnidriver.api.wrapper.Wrapper();
wrapper.openAllSpectrometers();
spectrum = wrapper.getSpectrum(0);
wavelengths = wrapper.getWavelengths(0);
plot(wavelengths, spectrum);
Further Reading
To learn more about how to control your spectrometer(s) from the OmniDriver
Wrapper class, see the "docs" directory of your OmniDriver installation, in
particular the javadoc for com.oceanoptics.omnidriver.api.wrapper.Wrapper.
For instance, to set integration time to 5sec, enable scan averaging with 3 scans, and
enable the connected light source before an acquisition, all using the first
spectrometer on the USB bus (index 0), you would call:
wrapper.setIntegrationTime(0, 5 * 1000 * 1000);
wrapper.setScansToAverage(0, 3);
wrapper.setStrobeEnable(0, 1);
Test Environment Used
Hardware: MacBook Pro i7 2.66Ghz
Operating System: MacOS 10.6.8
MATLAB Release: 2012a (7.14)
OmniDriver Version: 2.10 for MacOS X (Mar 5, 2012)
Download