Multifunction DAQ

cancel
Showing results for 
Search instead for 
Did you mean: 

Dynamically stack plots while preserving chart history?

I want to adjust a waveform chart output so that the number of plots matches the number of channels selected by the user for data acquisition. I've discovered that it is not possible to programmatically select "stack plots" for the waveform chart. I tried using the recommended VI "DynamicStackPlots.vi" (modified to display waveform data rather than scaled array data) and this almost works, however only one buffer of data is displayed at any given time - there seems to be no history data displayed on the chart. Do I need to somehow save the history data or is there another solution?
0 Kudos
Message 1 of 6
(3,044 Views)
Hi Nbaker,

Are you using charts or graphs? A chart will maintain a history of data, whereas a graph will not. See the following KB: What Is the Difference between Graphs and Charts in LabVIEW?

If this isn't what you're having problems with, please let us know!

Have a good one,
Travis H.
LabVIEW R&D
National Instruments
0 Kudos
Message 2 of 6
(3,032 Views)
Hi Travis,

Yes, I am using charts. I've attached an example of the code that I got from the website and modified (which is similar to my problem). I'm using LabVIEW 7.0 student edition. Run the code as is to see how the example initially worked. Then in the block diagram inside the for loop, wire the sine waveform to the cluster bundle function (and delete the wire from the sine array). Now the sine wave appears only in small increments in the chart.

I was wondering if this had to do with history data, but when the waveform chart is in a cluster inside an array, history data is not of the properties that you can access. See the following discussion forum link:

http://forums.ni.com/ni/board/message?board.id=170&message.id=45280&requireLogin=False

I tried some of the suggestions posted here, but I cannot get this to work for my application because the waveform chart is not only in a cluster, the cluster is also in an array. Again, I don't even know if this problem has to do with history data of the chart.

Thanks!
0 Kudos
Message 3 of 6
(3,026 Views)
Hi Nbaker,

The difference in the plots is a direct result of the difference in how the two VIs (Sine Wave.vi & Sine Waveform.vi) calculate the data output.

Sine Wave.vi:
The Sine Wave.vi does not have timing information built into the data array output. Therefore, there is only a pseudo "frequency" based on how may data points make up a single cycle of the sine wave (frequency is the frequency of sine wave in normalized units of cycles/sample). In this case, the frequency is set to .01, and thus 100 points are needed to represent a single cycle. And since samples is set to 128, this ensures that one 1.28 cycles of the sine wave are output with each iteration/plot.

Sine Waveform.vi:
The Sine Waveform.vi DOES have timing information built into the data output. Therefore, you can have a true signal frequency that is independent from the sampling frequency. In this case, the signal frequency is set to .01 cycles/second (remember, this is different than the .01 frequency of the Sine Wave.vi). Also, there is a sampling information input to the Sine Waveform.vi, which the default is Sampling Frequency = 1000 and Number of Samples = 1000. Since you haven't wired anything to this input, the default values are used. So, each iteration, 1000 data points are output (Number of Samples = 1000) from the Sine Waveform.vi, which represents 1 second (Sampling Frequency = 1000 pts/sec) and .01 cycles of the sine wave signal (signal frequency = .01).

This is why you are receiving much different results between the two data sets!!

Hope this helps,
Travis H.
LabVIEW R&D
National Instruments
0 Kudos
Message 4 of 6
(3,015 Views)
Hi Travis,

I understand that the two types of data are different. In my application, I am using waveform data. What I still don't understand is how to use the idea of the "dynamic stack plots" vi (to automatically adjust the number of charts that appear on the display) with waveform data, and get the data to stay displayed on the chart for as long as the program is running. Were you able to get my modified vi to run with waveform data and keep the chart history displayed?

Thanks,
Nicole
0 Kudos
Message 5 of 6
(3,008 Views)
Nicole,

I had to look at the vi for a while to figure out why it wasn't plotting the historical data and then I realized that the charts in the array weren't charts, but actually graphs that were labeled as charts. It turns out that you can have an array of clusters of graphs, but NOT and array of clusters of charts. I haven't been able to figure out the reasoning behind this, but because of it, you won't be able to plot historical data directly with the graph. You have a couple of options though. One is to add each iteration of data to previous data through shift registers and plot all of the data on the graph each iteration of the loop. The other is to use charts (which will give you historical data directly), but have several of them on the front panel (hidden) and only expose them as the user requests more charts to be visible with the "number of stacked plots" control.

I hope this information helps you out!

Tyler S.
0 Kudos
Message 6 of 6
(2,997 Views)