Counter/Timer

cancel
Showing results for 
Search instead for 
Did you mean: 

While loops within while loops?

I have created an app that has several subVIs calling data from different channels of our Daytronic System 10.

Everything is working well, but now I'd like to be able to control (slow) the update rate of 4 of the channels, while letting the rest update in "real-time".

The entire app is in one while loop.  I know I can set a timer within that loop, but it then slows down every channel's update rate.

Is it possible to place the particular subVIs within another while loop that is within the main while loop?  I can't find anything clear on this topic in the help or the Labview book I bought.

Thanks in advance!

Todd Munsell
Test Cell Manager
Wood Group Pratt & Whitney Industrial Turbine Services, LLC
Plattsburgh, NY
0 Kudos
Message 1 of 8
(4,868 Views)
If you want something to run independently, then you need to place the second while loop outside the first. Putting the second while loop inside the first will cause the exact same problem you had when you had a subVI with a while loop inside the main. I have no idea why the timer would cause a slowdown since you have never posted your code. Timers do not necessarily slow anything down but the way you implement them may.
0 Kudos
Message 2 of 8
(4,856 Views)
Actually, I'm using a "Wait until next" control within the main while loop with a knob to control the input variable from 0 to 3000 ms.  It works fine in controlling the entire app's update rate, but as I mentioned, I only want to control a few channels' update rate.  If I place the while loop outside the main loop, will it still run at the same time the main app is running (continously)?  I was also reading about the Time Delay Express VI.  Would this work if I put it in series with the channel I want to control?  I may try this tonight and see what happens.  It sounds like it may work for me.....

Thanks Dennis


Message Edited by tmunsell on 02-12-2008 03:23 PM
Todd Munsell
Test Cell Manager
Wood Group Pratt & Whitney Industrial Turbine Services, LLC
Plattsburgh, NY
0 Kudos
Message 3 of 8
(4,841 Views)

The Time Delay works just like the Wait (ms) function. It's not that much different than wait until next multiple.

You can create as many separate while loops as you want. Each will be independent from each other as long as there is no data dependcy between them. In other words, you can have one loop that iterates every second (or whatever) and a separate loop that iterates every minute (or whatever).

I don't remember from your earlier posts what you are using to acquire the data. If it's analog input from a data acquisition card, you have to acquire data from multiple channels at the same rate (assuming a DAQ board with muxed inputs). If its data from digital lines, then I believe you can.

0 Kudos
Message 4 of 8
(4,827 Views)
OK, I understand that I can run seperate while loops, but how would I get them to run at the same time as the main app without having to run them as seperate apps?  I tried placing a while loop outside the main loop, and placed the System 10 drivers for reading each channel in that loop.  When I try to connect them to the main app, only the VIs in the external while loop will run.  I can't find anything in the help or the book I have about this, at least not anything that I can understand clearly.

Thanks.
Todd Munsell
Test Cell Manager
Wood Group Pratt & Whitney Industrial Turbine Services, LLC
Plattsburgh, NY
0 Kudos
Message 5 of 8
(4,819 Views)
I just tried something else.  I placed all 4 channels, including indicators, inside the second while loop.  Now the main VI runs, but the second while loop does not.  I tried connecting the error out terminal from one of the VIs in the main loop to the error in terminal on one of the VIs in the second while loop, but when running it using highlight execution, the signal stops at the wall of the main while loop.  I've tried using tunnels and shift registers to pass the signal, but it still won't exit the main loop.  I need to be able to run both loops at the same time.  If I can, then I can set the update rate inside the second loop and all will work as needed.  Any help would be appreciated.  We have an engine coming up for test on Saturday, so I'd like to get this working as soon as possible.  Thanks again!

I've attached a pdf file of the block diagram for your review.  The four channels I'm trying to set up on a different update rate are in the small while loop on the right.  They will all be displayed on the main front panel, and must start when the main app starts.



Message Edited by tmunsell on 02-13-2008 06:28 PM
Todd Munsell
Test Cell Manager
Wood Group Pratt & Whitney Industrial Turbine Services, LLC
Plattsburgh, NY
0 Kudos
Message 6 of 8
(4,817 Views)
I've searched through the help and book and can't find anything that would simplify this task.  It's hard to believe that there isn't a VI that can be placed inline with a channel output (with terminals for input, output, and ms time delay) to delay the time it takes to display the data on the front panel indicator.....  Had anyone ever seen a VI like this? Smiley Indifferent
Todd Munsell
Test Cell Manager
Wood Group Pratt & Whitney Industrial Turbine Services, LLC
Plattsburgh, NY
0 Kudos
Message 7 of 8
(4,813 Views)
Dennis,

I've created another while loop outside the main one, and wired the inputs and outputs, but for some reason, the data gets to the output tunnel in the main loop and stops there.  I've tried using shift registers too with the same result.  What am I missing?  Thanks!


Message Edited by tmunsell on 02-14-2008 12:38 PM
Todd Munsell
Test Cell Manager
Wood Group Pratt & Whitney Industrial Turbine Services, LLC
Plattsburgh, NY
0 Kudos
Message 8 of 8
(4,798 Views)