キャンセル
次の結果を表示 
次の代わりに検索 
もしかして: 

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 件の賞賛
メッセージ11/22
2,026件の閲覧回数
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 件の賞賛
メッセージ12/22
2,023件の閲覧回数
Ok, I have understood, so the solution proposed by GerdW seems correct.
 
Bye
Fabio M.
NI
Principal Engineer
0 件の賞賛
メッセージ13/22
2,004件の閲覧回数
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 件の賞賛
メッセージ14/22
1,993件の閲覧回数
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 件の賞賛
メッセージ15/22
1,973件の閲覧回数


@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 件の賞賛
メッセージ16/22
1,972件の閲覧回数
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. スマイリー ハッピー

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

Randall Pursley
0 件の賞賛
メッセージ17/22
1,973件の閲覧回数


@rpursley8 wrote:

If its OK with you tst, I would like to steal your buffer icon from your example, though. スマイリー ハッピー

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. スマイリー とてもハッピー


___________________
Try to take over the world!
0 件の賞賛
メッセージ18/22
1,960件の閲覧回数

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 件の賞賛
メッセージ19/22
1,932件の閲覧回数
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 件の賞賛
メッセージ20/22
1,927件の閲覧回数