LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

single graph, multiple loops

Hello,

 

I have a (hopefully) simple problem with a (hopefully) simple solution. The picture explains it best I think.

 

example.JPG

 

There are three queues firing at different times, thus necessitating three independent FOR loops. I need to be able to plot the output from each FOR loop onto a single graph.

 

Any suggestions?

 

Thanks in advance

0 Kudos
Message 1 of 9
(3,644 Views)
If the queues are being populated at different times, then how is the data supposed to be graphed (never mind for now the technical aspect of its actual implementation)? It obviously can't be a waveform graph or chart, since that requires evenly spaced data. Since it's likely to be an XY chart, what is X? Just the next number in the sequence 1, 2, 3, ... ? But then, if that's the case, then you could use a waveform graph or chart.
Message Edited by smercurio_fc on 06-17-2009 09:11 PM
0 Kudos
Message 2 of 9
(3,634 Views)
Each queued array is the same length, I'm just plotting the array value versus index. I could just use three different plots, one for each queue, but front panel real estate is very limited. It would be nice to combine all three arrays from all three queues onto a single plot. I'm wondering if there is a 'NULL' array type that I can wire to a Build Array VI so that I can use a multiple-plot waveform graph local variable.
0 Kudos
Message 3 of 9
(3,631 Views)

Hey John,

 

OK I looked at the picture and we STILL need a thousand words.  Put each for loop in its own independent structure.  Then they can run in multiple threads.  Right now the while loop you have will not iterate until ALL of the for loops finish.  This style does not make it easy to extend or maintain when the assumption that the arrays have the same number of points becomes invalid (that is, always code around assumptions)

 

Now to break my own advice,  I'm assuming the user REALLY needs the data graphed, and the experiment cannot provide a result based on analysis of the data that you are graphing.  BUT- CHECK THIS ASSUMPTION before we go too far down the wrong road!

 

As I said, before waxing philosophically, your code needs some improvement to abstract the display functionalities and make them less dependent on the UI in this code level.  Or, to restate, you need LVOOP concepts!

 

One of the simplest ways to do this is to use an "Action Engine" to maintain the data in the UI graph.  You can pass a reference to the existing graph into this AE and use "Actions" (methods) "Clear", "Adopt", "Appendto.Plot" etc...

 

In this case I would also think about changing the graph into an "X-Control."  An X=Control allows code to be executed dependent on the action being performed on the data, like an AE but, with better handling of resource when called asynchronously from multiple locations.  For really good advice on how to go this route poke an NI KNIGHT. cus you've gotten out of my league (I know the concepts and theory, I've used X-Controls,  but I lack the amount of practical experience some of these Knights have with the newer powerful LV architectures)

 

Reguardless- keep me posted!  your code looks interesting!

 

 


"Should be" isn't "Is" -Jay
Message 4 of 9
(3,625 Views)

Jeff,

 

Thank you for your advice. I've attached another picture, hopefully it will substitute for 1,000 words! ZFC, ZFM and ZFC are array indicators which I've created local variables from. This code performs exactly what I want, but I know there's a better way forward:

 

example2.JPG

 

I agree that this totally screams of object-oriented concepts, alas I am not experienced with this programming style. Another issue is whether the (UI Server?) will force these graphs to run synchronously, which is unnecessary and may lead to lost data. Hopefully the above helps.

 

Thanks again,

John

0 Kudos
Message 5 of 9
(3,622 Views)

John-

 

I agree!  We need help to solve this and get more experience with LVOOP. IM[very]HO that won't happen if you post code with the dreaded "local variables" and "stacked sequences."  Both of those features are antithietical to LVOOP concepts.  (Why- because they hide funcions rather than abstract them)  but, of course ,you are newer to LV than to programming or you wouldn't be here.  

 

time to poke a Knight! 


"Should be" isn't "Is" -Jay
0 Kudos
Message 6 of 9
(3,619 Views)

I ain't Christian but I'll chime in.

 

If I understand the challenge (plot three data streams to the same display with proper timing) then I suggest you look into using a Waveform data type chart.

 

When the the data type is Waveform the X-postition of the plotted data is determine by the "t0" value of the waveform.

 

If you present an array of Wforms to the chart there do NOT have to be the same number of samples on all of the waveforms.

 

So...

 

Use an AE to store an array of Wforms. THis AE should return the entire array when queuried for presentation.

 

Each of the queue readers will invoke the AE to replace the waveform at thier index, appending to the data if there was already something there from the last update.

 

If the display reads an array that has two of the three Wform elements updated but the third is empty, the chart will just update those plots. The next time, when it get the missing data from the third source that data will be applied to that plot.

 

Summary:

 

Waveform data type charts;

1) Do not have to have the same number of data points.

2) Empty Wforms will not affect previously ploted data.

3) The Wforms can have differnet sample rates.

 

So experiment with "just how much you can get away with" when using waveform data types.

 

Waiting form Christian's opinion,

 

Ben

 

 

Retired Senior Automation Systems Architect with Data Science Automation LabVIEW Champion Knight of NI and Prepper LinkedIn Profile YouTube Channel
Message 7 of 9
(3,568 Views)

Thanks Ben,

 

Insomnia and forumitis do not mix well,  I thought an AE would be the easier way to go but then thought "how elegant to use an X-control" and turn the graph into an event based UI component.  

 

I know I can sleep well with the back-up available!

 


"Should be" isn't "Is" -Jay
0 Kudos
Message 8 of 9
(3,550 Views)

Jeff Bohrer wrote:

Thanks Ben,

 

Insomnia and forumitis do not mix well,  ...


 

My earlier reply sufered from lack of coffee. No need to use the AE, put a local in each of the loops and they build an array of empty waveforms and replace their index with their data. So all three could poke at the chart dircetly and le tthe chart do all of the work.

 

Ben

 

RE Forumitis - Don't be scared. We are all just a bunch of people that want to learn help out and have some fun as we go.

Retired Senior Automation Systems Architect with Data Science Automation LabVIEW Champion Knight of NI and Prepper LinkedIn Profile YouTube Channel
Message 9 of 9
(3,544 Views)