LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Time based peak matching VI

Solved!
Go to solution

(Using LabVIEW 2012)

 

Hi all,

 

I'm still fairly new to LV (and you will probably see evidence shortly), but I've been working on developing a VI for data acquisition of a gaussian shaped multiple channel PMT signal (voltage), where two separate signals appear with different amplitudes separated by a roughly constant time delay (with some tolerance), henceforth known as Spot 1 and Spot 2. I'd like to match these peaks given a time window. 

 

I've attached my attempt so far, but the way it functions, the while loop operates everytime there is new data from either Spot 1 or Spot 2. I only want it to operate when there is new Spot 2 data (as we are searching for a pair based on each spot 2. The queues contain peak data (time and amplitude) from a producer/consumer set of loops, and I'm just taking the data from there. I realize this could be done after the fact from a text file, but I would like a semi-realtime update as the experiment progresses.

 

So, I think the problem is I need to be able to only operate on new Spot 2 data and the continued influx of Spot 1 data is causing it to run and mismatch, but it could very well be something different, or maybe one of you has a much better idea how I might accomplish my goal.

 

Thanks for taking the time to help me out!

0 Kudos
Message 1 of 9
(3,689 Views)

Hi brfi7385,

 

Can you explain a little further how Spot 1 and Spot 2 are related? My understanding is that in one time window, there will be one data value for Spot 2 and several for Spot 1 and you are looking for the value of Spot one that matches the specified time delay. Is that correct?

Catherine B.
Applications Engineer
National Instruments
0 Kudos
Message 2 of 9
(3,635 Views)

Hi Catherine,

 

You're correct. Sorry if I'm not being explicit enough. If it means anything to you, the data flowing in is similar to a flow cytometry measurement, where every data point is measured twice, separated by a fixed delay (physically this is in time and space). So, while my intention is to match one peak after it has come in through Spot 2, data is still coming through Spot 1, continuosly added to its queue (the DAQ board is collecting Spot 1 data on one channel and Spot 2 data on a different channel).

This shoddy MSPaint image may or may not help.

 delay.JPG

 

So the goal is to match every Spot 2 with a Spot 1.

 

Thanks for any help you can give!

 

-Brett

 

 

0 Kudos
Message 3 of 9
(3,601 Views)

Hi Brett,

 

It looks like the basic logic of the VI is fairly sound. I think the unexpected behavior is coming from how the data is being queued and dequeued. From your descriptions, it seems like the new Spot 1 data should be paired with new Spot 2 data (though there is a time offset). It may make sense to reevaluate how you are queuing the data and put both the Spot 1 data and Spot 2 data in one cluster. This would require adding additional logic in the VI that is enqueuing the data.  

Catherine B.
Applications Engineer
National Instruments
0 Kudos
Message 4 of 9
(3,582 Views)

Alright. I see your point, but I can't quite figure out how else to go about the data communication between loops for my VI. I've attached the full VI. It's not the tidiest (a few too many botched Clean up diagrams), but hopefully it's of use.

 

Thank you for any help you can give!

 

 

0 Kudos
Message 5 of 9
(3,515 Views)

Hi Brett,

 

There is a lot going on in your VI, which makes it difficult to trace the logic flow. How many points are in the arrays in the clusters for Spot 1 versus Spot 2?

 

Also, have you tried running your code using highlight execution? This will help better trace the flow of the pair matching loop and should help to identify where the code is not behaving as you expect. 

Catherine B.
Applications Engineer
National Instruments
0 Kudos
Message 6 of 9
(3,494 Views)

There should be an equal number of points in either cluster, increasing over time, but in a given data set will not exceed a few thousand. I've attached another picture of what the incoming data looks like and how it should be matched.

 

There's a little bit of noise in the code, but essentially it boils down to two consumer loops (Spot 1/2 Peak Processing Loops) that take the peak data, grab some info about it (center time and amplitude, there's a lot of useless code that was to be implemented later sitting around that clogs the visual) and spit those to another loop that can take those times/amplitudes and match them up (Pairmatching loop)

 

The problem I believe I'm having is I'm trying to use two additional queues to extract the arrays containing the amplitudes and times out of those loops, so I can use them elsewhere together (the pairmatching loop). That pairmatching loop runs when there is new data in the Spot 1 queue OR the Spot 2 queue, but I only want the loop to run when there is new Spot 2 data. So, I guess my question is: Is there something I can do to make Pairmatching While loop execute upon new data from one queue but not the other? Or is there another way to grab the data from the two Peak Processing loops and use it without queues?

 

Hopefully that makes sense. Thank you!

 

InputData.png

0 Kudos
Message 7 of 9
(3,486 Views)
Solution
Accepted by topic author brfi7385

Queues are the best option here for passing the data as it ensures that you are not missing data points. The best way I can think of to make the loop wait on data from Spot 2 would be to wire the error output of the Dequeue Element VI for Spot 2 to the error input of the Dequeue Element VI for Spot 1 (in the pairmatching loop). Each Dequeue Element VI will wait until there is an element available in the queue. Wiring the error wires will enforce that there has to be a Spot 2 element available before an element is dequeued from the Spot 1 queue. I don’t know that this will really resolve the issue though. Each iteration of the while loop should dequeue new Spot 2 data and new Spot 1 data. Is this the behavior you are seeing? What behavior are you looking for?

 

Also, to clarify, the arrays of data in the clusters in the Spot 1 and Spot 2 queues grow as the program runs and contain all of the Spot 1 and Spot 2 data points that have been found while the program has been running? 

Catherine B.
Applications Engineer
National Instruments
Message 8 of 9
(3,451 Views)

For the most part, re-writing the entire program and taking advantage of more efficient queue structure solved this issue. Thanks for the help!

0 Kudos
Message 9 of 9
(3,376 Views)