From Friday, April 19th (11:00 PM CDT) through Saturday, April 20th (2:00 PM CDT), 2024, ni.com will undergo system upgrades that may result in temporary service interruption.

We appreciate your patience as we improve our online experience.

LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Plotting "Averaged" Data Every 10 Seconds

Hello! I'm trying to collect a voltage data and average them every 10 seconds then plot the average. I've attached a closed example of the vi I'm working on which is slowing my process. Thanks in advanced!!!!

______________
KowdTek
LabVIEW 2009

One Step At A Time, Maybe Two...
0 Kudos
Message 1 of 8
(3,269 Views)
0 Kudos
Message 2 of 8
(3,252 Views)

You are programming this like text based code, with each frame being a disconnected statement linked via locals. You don't need any local variables at all! Use dataflow!

 

You are using CPU burner loops that consume all CPU doing basically nothing millions of times /second.

 

You need to pace your loops to run them at a define rate, easiest is with a small wait statement. Now there is a fixed relation between [i] and time and all you need is count iterations.

 

Apparently, you don't understand the "built array" node. It does not keep any history, so all you do is converting a scalar to an array with a single element, so the average is the same as the original scalar. You would need to built your array in a shift regsiter or feedback node (or with the accumulator express VI). However, for averaging you don't even need arrays. Simply accumulate the random values in a simple scalar shift register and divide by the number of additions to get the average at each iteration. Reset and chart every X iterations.

 

Here's a simple rewrite of your VI. The loop runs 10x/second and the avarage is charted every 5 seconds. Modify as needed.

0 Kudos
Message 3 of 8
(3,232 Views)

I noticed you said you collected voltages. Then I assume you have some DAQ equipment also. A very common mistake by beginners is that they do the data collection in a software timed loop, reading 1 sample in each iteration. That is not the best approach. The best thing is to let the DAQ unit do the timing and buffering. Then you can relax and just pull data from the buffer then you want it. Go to help in the toolbar and then select "find examples" search for the term "continuous acq"  I think a good example for you to start with is the "Cont Acq&Chart Samples-Int Clk.vi"



Besides which, my opinion is that Express VIs Carthage must be destroyed deleted
(Sorry no Labview "brag list" so far)
0 Kudos
Message 4 of 8
(3,206 Views)

Thanks for the quick replies... But here's another question related to my problem. 

What if the scenario changed instead of time I need to plot the data using distance, every half inch perhaps.

 

______________
KowdTek
LabVIEW 2009

One Step At A Time, Maybe Two...
0 Kudos
Message 5 of 8
(3,185 Views)

KowdTek wrote:

What if the scenario changed instead of time I need to plot the data using distance, every half inch perhaps.

 


But then you would use a paper not a computer or not ? I am sure you have a reason for asking this question. But could you please elaborate your question.



Besides which, my opinion is that Express VIs Carthage must be destroyed deleted
(Sorry no Labview "brag list" so far)
0 Kudos
Message 6 of 8
(3,177 Views)

First, I made the example thinking that I'll be able to relate it to my problem. Here it is, I want to measure how fast a moving object travels by using a device that measure distance and dividing it by time. Let say I'm averaging the collected data every 1 inch then plot it. This is the reason why I asked for another scenario instead of time, I'll use distance. Please bare with me, I'm still new to this.

 

Thanks again.


Coq rouge wrote:


KowdTek wrote:

What if the scenario changed instead of time I need to plot the data using distance, every half inch perhaps.

 


But then you would use a paper not a computer or not ? I am sure you have a reason for asking this question. But could you please elaborate your question.


 

.

______________
KowdTek
LabVIEW 2009

One Step At A Time, Maybe Two...
0 Kudos
Message 7 of 8
(3,166 Views)
Just feel free to ask any question KowdTekSmiley Very Happy


Besides which, my opinion is that Express VIs Carthage must be destroyed deleted
(Sorry no Labview "brag list" so far)
0 Kudos
Message 8 of 8
(3,162 Views)