LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

How to average spectra and subtract background spectrum?

Hi there,

 

I am a chemist with little to no experience with electronics/engineering and I am trying to build a low-cost LDR based spectrometer. The general setup can be described as follows:

 

-The diffraction grating "splits" the light into its different wavelengths.

-A small region of that light passes through a solution and reaches the LDR where a signal proportional to the incoming light is generated.

-The difraction grating is mounted on a potentiometer, by rotating the potentiometer the wavelength of the radiation reaching the solution can be selected, and therefore a UV-VIS spectrum of such solution can be taken.

 

(The spectrometer is driven through an Arduino UNO board interfaced with Labview)

 

I have managed to make a simple VI able to track the signal of the LDR as a function of the voltage of the potentiometer (which can be directly related with the wavelength).However I need the spectrometer to have the following additional features:

 

-To average several spectra (now when I scan back and forth, all the spectra stack on top of each other).

-To take a background spectrum (of the solvent) and to subtract it from the measured spectra.I thought that this could be roughly done by creating three XY graphs (1-takes the background spectrum, 2- takes the sample spectrum,3- makes the difference between both spectra), right?

 

The problem is that I don't know where to start from..

 

Can someone help me to modify my VI?

 

Thanks in advance!

0 Kudos
Message 1 of 10
(3,062 Views)

If you save your VI for 2016 or earlier, I will be able to view it. (Maybe save for 2012 so even more people can chime in).

 

It sounds like you are conceptually on the right track. You don't need to create XY Graphs in LabVIEW for data to exist. Data exists on the wires, even if you don't display it in an indicator.

 

In order to average multiple scans, you can make use of a loop. Keep adding the new data onto the previous data and store in a shift register. Then, when you have taken your N scans you can divide by N to get the average at each wavelength bucket.

0 Kudos
Message 2 of 10
(3,043 Views)
  • You have no spectrum, just scalars that you graph in a charts with limited history and on an xygraph that stores data in the express VI.
  • You never need to close a static reference, all you probably want is clear the charts
  • Try to avoid hidden and backwards wires, make the flow hard to follow.
  • I assume that there is a define number of voltage steps defining the x-axis.
  • What you should do is create an array of fixed size and keep it in a shift register, then replace elements with "existing+new data" at index as a function of voltage to accumulate spectra. Divide by the number of additions to get the average.
  • Repeat for the background spectrum and subtract the two.
  • It would really help if you would control the arduino voltage update in the same loop to keep things in sync. Now all you need is incrementing the array index.
0 Kudos
Message 3 of 10
(3,042 Views)

Here you have the VI in an older version!

 

Best Regards

0 Kudos
Message 4 of 10
(3,031 Views)

Hi there,

 

Alright I will try that.

 

Thanks!

By the way, why do you not consider the LDR signal vs the voltage a spectrum?

0 Kudos
Message 5 of 10
(3,028 Views)

What you were describing was a set of points for intensity vs. a set of points for voltage. In LabVIEW these would be represented by arrays. However, most of your data is represented as a scalar. Once you have these 2 arrays, you can easily make an XY graph using a single "bundle" node, no need for express VIs.

0 Kudos
Message 6 of 10
(3,021 Views)

@Chemistry4all wrote:

 

By the way, why do you not consider the LDR signal vs the voltage a spectrum?


It is a spectrum but the data is only held inside the built xy graph express VI. You diagram only contains the last values as scalar.

 

In general, you cannot average spectra unless each point is aligned to the same voltage and since your arduino and this VI are not synchronized, this is not possible. Of course you could re-interpolate the xy data to a clean voltage ramp before averaging, but why do it the hard way. Us a single loop paved at a reasonable loop rate and with each iteration update the voltage and read a new sample.

0 Kudos
Message 7 of 10
(3,018 Views)

Here is a very simple example that ramps a voltage and averages a noisy signal. Maybe it can give you some ideas.

 

 

0 Kudos
Message 8 of 10
(3,008 Views)

Hi there,

 

Yeah, you are right, I didn't realize that each scan won't have exactly the same x values for a given measurement (and especially considering that the potentiometer is moved by hand and not by a stepper/servo motor). Anyway, the goal of averaging the spectra was to reduce the noise, but i think that using a simple smoothing filter might do the job.

 

Thanks!

Best Regards

0 Kudos
Message 9 of 10
(2,982 Views)

If you have a reasonably sampled scan, you can always bring it into a regularly x-spaced form using interpolation. Do it on each scan and averaging is possible.

0 Kudos
Message 10 of 10
(2,962 Views)