LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Collect data into an array and average it.

Hello!

 

A bit of background:
There are two spectrometers (visible and infrared) and two lasers. I made the following logic of their work - the laser turns on, irradiates the sample (phosphor), the laser is turned off, and the spectrometer is turned on immediately to collect the luminescence "tail" (without the laser peak in the spectrum). With this operation, the signal from the phosphor is weak. The signal to noise ratio is not very good.
To reduce noise, you need to average the data. In theory, this should help. In this case, it is necessary to carry out many measurements (10, 20, 50, 100, etc.), sum them up and divide by the number of measurements.

 

Problems:
1) My idea of ​​averaging doesn't work;
2) The time of one measurement is about 10 ms - will the labview be able to record, summarize and divide the data?

 

I would be grateful for any help. Thank you very much.

Безымянный.png

0 Kudos
Message 1 of 19
(3,615 Views)

There is too little of the program in the snippet to see what the problem is. If You can, please attach the complete VI.

 


@Fizikaman wrote:

 

Problems:
1) My idea of ​​averaging doesn't work;
2) The time of one measurement is about 10 ms - will the labview be able to record, summarize and divide the data?

 

  1. I guess that Your outer while loop runs once for every spectrum. Right now, the for loop on the right initializes a shift register and adds one specific output spectrum N times. If my guess is correct, You need to move this for loop outside the outer while loop and feed it the autoindexed array of the measurements. I will add a sketch of this below
  2. That depends on information You have not given. It is probably fastest to just try it with sample data. You can search the forum for "timing a function" or "execution profiling" on how to do this, e.g. here: https://forums.ni.com/t5/LabVIEW/For-loop-is-taking-too-muc-time-to-execute/m-p/4085199/highlight/tr...

LLindenbauer_0-1604571416201.png

 

0 Kudos
Message 2 of 19
(3,588 Views)

I think I can give you all the vi. There is no secrecy here. But I removed this piece of code so that it doesn't interfere with the work.
The whole program is big enough - do you really want to understand all this?

0 Kudos
Message 3 of 19
(3,578 Views)

I cannot open Your VI, but maybe someone else can take a look at it. Have You tried my suggestion above?

0 Kudos
Message 5 of 19
(3,552 Views)

This vi is from version 18. What version do you have?

No, I haven't tried it yet.

0 Kudos
Message 6 of 19
(3,550 Views)

Hey.
I seem to have managed to do it - everything is connected and everything is summed up and divided by the number of cycles.

 

I decided to check and turned off the Y division (according to the idea, the signal should just be the sum of 10 cycles) I noticed that Y is the last array multiplied by 10, and not the sum of 10 cycles (you can see it on probe # 37 and 38).


It should be like this - the sum of the arrays from all the cycles is divided by the number of cycles. And it turns out like this - the array from the last cycle is multiplied by the number of cycles and divided by it.


I can't understand why this is happening.

0 Kudos
Message 7 of 19
(3,495 Views)

Hello!

 

I have LabVIEW 16, but I do not know if I will have the time to troubleshoot Your code. Maybe this code can give You some hints?

LLindenbauer_0-1604918886617.png

Also, give this article a short try: https://knowledge.ni.com/KnowledgeArticleDetails?id=kA00Z0000019M3dSAE&l=de-AT

 

From the GUI screenshot, it seems that You want to continuously take a rolling average. If this is true, then You need to tap into the shift register where You accumulate the spectra. I did a quick forum and internet search for these terms. Try "Rolling average over 2d Array". I do not know Your specification, but there should be a lot of material to help You.

 

Also from the screenshot, it seems that there is a lot of problematic code. I seems that You are not only taking the average over the intensity values, but also over the wavenumbers. This is probably not at all what You want. I would recommend starting over: Read a few spectra from the spectrometer and save them into an array constant, as I did in the example above. Evaluate these data by hand, for example in a spreadsheet program. Then try to replicate that in LabVIEW and see if the result matches. This may seem like a tedious way to do it, but when it works You will be certain that it is correct.

 

Best regards,

0 Kudos
Message 8 of 19
(3,491 Views)

I made the averaging mode - take 10 measurements (for example), add all the arrays and divide them by the number of measurements (see the attached picture). Everything seems to work, but I'm not entirely sure.

 

To test this, I need to collect all 10 arrays and save them. And then fold and divide them myrself.

 

The problem is that I cannot save all the arrays, only the last one is written. Maybe someone did something similar?

0 Kudos
Message 9 of 19
(3,502 Views)

Get rid of the inner loops and anchor the shift registers on the outer loop. Learn about dataflow.

 

If you want more specific help, attach your VI. We cannot debug pictures.

0 Kudos
Message 10 of 19
(3,488 Views)