<?xml version="1.0" encoding="UTF-8"?>
<rss xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:taxo="http://purl.org/rss/1.0/modules/taxonomy/" version="2.0">
  <channel>
    <title>topic Re: averaging streaming data in LabVIEW</title>
    <link>https://forums.ni.com/t5/LabVIEW/averaging-streaming-data/m-p/1041892#M463530</link>
    <description>&lt;P&gt;I do write the file in a different loop by using queues. Their is also a parrallel output loop that gets information based on global booleans written to in the read loop. &lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;The Mean ptbypt VI&amp;nbsp;will only work once I have compiled the data from the previous five loop iterations. Looks like a functional global based buffer is the way to do this (I always call them functional locals, forgot that was the wrong name) .&amp;nbsp;Hoping somebody could point me towards an example of some sort to give me a&amp;nbsp;jumpstart. &amp;nbsp;&lt;/P&gt;</description>
    <pubDate>Thu, 17 Dec 2009 18:03:03 GMT</pubDate>
    <dc:creator>deskpilot</dc:creator>
    <dc:date>2009-12-17T18:03:03Z</dc:date>
    <item>
      <title>averaging streaming data</title>
      <link>https://forums.ni.com/t5/LabVIEW/averaging-streaming-data/m-p/1041879#M463525</link>
      <description>&lt;P&gt;I am taking analog measurements on an SCXI 1102C through a PXI to LV2009. I am running the DaqMx Read 1d Waveform at 100 Samples/second in a while loop that iterates every 45 - 50 ms. This means I get about 5 data points per while loop iteration. Even though the program is windows based, it has a fair amount of determinism built in. I now need to make a decision based on an average of 15 samples, preferably 25 - 50. &lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I can't slow the while loop down because their are other channels&amp;nbsp;in the data that need to trigger things at the quickest rate possible in windows. I can live with the 50 - 100 ms latency for these, but not the 500 ms I would get if I slowed the loop down to perform this new task. &lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;The only two options I've come up with are to use five shift registers on the while loop, but I really don't like this idea. Or open the TDMS file while I am writing this data to it and read the .25 second block that I need to average to make a decision. Also seems like a bad idea. &lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;A third option, I think would be to place a subVI that writes this channel to five different functional locals and constantly updates them creating a running buffer. This doesn't seem like a bad idea, I just haven't figured out how to implement it yet.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Any obviously better options that I'm missing?&lt;/P&gt;</description>
      <pubDate>Thu, 17 Dec 2009 17:44:09 GMT</pubDate>
      <guid>https://forums.ni.com/t5/LabVIEW/averaging-streaming-data/m-p/1041879#M463525</guid>
      <dc:creator>deskpilot</dc:creator>
      <dc:date>2009-12-17T17:44:09Z</dc:date>
    </item>
    <item>
      <title>Re: averaging streaming data</title>
      <link>https://forums.ni.com/t5/LabVIEW/averaging-streaming-data/m-p/1041881#M463526</link>
      <description>I have used Mean PtByPt inside the loop with good results - it is very fast. I write to file in a parallel loop.</description>
      <pubDate>Thu, 17 Dec 2009 17:48:11 GMT</pubDate>
      <guid>https://forums.ni.com/t5/LabVIEW/averaging-streaming-data/m-p/1041881#M463526</guid>
      <dc:creator>Broken_Arrow</dc:creator>
      <dc:date>2009-12-17T17:48:11Z</dc:date>
    </item>
    <item>
      <title>Re: averaging streaming data</title>
      <link>https://forums.ni.com/t5/LabVIEW/averaging-streaming-data/m-p/1041884#M463529</link>
      <description>&lt;P&gt;One of the most common structures is run parallel loops. One loop would handle data acquisition while another loop handles saving to file. This also allows another parallel loop to read the data and make decisions based on that data. It would be reasonable to set up a functional global to use as the buffer for this data.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Another benefit of this type of system is that the loop saving to disk does not have to run at the same rate as the acquisition loop. Makes disk access more efficient if saving data in larger chunks.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp; &amp;nbsp;&amp;nbsp; Rob &lt;/P&gt;</description>
      <pubDate>Thu, 17 Dec 2009 17:53:12 GMT</pubDate>
      <guid>https://forums.ni.com/t5/LabVIEW/averaging-streaming-data/m-p/1041884#M463529</guid>
      <dc:creator>RobCole</dc:creator>
      <dc:date>2009-12-17T17:53:12Z</dc:date>
    </item>
    <item>
      <title>Re: averaging streaming data</title>
      <link>https://forums.ni.com/t5/LabVIEW/averaging-streaming-data/m-p/1041892#M463530</link>
      <description>&lt;P&gt;I do write the file in a different loop by using queues. Their is also a parrallel output loop that gets information based on global booleans written to in the read loop. &lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;The Mean ptbypt VI&amp;nbsp;will only work once I have compiled the data from the previous five loop iterations. Looks like a functional global based buffer is the way to do this (I always call them functional locals, forgot that was the wrong name) .&amp;nbsp;Hoping somebody could point me towards an example of some sort to give me a&amp;nbsp;jumpstart. &amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Thu, 17 Dec 2009 18:03:03 GMT</pubDate>
      <guid>https://forums.ni.com/t5/LabVIEW/averaging-streaming-data/m-p/1041892#M463530</guid>
      <dc:creator>deskpilot</dc:creator>
      <dc:date>2009-12-17T18:03:03Z</dc:date>
    </item>
    <item>
      <title>Re: averaging streaming data</title>
      <link>https://forums.ni.com/t5/LabVIEW/averaging-streaming-data/m-p/1041893#M463531</link>
      <description>&lt;BLOCKQUOTE&gt;&lt;HR /&gt;Robert Cole wrote: &lt;BR /&gt;&lt;P&gt;.....&lt;/P&gt;&lt;P&gt;Another benefit of this type of system is that the loop saving to disk does not have to run at the same rate as the acquisition loop. Makes disk access more efficient if saving data in larger chunks.&lt;/P&gt;&lt;P&gt;Rob &lt;/P&gt;&lt;HR /&gt;&lt;/BLOCKQUOTE&gt;&lt;P&gt;Yep. When creating data fairly quickly like the OP suggested, I like to Queue up 50 or 100 lines of data then write that chunk to disk, with the&amp;nbsp;exception of&amp;nbsp;errors, which get written immediately.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;As far as the averaging goes, the speed suggested doesn't seem prohibitive of putting averaging code inside the data loop, IMO. &lt;/P&gt;</description>
      <pubDate>Thu, 17 Dec 2009 18:04:42 GMT</pubDate>
      <guid>https://forums.ni.com/t5/LabVIEW/averaging-streaming-data/m-p/1041893#M463531</guid>
      <dc:creator>Broken_Arrow</dc:creator>
      <dc:date>2009-12-17T18:04:42Z</dc:date>
    </item>
    <item>
      <title>Re: averaging streaming data</title>
      <link>https://forums.ni.com/t5/LabVIEW/averaging-streaming-data/m-p/1041902#M463537</link>
      <description>So how do you queue the 100 data points when each iteration only outputs 5. Do you read Queue status and wait until it has 100 data points in it and then dequeue?</description>
      <pubDate>Thu, 17 Dec 2009 18:08:57 GMT</pubDate>
      <guid>https://forums.ni.com/t5/LabVIEW/averaging-streaming-data/m-p/1041902#M463537</guid>
      <dc:creator>deskpilot</dc:creator>
      <dc:date>2009-12-17T18:08:57Z</dc:date>
    </item>
    <item>
      <title>Re: averaging streaming data</title>
      <link>https://forums.ni.com/t5/LabVIEW/averaging-streaming-data/m-p/1041911#M463544</link>
      <description>&lt;P&gt;There are a couple of different methods that can be used. If the write loop is running slower than the acquisition loop, then the functional global has to keep a number of samples in it anyway. This allows for more data to work on when averaging.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;The other is to use a running average. I have attached a VI that does that. It is a small functional global on its own.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp; &amp;nbsp;&amp;nbsp; Rob &lt;/P&gt;</description>
      <pubDate>Thu, 17 Dec 2009 18:23:46 GMT</pubDate>
      <guid>https://forums.ni.com/t5/LabVIEW/averaging-streaming-data/m-p/1041911#M463544</guid>
      <dc:creator>RobCole</dc:creator>
      <dc:date>2009-12-17T18:23:46Z</dc:date>
    </item>
    <item>
      <title>Re: averaging streaming data</title>
      <link>https://forums.ni.com/t5/LabVIEW/averaging-streaming-data/m-p/1041942#M463566</link>
      <description>&lt;BLOCKQUOTE&gt;&lt;HR /&gt;deskpilot wrote: &lt;BR /&gt;So how do you queue the 100 data points when each iteration only outputs 5. Do you read Queue status and wait until it has 100 data points in it and then dequeue? &lt;HR /&gt;&lt;/BLOCKQUOTE&gt;&lt;P&gt;Yes, and you can set the Queue size to 100 / preallocate the queue to better manage memory.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Note: Mean PtbyPt is also a FG. I don't see why&amp;nbsp;you can't use this, or the other posted VI, to get your averages.&lt;/P&gt;&lt;DIV class="message-edit-history"&gt;&lt;SPAN class="edit-author"&gt;Message Edited by Broken Arrow on &lt;/SPAN&gt;&lt;SPAN class="local-date"&gt; 12-17-2009&lt;/SPAN&gt;&lt;SPAN class="local-time"&gt; 01:04 PM&lt;/SPAN&gt;&lt;/DIV&gt;</description>
      <pubDate>Thu, 17 Dec 2009 19:04:13 GMT</pubDate>
      <guid>https://forums.ni.com/t5/LabVIEW/averaging-streaming-data/m-p/1041942#M463566</guid>
      <dc:creator>Broken_Arrow</dc:creator>
      <dc:date>2009-12-17T19:04:13Z</dc:date>
    </item>
    <item>
      <title>Re: averaging streaming data</title>
      <link>https://forums.ni.com/t5/LabVIEW/averaging-streaming-data/m-p/1041975#M463584</link>
      <description>&lt;P&gt;Robert, thanks that is perfect. It took me a few guesses and checks to get it to work with a waveform, but that is simpler than what I was chewing on.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Broken Arrow. I didn't realize how the ptbypt works, but now that I do, you can still only put in one data point at a time, unless I'm missing something. While you can wire a waveform to this input, when you do it is only actually looking at the last data point in that waveform packet.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;What I mean is, each iteration of the loop, the Daq Read outputs a certain number of data points. That number is approximately equal to&amp;nbsp;your acquisition rate setting on your&amp;nbsp;DAQ&amp;nbsp;Read, divided by your loop execution rate.&amp;nbsp;In my case, the acquisition rate is 100 Hz while the loop execution rate is about 20 Hz meaning each channel outputs about five points per loop iteration.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;While you can wire a waveform to scalar indicators and scalar inputs like the one on the ptbypt VI, if my data points for&amp;nbsp;a single&amp;nbsp;read of&amp;nbsp;a channel are 1.0, 1.1, 1.2, 1.1, 47.5, then the scalar indicator or input only sees 47.5. (Not that my data looks like this, just giving an example)&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I need to average five sets of those five points. If I do what you suggest I would only be averaging five out of the twenty five points.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;OH, and I swear I'm not giving you a hard time, but in regrads to your other comment this is straight from the help; "max queue size only limits the number of elements in the queue and does not preallocate the queue." You can preallocate to manage memory, but setting setting the queue size on obtain queue is not how you do it. &lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Thanks for all of the help and suggestions. &lt;/P&gt;&lt;DIV class="message-edit-history"&gt;&lt;SPAN class="edit-author"&gt;Message Edited by deskpilot on &lt;/SPAN&gt;&lt;SPAN class="local-date"&gt; 12-17-2009&lt;/SPAN&gt;&lt;SPAN class="local-time"&gt; 01:52 PM&lt;/SPAN&gt;&lt;/DIV&gt;</description>
      <pubDate>Thu, 17 Dec 2009 19:52:02 GMT</pubDate>
      <guid>https://forums.ni.com/t5/LabVIEW/averaging-streaming-data/m-p/1041975#M463584</guid>
      <dc:creator>deskpilot</dc:creator>
      <dc:date>2009-12-17T19:52:02Z</dc:date>
    </item>
    <item>
      <title>Re: averaging streaming data</title>
      <link>https://forums.ni.com/t5/LabVIEW/averaging-streaming-data/m-p/1041983#M463589</link>
      <description>&lt;BLOCKQUOTE&gt;&lt;HR /&gt;deskpilot wrote: &lt;BR /&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;OH, and I swear I'm not giving you a hard time, but in regrads to your other comment this is straight from the help; "max queue size only limits the number of elements in the queue and does not preallocate the queue." You can preallocate to manage memory, but setting setting the queue size on obtain queue is not how you do it. &lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Thanks for all of the help and suggestions. &lt;/P&gt;&lt;DIV class="message-edit-history"&gt;&lt;SPAN class="edit-author"&gt;Message Edited by deskpilot on &lt;/SPAN&gt;&lt;SPAN class="local-date"&gt;12-17-2009&lt;/SPAN&gt;&lt;SPAN class="local-time"&gt; 01:52 PM&lt;/SPAN&gt;&lt;/DIV&gt;&lt;HR /&gt;&lt;/BLOCKQUOTE&gt;&lt;P&gt;That's correct. I did not&amp;nbsp;imply&amp;nbsp;that setting the size of a Queue implicitly preallocates memory. &lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;p.s. Robert's VI&amp;nbsp;takes in a DBL, just like PtbyPt.&lt;/P&gt;&lt;DIV class="message-edit-history"&gt;&lt;SPAN class="edit-author"&gt;Message Edited by Broken Arrow on &lt;/SPAN&gt;&lt;SPAN class="local-date"&gt; 12-17-2009&lt;/SPAN&gt;&lt;SPAN class="local-time"&gt; 02:04 PM&lt;/SPAN&gt;&lt;/DIV&gt;</description>
      <pubDate>Thu, 17 Dec 2009 20:04:29 GMT</pubDate>
      <guid>https://forums.ni.com/t5/LabVIEW/averaging-streaming-data/m-p/1041983#M463589</guid>
      <dc:creator>Broken_Arrow</dc:creator>
      <dc:date>2009-12-17T20:04:29Z</dc:date>
    </item>
    <item>
      <title>Re: averaging streaming data</title>
      <link>https://forums.ni.com/t5/LabVIEW/averaging-streaming-data/m-p/1041994#M463593</link>
      <description>&lt;BLOCKQUOTE&gt;&lt;HR /&gt;Broken Arrow wrote: &lt;BR /&gt;&lt;BLOCKQUOTE&gt;p.s. Robert's VI&amp;nbsp;takes in a DBL, just like PtbyPt.&lt;/BLOCKQUOTE&gt;&lt;DIV class="message-edit-history"&gt;&lt;SPAN class="edit-author"&gt;Message Edited by Broken Arrow on &lt;/SPAN&gt;&lt;SPAN class="local-date"&gt;12-17-2009&lt;/SPAN&gt;&lt;SPAN class="local-time"&gt; 02:04 PM&lt;/SPAN&gt;&lt;/DIV&gt;&lt;HR /&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Sure does, but I was able to change that pretty easily. Just changed the control to a waveform input, picked off the ARRAY of Y values with get waveform components,&amp;nbsp;and then changed the build array to concatenate inputs.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I'm sure the ptbypt could be modified also, but that is a way more complex VI. &lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;BTW, this Running Average VI made my day. I have already thought of dozens of places I could have used this thing over the past year. &lt;/P&gt;&lt;/BLOCKQUOTE&gt;</description>
      <pubDate>Thu, 17 Dec 2009 20:16:37 GMT</pubDate>
      <guid>https://forums.ni.com/t5/LabVIEW/averaging-streaming-data/m-p/1041994#M463593</guid>
      <dc:creator>deskpilot</dc:creator>
      <dc:date>2009-12-17T20:16:37Z</dc:date>
    </item>
    <item>
      <title>Re: averaging streaming data</title>
      <link>https://forums.ni.com/t5/LabVIEW/averaging-streaming-data/m-p/1042024#M463611</link>
      <description>&lt;P&gt;Glad you liked it. We use it in a system with 1kHz sampling and 10 data points per second, so we're averaging 100 samples per channel. It's fast enough to keep up with more than 100 channels.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Build array is not the best choice in dealing with arrays, but sometimes it's the easiest. If it does what you need and makes for easy to understand code, it's done its job.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Have a Happy Holidays.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp; &amp;nbsp;&amp;nbsp; Rob &lt;/P&gt;</description>
      <pubDate>Thu, 17 Dec 2009 21:13:55 GMT</pubDate>
      <guid>https://forums.ni.com/t5/LabVIEW/averaging-streaming-data/m-p/1042024#M463611</guid>
      <dc:creator>RobCole</dc:creator>
      <dc:date>2009-12-17T21:13:55Z</dc:date>
    </item>
  </channel>
</rss>

