LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Open sub VI by clicking on indicator of Main VI

I have posted on this before. I got an answer that only confused me more, but I provided very few details on my previous post. I am going to be more specific in my post this time, because I need a solution that I can implement quickly, I AM ABOUT TO GET FIRED. I have not been programming very long (a few months) and this was the first real VI ihave built, so please be gentle when looking at it.
 
My VI is used to monitor the position of a garage door while it cycles up and down. I am using a potentiometer on each door to determine its position. That part works great. I am using a property node to auto scale the slide so it doesn't matter what the voltage drop in the very long wires is. I set my min and max by monitoring the voltage and setting those values as my min and max for the indicator. Once those values are set, I change over to tracking position instead of setting limits. While the position is being tracked I look for the door to be in the up or down position and indicate it with booleans. I am waiting the amount of time specified on the control and "pressing" the button I watch the position of the door and if the door does not reach either the up or down position in the set time plus 20 seconds, I turn the door red, and tell the oprator there is a problem/ I also have added a manual pushbutton, and a reset count to zero. I have the following inputs STOP, RELAY CH TO CLOSE, RELAY COM TO CLOSE, (relays are for pushbutton) PHYSICAL CHANNEL (analog in to monitor potentiometer) and ERROR IN. My  ouputs are as follows,DOOR POSITION, UP, DOWN,CYCLE COUNT, and ERROR OUT , I know that I did not use the best practices, but, like I said, I am learning...
 
HERE IS MY ISSUE   \/ \/ \/
 
I need to take this VI, 30 times, and put all of the indicators on a "Main" front panel. I need to show them all on one screen, while these 30 sub vi's are running I need to monitor the values on the main screen. I need to make it so our technicians can click on the indicator, and pull up the still running sub-vi and use it. I also still need the other 29 subs to continue running quietly in the background.  I then need to be able to make the sub-vi front panel go away and return to the big screen. PLEASE HELP ME!!  Thanks 🙂
One should welcome adversity as an opportunity to excel.
0 Kudos
Message 1 of 9
(4,026 Views)
Sounds like you might be able to use VI templates. There's an example that ships with LabVIEW called "Subpanel Templates" that you might want to take a look at.
0 Kudos
Message 2 of 9
(4,006 Views)
Ok, Step 1: Don't Panic! Have your towel with you? Good... Now take a couple deep cleansing breaths...

The architecture you need to implement involves combining two features of LV to produce an interesting and useful effect.

First is a side-effect of the way LV handles template VIs. Normally template VIs ( extension *.vit ) are never linked into code. They exist to make life easier for programmers by allowing you to implement common functions as a starting place for developing code. So what good is a template at runtime?

This is where the second feature comes into play: VI Server. Every time you open a reference to a template VI, LV loads a new copy of the VI into memory dynamically. Now let's say that you put the Open VI Reference function in a loop (along with a call to the RunVI method) and buffer the resulting VI references. If you need to control 30 door, you execute the loop 30 times and end up with 30 independent copies of the VI running in memory. Only need to control 10 doors today? Then execute the loop just 10 times. Get the idea?

Now how to implement this... First your code basically looks pretty good - I have seen a LOT worse. Right off hand I would say there are two things you need: 1) an input parameter that you can pass to the VI when its launched to tell it which door its controlling/monitoring and 2) a mechanism for reporting its status back to the main VI. Some sort of functional global should do the trick - we can deal with how to structure that later.

In terms of the structure of the main VI it sounds like you need a couple things. First you need some sort of overview that allows the operator to oversee the operation of all the doors at some high level like: green light = everything is good, red light = door needs attention. Second you need a way to display the front panel of the VI copy (or clone) servicing a selected door. For the first requirement I would recommend an array of clusters where each element contains a colored boolean and a string indicator containing label of a door. With this interface, clicking a button (the colored boolean) would fire an event that would select the associated VI clone for display. To display the clone's front panel use a subpanel. To insert a front panel into the subpanel all you have to do is pass the associated clone's VI reference (which we got when we launched the thing) to the subpanel's InsertVI method.

Essentially that's all there is to it. Obviously there are details to be worked out but this should show you the direction to be moving in. To get started, spend a little time going over the LV examples dealing with VI Server, and subpanels. And ask lots of questions... We - I - will be here for you.

Mike...



Certified Professional Instructor
Certified LabVIEW Architect
LabVIEW Champion

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

