How do I record from two spectrometers simultaneously
Show older comments
I am running two OceanOptics Spectrometers with the instrument control toolbox, and need them to record at the same time
With the function below, a given spectrometer (object) will run for a set number of iterations, and plots the spectrum. The sampling time is preset outside of the function. A slight variation is when I save the spectrum, but I don't think needs including here.
The invoke('getSpectrum') begins it recording, and then creates an array with one value per detector pixel. The issue is that if I want to run two objects within the same loop, it records the first, then records the second etc.
I've tried looking at the parallel processing toolbox but the only information I found was on running two functions that return data, which is not the case for this particular function
function spectrometerLive(iterations, spectrometer)
spectrometerIndex = 0;
channelIndex = 0;
wavelengths = invoke(spectrometer, 'getWavelengths', spectrometerIndex, channelIndex);
figure();
for i = 1:iterations
spectralData = invoke(spectrometer, 'getSpectrum', 0);
plot(wavelengths,spectralData)
title('Optical Spectrum');
ylabel('Intensity (counts)');
xlabel('\lambda (nm)');
grid on
axis tight
drawnow
end
Accepted Answer
More Answers (1)
Dhruv
on 25 Apr 2023
1 vote
To record from two OceanOptics spectrometers simultaneously, try following the below steps:
- Create two instances of the instrument control toolbox for each spectrometer, and assign them to separate variables (e.g., spectrometer1 and spectrometer2).
- Retrieve the wavelengths of both spectrometers using the getWavelengths function.
- Create a figure to plot the spectra from both spectrometers.
- Use a loop to acquire data from both spectrometers simultaneously. Inside the loop, call the getSpectrum function on both spectrometers and store the returned data in separate variables (e.g., spectralData1 and spectralData2).
- Plot both spectra in the same figure using different line colors or styles to distinguish between them.
I hope that the steps outlined above will help you with the solution you are looking for.
Categories
Find more on MATLAB Support Packages in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!