Machine Vision

cancel
Showing results for 
Search instead for 
Did you mean: 

Calling multiple identical subVIs that have an embedded while loop

I have up to now always coded labview in a fairly linear manner.  My applications typically involve one thing happening, then the next, then the next.  However, I now want to do something a bit different, or at least try.

 

The purpose of the VI is to monitor a spinning wheel with a video camera.  Some times we monitor one wheel, sometimes we monitor up to 12 wheels, each with its own camera.

 

I have a parent VI that sets up the parameters for testing (number of wheels, Camera number for each wheel etc).  It then call a subvi that loads the camera settings,and proceeds to 'watch' the spinning wheel and make some machine vision measurements based on the images.  This proceeds for 10 minutes, then the VI does some final calculations and closes and 'passes' the measurement data back to the parent VI.  If there is more than one wheel, it then calls the same VI with the parameters for the next wheel.

 

What I want to do is have the parent VI call many copies of my same subvi at the same time, so that multiple wheels are being monitored at the same time, not one after the other.  I can't figure out how best to do this.  To date I have not used global variables, or libraries in Labview, maybe these would make my problem easier.  When I have needed more than one camera at a time, I have opened and closed them in the same VI; however, in this case I could need as many as 12, making the code really ugly.  

 

I could pull all the timing out of the subvi and move it to the parent VI.  I would also need tomove the open and close camera portion of the subvi to the parent vi.  But this approach will make my code really ugly (which isn't the best to begin with!).   So I am looking for ways to approach the problem..

Cheers,

Andre

 

 

0 Kudos
Message 1 of 3
(2,778 Views)

Hi Andre,

 

First you might want to try asking this in the LabVIEW board as well, since this is really more of a LabVIEW question than one related to Vision...

 

However, I've hit this type of problem before and have a few suggestions. Firstly, if you are going to have a fixed number of sub-VI calls you could always go the traditional route and simply put multiple instances of your sub-VI in parallel on the diagram (making it re-entrant first, of course). However, this doesn't scale too well if you could have lots of simultaneous calls or if you want to run them dynamically. However, it is much simpler than the next method I'll describe.

 

The pattern I typically end up using in those cases is to use VI server. You can have it start running a VI dynamically using a reference and then return before waiting for it to complete (so it is running in the background like a thread). Using that reference you can then interact with the front panel of that VI and do things like set input parameters, poll for completion, and get results.

 

Eric 

Message 2 of 3
(2,776 Views)

Thanks for the advice.  I'll look into the server route....  I have also made a copy of the post on the labview board here

http://forums.ni.com/ni/board/message?board.id=170&message.id=500793#M500793

Lets make that one active.

 

0 Kudos
Message 3 of 3
(2,767 Views)