LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Main and subvi question

Hi All,

 

I was wondering if there is any difference between the two codes I have attached. They are simple codes, but, I would like to understand main and subvi better. I saw this type of coding in one of the examples.

 

Notice the second example has a 'while' loop but the STOP=TRUE. This means that it runs only once everytime. But, why should you specifically have a while loop with a STOP=TRUE? How is it different from the first one? Is it just good programming? THanks!

 

V

I may not be perfect, but I'm all I got!
Download All
0 Kudos
Message 1 of 4
(2,195 Views)

There is no point to the while loop in your 2nd jpeg.  There are subVI's that have a True wired to the stop terminal with a purpose.  They are called functional global variables or Action Engines Those have uninitialized shift registers that can store data between calls of the subVI.

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

Also note that there is no delay in the main while loops. This will cause a high CPU usage for no good reason.

 

Use a "Wait(ms)" or "Wait Until Next ms Multiple" function to give the CPU time for other tasks.

 

steve 

--------------------------------------------------------------------------------------------------------------------------
Help the forum when you get help. Click the "Solution?" icon on the reply that answers your
question. Give "Kudos" to replies that help.
--------------------------------------------------------------------------------------------------------------------------
0 Kudos
Message 3 of 4
(2,124 Views)

Yea, I always use delay in while loops, lest my CPU would max out. I put this example up in like a minute without giving so much thought into detail I guess.

I may not be perfect, but I'm all I got!
0 Kudos
Message 4 of 4
(2,094 Views)