LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

build clusters programmatically?

Solved!
Go to solution

Hi,

I was playing around on labview and I was wondering if would be possible to achieve the following task. Is it possible to build a cluster of clusters programmatically?

If not, is it possible with some work around to get the cluster I want between the available ones I am building as a unique output? I mean something like having a subvi with a single output regardless if the cluster has a different size.

 

I attach a code (very basic) that might give an idea. The problem is that after creating the cluster, than I can't find a way to collect it. I think variant might do the job, however I can't see a good way to get the data from the variant afterwards.

Thanks

E

0 Kudos
Message 1 of 11
(2,130 Views)

Clusters must be defined at compile time.  The only way that clusters can be created programmatically is on the front panel of a VI that is in edit mode.

Also, as you noted, there would be the problem of collecting the elements.

Describe what is the overall objective, and people will come up with different approaches.

0 Kudos
Message 2 of 11
(2,102 Views)

@EdoardoA wrote:

I was playing around on labview and I was wondering if would be possible to achieve the following task. Is it possible to build a cluster of clusters programmatically?

To be more correct (sorry Paul 😉 )

It is generally possible but never ever with "playing around on labview". It's similar to other programming languages. You have to deal with internal data structures, type descriptors and how labview stores data. The OpenG variant tools can give you an idea what's needed for such tasks. But why and for what reason? 

 

Your example VI shows, that you misunderstanding the very basics of labview: Dataflow. So forget your ugly idea of a dynamic cluster creation and follow Pauls answer.

 

 

0 Kudos
Message 3 of 11
(2,073 Views)

Thanks for the reply!

My goal would be to create a cluster with "n" elements where the number "n" is fo instance the number of slots in a chassis cDAQ. 

So, if I connect a cDAQ with 4 slots, create a cluster containing 4 elements.

 

E

0 Kudos
Message 4 of 11
(2,064 Views)

Hi,

Sorry for my mistakes but I'm still in the learning process! However, as I answered to Paul, my goal would be to create a cluster with "n" elements where the number "n" is the number of slots in a chassis cDAQ. 

I was checking the OpenG tools but I couldn't find a solution since I have never worked with variant before and I would like to learn how to handle it.

I knew the example was terrible, it was just to give an idea of what I wanted to do.

Thanks for helping 

0 Kudos
Message 5 of 11
(2,061 Views)

@EdoardoA wrote:

Hi,

Sorry for my mistakes but I'm still in the learning process! However, as I answered to Paul, my goal would be to create a cluster with "n" elements where the number "n" is the number of slots in a chassis cDAQ. 

I was checking the OpenG tools but I couldn't find a solution since I have never worked with variant before and I would like to learn how to handle it.

I knew the example was terrible, it was just to give an idea of what I wanted to do.

Thanks for helping 


I don't believe that creating a cluster with "n" elements is really your goal.  You are trying to accomplish something else, and you think that you could get to your real goal if you could perform the step of 'creating a cluster with "n" elements'.

You won't get much help if you won't tell us what you are really trying to accomplish.

 

But if you REALLY REALLY REALLY want to programmatically create a 'create a cluster with "n" elements', use the attached VI.

Message 6 of 11
(2,038 Views)

Hi,

Thanks a lot for the vi, somehow it is doing what I had in mind but not exactly.

In few words I need to acquire some data through couple of modules in a cDAQ chassis device (I am using a cDAQ-9174). So far, I was able to connect and get it work and record as I want. Specifically, I will use a NI9239 and NI9402 modules, and I built the DAQ Linked Device.vi in order to get the channels of the modules I am using based on the position they occupy in the slot : so, now I can programmatically run the experiment using the task VIs and record the data regardless of the modules position in the cDAQ9174 because I can just check the channel of the modules I am using).

But then you can notice that to make it work I manually built the 4 Mod n channels, one for each chassis slot. So, now I was trying to make it even more generic in order to programmatically set the number of the Mod n channels based on the chassis connected (i.e. 4 for the cDAQ-9174, 8 for cDAQ-9178...) and after that replace the custom Mod n channels cluster with an array of clusters (see Clusters.vi). In this way, replacing the NI9239 with some other modules with more than 4 terminals (i.e. NI9207) I can programmatically get access to all of the available channels.

Basically I am trying to understand if it is possible to programmatically get what you can see in the clusters.vi front panel and possibly dynamically update it using an interface.

I hope this can be more clear. Maybe it is not possible or so tricky that it is not worthy to do. Hope you can have good suggestions. Thanks a lot in advance for the support.

E

Download All
0 Kudos
Message 7 of 11
(2,000 Views)
Solution
Accepted by topic author EdoardoA

@EdoardoA wrote:

Hi,

Thanks a lot for the vi, somehow it is doing what I had in mind but not exactly.

In few words I need to acquire some data through couple of modules in a cDAQ chassis device (I am using a cDAQ-9174). So far, I was able to connect and get it work and record as I want. Specifically, I will use a NI9239 and NI9402 modules, and I built the DAQ Linked Device.vi in order to get the channels of the modules I am using based on the position they occupy in the slot : so, now I can programmatically run the experiment using the task VIs and record the data regardless of the modules position in the cDAQ9174 because I can just check the channel of the modules I am using).

But then you can notice that to make it work I manually built the 4 Mod n channels, one for each chassis slot. So, now I was trying to make it even more generic in order to programmatically set the number of the Mod n channels based on the chassis connected (i.e. 4 for the cDAQ-9174, 8 for cDAQ-9178...) and after that replace the custom Mod n channels cluster with an array of clusters (see Clusters.vi). In this way, replacing the NI9239 with some other modules with more than 4 terminals (i.e. NI9207) I can programmatically get access to all of the available channels.

Basically I am trying to understand if it is possible to programmatically get what you can see in the clusters.vi front panel and possibly dynamically update it using an interface.

I hope this can be more clear. Maybe it is not possible or so tricky that it is not worthy to do. Hope you can have good suggestions. Thanks a lot in advance for the support.

E


In my first response to you, I wrote: "Clusters must be defined at compile time.  The only way that clusters can be created programmatically is on the front panel of a VI that is in edit mode*."  That is still true!

If you want to have a variable number of control elements, you must use an array, listbox, multicolumn listbox, table, or tree.  You cannot have a variable number of discrete controls (such as clusters) at run time.

 

* Which is what my silly VI does.

0 Kudos
Message 8 of 11
(1,989 Views)

Thanks for help, I think I will stick with a fixed cluster and that's it... probably it's easier to rewrite the whole code (or part of it) if the cDAQ will be changed. However, I understood that changing the inputs in the for loop I can get n cluster or n array, but what if I want to get n array of clusters (like the one I shared in the cluster.vi)?

And how can I get the data out if I would need to make some change or updates programmatically?

 

E

0 Kudos
Message 9 of 11
(1,956 Views)
Solution
Accepted by topic author EdoardoA

(sorry, cannot look at your code, only LabVIEW 2020 here. Consider "save for previous" before attaching)

 

While you cannot create cluster elements dynamically at runtime (that would only be your first problem, you also need to be able to reasonably wire it onto the rest of the logic later!!)

 

Of course a chassis has a relatively small hard upper limit of filled slots, so you can create a cluster with that upper limit of elements, then hide what's not used. Here's a trivially simple example.

 

altenbach_0-1703527549995.png

 

A better solution would be an array of clusters where you would add disabled string controls for labels.

 

See here for an example:

 

altenbach_0-1703220974482.png

 

 

 

Message 10 of 11
(1,937 Views)