LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

how do i stop a while loop

I'm new to labview and I'm having a problem stopping a while loop (running windows XP/2000 with the student edition of labview express 7).

I'm doing a data acquisition program where I'm constantly reading in voltage and comparing it to a set point value, when the input voltage goes above the set point, i want the while loop to stop. How do I do this? I already have an LED going on when the criteria is met, but I'm not sure how to actually stop the loop (i.e. change the iteration value from true to false-i guess). If anyone can please assist me with this I would very much appreciate it.

I've included my program too.
0 Kudos
Message 1 of 21
(4,361 Views)
Hi,

A while loop is stoped when it's loop contition happens.
The loop condition is that yelow square with that green arrow in that's connected to that not or you have there.
Now your loop is running until you have an error in your acquisition of you press the stop buton.
You have to add that some logic to connect also your complete signal.
I guess that a not and a and with the value you have now will work, but you better check it.

Hope this helps,
Paulo
0 Kudos
Message 2 of 21
(4,351 Views)
Here is a simple way to stop the loop. Just remember, unless you have this loop in a sub-vi that can be called again, or surrounded by an outer loop, once it is stopped you won't be able to run it again with out rerunning the vi.


Putnam Monroe
Putnam
Certified LabVIEW Developer

Senior Test Engineer North Shore Technology, Inc.
Currently using LV 2012-LabVIEW 2018, RT8.5


LabVIEW Champion



Message 3 of 21
(4,350 Views)
Hello Everyone-

I've just posted a message about stopping a while loop and it was answered accurately and quickly- thanks to LV_Pro and PauloM- thanks much- its nice too see that there are many helpful people out there! 🙂 Unfortunately, I have 2 more questions to ask of the forum. 😐

My application is almost completed- I just need to add an elapsed time counter that will tell me how long it took for my LED to trigger (from my set point-i.e. when from 0:00:00 until when my loop stopped).

Now I've found a perfect elapsed time counter on the NI web site contributed from Mike Hall from Ohmeda Medical- the page is here.... http://sine.ni.com/apps/we/niepd_web_display.display_epd4?p_guid=D37E2493DC333076E034080020E74861&p_node=DZ52032&p_source=external

So my first question is, it looks like I can just extend the while loop box in my 'CO detector... .vi' and paste just the code from the 'elapsed time.vi' while loop into my loop and I will be set- but do I need to change my wait until next multiple to be a 1000 too in my program? Probably, but I'm not sure hence the question- or other ideas would appreciated.

My second question is now that my application is complete (after I add the elapsed time above), I need to exactly duplicate this process for 7 other DAQ inputs (i.e. right now I'm using only 1 of 8 analog inputs on the FP-AI110). So should I make my 'CO detector.. .vi' a separate program (I remember reading something about this in one of the posts earlier).

Any help is very appreciated.

Thank you again,

Daniel
0 Kudos
Message 4 of 21
(4,339 Views)

@dschuller wrote:
So my first question is, it looks like I can just extend the while loop box in my 'CO detector... .vi' and paste just the code from the 'elapsed time.vi' while loop into my loop and I will be set- but do I need to change my wait until next multiple to be a 1000 too in my program? Probably, but I'm not sure hence the question- or other ideas would appreciated.

My second question is now that my application is complete (after I add the elapsed time above), I need to exactly duplicate this process for 7 other DAQ inputs (i.e. right now I'm using only 1 of 8 analog inputs on the FP-AI110). So should I make my 'CO detector.. .vi' a separate program (I remember reading something about this in one of the posts earlier).


The wait function determines how fast your loop runs, and this indirectly limits the resolution of your elapsed timers. They are otherwise independent.

I assume that you read all 8 channels at once, so you simply should keep track of 8 values and 8 timers. Once ALL are complete, the loop should stop.
I would just use arrays for this, no need to duplicate code for multiple channels. Attached is one simple possibility (LabVIEW 7.0). Since I don't have your hardware, I simulate some data instead. Let me know if you have questions.
Message 5 of 21
(4,331 Views)
Hi altenbach-

That's awesome!!! Your program does pretty much exactly what I want to do, but simce im a newbee im really 'lost in translation'.... partly because my program is set up to only read 1 channel coupled with the fact that i am not familiar what most of the symbols are. However, as I understand it, my theory about adding the elapsed time wont work becuase of the wait parm??

Thanks,

Dan
0 Kudos
Message 6 of 21
(4,325 Views)
Hi again altenbach-

I just talked to the guy in charge after I showed him your example (which he really liked) but he said that each channel should be on a separate plot and have their own separate output fields- so I really do need to make 8 separate charts/fields, etc. I'm modifying your program now but just want to make sure I'm on the right track- for a single channel/input, I am going to keep everything that's blue and green connected and make the orange wired stuff point to my detector number 1 output.?

Thanks,

Dan
PS- excuse my ignorance with using the nontechnical names but I've only been working with LabVIEW a few weeks now.
0 Kudos
Message 7 of 21
(4,310 Views)

@dschuller wrote:
However, as I understand it, my theory about adding the elapsed time wont work becuase of the wait parm??

No they should be independent. My primitive version does both, except it only displays the time in ms. You can easily convert it to a more fancy time display with hours, minutes, seconds, etc.

In the attached modification, it now displays the current elapsed time in a seperate indicator. You can easily change to a longer wait times (e.g. 200ms) and the timers are still correct, they just only get updated every 200ms.

Maybe I don't quite understand what you mean... 😉
0 Kudos
Message 8 of 21
(4,299 Views)
Sorry, I missed your second reply. I would still use everything as is and do all operations on arrays, then you can index out the elements for the different displays as needed. Remember, you can also set your graph to "stacked plots". I think it will keept the FP less cluttered than with 8 different charts. But that's up to you.

Anyway, once you have a new version, please post it. 🙂
0 Kudos
Message 9 of 21
(4,294 Views)
Hello altenbach-

So far I've been able to understand what your discussing, but haven't been able to successfully implement it yet- I'm receiving quite a few errors when removing the other 7 inputs from your most recent CO_Detection_Monitoring_System_ModifiedMOD3.vi (which I may add is even better than the first!!!). If you're not too busy can you delete the 8 inputs and only make 1 input for the CO_Detection_Monitoring_System_ModifiedMOD3.vi ? I just need to make it look at one channel (aka one input) rather than all 8 at a time for now then I'll work on tweaking the code for the other 7 inputs.

Thank you,

Daniel
0 Kudos
Message 10 of 21
(4,287 Views)