Why does setCalibra​tionCoeffi​cientsInto​EEProm not write the correct values to the spectrometer's EEPROM when using the OceanOptics driver and Instrument Control Toolbox?

2 views (last 30 days)
I write the wavelength calibration coefficients to spectrometer's EEPROM using setCalibrationCoefficientsIntoEEProm as in the following script:
% define wavelength calibration coefficients values
calibCoeffWl = [178.70158, 0.379557, -1.442072e-05, -1.855855e-09];
% identify spectrometer index and channel index
spIndex = 0;
chIndex = 0;
% connect to spectrometer
sp = icdevice('OceanOptics_OmniDriver.mdd');
connect(sp);
% initialize coefficients data
coeff = invoke(sp.Coefficients, 'Coefficients');
% update coefficients data with wavelength calibration coefficients
invoke(coeff, 'setWlCoefficients', calibCoeffWl)
% write coefficients data to EEPROM (apply wavelength coefficients only)
invoke(sp, 'insertKey', 'Mat429sky');
invoke(sp, 'setCalibrationCoefficientsIntoEEProm', spIndex, chIndex, 1, 0, 0);
invoke(sp, 'removeKey');
% disconnect
disconnect(sp);
Next time I connect to the spectrometer I receive the following warning/error and the coefficients read back from the spectrometer's EEPROM have incorrect values.
% identify spectrometer index and channel index
spIndex = 0;
chIndex = 0;
% connect to spectrometer
sp = icdevice('OceanOptics_OmniDriver.mdd');
connect(sp);
% read coefficients data from EEPROM
coeff = invoke(sp, 'getCalibrationCoefficientsFromEEProm', spIndex, chIndex);
% obtain array with wavelength calibration coefficients values
calibCoeffWl = invoke(coeff, 'getWlCoefficients');
% display wavelength calibration coefficients values
sprintf('%.7e\n', calibCoeffWl)
% disconnect
disconnect(sp);
Mar 28, 2014 8:25:33 PM com.oceanoptics.omnidriver.spectrometer.SpectrometerChannel getCoefficientsFromSpectrometer
WARNUNG: ERROR: For input string: "1,787016E002"
Mar 28, 2014 8:25:33 PM com.oceanoptics.omnidriver.spectrometer.SpectrometerChannel getCoefficientsFromSpectrometer
WARNUNG: ERROR: cannot read wavelength coefficients from spectrometer. Setting to pixel indices.
Mar 28, 2014 8:25:33 PM com.oceanoptics.omnidriver.spectrometer.SpectrometerChannel getCoefficientsFromSpectrometer
WARNUNG: Intercept was [1,787016E002]
...
ans =
0.0000000e+00
1.0000000e+00
0.0000000e+00
0.0000000e+00

Accepted Answer

MathWorks Support Team
MathWorks Support Team on 29 Mar 2014
This is caused by an OceanOptics Java driver limitation in the way number formatting depends on the system locale. The problem arises when the computer's system locale is using a decimal symbol separator different that the one used in United States locale (for example comma in Germany locale instead of dot: 3,14 vs 3.14)
A workaround for this OceanOptics driver limitation is to set the default Java Locale in MATLAB to US, at the beginning at the MATLAB script:
java.util.Locale.setDefault(java.util.Locale.US)
A working example script would then be:
%workaround for OceanOptics driver system locale limitation (set to US)
java.util.Locale.setDefault(java.util.Locale.US)
% define wavelength calibration coefficients values
calibCoeffWl = [178.70158, 0.379557, -1.442072e-05, -1.855855e-09];
% identify spectrometer index and channel index
spIndex = 0;
chIndex = 0;
% connect to spectrometer
sp = icdevice('OceanOptics_OmniDriver.mdd');
connect(sp);
% initialize coefficients data
coeff = invoke(sp.Coefficients, 'Coefficients');
% update coefficients data with wavelength calibration coefficients
invoke(coeff, 'setWlCoefficients', calibCoeffWl)
% write coefficients data to EEPROM (apply wavelength coefficients only)
invoke(sp, 'insertKey', 'Mat429sky');
invoke(sp, 'setCalibrationCoefficientsIntoEEProm', spIndex, chIndex, 1, 0, 0);
invoke(sp, 'removeKey');
% disconnect
disconnect(sp);

More Answers (0)

Tags

No tags entered yet.

Products


Release

R2012b

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!