LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

synchronously run both vi

HI all,

      As i am a new to this labview, i have already explored many things here and i need a new and simple idea to learn about synchronously run the both vi.

It was actually i made three vi, one among the three is main vi and the remaining two is sub vi.

1. Main vi

2. process window

3. Header details window

In main window two boolean control button to open a two sub vi whenever it is called and third boolean button is to specify the file location ,i have created something like that for you to understand but i need your step-by-step ideas to make it work perfectly  and also i need to create a logic without specifying the path for a file the process window vi should not run, that i can do it later, first i need to know about this. I have attached you the code to understand what i am telling

Thanks in advance,

Regards,

Dinesh

0 Kudos
Message 1 of 11
(3,203 Views)

Hi Dinesh,

 

what is the purpose of this at all?

 

- Why do you run two VI accessing the very same file in parallel?

- Why do you access/write to a file in a loop without any delay?

- Why don't you put the calling of the subVIs in a loop? So you don't have a chance to call them at runtime…

- Why do you hide the file path control?

- Why do you try to start the very same subVIs using VIServer functions?

- Why is there a TimeOut event when you don't set a timeout value?

- Why do you hesitate to use the AutoCleanup tool?

 

What is this all about???

 

As i am a new to this labview

You're not new: you're a member of this community for about 3 months!

I guess this is lot of time to go through all those free learning stuff provided by NI!

 

 

Best regards,
GerdW


using LV2016/2019/2021 on Win10/11+cRIO, TestStand2016/2019
0 Kudos
Message 2 of 11
(3,196 Views)

Hi, 

    Anyway i have used asynchronous call and notifier method to write a header file and to call the subvi asynchronously now instead of using file path control to specify a file, i need boolean control to specify a file path here how can i do that 

Download All
0 Kudos
Message 3 of 11
(3,158 Views)

Hi butcher,

Is that any method to call a sub vi without stopping the main vi? i need further example on this, i need your idea this one time

0 Kudos
Message 4 of 11
(3,150 Views)

OK, so here is where I reveal the Big Secret and Important Tool for developing good LabVIEW code (you can even use this method for C, C++, Matlab, Python, Pascal, Cobol, etc.) -- get out a piece of paper, a pen (or pencil), and Write Some Documentation.  [You can also use Word, LaTeX, or another "word-y" program of your choice).

 

The idea is to, as simply and clearly as you can, describe (for yourself) exactly what you want to do.  Do not worry about how to do it, just get the mechanics down.

 

In the descriptions that you've given for the current problem, I really have no idea what you are trying to do, except that it involves file I/O.  The title uses the word "synchronously", the last response says "asynchronous", and neither has anything especially to do with File I/O.  Similarly, buttons have nothing to do with File I/O.

 

So what are you trying to do?  You might describe (a) whether you are reading data from a file, writing data to a file, or appending data to a file, (b) the nature of the data, (c) an estimate on the amount (and potentially the rate-of-acquisition) of the data, and (d) any other special considerations (such as "It is important that the File Name is unique" or "I want to embed the Time-of-Day in the File Name" or "I have 13 processes running at the same time and I want each process to save to its own file, distinguishing the files by having them be named "Process #1 Data", "Process #2 Data", etc").

 

When you know what you want to do, it is much easier to start coding.  Conversely, when you do not know what you are doing, you tend to make a mess ...

 

Bob Schor

0 Kudos
Message 5 of 11
(3,145 Views)

Hi Dinesh,

 

please try to keep discussion threads related to one topic per thread.

No need to bring back your already very long discussion (nearly 100 messages right now!) back to top by asking basically the same as in this thread:

Hi butcher, Is that any method to call a sub vi without stopping the main vi?

 

You should have learned by now how & when to create a new thread. And you should have learned by now to provide enough information with your question so we are able to help and answer!

Best regards,
GerdW


using LV2016/2019/2021 on Win10/11+cRIO, TestStand2016/2019
0 Kudos
Message 6 of 11
(3,140 Views)

You already received good advice, the best one is to go back and continue with LabVIEW tutorials.

 

Then decide on terminology. The word "synchronously" means something very differently than what you are talking about. (Hint :Asynchronous run" is the exact opposite!. You would run the two subVIs synchronously if they would start at the same time and all iteration in the two VIs occur in lockstep. But in that case, a single subVI that does both seem more appropriate :D).

Your two run events are identical except for the path name, so why is all the code duplicated? Your lower code runs once when the VI starts and then never again. If the path is important, create an event for path change and ensure that the two subVIs cannot be called unless there is a valid path defined (and unless they are not already running). If you want to redefine the path if the subVIs are already running, you would need significantly more, and more complicated code.

0 Kudos
Message 7 of 11
(3,128 Views)

how can i run a subvi without stopping the mainvi in this example, i've attached here

Download All
0 Kudos
Message 8 of 11
(3,031 Views)

You really need to learn about Version Control Systems and proper naming of Main and Sub-VIs.  A name like "Example2013(2) (1)", where I assume the second (1) is tacked on by Windows as there is already an "Example2013(2)" somewhere on your system (and, indeed, is the name used by the other function, so your code won't load properly), is totally unhelpful.  "Main Example 1" and "SubVI Example 1" are much clearer names.  If you used Subversion, Git, or any other VCS, you could reuse these names as you make revisions without needing (2) (1) suffixes!

 

I'll be back when I can figure out and rename the two VIs you have attached.

 

Bob Schor

0 Kudos
Message 9 of 11
(3,025 Views)

OK, figured it out.  I renamed "Example2013 (1) (1)" to "Main Ex", and "Example2013(2) (1)" to "Sub Ex", opened Main Ex, and reinserted Sub Ex (which couldn't be found using the uploaded code and names).

 

So I look at this code (not having gone back and read the whole Post in its entirety) and say "What is he (or she) trying to do?"  I certainly cannot tell by looking at the code, even with Free Labels there to help.  All that I can say is this is clearly wrong, if for no other reason that it is so obscure!

 

Here's what I think is intended, and here is how I would suggest it be implemented:

  • Analog data is being acquired, probably with Continuous Acquisition (N Channels, N Samples).
  • As the data are coming in, they are being plotted (so that you can "see" the incoming data).  Curiously, they are being plotted using a graph, appending new data to the end of a (potentially-infinite) array of data each time through the loop, rather than be plotted using a chart which auto-scrolls, showing the "latest" arrivals in context.  Depending on the data rate, this could/should be handled by being "pushed" to a Consumer Loop (Producer/Consumer Design Pattern).
  • Another display of the data, possibly under control of a button, possibly with a 200 msec timing property, also seems to be producing a Graph display, though here it appears that this may be a scatter-plot.  Again, data are being accumulated (if it is an evolving scatter-plot, this may be inevitable), but this is also a candidate for being "exported" to another Consumer loop.
  • The Data Acquisition Loop should be a pure Producer loop, taking the output of the DAQmx Read and putting it directly on one or two Queues for export to the Consumer(s).  This Design Pattern will give you two (or three) independent asynchronous loops, one dedicated to acquiring data, one dedicated to charting the incoming data, and (if I understand it) one dedicated to creating periodic scatter-plots of the data.
  • Separating the three different functions into three independent loops will clarify what you are trying to do and, by separating the functions, make it much easier to understandcreate, and maintain your code.

The Producer/Consumer Design Pattern comes installed as a LabVIEW Template, and there are numerous Examples in LabVIEW and on the Web (not to mention this Discussion Group).

 

Bob Schor

0 Kudos
Message 10 of 11
(3,017 Views)