LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Inquiring to make Three VIs into one VI with time delay

Solved!
Go to solution

Hello all,

 

I hope you guys are doing well. I am started to study LabVIEW for one week. I am so sorry for the long description.

 

I would like to request to make three VIs into one VI with a time delay. Meaning that I want to mix up all together on the one front panel. 

 

You can see three VIs with attached files

1)Animatic motor -> "smi_example_1"

2)Function generator -> "NF WF1973_74 sample output"

3)Oscilloscope -> "Tektronix DPO MSO 2000 4000 Series Acquire Multiple Waveform Example"

 

I want to run three VIs with a time delay when I click the global start button (I can control each VI respectevely.) Also, I want to control all knobs (ex, motor speed, applied voltage....) on the one front panel. 

The details are as follow:

 

1. When I click the global start button, the oscilloscope (three channels) will start to acquire the three wave functions.

2. after 100 ms, the function generator will apply the voltage to my experimental setup.

3. after 150 ms, the motor will start to rotate.

4. Osiloscope will be stopped after 5 s.

 

I see some examples and questions, Would it be possible to use the sequence and time delay to make three VIs into one VI?

 

I love to get advice or a big picture or recommended example to do this. 

 

Thank you guys, Have a nice day!

 

0 Kudos
Message 1 of 2
(979 Views)
Solution
Accepted by topic author Sunho

Please excuse me -- I have not looked at your code, but will try to answer your question by discussing an important point about LabVIEW that you haven't learned in your one week of study -- LabVIEW operates according to the Principle of Data Flow, which (in LabVIEW terms, means the following:

  • Data (mostly) flows in "wires".
  • Structures (such as Case, While, or other things on the "Structures" Palette), have "Inputs" (typically wires that come into the Structure through its Left edge) and "Outputs" (typically wires that come out of the Structure on its right edge).
  • Functions (the blocks on most of the other Block Diagram Palettes, as well as any sub-VI that you write) also have "Inputs" (again, usually on the left edge) and "Outputs" (usually on the right edge).
  • Data Flow Rule #1:  No Structure or Function starts to execute until all of its inputs have Data (which can include "default values" if the input can be unwired without causing an Error).
  • Data Flow Rule #2:  No Structure or Function can exit until everything inside it has run and any outputs have Data wired to them.
  • Data Flow Rule #3:  No Output of a Structure or Function has data (to pass onward) until the Structure or Function exits.

Note that there are some "advanced exceptions" to these Principles, but as has been said, often "the Exceptions Prove the Rules".

 

So what does this mean?  Assume you have three While Loops, one that (when started) runs the Oscilloscope, one that runs the Function Generator, and one that runs the Motor.  Assume that they are arranged in a "vertical stack", one above the other, have constant inputs (i.e. no Boolean "Start" buttons or "Delay" functions) wired in on the left side, and have outputs that go to unique Indicators.  Which one will start first?

 

If you think about the Principle of Data Flow, the answer is "you can't tell".  What LabVIEW will do is to start these loops running in parallel, and will do its best to keep them running in parallel.

 

So the way to accomplish your goal is to do the following:

  1. Write three Loops to "do the work" of the Oscilloscope, Function Generator, and Motor (that is, the "loop" part, after everything inside the loop as been initialized).
  2. Write three more routines (I recommend you write them as separate sub-VIs -- do you know how to write sub-VIs?) to initialize the Scope, Generator, and Motor.
  3. First test that connecting the outputs of "Initialize Scope" to the inputs of "Run Scope" actually runs the Scope, and similarly the other Initialize routines run their respective "Run" routine.
  4. Now all you need is a "Do when I push the Button" routine in the middle.  Its inputs will be the three sets of controls needed to run the three parallel Scope, Generator, and Motor loops (plus three copies of the Error Line, the principle way LabVIEW serializes routines), and a routine to monitor the "Start" button and let the Controller exit.  When it does, it will send three sets of wires (the Scope Controls + Scope Error Line, Generator Controls + Generator Error Line, and Motor Controls + Motor Error Line) to the three parallel loops.  Now, all you have to do is to put a 100 ms delay on the Generator's Error Line, and a 150 ms delay (unless you meant 150 ms after the 100 ms) on the Motor Error Line, and the three parallel loops will start with the timing sequence you desire.
  5. As I'm sure you realize (if you've been paying attention), you will need to stop all three of these parallel loops to get this routine to stop.  I'm sure if you do a Web search for "Stop Parallel LabVIEW Loops" you'll find a number of ways to do this.

Bob Schor

Message 2 of 2
(936 Views)