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.

LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Plotting data from two locations on the block diagram on the same graph

Solved!
Go to solution

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

 

0 Kudos
Message 1 of 13
(3,272 Views)

You can use queues to send data between parallel processes. I've made an example for you below:

 

same plot.png

0 Kudos
Message 2 of 13
(3,252 Views)

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.

 

 

 

0 Kudos
Message 3 of 13
(3,242 Views)

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.

TestCode.png

 

0 Kudos
Message 4 of 13
(3,231 Views)
Solution
Accepted by topic author Kibbles

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.

 

plotTest-1.png

Message 5 of 13
(3,222 Views)

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.

0 Kudos
Message 6 of 13
(3,208 Views)

@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  Smiley Tongue

 

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!



 

0 Kudos
Message 7 of 13
(3,198 Views)
The thing is, you don't need a sequence structure of either kind. You have the data array establishing execution order.

And yes, never use sequence structures of either kind in deliverable code.

Mike...

Certified Professional Instructor
Certified LabVIEW Architect
LabVIEW Champion

"... after all, He's not a tame lion..."

For help with grief and grieving.
0 Kudos
Message 8 of 13
(3,185 Views)

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.

0 Kudos
Message 9 of 13
(3,176 Views)

@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.

0 Kudos
Message 10 of 13
(3,147 Views)