LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Running subvi's once per hour

Hello,
I have two subvi's that I want to run. The first one (let's call it suba) is to run once per hour, and will update a front panel indicator "count". The second one (subb) runs once per second, and also updates the same front panel indicator. However, I want subb to stop executing when suba runs once per hour. suba may take, for example, 20 minutes to execute. I then want subb to execute for the remaining time (40 min in this case, once per second) and then start over with suba again.
And, both of the subvi's are to update the same front panel indicator.
I have been trying everything I can think of to do this...how can I do this?
Thanks in advance!
(I am running Labview 6.1 full system)
0 Kudos
Message 1 of 4
(4,165 Views)
Your top-level VI should have a while loop. Inside the while loop you will want a case structure. Inside the case structure you can have two cases, one for the once-per-second subVI and one for the once-per-hour subVI.

The output of each subVI should be the value of the front panel indicator you want to update. You must wire the outputs from each case to the same tunnel out of the case structure. You will notice that once you wire the first subVI's output through the right hand wall of the case structure, it will require you to wire something out of the other case(s). I know you are using 6.1 so you do not HAVE to wire something from the other cases, but here it is a good idea. Wire the other subVIs output to the tunnel created by the first subVI. Con
nect the tunnel to the front panel indictor.

Construct logic to drive your case structure. Place a 1000 msec "Wait until Next Interval" function in the while loop. That will make sure the while loop runs once per second. Divide the index of the while loop by 3600 (seconds per hour). Use the special division function with the remainder. When the remainder is zero, it is time to run the once-per-hour subVI.

Obviously the solution presented here may be too simplified. There are lots of ways to solve your problem. A more advanced method would be to use a state machine that calls the case for the correct function based in internal timing calculations.

If you are having trouble with these fundamental aspects of LabVIEW, I strongly recommend finding an Alliance Member company to help you. Many of them offer start-up assistance. I know our company has helped dozens of folks in your situation. Talk to your NI sales rep. He or she can recommend a few good Alliance Members to
help jump-start your application. I promise that you will learn quite a bit about LabVIEW from one of them.

Good luck!

Daniel L. Press
PrimeTest Corp.
www.primetest.com
0 Kudos
Message 2 of 4
(4,165 Views)
Hi Terry,

This is a slightly different approach that may help.

Create a new sub-VI, call it "1@aTime.VI".
Drop a case on the diagram.
Put suba in one state and subb in the other.
Make "1@aTime.VI" non-reentrant.
Use a boolean to control which state executes.
Put "1@aTime.VI" in the code where suba and subb where.
Done!
Now LV will make sure only suba or subb runs at any time.

Ben
Retired Senior Automation Systems Architect with Data Science Automation LabVIEW Champion Knight of NI and Prepper LinkedIn Profile YouTube Channel
0 Kudos
Message 3 of 4
(4,165 Views)

Excelent code!!! 

0 Kudos
Message 4 of 4
(2,936 Views)