For help with grief and grieving.
Message 3 of 9
(3,993 Views)
On Jun 7, 12:40 pm, Daddy-O <x...@no.email> wrote:
>I have posted on this before. I got an answer that only confused me more, but I provided very few details on my previous post. I am going to be more specific in my post this time, because I need a&nbsp;solution that I can implement quickly, I AM ABOUT TO GET FIRED.&nbsp;I have not been programming very long (a few months) and&nbsp;this was the first real VI ihave built, so please be gentle when looking at it.
>&nbsp;
>My VI is used to monitor the position of a garage door while it cycles up and down. I am using a potentiometer on each door to determine its position. That part works great. I am using a property node to auto scale the slide so it doesn't matter what the voltage drop in the very long wires is. I set my min and max by monitoring the voltage and setting those values as my min and max for the indicator. Once those values are set, I change over to tracking position instead of setting limits. While the position is being tracked I look for the door to be in the up or down position and indicate it with booleans. I am waiting the amount of time specified on the control and "pressing" the button I watch the position of the door and if the door does not reach either the up or down position in the set time plus 20 seconds, I turn the door red, and tell the oprator there is a problem/ I also have added a manual pushbutton, and a reset count to zero. I have the following inputs STOP, RELAY CH TO CLOSE, RELAY COM TO CLOSE, (relays are for pushbutton)&nbsp;PHYSICAL CHANNEL (analog in to monitor potentiometer) and ERROR IN. My&nbsp; ouputs are as follows,DOOR POSITION, UP, DOWN,CYCLE COUNT, and ERROR OUT&nbsp;, I know that I did not use the best practices, but, like I said, I am learning...
>&nbsp;
>HERE IS MY ISSUE&nbsp;&nbsp; \/ \/&nbsp;\/
>&nbsp;
>I need to take this VI, 30 times, and put all of the indicators on a "Main" front panel. I need to show them all on one screen,&nbsp;while these 30 sub vi's are running I need to monitor the values on the main screen. I need to make it so our technicians can click on the indicator, and pull up the still running&nbsp;sub-vi and use it. I also still need the other 29 subs to continue running quietly&nbsp;in the background. &nbsp;I then need to be able to make the sub-vi front panel go away and return to the big screen. PLEASE HELP ME!!&nbsp; Thanks 🙂
>
>F2_CSM_GOOD.vi:http://forums.ni.com/attachments/ni/170/251906/1/F2_CSM_GOOD.vi

Couple of thoughts:

1. Try to split your vi into open, run and stop elements. You can
then easily copy the run portion without affecting the initialization
and shutdown elements.
2. If you need to run 30 copies of the same vi at the same time the
vi needs to be very self contained. IE it should not interact with
any other vi's and have dedicated system resources. Think about your
system resources. Do all of the running vi's need to share common
resources? If so you will have to create queues for each of the
shared resources so that only one vi is trying to use the resource at
a time.
3. You could simply place 30 copies of a self contained vi in one
large while loop to get them all on the front panel at the same time.
You would have to pass into each copy all of its unique resource
information.

Good Luck! This is not easy to do.

Bluesky

0 Kudos
Message 4 of 9
(3,955 Views)

Hello Daddy,

Mike said it all!

interestingly , i wrote a thread a few weeks ago exactly about how to implement template vi's. check the link below

http://forums.ni.com/ni/board/message?board.id=170&message.id=245742&view=by_date_ascending&page=1

if you look further down in the thread, you will find Altenbach touch to it Smiley Happy, which i think you could implement directly.

to monitor all doors together, think of utilizing pages.

Good luck!

-----------------------------------------------------------------------------------------------------
... And here's where I keep assorted lengths of wires...
0 Kudos
Message 5 of 9
(3,950 Views)
OK, I have been using LabVIEW for 5 years now and this is the first time that I will be using vi templates. I attached my practice VIs, I think this can help you.
Download All
0 Kudos
Message 6 of 9
(3,909 Views)
I cleaned up the code a bit, but this is basically a good view of how to get to what Daddy-O is needing. The main difference is that he doesn't need to open their front panels, but requires the ability to select one clone and put its FP in a subpanel. The main changes I made were to make the whole thing event driven - which itself cleansed things up - and modified how you open and close FPs. Check the comment I left in the Exit event. Oh yes, I also made the array handling in the timeout event more efficient. Now the array is only modified if a clone is being closed.

Mike...

Certified Professional Instructor
Certified LabVIEW Architect
LabVIEW Champion

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

For help with grief and grieving.
0 Kudos
Message 7 of 9
(3,888 Views)
WOW, this is a pile of great information. It may take me some time to sift through, so I have a thorough understanding of the concepts. I appreciate the help from everyone. Give me a day or two, and I will get back to y'all with what worked best, again, THANKS A BUNCH!!
One should welcome adversity as an opportunity to excel.
0 Kudos
Message 8 of 9
(3,878 Views)
Definitely, I must learn how to use sub-panels. And that's a cool thing that you call event structure. I was conceived and born using LabVIEW Base Packages Smiley Sad.
0 Kudos
Message 9 of 9
(3,849 Views)