LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Cluster vs Multiple Shift Registers

Solved!
Go to solution

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?

Cory K
0 Kudos
Message 1 of 17
(5,069 Views)
Solution
Accepted by Cory_K

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

Message 2 of 17
(5,058 Views)

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.

Message 3 of 17
(5,040 Views)

I did not know that.  Thanks, Andrey.

 

Lynn 

0 Kudos
Message 4 of 17
(5,023 Views)
I predominately use a big cluster of shift registers at the top of the BD and the Error Cluster(s) on SR at the bottom of the BD. IMHO this produces cleaner code than a BD that has 20 or so different SRs and the big cluster uses up a lot less real estate on the BD plus it tends to self-document  because of the bundle by name and unbundle by name.
Visualize the Solution

CLA

LabVIEW, LabVIEW FPGA
0 Kudos
Message 5 of 17
(5,021 Views)

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 

0 Kudos
Message 6 of 17
(4,961 Views)

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. 😉

0 Kudos
Message 7 of 17
(4,952 Views)

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

0 Kudos
Message 8 of 17
(4,949 Views)

We were referring to passing things into a cluster, then the cluster into a shift register.

You cant pass shift registers into a cluster.

 

cluster.PNG

 

The top case would be clustering everything into one shift register.

The bottom case would be each item getting its own shift register.

Cory K
0 Kudos
Message 9 of 17
(4,946 Views)

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. 😉

0 Kudos
Message 10 of 17
(4,929 Views)