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.
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.
01-19-2016 11:46 AM
Hi everyone,
I'm trying to plot data from two seperate processes on one graph. These processes occur in sequence.
I've developed several solutions, none of which produce the result I want. What I want is for the data to be plotted in real-time as each process executes.
The two processes are functionally identical - a single 'for' loop. With each iteration of these loops, a datum is produced and plotted.
The data is plotted in real-time, meaning that each datum appears on the graph as soon as it is produced.
However, I am not able to get the data from the second process onto the same graph in the same manner.
The closest I've gotten is associating the graph with a local variable. This allows the data for both processes to be plotted in real-time, but the second set of data overwrites the first.
I've attached a very simple test VI demonstrating my problem.
Any help with this would be greatly appreciated.
Thank you
Solved! Go to Solution.
01-19-2016 12:36 PM - edited 01-19-2016 12:36 PM
You can use queues to send data between parallel processes. I've made an example for you below:
01-19-2016 12:43 PM
The real issue you are having is the express VIs. If you open the front panels of them and dig into the code you will see that they are using local variables. So express VI one builds 1 graph and it has a local variable and then the second creates a totally different graph and local.
I would suggest looking at how the express VIs add data to XY graphs and do it manually, at least in the second loop.
See the attached.
Note: I really think there are MUCH better ways to share the data from one sequence to another. First off I would totally remove the read local and just pass the data from one sequence to the next. So in your real applicaiton you may want to look very carefully at the local usage.
01-19-2016 12:50 PM
Thank you for the reply, but my processes necessarily occur in sequence.
I need the data produced with each iteration of both loops plotted to the same graph.
I had hoped that using local variables would solve the problem, but the data from the second loop overwrites that of the first.
This is an image of the test code I attached, which is the simplest demonstration of the problem that I could produce.
01-19-2016 01:05 PM
You can do something like this. Is the second process just a continuation of the first? If so, it becomes even easier and you can just keep building array in the second loop.
01-19-2016 01:26 PM
This worked exactly as intended, thank you!
I do have a few remaining questions, though.
I copied the 'Build XY Graph' express VIs out of extant programs. You were able to put together a functional graph without them, so what exactly to they do?
Also, in my actual program, I'll be using a stacked sequence structure. I can pass data between frames in this way simply by using a sequence local, correct?
Thank you again for your time.
01-19-2016 01:38 PM - edited 01-19-2016 01:39 PM
@Kibbles wrote:
I copied the 'Build XY Graph' express VIs out of extant programs. You were able to put together a functional graph without them, so what exactly to they do?
I'm not sure, I think they just make things confusing by using dynamic data
Also, in my actual program, I'll be using a stacked sequence structure. I can pass data between frames in this way simply by using a sequence local, correct?
I'm also not familiar with stacked sequence structures, I've always been told to stay away from them!
01-19-2016 01:50 PM
01-19-2016 02:02 PM
My test code doesn't require the sequence structures, but my actual code does.
It involves the operation of and data acquisition from multiple instruments. Orchestrating this requires multiple intricate sequences.
I chose stacked sequence structures because each fram is massive, and very little data is passed between frames.
01-19-2016 02:51 PM
@Kibbles wrote:
I chose stacked sequence structures because each fram is massive, and very little data is passed between frames.
Have you thought about using subVIs instead? It would make the code much more readable.