10-16-2017 03:54 PM
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!
Solved! Go to Solution.
10-16-2017 04:17 PM
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.
10-16-2017 04:23 PM
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.
10-16-2017 04:59 PM
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!
10-16-2017 05:19 PM
Here is an example of using "User Events" to trigger the event structure.
10-30-2017 12:31 PM
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?
10-30-2017 10:56 PM - edited 10-30-2017 10:56 PM
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.