LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

passing multiple graphs to sub vi

Solved!
Go to solution

Hello,

 

I'm rather new to labview and could use some advice.  My current project utilizes a for loop to create a graph for the I-V measurements of each sample solar cell (each plot is on a seperate graph).  Multiplexing is done externally via labview control.  I have a subvi to show a sample report to the user before they are prompted to save the report.

 

What would be the best way to pass the data for 6 (or more) graphs to a subvi, and then create the graphs again in the subvi?  I think an option would be to utilize a shift register to concate the arrays from each run.  Unfortunately, the array size is determined by the user at run-time (number of test points on the graph) and I'm not sure if I can seperate the data properly in the subvi.

 

Another question would be can I create an array of the seperate graphs (graph 1 in array element 1, etc.) utilizing the data cluster of each graph as an array element?  I ask this because it seems that data seperation within the subvi would be easier with this method.

 

Thanks in advance for the help.

0 Kudos
Message 1 of 18
(3,317 Views)

OP asked "can I create an array of the seperate graphs (graph 1 in array element 1, etc.) utilizing the data cluster of each graph as an array element?  I ask this because it seems that data seperation within the subvi would be easier with this method.

 

Yes you can! and this is what I would recommend doing for the exact reasons you stated!


"Should be" isn't "Is" -Jay
0 Kudos
Message 2 of 18
(3,310 Views)

A few questions first:

  • Is there a reason you're using 6 different graphs as opposed to just one graph with 6 plots on it?
  • If the subVI is supposed to just show a sample report, can it simply generate random data, or perhaps just use one of the signal processing functions to generate, say, a simple sine wave?
  • What is the purpose of the separation? I don't quite understand what you're trying to do here.

In general, you could just use an array of waveforms (i.e., the waveform data type). This can be used regardless of whether you have 6 independent graphs or one graph with 6 plots.

 

You mentioned you're using a shift register to concatenate the arrays from each run. I'm assuming you're referring to using Build Array. This is generally a bad way to do it since you're likely to encounter memory thrashing as LabVIEW tries to allocate more memory for the array. Since you're told how big the array will be based on the user, you can pre-allocate the array and use Replace Array Subset to fill in the points.

0 Kudos
Message 3 of 18
(3,309 Views)
Hello,

 

Thank you for the quick reply.  Answering your questions in order:

I need the graphs seperate because the number of graphs will vary depending in the number of samples measured (from 1 to 20; user input).  Having 20 plots on a single graph will make it too difficlult to see anything.

 

I suppose I mispoke when I said "sample report".  What is shown, is the report of the collected data to be saved.  This is to allow to user to confirm that the data is correct before saving.

 

What I meant by seperation is that once the data is passed to the subvi (in an array or some other form) I need to once again plot the individual graphs to show them on the subvi front panel.  It is this step of passing the data to the subvi and then creating the graphs on the subvi front panel which I am not sure how to do efficiently.

 

The shift register method is currently just an idea as I don't know if it is a good idea or not.  The reason I mentioned shift register is because each sample is measured in a for loop and the shift register would be an easy way to keep track of previous for loop steps.

0 Kudos
Message 4 of 18
(3,303 Views)

Hello Jeff,

 

Do you know of an example which shows placing clusters within an array?

 

0 Kudos
Message 5 of 18
(3,301 Views)

Hi pjr,

 

you want something like this? A cluster placed in an array?

17665i61F07704C5188F9C

Best regards,
GerdW


using LV2016/2019/2021 on Win10/11+cRIO, TestStand2016/2019
Message 6 of 18
(3,289 Views)
Solution
Accepted by topic author pjr1121

Without seeing the rest of your code you can use either an array of references or just an array of waveforms. If you data for the graphs is not in the form of waveforms then you can simply create the waveform data type using the Build Waveform function. See attached example for the references approach.

 

 


@pjr1121 wrote:
Do you know of an example which shows placing clusters within an array?

 

I don't understand what you're asking here. Are you referring to making an array of clusters? On the front panel or on the block diagram as a constant, or on the block diagram in terms of building an array of clusters programmatically. For the front panel just place an array control, and then drag a cluster control inside the array. Then place the elements of the cluster inside the cluster element. For a block diagram constant it's the same approach. For building it programmatically use Bundle or Bundle by Name and then Build Array or Replace Array Subset depending on whether you're building a new array or replacing an array element.

 

Have you done the LabVIEW tutorials? To learn more about LabVIEW it is recommended that you go through the tutorial(s) and look over the material in the NI Developer Zone's Learning Center which provides links to other materials and other tutorials. You can also take the online courses for free.

Download All
0 Kudos
Message 7 of 18
(3,286 Views)

There is already a Waveform type that contains a Y-array, time between samples (dT) and start time (t0) so you can use that.  Or, you can roll your own if you want (see pic).

LabVIEW Pro Dev & Measurement Studio Pro (VS Pro) 2019 - Unfortunately now moving back to C#, .NET, Python due to forced change to subscription model by NI. 8^{
0 Kudos
Message 8 of 18
(3,280 Views)

Thank you  ,

 

This looks like the solution I was looking for.  Using an array of references (as in your example) will work very well for my application.

 

Also, thank you for mentioning that the online courses are free.  I will look into this.

0 Kudos
Message 9 of 18
(3,270 Views)

Hello once again,

 

After seeing the suggested solutions, I was a bit hasty as I've now encountered a problem.  When trying to implement the method of using a Control Refnum for my XY graphs, I am getting an error that states the refnum are of two different types.  The XY graph on my main VI (connected to express build xygraph vi) is pink (i think this means string type data which seems odd for a chart).  The xy graph in my subvi connected to the control refnum and property node (value) is brown (i'm not sure what data type this is).

 

How can I work around the refnum type problem?  Can the xy graph on my main VI be forced to be the same type as the subvi?

 

Thank you.

0 Kudos
Message 10 of 18
(3,255 Views)