LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Stopping Parallel While Loops With Single Boolean

Solved!
Go to solution

Hi there, I'm having some trouble stopping two parallel While loops in Labview 2020. One loops receives and displays real-time data from a spectrometer while the second contains an Event structure that handles specific button presses from the user. After some searching I've found that I can use Read and Write tags to pass the stop signal from one loop to the other. This does seem to occur but even though the loops do stop, the vi does not stop executing and I can't figure out why.

 

In my mind once both loops are stopped the program should exit the flat sequence and the last two vi's in the bottom right should end the acquisition from the spectrometer. I could really use a hand with this, I just know it's going to be simple that'll show how little experience I have with Labview.

0 Kudos
Message 1 of 8
(2,423 Views)

Are you absolutely sure both loops are stopping?  There is a good chance your Event Structure is keeping that loop from iterating and therefore reading the stop value.  You don't really need the channel wire here.  Just have the Event Structure handle the Stop->Value Change event and stop the loop when that case runs.


GCentral
There are only two ways to tell somebody thanks: Kudos and Marked Solutions
Unofficial Forum Rules and Guidelines
"Not that we are sufficient in ourselves to claim anything as coming from us, but our sufficiency is from God" - 2 Corinthians 3:5
Message 2 of 8
(2,386 Views)
Solution
Accepted by Ackalap

Here's what Tim meant (approximately):

 

altenbach_1-1595624444647.png

 

Still, you have some serious architectural problems in general (e.g. why have switch booelans if the value does not matter?. your left while loop is a CPU burner when not doing anything useful. With proper dataflow, your sequence structure is not needed. Replace all value property nodes with local variables. You don't really need the right loop and event structure to pingpong data back and forth between loops using local variables.  Just have a case structure in the left loop that depends on the booleans and calculates all graphs accordingly or writes empty data to erase. No locals needed at all!. What is the loop rate on the left? etc.)

Message 3 of 8
(2,354 Views)

Hi, thank you to both yourself and crossrulz for the help(not sure why you called him Tim but anyway(unless you are a fan of the Hello Internet podcast in which case I applaud you for being a connoisseur of fine youtube entertainment)). You make some very good points and I agree with many of them. I'll admit the whole thing is quite rough and without polish, I picked switch booleans simply because they happen to be the first ones I grabbed.The reason I had behind using two loops was mainly to keep the Live Acquisition and Final Spectrum graphs updating in real time while simultaneously having access to user input. The spectrometer I'm using is very small and portable so I wanted to be able to see changes in the detected signal as they occur. At the time it seemed like the easiest option.

 

I know what you mean about the the Event structure loop being somewhat unnecessary, I have in fact been making a different version using Case structures and a single While loop just like you described. I did however want to make the Event version work because I was under the impression that it was less resource demanding than having a large quantity of Case structures in a single loop? I could be entirely mistaken, it's just something I was told by my tutor when I was initially learning to use Labview.

 

There is one thing I do not completely understand and that is how I might do away with the Sequence structure? I know from the spectrometer manufacturer that it is essential for the final two vi's to execute as the very last ones and was suggested the Sequence as a way to do this. Would wiring it across/through the two While loops have a similar effect? (I'm away from the setup at the moment and can't test this myself which is why I'm asking)

0 Kudos
Message 4 of 8
(2,338 Views)

I'm guessing that you are relatively inexperienced in using LabVIEW.  I didn't see a single appearance of the Error Line in the code sample you posted (there were many functions represented by boxes with a Question Mark inside, as they were functions that don't ship with LabVIEW, but they didn't appear to have Error In and Error Out at the lower corners, either).  Do you understand the Principle of Data Flow, which governs execution of LabVIEW functions and VIs?

 

It's pretty difficult to figure out which wires are Inputs and which are Outputs (note the Integer wire that appears to be an Input to Wrapper_openAllOpenSphectrometers and Wrapper_getWavelengths and to the first While Loop and into the Frame Sequence.  I call them "inputs" because they are shown as attached to the left edge of the (unseen) VI, where Inputs conventionally go.  So where is the input?

 

So the only "sequencing" that I see here is that you want Wrapper_CloseAllSpectometers to run when the (first) While Loop exits.  Simple, simply run the Blue Wire through the While Loop.  The Principle of Data Flow will hold off the Close function until the While Loop exits.  End of story, no need for Sequence.

 

Bob Schor

Message 5 of 8
(2,316 Views)

@Ackalap wrote:

Hi, thank you to both yourself and crossrulz for the help(not sure why you called him Tim but anyway(unless you are a fan of the Hello Internet podcast in which case I applaud you for being a connoisseur of fine youtube entertainment)).


I don't know what that podcast you refer to is or if it has anything to do with Crossrulz/Tim.  Altenbach said Tim because he know that is Crossrulz's real-life name.  But that would be confusing to anyone who wouldn't have known that.

0 Kudos
Message 6 of 8
(2,300 Views)

@RavensFan wrote:

@Ackalap wrote:

Hi, thank you to both yourself and crossrulz for the help(not sure why you called him Tim but anyway(unless you are a fan of the Hello Internet podcast in which case I applaud you for being a connoisseur of fine youtube entertainment)).


I don't know what that podcast you refer to is or if it has anything to do with Crossrulz/Tim.  Altenbach said Tim because he know that is Crossrulz's real-life name.  But that would be confusing to anyone who wouldn't have known that.


It's not like I hide my identities...https://forums.ni.com/t5/LabVIEW-Champions-Directory/LabVIEW-Champion-Tim-Robinson/ta-p/3492738 


GCentral
There are only two ways to tell somebody thanks: Kudos and Marked Solutions
Unofficial Forum Rules and Guidelines
"Not that we are sufficient in ourselves to claim anything as coming from us, but our sufficiency is from God" - 2 Corinthians 3:5
Message 7 of 8
(2,236 Views)

RavensFan is quite correct, I didn't know the background context and so I made a reference/joke related to a (perhaps slightly obscure) podcast the fans of which are colloquially known as Tims. But back to the topic of Labview, thanks to you all involved for the help and advice, altenbach's post did indeed solve my problem and so I'll mark it as the solution. Thanks again, its been a pleasure.

0 Kudos
Message 8 of 8
(2,228 Views)