05-14-2009 02:48 PM
Hello,
I would like to know what is better (when thinking about program velocity), to make a huge VI or a lot of subvis distributed in many levels.
I imagine that this relation (number of sub VIs and program efficiency) will have something to do with the way I pass values between VIs.
So my second question is what is better, to pass values using global variables, to pass control references and use a lot of property nodes, or to pass it in another way.
I tried to find info about this questions but I had little success,
I hope someone can help me!
Best regards,
Gabriel
Solved! Go to Solution.
05-14-2009 03:36 PM
Hi GPC,
it seems you're new to Labview:
Some rules:
- Best way to move data is to use wires. LabView uses dataflow...
- Style guide: block diagram should not exceed the screen size...
- globals create datacopies, property nodes create datacopies and require a thread-switch...
- when putting subvi connector terminals outside any structure LabView is able to minimze mem usage...
05-14-2009 04:07 PM
Gerd already covered most points.
Typically, you pass data to subVIs via the connector pane.
GPC wrote:I would like to know what is better (when thinking about program velocity), to make a huge VI or a lot of subvis distributed in many levels.
With todays computers, you should not worry about performance, but focus on a modular program design that is easy to debug. You should not make one gigantic flat diagram, because you'll spend days debugging it for a possible saving of a few nanoseconds in execution time. Correctly programmed, you will never even get near 100% CPU usage in normal operations, except for short bursts.
Many of my older (quite fancy!) programs were first developed on a 100MHz Pentium with 64 MB od RAM and they run just fine back then. Today, the computers are orders of magnitude more powerful.
If your think that performance is insufficient, look for better algorithms but don't sacrifice modular program design. Compared to everything else, the subVI calling overhead is negligible. Don't worry about it.
If you have very specific performance problems, please post your VIs and we have a look.
05-14-2009 04:25 PM
Many of my older (quite fancy!) programs were first developed on a 100MHz Pentium with 64 MB od RAM and they run just fine back then. Today, the computers are orders of magnitude more powerful.
LOL, maybe this is a better way to get efficient at labview. Forget all the standards about fitting your block diagram on your screen, just make it work on an ancient computer first, and you know its good!
05-14-2009 05:25 PM
Ok, so we have the first answer: Making lots of sub vi is not going to make my application slower. Thanks!
I will try to explain better my other problem:
I have to read and write on 20 indicators lots of times. Sometimes this updates are triggered by the user, sometimes are triggered by the slave loop and some of them are done on each loop interaction of the main while loop of my application.
As my program is really modular and the updates are done on different parts of the software. I thought it would be a good idea to created a cluster with all the references from my indicators and I wire it on all the vis so I would have access to the controls and indicators of my main front panel all the time.
I already do the updates only when it is really necessary.
What I would like to know is the best way to handle all this reading and writing on the interface of the application. All the books and websites about programming in labview that I have found shows how to make small applications and to solve specific tasks. I have no problem with coding and making the program work, I would just like to do it in the best way possible.
Thanks!
Gabriel
05-14-2009 07:07 PM
GPC wrote:I have to read and write on 20 indicators lots of times. Sometimes this updates are triggered by the user, sometimes are triggered by the slave loop and some of them are done on each loop interaction of the main while loop of my application.
As my program is really modular and the updates are done on different parts of the software. I thought it would be a good idea to created a cluster with all the references from my indicators and I wire it on all the vis so I would have access to the controls and indicators of my main front panel all the time.
NO!!!!
Don't use controls/indicators as a primary means of data storage. Accessing them via references and value property nodes is extremely inefficient because each read or write forces synchronous execution. This method is several orders of magnitude slower than better alternatives.
You probably want to keep all your data for example in an action engine subVI where you can read and write an nearly any speed and order because it does not involve the UI. The main program can asynchronously read from it and update the relevant indicators at a leisurely pace, e.g. 10x/second. That's all you need for a smooth display to the observer.
05-14-2009 08:17 PM
But I am not using it to store the data. I am using it to show the data to the user.
This data is, actually, a set of pictures. An image is acquired from the web cam then shown to the user, the other indicators contain the processed image and a set of images that are generated depending on the changes of the UI controllers.
And I have a master (events) slave (image acquisition and processing) structure....
10-01-2009
03:10 PM
- last edited on
11-13-2024
08:42 AM
by
Content Cleaner
I have found the answer for my question on the following webcasts:
Best Practices for Managing Application Development with the LabVIEW ProjectTips and Tricks for Improving LabVIEW Application Performance
Software Design Architectures in NI LabVIEW
Design Multirate Applications with LabVIEW Timed Loop