LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Plot multiple functions on the same chart

I have written a program that plots a graph, and I need that graph to have 3 seperate functions plotted on it.  The actual program is for a sound response calibration for a microphone, and I will have 1 function that is the microphone response, 1 function that plots the upper allowable limit and 1 function the plots the lower allowable limit.  Attached are my attempts to get the 2 limit functions plotted on the same graph, and I can't seem to make it work like I want it.  My limits come from a .txt file in a table, and I have a sub.vi that reads and outputs the centerline, as well as how far up and down the data is allowed to go.  I get the upper limit by adding the centerline and the upper tolerance, and I get the lower limit by subtracting the lower tolerance from the centerline. 

 

In the 1st for loop, I tried to plot them both at the same time, and it looks like it plotted both functions, but didn't view them as 2 seperate functions, and I ended up with a sawtooth-type plot instead of 2 plots.

In the second/third for loops, I tried to plot them one at a time using a local variable but that didn't seem to work either, as I still only see 1 plot.

 

The end goal is to get 3 seperate plots (with 3 seperate legend bars!) on the same XY graph.

Thanks for the help : )

0 Kudos
Message 1 of 20
(4,174 Views)

I would suggest you have a look a the following functions:

 

Mask and Limit Testing from  Waveform -> Analog Waveform -> Waveform Measurement ->Waveform Monitoring palette

Limit Test from   Signal Express-> Analysis-> Test and Compare

 

Ben64

 

Message 2 of 20
(4,162 Views)

So I found a "Limit Testing.vi" and it seems like it should do what I need it to, but it has a bunch of other capabilities that I don't need that are making it unweildy for me.  The upper and lower limits are clusters, (and maybe some sort of array?) but I can't get them to work right.  I have no need for a dX or X0 limit, so I've tried multiple ways of just sending the Y max value, but none of them seem to work.

 

I did find a "Max and Limit Testing.vi" that doesn't have dX or Xo inputs, and I got it wired correctly, but when I send it's output to the graph I still end up with only 1 plot.  It will tell me if I am outside the limits, which is useful, but it won't plot the limits. 

0 Kudos
Message 3 of 20
(4,152 Views)

From the picture it looks like you're writing a single point in the xy graph and overwrite it at each iteration.

 

At the bottom of the detailed help of the mask and limit testing vi there is a link to an application example.

 

Ben64

Message 4 of 20
(4,139 Views)

Thanks for your help Ben, I am almost to where I need to be.

 

Using the example, I got the "tested signals" chart (shown in image) to plot the errors correctly, but it is a waveform chart, and I cannot input my frequency values for the X-axis!  ...so that won't work.

I tried the exact same setup with the XY graph, but again, no limits, only 1 plot.

 

This seems like it should be an extremely easy fix, is there no simple way to add a second input to the XY graph?  I don't really need all the extra analysis that comes with the mask and limit testing.vi, and simply adding a second input seems like a basic functionality that the XY graph should have. 

0 Kudos
Message 5 of 20
(4,133 Views)

Have a look at the XY Graph.vi from the LabVIEW examples, it shows how to add multiple plots to an XY Graph.

 

Ben64

Message 6 of 20
(4,120 Views)

Again, Ben, thanks for all your help.

I finally got it working, and attached an image to this post of what I needed to do.

It would certainly make things easier though if you could just expand the XY chart to add inputs just like you can the "build array" functions, though.

0 Kudos
Message 7 of 20
(4,106 Views)

You can also index the Tested Signals output, bundle the indexed outputs with the X values and then build the plot array .

 

Ben64

 

Plot Multiple Functions.png

0 Kudos
Message 8 of 20
(4,094 Views)

ugh, ok I just realized something. 

 

This will work, but I lose the ability to reset the graph when I take away the "build XY graph."

 

So... riddle me this, Batman.  The loop on the bottom of the attached image works, and produces the correct graph with 3 functions plotted (but again, no ability to reset the graph).

The loop on the top, however, won't plot anything at all, it is just blank.  The reset is a control, and when false (it's default setting) it SHOULD work just like the one without the build XY graph... except it doesn't.

 

0 Kudos
Message 9 of 20
(4,085 Views)

My suggestion is to open the front panel of the Build XY Graph express vi and to replicate the code to reset the graph (do not save modification of the express vi). Basically what it does is to reinitialize the graph with an empty array of type cluster of numeric array.

 

Ben64

 

array of cluster of numeric arrays.png

 

note: the inner arrays do not show up well in a snippet!

0 Kudos
Message 10 of 20
(4,076 Views)