LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

How to add indicators from subVIs to main VI

Hi,

 

I have a similar problem as well as a question or two about running subVI's.  Basically, I am trying to create a project that will use both syringe pump injections and the opening and closing of valves to transport a fluid.  As of now, I have a program written for the syringe pump that I was able to modify from an instrument driver from the manufactuer of the syringe.  The goal is to just have the operator press a single run button, as all volume and flow rate conditions will stay the same from trial to trial.  I created two separate syringe pump suvbVI's, one injects 1mL of fluid at 1mL/min and the second injects 2mL of fluid at 1mL/min.  

 

I want to use the flat sequence structure to run these two subVI's sequentially, which I am having some difficulty with.  I set this up so that the operator must press an "OK" button in order for the case structre to read "true" and begin the operations in the flat sequence.  Both subVI's work correctly if operated on their own.  However, when I use the highlight data flow function (lightbulb on block diagram) I can see that pressing the OK button causes the case structure to read true, and the program to engage the first subVI.  Upon opening the block diagram of the first subVI and using the same lightbulb tool, I noticed that the information is getting stuck in the first while loop and repeating itself endlessly.  Any suggestions as to why this may be the case?  (I did go into each subVI and changed the VISA resource name to the correct COM port)

 

Also, once I figure out how to get the information to flow correctly, I do want my main VI front panel to display some of the front panel indicators on the syringe pump VI's, such as the volume dispense and tank.  I would like to know more information about how to reference a wire to the subVI as previously mentioned in this thread.

 

Sorry this was such a long post!  I attached the main VI with the embedded syringe pump subVI's as well as both individual subVI's.  Any suggestions would be greatly appreciated!

Thanks

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

I was actually able to answer my own question for part of this and get the system to run!  The whole flat sequence works which is great, now I just need to know how to view the indicators on the main VI's front panel.  Basically, from the subVI's I'd like to include the "Status" with the different LEDs for infusing...etc, the tank, as well as the volume dispense.

 

In an older thread I read through, someone mentioned being able to put the indicators on the main VI's block diagram and then wiring a reference to the subVI's.  Does anyone have any more information or can elaborate on how to do this?

 

Again, any feedback and greatly appreciated, thanks!

0 Kudos
Message 2 of 10
(4,886 Views)

in this thread I explained on emethod of accessing FP objects from sub-VIs.

 

Hopefull that post willl inspire you.

 

Ben

Retired Senior Automation Systems Architect with Data Science Automation LabVIEW Champion Knight of NI and Prepper LinkedIn Profile YouTube Channel
0 Kudos
Message 3 of 10
(4,873 Views)

This impressed me a lot Ben.. Thanks.. I have used the bundling of ref but never checked whether it is valid..

-----

The best solution is the one you find it by yourself
0 Kudos
Message 4 of 10
(4,853 Views)

@P Anand wrote:

This impressed me a lot Ben.. Thanks.. I have used the bundling of ref but never checked whether it is valid..


 

When adding a new widget to the collection of FP objects, I sometimes forget to actually wire-up the ref. it has saved me time on more than one occation.

 

I hope it helps you,

 

Ben

 

Retired Senior Automation Systems Architect with Data Science Automation LabVIEW Champion Knight of NI and Prepper LinkedIn Profile YouTube Channel
0 Kudos
Message 5 of 10
(4,840 Views)

I have to follow the same thing as you have shown by using the AE for ref before I was using shift register but that became clumpsy at some point. It would be better if we are able to see all the Nuggets posted by you, and others because my belief is these simple things will make us a very good programmer (Sorry for speaking irrelevant to the topic)

-----

The best solution is the one you find it by yourself
Message 6 of 10
(4,831 Views)

Hi Ben,

 

Thank you for providing the link to the example, unfortunately for me I think it is a bit above my skill level at this time.  I read through the example as well as the Nuggest on AE's but am still having a lot of difficulty understanding what is going on in the example, as well as how it relates to my program.

 

Is there anyway you could possibly elaborate or simplify how to reference my front panel items in my subVI's to my main VI front panel?  I plan on using the flat sequence to sequentially run each subVI.  That means that the indicators for the first subVI (which is a syringe pump) should be the same indicator that is just updated when it gets to the next syringe pump subVI.

 

Maybe someone could possibly elaborate on what "collecting all the refs I will need and bundle them in a type def" from Ben's example means?  My program is pretty simple, and there isn't a lot to it other than the syringe pump and valves so I'm hoping for as simple a solution as possible.  I will be using a max of maybe 10 subVI's when the whole project is complete.

 

Thanks!

0 Kudos
Message 7 of 10
(4,802 Views)

galXE1, 

 

A much easier solution would just be to pass the data back to the main VI and write to the same indicator. You could move all your loops to the main VI and leave all the calculations in sub VIs. Then use a state machine to pass the values switch between which subvis are writing to the indicator. You can use something simple as a local variable to pass information back and forth. 

 

Or you could create a reference to the running VI and get the values for the indicators using an invoke node. See my attached VIs. I need to reintialize the stop condition of the loops each time it runs. 

Kyle Hartley
Senior Embedded Software Engineer

Download All
0 Kudos
Message 8 of 10
(4,778 Views)

Hi Kyle,

 

Thanks for the example code, I've been trying to work with that for the past couple of days to make it work for my program.  The tank you used is great because it's exactly what I had as an indicator in my example.  My question is though how do I add other indicators.  For example, I also want a status bar from the syringe pump subVI to display on my main VI.  I see that the tank connects to the "variant to data" VI, however I am not sure how to add other indicators from my system.  Where/how would I wire those into this system?  Would I have to repeat the whole program (all the property and invoke nodes) for each indicator I want to reference?

 

Also, could you possibly expand on what you mean my "moving loops in main vi and leaving the calculations into the subVIs"  Originally it sounded like it would be the simplest solution to me, but I wasn't really sure how to go about actually programming and wiring it.

 

Thanks again for providing the example!

0 Kudos
Message 9 of 10
(4,753 Views)

galXE1,

 

From my example you can use the invoke node method of "get all" and it will retrieve all the indicator names and values and then you can get the values you want. 

 

Sorry for not posting this originally but without modifying your code a bunch your quickest option is to use shared variables. If you have important vital tasks they aren't the best but if you're just looking to pass data between vi's then they are you're easiest option. 

 

Creating a Shared Variable - look at single process shared variable section. 

http://zone.ni.com/devzone/cda/tut/p/id/4679

 

So you basically call your subvi every time the loop iterates to perform some execution and then you can update your main front panel with the newest values. Calling the subvi with a loop in it. Nothing special but it gets the job done. Its not very good practice if you have a bunch of values you want to pass. 

See subvi calculations.jpg

 

A better approach to passing data between vi's is detailed in the document. Its called a Functional Global Variable. 

https://decibel.ni.com/content/docs/DOC-12876

Kyle Hartley
Senior Embedded Software Engineer

0 Kudos
Message 10 of 10
(4,737 Views)