From Friday, April 19th (11:00 PM CDT) through Saturday, April 20th (2:00 PM CDT), 2024, ni.com will undergo system upgrades that may result in temporary service interruption.

We appreciate your patience as we improve our online experience.

LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Making one VI from two

Hey guys,

 

I am very new to labview, have never used it to interface with devices like the ones I am using here.

 

The project is to measure and control the position of a microscope and to capture images from a camera. I have a VI that controls position, and I have a VI that gets an image. Each of these from different sources. However, I would like to make one comprehensive VI that does everything the two individual VIs do. I tried "Merge VIs", but that gave me a lengthy list of errors in the new VI.

 

My question is: What is the best approach to doing this? I do not have to knowledge (yet) to rewrite either of these VIs because they seem complicated, so is there a way to combine these two Vis?

 

Working on windows 10, microscope is an Olympus, camera is X-Cite 120LED Boost. Please let me know if there is any other information that would be useful.

Thanks for any and all help, it is much appreciated.

0 Kudos
Message 1 of 6
(2,711 Views)

Hi Andrew,

 

I can see how you misunderstood "merge VIs". What it actually is meant for is to merge 2 very similar VIs together. Imagine 2 people are editing the same VI, and when they are done, they don't want to lose any functionality, so they can merge the two VIs together and try to keep both of their changes. (easier said than done)

 

What you want to do is call your two VIs as subVIs. Other programming languages would call them "functions" or "subroutines". The inputs and outputs are determined by the connector pane. You must create a new VI, then you can drag and drop (either from a LabVIEW project or even windows explorer) your two VIs onto the block diagram. Of course, how easy it is to get this working will depend entirely on how the two SubVIs are written. I imagine at the least that your stage control will need X and Y coordinate inputs, and your camera grabber will need an image output. 

Message 2 of 6
(2,695 Views)

@AndrewJD wrote:
Please let me know if there is any other information that would be useful.

 


Mostly just the code. 

 

Also helpful would be an explanation of why you want to combine two separate VIs that are already defined to accomplish two independent tasks.  Separating functionality is one of the main purposes of subVIs,  Instead of  combining the VIs, maybe all you need now is an upper level VI that uses a state machine architecture based on user events.  When an event occurs (for instance a button press to move to a specific coordinate), your state machine would then call the "move position" subVI to execute that functionality.  Or when a button is pressed to grab an image, then the "capture image" subVI is called to execute that functionality. 

 

You could even have a functionality defined where the program will move to a certain position, grab an image, move to another position and grab that image, save the images to a location, and email you a link to the files.  This is simple to do with a good state machine architecture and subVIs that are broken down based on their function. 

aputman
------------------
Heads up! NI has moved LabVIEW to a mandatory SaaS subscription policy, along with a big price increase. Make your voice heard.
Message 3 of 6
(2,691 Views)

These are the two files. TopLevel is the stage control, tm481 is camera capture.

 

The purpose of the project is to track bacteria movement under the microscope, so knowing the location of the stage at every image that the camera captures is important. 

 

Thank again.

Download All
0 Kudos
Message 4 of 6
(2,675 Views)

Generally, my recommendation to new LabVIEW Developers is to break big VIs up into lots (20? 40?) of little sub-VIs, each of which does one thing.  Your Top Level VI is already way too crowded (do you notice how much Screen Space it takes?  Strive for "no screen bigger than a modest-sized Laptop Screen", which usually forces you into good Design Choices such as a State Machine or a Queued Message Handler design, where you do things Step-by-Step or do a particular Task when the User pushes a particular Front Panel Control.

 

I saw the words "Active X" somewhere in your code.  I recommend trying to avoid ActiveX if possible (even Microsoft, who invented it, is abandoning it, I understand).

 

Bob Schor

0 Kudos
Message 5 of 6
(2,636 Views)

@Bob_Schor wrote:

 Strive for "no screen bigger than a modest-sized Laptop Screen", which usually forces you into good Design Choices such as a State Machine or a Queued Message Handler design, where you do things Step-by-Step or do a particular Task when the User pushes a particular Front Panel Control.

 


With screens getting bigger and resolutions getting higher i prefer the wording "Aim for 4-6 primitives and no more than 12 in a subVI." - but it's the same idea and goal. 🙂

/Y

G# - Award winning reference based OOP for LV, for free! - Qestit VIPM GitHub

Qestit Systems
Certified-LabVIEW-Developer
0 Kudos
Message 6 of 6
(2,590 Views)