LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Automatically resize cluster based on number of elements within

Solved!
Go to solution
Solution
Accepted by PhilipJoeP

Well it turns out I had a copy on one of my old machines at work, so I may be the first person to post LV scripting code to the NI fourm without it being pulled down.

 

This works in LV 7.1 just fine.

 

 

A) A new VI is created.

 

B) An empty cluster is inserted on the FP.

 

C) is an array of enums that determine what types of controls get dropped in the cluster.

 

D) The For loop insertes each control and set their position inside the cluster.

 

The code is attached.

 

I do not know if this will run on more recent versions.

 

Please don't use this in a real app.

 

Ben

 

 

 

Message Edited by Ben on 05-21-2009 07:36 AM
Retired Senior Automation Systems Architect with Data Science Automation LabVIEW Champion Knight of NI and Prepper LinkedIn Profile YouTube Channel
Download All
Message 21 of 32
(3,080 Views)

Ben,

 

This solution is perfect and really helps!  Thank you so much for helping me on this!  Not only did you help me on the problem of creating a cluster based off an array, you also answered my earlier question from a few weeks ago about how to autogenerate a cluster. 

 

Thanks again!

 

Phil

0 Kudos
Message 22 of 32
(3,047 Views)

So... I was playing around with this solution and came across, what is hopefully, a small obstacle.  The VI uses an enumerated array value to select which control to place in the cluster.  For a numeric control, the user would have to select "Digital Control" or "Digital Control 1".  However, this control defaults to the Double representation. 

 

Is there any way to change the representation of the numeric control before it is placed in the cluster? 

 

Ideally, I would like to have a text file like this....

 

U32   numX

I16    numY

DBL   numZ

 

The VI would have a case statement that would recognize that the user is looking for a numeric control (named numX, etc...) to be placed in the cluster.  It would then create that numeric control and set its representation to U32, etc...

 

0 Kudos
Message 23 of 32
(2,999 Views)
Is there a way? Yes. But, you need to have LabVIEW 7.1 to edit the code since scripting is not available for general use in 8.x. That means you either need to get LabVIEW 7.1, or have someone with LabVIEW 7.1 write the VI for you. Or, you can wait to see if NI really does make scripting available as they claim they will. Though under what circumstances is unknown.
0 Kudos
Message 24 of 32
(2,989 Views)
As a follow-up: Let's not forget the whole reason for this, which is what you described way back in post #10. The crux of your issue is that you are trying to feed data into a Simulink DLL. I contend that it will be a whole lot easier and more robust to write a wrapper DLL to provide the data translation between LabVIEW and Simulink. You will not have to rely on scripting (which may or may not be available and at the very least requires you to write the code in LabVIEW 7.1 for right now) and you don't have to create a cluster with 2000+ elements which I think is simply silly.
0 Kudos
Message 25 of 32
(2,985 Views)

smercurio_fc wrote:
As a follow-up: Let's not forget the whole reason for this, which is what you described way back in post #10. The crux of your issue is that you are trying to feed data into a Simulink DLL. I contend that it will be a whole lot easier and more robust to write a wrapper DLL to provide the data translation between LabVIEW and Simulink. You will not have to rely on scripting (which may or may not be available and at the very least requires you to write the code in LabVIEW 7.1 for right now) and you don't have to create a cluster with 2000+ elements which I think is simply silly.

 

True... This would be ideal.  However, I think you'd still run into the same problem this way.  If I created a wrapper DLL to translate the data, I would still be translating between a LabView array (variable length) to a Simulink array (fixed length).  I believe this conversion problem would simply be removed from the step DLL and placed in the wrapper DLL. 

0 Kudos
Message 26 of 32
(2,952 Views)

Hi Philip,

 

what's the difference between conversion from "LabView array (variable length) to a Simulink array (fixed length)" and conversion from variable sized cluster to fixed sized Simulink array?

Best regards,
GerdW


using LV2016/2019/2021 on Win10/11+cRIO, TestStand2016/2019
0 Kudos
Message 27 of 32
(2,945 Views)
That's correct. That would be the whole point of the wrapper DLL. I don't know what conversion problem you'd be having. All that the wrapper DLL would need to do is copy data from one array into another. What is difficult about that?
0 Kudos
Message 28 of 32
(2,942 Views)

My apologizes… I often forget that I discuss issues under different posts.  Here is my detailed post on the array issue.

 

http://forums.ni.com/ni/board/message?board.id=170&message.id=408616#M408616

 

Please note that I made a mistake in the explanation.  Turns out, there is no “good” or “working” solution.  Because I didn’t do anything but pass my array through the Simulink model, I didn’t catch the fact that the resulting indicator array isn’t updated at all by the model.

0 Kudos
Message 29 of 32
(2,929 Views)

If I were able to get a copy of 7.1, would I even be able to change the representation?  I have a feeling that the numeric control always defaults to Double representation.  I've noticed in 8.6 that there is no Invoke Node or Property node that has anything to do with representation.  This makes me believe that even if I got 7.1, there would be no way for me to modify the above VI to create a numeric control inside a cluster with a specific representation.  Am I wrong?  I suspect the only way change the representation is by right-clicking the control and changing the representation by hand.

   

0 Kudos
Message 30 of 32
(2,906 Views)