LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

How to use clusters to pass variables to events

I am trying to use a cluster to by the source of all data I am passing through a stack of events. 
I have a Reset Event where I Bundle all the default values to the cluster.  Then I wire the cluster to the edge of the event and out to the edge of the while loop.  I make the terminal on the while loop a shift register...bringing the data back to the while loop on the left side and then into the event stack on a terminal.  This way I can grab a variable and change it using the bundle by name or the unbundle by name within any event.
 
THE PROBLEM IS...(not shouting...just emphasis so you can skip to the real stuff), When I went to change the number of variables I wanted to include in the cluster, all the wires broke...
 
It sure would be helpful to be able to change the definition of a cluster and have all the attached bundle/unbundle ... change accordingly.
 
Can you do that somehow?
 
Thanks in advance for your help.
 
Humming ... but not very effeciently.
0 Kudos
Message 1 of 7
(3,083 Views)
You should create a typedef. Read the LabVIEW Help on creating custom controls that are typedefs. That way, when you update the typedef all instances of the typedef are automagically updated.


Message Edited by smercurio_fc on 07-16-2008 01:49 PM
0 Kudos
Message 2 of 7
(3,075 Views)

Thanks,

But by creating a custom control/indicator don't you slow things down compared to passing information along "wire" created by a cluster?

Trying to Humm effeciently.

0 Kudos
Message 3 of 7
(3,061 Views)
No.  You won't notice a speed difference.

Shane.
0 Kudos
Message 4 of 7
(3,055 Views)

Thanks,

I found the "cluster" for the controls.  You just put a cluster on the front panel, resize it to be big enough to include all the clontrols you want to have in it...move the controls inside and presto...the controls are included in any bundle/unbundle by name.  If you drag another control into the cluster, it gets included too. 

That's neat...too bad its not explained that way in any of the LV documentation.

 

I have included an example to be sure I got it right...any thoughts?

 

Thanks a bunch for the help.

Hummin' along again.

 

0 Kudos
Message 5 of 7
(3,047 Views)
I'm not sure what you mean when you say: I found the "cluster" for the controls. To what are you referring? Initially you said you were bundling default values into a cluster. Were you wiring named constants? Unbundling by name only works with named constants.

In your current VI the "Reset" event probably doesn't actually work the way I think you want it to work. That case simply outputs the control's value to the shift register. You probably wrote this as a learning exercise, but just to explain, if you open your VI (don't run it), set the cluster's numeric values to some values, run the VI, press the "Reset" button, you will see the values you initially entered into the cluster control transferred to the indicators. If you follow the same steps, but instead of pressing the "Reset" button you change one of the numerical values using your separate controls, say "Numeric 6", you will see that "Current Value 2" gets the same value, while the other ones are zero.

Tip: You can set the cluster to autosize so you don't need to make it "
big enough to include all the clontrols you want to have in it". The cluster will resize as you add controls. Simply right-click on the cluster and select AutoSizing, and then select one of the options.
0 Kudos
Message 6 of 7
(3,029 Views)

Thanks...that is all absolutely correct and very helpful.

I was using clusters on the block diagram (without any use of them on the front panel) by bundeling named Control values ... just as a learning exercise.  I noticed the values of the output being 0 if the reset button had not been pressed and assumed that was the default value of any variable if it had not been written...(bad assumption sometimes which you have reminded me of...great.) 

Thanks for the tip on the autosize.

This should really help clean up my "code" ... "drawings" ... "diagrams" that's it.

Now I'm really embarassed about some of the stuff I "drew" a month ago...but it is all working so will fix it carefully.

This forum has been a great resource and I want to thank you for taking time to help me.

Hummin.

0 Kudos
Message 7 of 7
(3,021 Views)