03-14-2011 08:50 AM
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
03-14-2011 09:02 AM
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.
03-15-2011 02:43 AM
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
03-15-2011 10:18 AM
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.