LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Automatic add controls

Solved!
Go to solution

Hi all

 

I have been thinking about a nice way to do automatic adjustments on a random number of datatypes in a 1D array:

 

So I have a for loop that takes lets say a 1D array of waveforms as input. I want to be able to adjust gain, offset and to enable/disable the waveforms individually, with respective controls on the front panel.

The name of each control should take after the name of the waveform, with the functionallity extension eg. gain, offset and enable.

So if the waveforms are called Data1 to Data10, then the code should generate controls called "Data1 offset" , "Data1 gain", "Data1 enable" ... all the way through to Data10...

 

Each control should be placed in a control pane on the front panel, and by using of some property node they are arranged in a nice way (at least this is my current thought).

 

I hope it makes sense what I am trying to do, and that some of you are able to give me an idea of how to start! I have tried to sketch it in the following snippet..

 

Best,

Tommy

 

offset_gain_enable.png

 

0 Kudos
Message 1 of 10
(4,033 Views)

Hi Tommy,

 

One idea would be to make an array out of a cluster of controls, then use a property node to show as many controls as you have waveforms.

 

Chris



This avatar was scraped from an instance of good public spending: http://apod.nasa.gov
Message 2 of 10
(3,982 Views)
Solution
Accepted by topic author Tombech84

One idea would be to make an array out of a cluster of controls, then use a property node to show as many controls as you have waveforms.

 

Chris


While an Array of Clusters is a good idea, I'm not sure how you'd get unique Names (like Chan 1, Chan 2, etc.).  But the Clusters makes sense.  Create a cluster with Gain, Offset, and Enable, and make a TypeDef out of it.  Now put this down on your Front Panel whereever you want Channel 1 to be.  Label the cluster Channel 1 -- LabVIEW's natural "grouping" of the Cluster "control" will do the rest, and more cleanly (in my opinion) than having a Channel 1 Gain, Channel 1 Offset, Channel 1 Enable.  Of course, this only works if you can group the controls in a nice manner (note that LabVIEW lets you easily arrange Cluster elements horizontally or vertically, and once they are aligned, you can turn off alignment and "adjust" the positioning).  Best of all, if you tweak the TypeDef, then any "Channel Control" you put on your Front Panel will have the same look.

 

Bob Schor

0 Kudos
Message 3 of 10
(3,964 Views)

Hi,

 

I agree that a TypeDef'ed cluster is the way to go.

 

Do you have a fixed number of channels? If so, you can pput multiple clusters on your front panel and give each cluster a unique name:

clusters.png

 

 

However, if you want a variable number of channels, then you need to use an array like what qzerror suggested.

 


Bob_Schor wrote:

Best of all, if you tweak the TypeDef, then any "Channel Control" you put on your Front Panel will have the same look.


Use a Strict Type Definition if you need to update multiple clusters.

Certified LabVIEW Developer
Message 4 of 10
(3,925 Views)

Hi all 

 

First of all, thank you for the ideas!

However, I cant figure out how to give each cluster a unique name. I've tried to make it both a strict and normal type def but every time I (manually) change the name of one cluster in the array, all others change name as well. 

I also tried with a property node both with name and caption but neither works in run time. The attached is as far as i got. I also thought about adding a string to the typedef and just edit the string according to the package name, however this does not look as nice in my opinion and I consider this solution a "last resort".

 

Thanks,

Tommy

 

offset_gain_enable_v1.png

0 Kudos
Message 5 of 10
(3,902 Views)

Unique names can only be given to individual clusters added to the front panel, as each cluster has its own label.

 

Array elements cannot have unique names, unfortunately. The array gets a label, but its elements don't.

 

The extra-string-in-typedef sounds like the easiest way to do what you want in an array (but I agree it's hacky)

Certified LabVIEW Developer
0 Kudos
Message 6 of 10
(3,892 Views)

Okay.

 

I'll give it a shot, maybe I can format the string box with the same color as the background in the cluster and get it to look like it only is a text and not a box.

 

I appreciate the help! 

 

Best,

Tommy

0 Kudos
Message 7 of 10
(3,890 Views)

Hi Tommy,

 

don't use the "same" color: make the string control/indicator transparent!

Best regards,
GerdW


using LV2016/2019/2021 on Win10/11+cRIO, TestStand2016/2019
Message 8 of 10
(3,886 Views)

Hi All

 

Thanks for your ideas. I think it got it the way I want now. GerdW it was a nice idea with the transparent string indicator, it looks just like a normal text 🙂

 

Good day to ya' all! 

 

Best,

Tommy

0 Kudos
Message 9 of 10
(3,825 Views)

Very clever!  I must confess I never thought of doing this!

 

Bob Schor

0 Kudos
Message 10 of 10
(3,796 Views)