From Friday, April 19th (11:00 PM CDT) through Saturday, April 20th (2:00 PM CDT), 2024, ni.com will undergo system upgrades that may result in temporary service interruption.

We appreciate your patience as we improve our online experience.

LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

LabVIEW Equivalent of Control Array in LabWindows

Solved!
Go to solution

Hello all,

 

I come from a world of LabWindows and I'm trying to wrap my head around LabVIEW. I have a project in which I have 10 LEDs that are correlated by some sequence. Firstly I'll need to make these colour boxes as I need to switch between three colours: red, green, & amber. 

 

While the in code they are sequentially called, they are far from related on the GUI. I want to scatter these colour boxes in corners, beside each other horizontally, vertically, diagonally, across the screen, etc. The idea with LabWindows is that I can create N many LEDs, then I can group these LEDs into a Control Array.

 

With this control array I can call each LED through the array, instead of calling a reference to each LED. Now I called NI and the guy told me "Just throw all those bad boys into a cluster and bobs your uncle". Well if I do that then I have to make my entire front panel a cluster.

 

So my solution is the following:

1. Create colour boxes wherever I want.

2. Create references to each box.

3. Build an array or cluster from these references.

 

Now I have the ability to call out my LEDs and change their colour via an index array/cluster.

 

What my question is, is this the only way? Is this the best way? 

 

 

Thanks in advance.

-Dwayne

0 Kudos
Message 1 of 7
(2,532 Views)

So, to start with... a couple months back I did a short writeup as an introduction to LabVIEW coming from the Labwindows world.  I'd suggest you glance through it.

 

To answer your question:  There are several ways you could do this inside of LabVIEW.  A cluster is one option.  You can have an array of controls, or an array of references (though I advise against this).  You can also just store the index of the control in an array and call the Set Control Values by Index function.

 

My suggestion would be:  give something a try and post it asking for constructive criticism.  I can promise you'll get lots of good comments... and likely even have one or two people write you a VI that accomplishes the same thing but using a standard LabVIEW architecture.

0 Kudos
Message 2 of 7
(2,504 Views)
Solution
Accepted by topic author Dwayne_Arxtron

It's the end of the day and I was tired of work (which is why I'm on the forums in the first place),  so I put together a quick example VI of "Set Control Values by Index". 

 

This is just one option, and most it closely fits what you described... but I'm not sure it is the best option.  I would need to see what you are trying to accomplish with all of these boxes scattered across the screen to tell you which option would be the best though.

Message 3 of 7
(2,499 Views)

@BowenM:

 

     I like your example.  I had a similar task, though mine was to both Control and Show Status on up to 24 Stations arranged in two sets of four-across, three-down arrays.  I built a Cluster of  Boolean Round LEDs (as Controls), as my "view" was specific and fixed.  The Buttons represented a spatial arrangement of 24 experimental stations that the program controlled.  Stations could be "occupied" (and the control would be visible) or "unoccupied" (and the control would not be visible).  "Status" was indicated by control Color (Green = Active, running, Blue = Active, something happening, Red = Error, shutting down, Black = Shut off).  Since up to 24 stations could be run at the same time, the user pushed the button (and changed the button's appearance from Off, dim light, to On, bright light), which also resulted in any currently "On" switch being programmatically turned off.

     Since this Front Panel display was of fixed size and orientation, a Cluster (which allowed me to "freeze" the arrangement, yet space it how I wanted) was appropriate, with an Array of References (tedious to build, but only do it once) to interact with it.

 

Bob Schor

0 Kudos
Message 4 of 7
(2,473 Views)

This solution is by-far more cleaner than what that NI guy suggested. This is the solution I was looking for, it makes me dislike LabVIEW less. Still need to cope with loss of lots of other features though.

 

Thanks for you help.

0 Kudos
Message 5 of 7
(2,469 Views)

Hang in there, Dwayne_Arxtron!  Don't give up on LabVIEW yet.  In my time programming in LabVIEW, there are very few things that I have been unable to find an elegant solution to.

 

Since it appears you have decided to go with this solution, I have attached a modified vi showing an architecture I very regularly use in applications.  This example uses a nifty thing in LabVIEW called Variant Attributes.  Think of it as a LabVIEW dictionary that uses the Red-black tree search algorithm - so it returns results on an order of O(log n) instead of O(n) like linear searches would.

 

The thing about this architecture that I like is that I can pass one variant data wire anywhere I want and update my front panel quickly.  This will allow you to update things from other loops, from sub vis, etc.  And because it is a dictionary, you can reference things by name in your program - which makes things much more readable.  If you look at the code, I'm no longer updating the value of ControlArray[2], I'm updating the value of "Box 3".

0 Kudos
Message 6 of 7
(2,454 Views)

I attached the wrong VI.  This is the one I meant to post 🙂

 

0 Kudos
Message 7 of 7
(2,448 Views)