LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Linking two VI

Solved!
Go to solution

I'm currently running two VI simultaneously to operate two instruments. Due to the complexity of one of the VI, combining them is still a challenge. Therefore the user starts running one VI, then has to switch manually to the other VI to turn the second VI on. Creating a delay in the data of a couple of seconds.

My question is: is there a way to link the "START" button from one vi, to start the second VI?

Below is a screenshot of how it's operated now. Both buttons in green have to be pressed to collect data from each instrument.

Many thanks for any information!

0 Kudos
Message 1 of 7
(4,369 Views)

You have shown two front panels and circled some boolean buttons, but that doesn't tell us anything about the code. You could make it so that when you press one of the buttons, the mouse moves and clicks the other button as well, but that's really not a good solution. 

 

If the "Start" button triggers and event structure, you could add a user event that gets generated from the other VI.

If the "Start" button is polled to check for changes, you could replace it with a global variable that is set by the other VI.

 

It looks like you are just working with examples now, and might just want a quick fix, but if this is going to turn into software that will be used for any amount of time you should get away from the examples and use the APIs in your own program in a way that allows you to easily start collecting data and add more instruments in the future, if necessary. 

 

 

0 Kudos
Message 2 of 7
(4,350 Views)

Make a top level vi that calls both as subvis?  You'll get some delay, depending on how long the code in each subvi takes to execute before it reaches the part where it collects data.  Direct calls should be faster than users pressing buttons! 😉

 

But if the code is "so complex" that its already hard to integrate things into 1 program you you SHOULD look at a redesign that employs a design pattern and cleans things up.  You should use subvis on your diagram to reduce the block diagram to fill only 1 monitor - i.e. no need to scroll to see everything.

 

Search the labview learning resources for design patterns, State machine, QMH, etc..

 

Or post some code and ask for clean-up suggestions.

0 Kudos
Message 3 of 7
(4,346 Views)

Thank you for the replies, yes I am going for a quick fix to run the VI --- temporarily.

The problem with the VI's is that both have event structures and while loops in their own VI, that when I've attempted to combine them, I can not get the while loops to run simultaneously. The code is posted in this reply. The one titled "ReadProfiles.." runs three lasers (operated by two controllers connected via USB and Ethernet) the other, "ReadArduinoGyro" runs a gyroscope and an accelerometer.

If I can get help in running three while loops (which they all run at different sampling rates), it would be great, or even simplifying the VI's!

Download All
0 Kudos
Message 4 of 7
(4,329 Views)
Solution
Accepted by topic author Joaquinh

Here is an example of using "User Events" to trigger the event structure.

  1. Open the .lvproj
  2. Run VI 1 and VI 2.
  3. Fire the start event by running Start Event.lvlib:Fire Event.vi. Notice how both VIs receive the event at the same time.
  4. Fire the stop event by running Stop Event.lvlibFire Event.vi. Both VIs will stop.

 

Message 5 of 7
(4,317 Views)

Yes, this example is similar to what I want to achieve. Do you have experience with using user events? I've been trying to implement it but has not been working well.


First  program has a event sequence in a while loop which first initializes the sensor, and eventually gets to a start button.

Second program has a while while loop and a start button inside of an event structure.

These two buttons need to be enabled at the same time. Not sure how to add the user event properly... any suggestions?

0 Kudos
Message 6 of 7
(4,244 Views)

Share the code development or Developed VI.

 

With proper architecture its good to go and easy to handle your scenario.

 

Try to learn more about synchronization stuffs.

----------------------------------------------------------------------------------------------------------------
Palanivel Thiruvenkadam | பழனிவேல் திருவெங்கடம்
LabVIEW™ Champion |Certified LabVIEW™ Architect |Certified TestStand Developer

Kidlin's Law -If you can write the problem down clearly then the matter is half solved.
-----------------------------------------------------------------------------------------------------------------
Message 7 of 7
(4,215 Views)