LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

real time waveform graph in while loop

Hi

I have a VI which includes a subVI that reads data from an oscilloscope and presents the output in the form of a cluster made up of the initial time t(0), a time interval delta t and an array of voltage readings.

This cluster can then be wired to a waveform graph in the usual way. All of this is situated within a while loop in my VI and on each iteration of the loop I obtain a waveform graph of the voltage readings starting at the same time t(0) and ending at the same time t. However I want my graph to begin at a time t(0) when I set my VI running and then continuously acquire and build up the data on each iteration of the while loop so after my VI has finished executing I have a complete graph of all the voltage readings acquired after the set number of iterations of the loop. I know on the Express X-Y Graph VI you can double-click the node and deselect the box that says 'clear data on each call' - if I could do this in my case that would be great but I can't use an x-y graph because I have an array of y-values to plot on each iteration.

If anyone can help me out it would be much appreciated - I'm sure there must be an easy solution to this but I'm going out of my mind trying to find out what it is!

Many thanks,

Bex.
0 Kudos
Message 1 of 16
(16,529 Views)
As usual, you have several options.

  1. You can use an XY Graph by generating the X values yourself. This will ensure that you place the data exactly where you want it on the X axis. This is fast, but does involve a memory cost.

  2. You can use a Waveform Graph with a waveform input instead of the cluster you are using. Use the Build Waveform primitive instead of the bundler to make your waveform. Set the t0 values to the appropriate values (negatives do work, as do small numbers - time is in seconds, use the To Time Stamp primitive to convert from DBL to timestamp). Finally, you need to set the Waveform Graph to use the t0 values. Pop up on the Waveform Graph and make sure Ignore Time Stamp is not checked. Depending on your version of LabVIEW, you may have to pop up on the graph or the axis. When you unselect Ignore Time Stamp, you will probably want to reformat the X-axis again. The Waveform Graph clears data at each iteration, so you will need to replot all your data each time. Just create an array of waveforms and keep adding to it. The t0s will put the waveforms in the right places. Yes, this may cause memory problems.

  3. Finally, you can use the Waveform Chart, which does have memory. Create the waveforms like you did for the Waveform Graph and send them to the chart. It will remember what was sent to it from run to run. Make sure you set the Chart History Length (pop up on chart and select Chart History Length...) to long enough to hold your entire data. You can use a property node to get the data back at the end, if you need to.

Good luck!
Message 2 of 16
(16,504 Views)
Thanks for your advice, it's much appreciated!

I'll try them out and hopefully I'll then have everything working correctly!

Bex.
0 Kudos
Message 3 of 16
(16,496 Views)
Hi Bex,

Hope this will help. Maybe I didn't quite understand what you were saying. There is a vi attached which might be what you are looking for. If not reply and maybe attach some of your code so I can have a look at it for you.

regards,

Seamus
0 Kudos
Message 4 of 16
(16,496 Views)
Hi Seamus

Unfortunately I only have LabView 7.0 on my PC so I can't open the VI you attached!

Thanks anyway though,

Bex.
Message 5 of 16
(16,491 Views)
Hi Bex,

It might work now!

chat soon
0 Kudos
Message 6 of 16
(16,472 Views)
I'm trying to accomplish a similar task. I downloaded the sample code “indexing.vi” to try and it has the same problem that I’ve been trying to fix. The X-Axis is NOT time, but the index number of the sample. When you change the timer constant to 1000, you get ‘elapsed time’ but that’s only by coincidence. Does anyone know how to get the X-Axis of a waveform chart to display the elapsed time? I have a slow sampling system where we only sample every 10 seconds or so. I write all the values to a spreadsheet file, but I can’t get the chart to read correctly. I’ve tried X-Y charts without much luck as well.
0 Kudos
Message 7 of 16
(16,405 Views)
scubadude,

You need to specify your sampling period for the chart, because in the absence of any user specification, the chart assumes a starting time of 0 and a sampling period of 1. You can change this in one of two ways:

1. Right-click on the X axis and choose Formatting (or right-click the chart itself and choose X Scale >> Formatting). On the Scales tab, select the X axis and then input your sampling period under Scaling Factors where it says Multiplier, and is 1 by default.
2. Programmatically, you can create a Property Node for the chart by right-clicking. Then select the X Scale >> Offset and Multiplier >> Multiplier property and wire your desired samping period into it.

Hope that helps,
John
0 Kudos
Message 8 of 16
(16,394 Views)
Since first posting this question I have now managed to build a VI that plots the mean of the voltage readings from my oscilloscope as a function of elapsed time. Basically I use an X-Y graph along with an 'elapsed time' node and the whole thing is contained within a while loop. The mean value of the voltage is wired to the Y-input of the X-Y graph and the elapsed time is wired to the X-input. You have to remember to double-click on the X-Y graph on the block diagram and deselect the 'clear data on each call' box.
0 Kudos
Message 9 of 16
(16,379 Views)
Johnner,
I understand the need to set the x-axis rate. I’ve managed to do that part. As I read Bex’s last comment I realized that I’m trying to do something a bit different. Whether it is the correct method remains to be seen. Here is my situation.

I have a test where I record about 8 values every 15 seconds (written to a spreadsheet file) The test lasts about 4 hours. I would like to plot the data I’ve recorded in real-time on a chart/graph so we can monitor performance. The x-axis of this plot is the ‘elapsed time’ that I’ve recorded in the file. I originally used the Datalogger to Spreadsheet.vi example with some small modifications. It actually worked pretty well. Unfortunately, I’ve changed to a Fieldpoint system that doesn’t allow ‘virtual’ channels. In addition, I also needed to be able to switch between different inputs, which the original vi would not let me do easily. I’ve been trying to record the data to spreadsheet file and at the same time update a chart with the same wire. If I use an X-Y graph, I get the x-axis right, but only 1 data point in the Y-axis. If I use a chart, I either get all the data plotted sequentially across my graph (i.e. each channel plotted with one line vs. time) or all the channels plotted separately as a different line, including time vs. current time.

This seems like it should be simple, but I’ve been messing with this for quite a while.
0 Kudos
Message 10 of 16
(16,358 Views)