Clustering in Labview

I can’t seem to get this clustering to work, here is a several screenshots

Labview is very annoying

images.zip (325 KB)


images.zip (325 KB)

“Labview is very annoying”? Them’s fightin’ words :wink:

I happen to find clusters to be SUPER AWESOME! When properly designed and packed with the data that you need for a given “object”, they can be incredibly useful.

A few recommendations (I’m not exactly sure which issues you’re finding most problematic) -

  1. your case structure doesn’t have a control to select true vs. false, that’s one error
  2. your case structure doesn’t have a value to pass out when set to “false”, that’s the second error
  3. select the error in the error window and press “show error” to highlight the specific issue
  4. use “bundle by name” and “unbundle by name” instead of “bundle” and “unbundle” - you’ll have user-friendly tags to identify what wires go where
  5. when using the “by name” variants, you’ll need to “input” a cluster to allow the function to know what the datatypes and names are (you could use, for example, a local variable as the “input” to the bundle - right-click on the variable-create-local variable-change to read)

After a few years of programming LabVIEW without using clusters, I was playing around one day, found out how powerful they can be and haven’t looked back since.

Once you get past the above hurdles, you could even consider creating a custom control to define your cluster. If your custom control is set to “strict type def”, you’ll be able to modify the cluster in the .ctl custom control file and “push it out” to every VI that uses it. This is a more advanced LabVIEW concept but really not too hard to use once you get the hang of it.

Russ

I was using Case structures to be “Functions”

how do I return a cluster

I’m not sure that I understand what you’re trying to do. Unless “objects” in C++ that include both data and functions, clusters in LabVIEW are really more related to structures in C/C++ (ie a simple grouping of possibly disparate datatypes).

If you’re trying to get a subVI that can be called from other VIs, the easiest technique to use is to highlight the “code” that you wish to make a “function” from and select “edit-create subVI”. This will automatically gather up the software and create inputs and outputs for you.

The old-school technique is to right-click on the icon in the upper right of your front panel and select “edit icon” to change the icon and “show connector” to display the connector pane for the VI. With the connector pane displayed, you can use the wiring tool to select the inputs and outputs for the VI. After saving the VI, you can use it as a subVI in any other VI.

Is this what you’re looking for?
Russ

I know its like a struct, and in C you can return structs

I have already built functions, just not clusters

You have two identical things coming in, (wheel, and then it’s mirror minus the cluster/bundler thingy). The issue is (beside the case structure errors), that you have more inputs then outputs…
You have every input doubled, so you need to double every output, that should (big should work)…

you have all the wheel stuff taken care of (your original input i think (the big clustered thing)), but then you add all the other stuff, and you are only outputting you wheel info, and nothing else.

Are you trying to build a cluster? If so, I’d recommend that you use “bundle by name” and check out its examples and “context help”. If you’re trying to modify a single element within a cluster, do something like the attached.

cluster example.vi (15.1 KB)


cluster example.vi (15.1 KB)

I can’t make a function that creates a cluster
I want to standardize the cluster

A function, or subVI, can return any number of outputs of any datatype including cluster. The return values are returned via the icon in the upper right. You might want to look up a tutorial on building a subVI, but the short steps are to right click on the icon and show the connector terminals. If you need to, pick a terminal pattern with at least enough inputs and outputs (extra are fine, and often a good idea for forward compatibility). Click on a terminal where you want the output, then click on the indicator(cluster). If you show the help window, you should see that you now have your function returning a cluster.

To explain a bit more about the other syntax errors in your diagram, LV doesn’t like uninitialized data. For a case to pass data out of it to the outer diagram, every diagram must pass some data out, otherwise it’d be uninitialized.

Greg McKaskle

I’m really struggling to understand your objective. You did successfully create a cluster in your first bitmap using the “bundle” VI and then you wrote its value to a control. What else are you trying to do? I’d call that “a function that creates a cluster”.

If you want to standardize a cluster, you should create a custom control that contains the standard cluster with “strict type def” setting.

Russ

I am trying to make a function that creates a cluster, like an init function in C++.

I want the function to take as input, at least all the components of the cluster, bundle them and return the bundle. Thats it

With the exception of the errors in the VI that I mentioned above, you did just that (based on the first bitmap that you posted). All that you need to do is wire up the connection panel for the VI. Go to icon in the upper right of the front panel, right-click and select Show Connector. Then proceed to use the wiring tool to attach the inputs (all of the terminals on the left side of your block diagram) and outputs (the terminal on the right side of your block diagram). After you save the VI, you can then place the VI in any other VI and use it as a subVI.

I wish that I could log onto your computer and do this for you. It takes much longer to describe than to actually implement. There must be a help file for “creating a subVI”.

Russ

All you have to do to make a subVI is select all the components, go to edit across the top and click the “create a subVI” option.

Sounds like you are duplicating the bundle by name function.

“Sounds like you are duplicating the bundle by name function.”

Yes exactly, but limiting the inputs