LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Using a subvi to set indicator values...???

I have 14 boolean indicators (LED's) in my main program that correspond to 14 relay channels in my DAQ system (when the relay is open a True is written to the indicator). As the user changes settings within the program, various relays are commanded open or closed. I would like to be able to write a 14 element array of states (T/F) to a subvi and have that subvi update the LED's in the main program. Right now I have the array of states running throughout the program but I have to use an index array and 14 local variables every time a relay is commanded open or closed - as you can image the code is quite messy. I'm pretty sure there is a way to do this with references or global variables but I'm still very new to LabVIEW and don't have any idea how to accomplish this. Any help on how to do this would be greatly appreciated. Thanks!

 

-Erik

0 Kudos
Message 1 of 4
(2,977 Views)
Given the number of LEDs you have to manipulate, I would pass a reference to the top-level VI to a subVI along with the array of values for the LEDs. Inside the subVI you would use the VI reference to extract references to all the LEDs and then use those references to update teh state of the LEDs. If you can wait, tomorrow morning (East Coast US time) I'll put together a simple example.

Mike...

PS: If the 14 LEDs could go into a cluster, the code would be a lot easier. What do you think?

Certified Professional Instructor
Certified LabVIEW Architect
LabVIEW Champion

"... after all, He's not a tame lion..."

For help with grief and grieving.
Message 2 of 4
(2,973 Views)
Hmm...I think bundling them into a cluster would make other portions of the code more difficult to manipulate. Right now I'm able to change relay states by using the "replace array subset" for the specific channel im interested in. In some cases I'm required to change multiple relay states at the same time (which is easily accomplished with the replace array subset icon).
 
What do you think?
 
Either way, an example would be absolutely awesome. Thanks!
 
-Erik
0 Kudos
Message 3 of 4
(2,969 Views)
I have a couple things for you. First is a VI that demonstrates the ease with which clusters of like-values (like booleans) can be manipulated logically. It has an input for the old values an input for the modified values and a mask input that identifies the bit(s) that you want to alter. There are two advantages to using code like this: First you can change bits at arbitrary locations in one pass. Second, the need for a subVI to update the LEDs basically goes away since you're only talking about one wire.

The other attached VI shows two approaches for logic to go inside a subVI for updating the value of separate booleans. The top one works if your LEDs have some sort of systematic naming convention like LED1, LED2, etc. The bottom one works of the LEDs have arbitrary labels. Note: The sequences have no function other than to visually separate or highlight the two approaches.

Mike...

Certified Professional Instructor
Certified LabVIEW Architect
LabVIEW Champion

"... after all, He's not a tame lion..."

For help with grief and grieving.
Download All
Message 4 of 4
(2,947 Views)