‎08-18-2009 09:40 AM
I had a question regarding good coding practice.
Say you have multiple elements (numerics, strings, .... whatever) that you need to iterate between loops.
Is it better to make a shift register for each element?
Or cluster everything, then pass the cluster to a single shift register?
Is one faster than the other? Or better/worse for another reason?
Solved! Go to Solution.
‎08-18-2009 09:52 AM
Cory,
Yes. and No.
I usually create a large typedef cluster I call Indicators and Flags (InF). I put most things which need to be passed around in there. The Error cluster, the State enum, and large data arrays are usually in separate shift registers. The InF and data array shift registers are at the top of the loop and the error and state SRs are at the bottom. Most code goes between them. Using Bundle/Unbundle by Name documents which data are used in any given case. The InF cluster is usually not displayed on the front panel and may only exist in a subVI to save block diagram space. Data is unbundled to individual indicators as needed for display to the user.
If you have a situation where speed is an issue, separate the data which needs to be processed quickly from everything else and optimize for that. Strings and arrays inside the cluster probably cause some interesting memory allocation issues as they change sizes, so that can be an argument for separating them.
Lynn
‎08-18-2009 10:48 AM
johnsold wrote:...Strings and arrays inside the cluster probably cause some interesting memory allocation issues as they change sizes, so that can be an argument for separating them.
Lynn
Strings and arrays (and paths) stores in clusters indirectly, so it should be no any "interesting memory allocation issues".
Andrey.
‎08-18-2009 11:38 AM
I did not know that. Thanks, Andrey.
Lynn
‎08-18-2009 11:40 AM
‎08-26-2009 10:43 AM
Hallo,
do you please know how to create a cluster of shift registers ? I have an application with cca. 7 shift registers and it seems to clutter the diagram too much. Is there any way to make it more readable ?
Any hin is appreciated, Thank You
Karlito
‎08-26-2009 10:55 AM
Karlito wrote:do you please know how to create a cluster of shift registers ?
You probably misunderstood. You don't create a cluster of shift registers, but a single shift register containing a cluster of all your data. 😉
‎08-26-2009 11:00 AM
Hallo, thank you for the clarification, but do you suggest to put all the controls and indicators into one cluster ? I currently have a cluster of controls, a cluster of indicators, so that makes two shift registers, there are three QAQmx taks to my hardware and additional shift registers for, file path, refnum and error, I was thinking to simplify it a bit, but not sure how to do it.
Yours Sincerely
Karlito
‎08-26-2009 11:03 AM
We were referring to passing things into a cluster, then the cluster into a shift register.
You cant pass shift registers into a cluster.
The top case would be clustering everything into one shift register.
The bottom case would be each item getting its own shift register.
‎08-26-2009 11:37 AM
Karlito wrote:Hallo, thank you for the clarification, but do you suggest to put all the controls and indicators into one cluster ? I currently have a cluster of controls, a cluster of indicators, so that makes two shift registers, there are three QAQmx taks to my hardware and additional shift registers for, file path, refnum and error, I was thinking to simplify it a bit, but not sure how to do it.
Why don't you simply attach some example code instead? It is difficult to discuss LabVIEW code with words only. 😉