LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Calculating Graph Midpoint Using Collector and Averaging

Solved!
Go to solution

Hello,

 

I've been looking for a way to use a waveform graph, adding the capability to set the breadth of the y axis readout while still allowing the chart's focus to follow the data, somewhat.  This is because the auto-centering feature of the graph is jerky, and doesn't allow users to zoom in or out on the plot (which my colleagues have requested).

This is my current solution, posted here essentially because I think I finally got one right, but also because I know you guys will tell me ten ways to do it better.  :%^)

Note that the data here are slow-moving; I think this would get really messy if we were looking at rapidly-fluctuating data, although you could probably "Collect" more data and average it all in the same manner, to set the center of the graph's Y-Axis.

RUNNING AVERAGE.jpg

 

 

The front panel; I set up the three graphs on a Tab control.  (Of course, there were no signals on the data acquisition module when I did this; but at least zero is auto-centered, and the range control works). 

 

RUNNING AVERAGE FRONT PANEL.jpg

 

I guess I'm mostly looking for feedback, and wondering if I missed some obvious way to simplify this process.

 

Thanks,

 

Danielle

 

0 Kudos
Message 1 of 5
(3,073 Views)

Hey Danielle,

 

What you have done looks like a viable solution. Is there an expected center of your data? Right now, you are averaging the last 10 data points. However, I could see that this could get a little choppy if you are continuously moving the center of your plot. You could simply pick a stationary center point and then adjust the range; or you could allow the center point to be a user input.

 

Also, are you indeed using a graph (it is a little hard to tell from the picture). With a graph, there is no history being displayed. The graph only displays the set of data the your provide it. So, each time through the while loop you are clearing the graph and displaying your new set of data. So, it may be better to simply take the entire set of data that you are displaying on the graph, convert it to an array, and find the average; instead of using the Collector to save past data points and then trying to take the average of past data points. 

 

 

Hope this helps.
-Ben

WaterlooLabs
0 Kudos
Message 2 of 5
(3,052 Views)

Thanks for the input, Ben. 

The data is being collected as part of a long-term life testing plan, in which temperatures and voltages are periodically adjusted on components in a thermal chamber, but then held stable for a fairly long period of time (typically a few days).  I'd initially used a slider to set the center of the y-axis readout, but then people would walk up to the screen several hours after the last change and would have to hunt for the plots.  At one point I implemented a switch to permit toggling back to auto-adjust, but then the graph gets too choppy, and you still have no control over the width of the plot (I kept finding it in auto mode, and hearing the same question about whether I'd solved that "zoom" problem with the graph).  This approach kind of tamed both of those beasts, I suppose.

This is in fact a waveform graph, but as a newbie I didn't know how to tackle taking the dynamic data set and turning it into an array and then averaging it.  Guess I can see the first two parts of that, but is there a function that could take the entire set of data that's being passed through the dynamic data wire and average it, without having to use the brute-force approach that I employed here?  If so, I can see that this vi could be reused with more rapidly-acquired and updated data sets, simply allowing the express vi to save the last several hundreds or thousands of samples.  If not, well there'd be some way to reuse the code, but somehow breaking out all those data points individually and then adding and dividing them; it just doesn't sound too appealing, ya know?  :&^)

 

Thank you,

 

Danielle

0 Kudos
Message 3 of 5
(3,048 Views)
Solution
Accepted by danielleoh

Hey Danielle,

 

Given that this is a long term test, are you interested is displaying all of the data from your test or only the most recent set? The waveform chart allows you to save and display historical information as it has a buffer associated with it. From your code, it looks like this collector is just being used to store information so that you can average the last few data points. The only thing that I see standing in your way from simply averaging your data is that it appears that you are displaying two signals on that graph. So, which signal do you want to be centered? If you have one signal that you would like to average to get the center of your graph, you could wire that signal into a Convert from Dynamic Data express VI. When you first put it down, a configuration window will appear. You can then select '1D array of scalars' as the type to convert to. The output of this VI will then be an array of your data points. You can then use the Mean VI to find the average of this 1-D array.

Hope this helps.
-Ben

WaterlooLabs
0 Kudos
Message 4 of 5
(3,045 Views)

Hi Ben,

 

I was already there with using the 1D array of scalars, but deriving that from two waveforms at once (acceptable in this case because in the actual test I am reading temperatures in the same oven onto each graph, so there will be little variation in the two inputs).  The thing I hadn't gotten was that I was using a clumsy 'brute-force' method to achieve a mean, whereas I am now just grabbing the data as it heads into the graph, converting, taking the mean (with the Mean.vi) and performing the remaining math on it as in the previous example.  I like this; it seems like the kind of display option that'll get reused quite a bit.

 

Thanks!

 

Danielle

0 Kudos
Message 5 of 5
(3,021 Views)