LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

running average



@Kevin Price wrote:

I like your trick of using a hidden chart control as a lossy circular buffer.  Have you done any performance benchmarking on this technique?  I keep meaning to, but perhaps you've already gone down that road...?


I can't see the code, but I suspect that if using the History Data[] property, then LV would need to to a switch to the UI thread to get the data each time.

I wrote an LV2 implementation once which reuses the buffer, so it should be efficient.


___________________
Try to take over the world!
0 Kudos
Message 11 of 22
(1,847 Views)
It is using the History Data property as you assumed and I have not done any type of benchmarking.

It isn't an approach I would use for high-speed/high-volume data applications, but for the type of application discussed here, it is more than adequate.



Message Edited by rpursley8 on 11-01-2006 07:39 PM

Randall Pursley
0 Kudos
Message 12 of 22
(1,844 Views)
Ok, I have understood, so the solution proposed by GerdW seems correct.
 
Bye
Fabio M.
NI
Principal Engineer
0 Kudos
Message 13 of 22
(1,825 Views)
Hi Randall
Thanks for your solution. I have a question: why have you used 2 while loop in your solution? wasn't it more safe to use only once? I mean, with 2 parallel while loop how can you know which one start for first?
Moreover, how could you hide that chart?
Finally, do you think the GerdW solution is a good one?
Thanks again for your time.
Best regards.
I love the smell of napalm in the morning
0 Kudos
Message 14 of 22
(1,814 Views)
why have you used 2 while loop in your solution? wasn't it more safe to use only once?

You are doing two different independent tasks.  With two loops they can run in parallel without one having to depend on the timing of the other.  This way isn't more or less safe than the other.  One task all you are doing is acquiring data.  With the parallel loops, you can change your data rate, reading rate, or any other characteristic of the acquisition without having to worry about the timing of the temp guage readings.  You can also change the update rate of the temp guage without having to worry about the timing of the acquisition.


I mean, with 2 parallel while loop how can you know which one start for first?

They both start about the same time, your temp guage readings will be inaccurate until the 500 point buffer is full (at 200 S/s this would be 2.5 s), but after that everything is fine.  The temp guage is averaging whatever is in the chart buffer at a given time.  Since you are averaging 2.5 s of data every 0.5 seconds, the mean value you compute each time will not 'miss' any acquired data.


Moreover, how could you hide that chart?

If you click the right button on the terminal for the chart on the block diagram, one of the choices is Hide/Show Indicator.


Finally, do you think the GerdW solution is a good one?


His solution works fine.  You will just be updating the front panel temp guage at the same rate you are reading in the acquired data.  If this works OK, then go with it.  Probably the optimum solution is the take GerdW's loop and turn it into a LV2 global and then use the two loop approach.  In one loop you would write to this global and in the other you would be reading from it.  I will post one like this later if someone doesn't beat me to it.



Randall Pursley
0 Kudos
Message 15 of 22
(1,794 Views)


@rpursley8 wrote:

Probably the optimum solution is the take GerdW's loop and turn it into a LV2 global and then use the two loop approach.  In one loop you would write to this global and in the other you would be reading from it.  I will post one like this later if someone doesn't beat me to it.

If I understand correctly, then the VI I linked to in my last post should already do something similar (it's reentrant, so it needs to be modified and have a few actions before it can be used like that).

___________________
Try to take over the world!
0 Kudos
Message 16 of 22
(1,793 Views)
Attached is an example using LV2 globals.  You can initialize to whatever size buffer you want and then read and write data to it.

It is like what tst proposed but this buffer is a little different.  Data comes in chunks, it cannot be resized on the fly without clearing it, and the buffer is not reentrant. 

If its OK with you tst, I would like to steal your buffer icon from your example, though. Smiley Happy

Message Edited by rpursley8 on 11-02-2006 11:08 AM

Randall Pursley
0 Kudos
Message 17 of 22
(1,794 Views)


@rpursley8 wrote:

If its OK with you tst, I would like to steal your buffer icon from your example, though. Smiley Happy

Since I borrowed it myself (see if you can figure out where from), I don't think I have any real right to tell you otherwise. Smiley Very Happy


___________________
Try to take over the world!
0 Kudos
Message 18 of 22
(1,781 Views)

Getting back to the "hidden chart control as lossy circular buffer" thing...

When I get around to it (unless someone else tries this out first, hint, hint), I'd still kinda like to do some benchmarking where the data is extracted using a "Read"-type local variable copy of the chart instead of with a "History" property node.  That would avoid the context switch into the UI thread.

-Kevin P.

ALERT! LabVIEW's subscription-only policy came to an end (finally!). Unfortunately, pricing favors the captured and committed over new adopters -- so tread carefully.
0 Kudos
Message 19 of 22
(1,753 Views)
The local variable of a chart would only output the last value written to it (it is a numeric value), not the whole array of data displayed in the chart or am I misnunderstanding what you mean.

Message Edited by rpursley8 on 11-03-2006 01:23 PM

Randall Pursley
0 Kudos
Message 20 of 22
(1,748 Views)