LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Passing of variable name to switch LEDs

Hi,

I need to design a VI that uses 32 lEDs to indicate the pass/fail results of 32 UUTs. The user is able to choose the unit/units to be tested and after the tests are carried out, the corresponding LED/LEDs will light up accordingly. My question is, how do i design the VI such that i only need to pass the variable name of the LED to the VI and it will light up the corresponding LED. The below C codes gives an illustration of what i meant.

Void Pass(int x)
{
SetCrtAttribute (MUST, LED[x], ATTR-ON-COLOR, Val- GREEN)
}

Such that when i pass a value of x (which indicates a particular LED on the user panel), it will light up the correct LED. I meant to write this part as a Sub-VI such that i only need to call this
VI to light up the correct LED but i do not know how to design the VI to be so generic. Doing a case loop is out of the question cos it is too complex and untidy. Please help.

Thanks.
0 Kudos
Message 1 of 16
(3,951 Views)
Instead of passing the name of the control, you should pass its Control Reference. In the subVI you can then set the value and color of the LED and read its name using the label or caption property.
However, if the subVI has to use the name only, you'll have to retrieve the control reference anyway to set its attribute from the subVI.
You create a control reference on the diagram right-clicking on its terminal and selecting Create -> Reference.


LabVIEW, C'est LabVIEW

0 Kudos
Message 2 of 16
(3,949 Views)
If the LEDs are in a cluster it will make this a bit easier, but if not,
you can build up an array of references of the LEDs. Build a function
that loops through reading the Caption or Label Name and returns with
the reference. Then you can set the rest of the attributes like the
value, color, or whatever. If you build it correctly, you can also have
some symbolic names like ALL that act on the entire group or ROW 0, ROW
1, and so on so that there are multiple ways of referring to the objects
depending on what you need to accomplish.

Greg McKaskle

JuneN wrote:

> Hi,
>
> I need to design a VI that uses 32 lEDs to indicate the pass/fail
> results of 32 UUTs. The user is able to choose the unit/units to be
> tested and after the tests are carried ou
t, the corresponding LED/LEDs
> will light up accordingly. My question is, how do i design the VI such
> that i only need to pass the variable name of the LED to the VI and it
> will light up the corresponding LED. The below C codes gives an
> illustration of what i meant.
>
> Void Pass(int x)
> {
> SetCrtAttribute (MUST, LED[x], ATTR-ON-COLOR, Val- GREEN)
> }
>
> Such that when i pass a value of x (which indicates a particular LED
> on the user panel), it will light up the correct LED. I meant to write
> this part as a Sub-VI such that i only need to call this VI to light
> up the correct LED but i do not know how to design the VI to be so
> generic. Doing a case loop is out of the question cos it is too
> complex and untidy. Please help.
>
> Thanks.
>
0 Kudos
Message 3 of 16
(3,949 Views)
Hi Greg,

Thanks for the answer but i need you to explain it in more details as i am only a beginner in LabView. Maybe you can do a sample VI to illustrate it to me.

Thanks.
0 Kudos
Message 4 of 16
(3,949 Views)
> Thanks for the answer but i need you to explain it in more details as
> i am only a beginner in LabView. Maybe you can do a sample VI to
> illustrate it to me.
>


You don't mention whether your LEDs are inside of a cluster. Like I
said, this will simplify it because the cluster can provide an array of
references of the controls that the cluster contains. To do this, drop
the cluster and place the LEDs inside of it. Popup on the cluster and
create a property node. On the diagram, choose to read the Controls[].
This gives you an array of control references that allow you access to
all of the LEDs. Now you can wire the array into a For loop which will
iterate through each of them. Inside of the array, you want to cast the
cont
rol refnum to a Boolean Refnum. The cast you want to use is the
Cast to more specific class from the VI Server palette. Use the Class
Specifier constant from the same palette to choose the class to cast to.

Wire the Boolean class refnum into a property node where you can read
the Label Text and compare it to the one you are looking for. When the
strings match, you can wire to another property node and change color or
whatever else you like.

It isn't easy for me to post a VI, so I hope the description helps.

Greg McKaskle
0 Kudos
Message 6 of 16
(3,949 Views)
From looking at the discussion so far, I think that this example is more or less what you are looking for. Notice that with the use of references, all of this could be used as a subVI. Run the LED Colour Test VI from the library.

I hope this helps.

Rob
0 Kudos
Message 5 of 16
(3,949 Views)
Rob,
I don't know if I'm the only one or not, but I can't open your files again...

Brian
0 Kudos
Message 7 of 16
(3,949 Views)
And I checked this one too. I can open every VI in the library. They are all there. I just checked again. Very strange. I'll upload it again, just in case it got messed up in the sending. What VI does it tell you it's missing this time?

Rob
0 Kudos
Message 8 of 16
(3,949 Views)
Hmm... very strange... The first time it said it couldn't find Open Reference.vi, Button Check.vi, and LED Set.vi. Now it says it can't find the top level VI (LED Colour Test.vi). I don't understand why, I've only had this problem that one other time with your soft button example. Is any one else having a problem or is just me this time?

Anyway it looks like a well laid out VI.

Brian
0 Kudos
Message 9 of 16
(3,949 Views)
Ignore my previous reply. I found the missing VI buried a couple of level deep. I've manually placed all of the subVIs into the library this time (wish it would put them in automatically like it's supposed to). So HERE is a working version (tested on a computer without access to me "standard" libraries).

Rob
0 Kudos
Message 10 of 16
(3,949 Views)