LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Problem with multiple loops

Hi all,

I recently wrote my first VI for a soil consolidation test, which reads voltage measurements from an LVDT, keeps a moving average, and records the LVDT measurements versus time an XY graph.  Everything is contained in a while loop with a stop button and works just fine.  However,I'm having some trouble scaling this approach up for multiple LVDT measurements at once.  What I want to do is this:

I have a while loop with a relatively short time delay that reads all channels in my SCC system at once.  My DAQ Express VI is set to acquire 1 data point on demand.  Then I send the dynamic data type wire out of the loop and convert the data for each channel to a different scalar value.

Next, I have another while loop for EACH channel/consolidation test.  I'm doing this because I want each loop to have the potential cycle at a different rate, depending on the soil type I'm testing on that particular LVDT.  For example, on Test 1, I may want to acquire a point every half second, whereas for Test 2 I only want a point every 5 minutes.  I'd assumed the best way to do that would be to have ONE DAQ VI set to acquire all channels at a relatively high frequency (as I mentioned before), and then have each test go "get" the appropriate reading when it needs one.  I don't think I want to use a queue, because I may be skipping quite a few data points in between the ones I actually care about.

This is the approach I'd thought up, but the concept could be completely wrong.  To make a long story short, I want to acquire time elapsed/voltage data for 5-6 different channels at different rates.  I want each channel/test to be contained in a different loop so that I can compute individual moving averages for each one.

My problem is getting the multiple while loops to work with one another.  My 'secondary' loops for the individual channels don't seem to be cycling.  If I put a probe on the data tunnels, I get nothing passing out of the first loop containing the DAQ Express VI.  However, everything within that 'primary' loop works just fine.  If anyone has any suggestions, I'd greatly appreciate it.


0 Kudos
Message 1 of 6
(3,020 Views)
It seems you have some misconceptions about dataflow. Outputs of a while loop only contain data once that loop finishes, subsequent nodes need to wait until all ther inputs contain data. Dataflow enforces execution order.
 
Maybe you want to post a quick draft of your VI so we can suggest an alternate solution. Most likely, you need paralell, independent  loops without wires between them.
0 Kudos
Message 2 of 6
(3,013 Views)
Thanks, I'll try to post a rough draft as soon as I get the Labview computer on the LAN.  Until then, what method would you recommend for passing measurement data from one loop to the next?  Say I have the following:

"Main" Loop: Loops every 100ms and reads values for all of my LVDT channels

"Secondary" Loop A:  Loops every 1 second and gets the last read value of LVDT 1
"Secondary" Loop B:  Loops every 10 seconds and gets the last read value of LVDT 2
"Secondary" Loop C:  Loops every 100 seconds and gets the last read value of LVDT 3

The reason I have the Main/Secondary loops is because I assumed it would be more efficient to have one DAQ Express VI read everything at once rather than putting a separate instance of it in multiple loops.  Of course, I'm prepared to accept the fact that that assumption is completely wrong Smiley Happy
0 Kudos
Message 3 of 6
(3,004 Views)
I would recommend a single loop. Just put the slow stuff in case structures so it only gets updated at certain multiples on N.
0 Kudos
Message 4 of 6
(2,994 Views)

Here's what I had in mind (LabVIEW 7.0).

Message Edited by altenbach on 04-26-2006 01:25 PM

Download All
Message 5 of 6
(2,987 Views)
Thanks, I'll give that a shot and see how it works.  I also found a workaround by using queues - basically I feed the dynamic data into a queue, then flush that queue before taking the next reading from the DAQ.  It seems that this way it only keeps the last element and I don't have to worry about dequeueing elements, which could be a problem given the fact that I want my individual tests receiving/plotting data points at different rates.  Basically it keeps the most recently read set of voltage data on hand for my individual tests to go fetch when they need it (though I'm sure there's a more elegant way to do this).  Then in each of my "secondary" loops, I use preview queue element, convert the dynamic data into a single scalar for the DAQ channel I'm interested in, and perform my logging/plotting operations.  I may post it when it's done because I'm sure the efficiency of my approach could be improved.
0 Kudos
Message 6 of 6
(2,974 Views)