<?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: timing on first iteration wrong in LabVIEW</title>
    <link>https://forums.ni.com/t5/LabVIEW/timing-on-first-iteration-wrong/m-p/2983523#M856465</link>
    <description>&lt;P&gt;As I said,&amp;nbsp;on the very first iteration, the code that executes to check the times is happening in parallel to the code that is doing the time difference calculation.&amp;nbsp; Actually, the error in your time will show up in the Nth iteration when the time differences have happened N times, but you've only executed N-1 waits.&amp;nbsp; The Nth wait is happening in parallel (thus after) the Nth time calculation.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;The next time around you won't see the problem problem because the Nth wait will have occurred before the Nth+1 iteration.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;You need to set up a dataflow dependence (possibly a simple 2 framed flat sequence) in the loop so that the calculations happen after the Wait function.&lt;/P&gt;</description>
    <pubDate>Mon, 08 Sep 2014 16:46:12 GMT</pubDate>
    <dc:creator>RavensFan</dc:creator>
    <dc:date>2014-09-08T16:46:12Z</dc:date>
    <item>
      <title>timing on first iteration wrong</title>
      <link>https://forums.ni.com/t5/LabVIEW/timing-on-first-iteration-wrong/m-p/2983317#M856429</link>
      <description>&lt;P&gt;Hi folks!&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I have a problem with a timer, that gives me a wrong result (only) on the first iteration (see code below).&amp;nbsp; This test code is suppose to measure the time the loop needs to iterate x-times.&lt;/P&gt;
&lt;P&gt;I would expect to get allways the same&amp;nbsp;time difference &amp;nbsp;(i.e.&amp;nbsp; "period" &amp;nbsp;= &amp;nbsp;10 (msec) if the settings used in the screenshot) but in fact, the first iteration results allways in a smaller number -&lt;/P&gt;
&lt;P&gt;but every iteration after the first one yields the right result.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Many thanks for your help in advance!&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Luke&lt;/P&gt;</description>
      <pubDate>Mon, 08 Sep 2014 14:33:31 GMT</pubDate>
      <guid>https://forums.ni.com/t5/LabVIEW/timing-on-first-iteration-wrong/m-p/2983317#M856429</guid>
      <dc:creator>BrainDrain</dc:creator>
      <dc:date>2014-09-08T14:33:31Z</dc:date>
    </item>
    <item>
      <title>Re: timing on first iteration wrong</title>
      <link>https://forums.ni.com/t5/LabVIEW/timing-on-first-iteration-wrong/m-p/2983325#M856431</link>
      <description>&lt;P&gt;Your 1000 millisecond wait until next runs in parallel with everything else.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;So in that first iteration, your intial time stamp, and the one in the case structure will happen very quickly&amp;nbsp;because the comparison code executes very quickly.&amp;nbsp; Only after the wait until next finishes will the loop iterate again.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Also, you are using the wrong wait function.&amp;nbsp; Wait until Next causes the VI to wait only until the system clock reaches a multiple of that value.&amp;nbsp; So if your VI starts 1/2 second into your system clock, the first loop iteration will only take 1/2 second.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;If you used the regular Wait function, then the loop iteration will actually take the full amount of time you are trying to wait.&lt;/P&gt;</description>
      <pubDate>Mon, 08 Sep 2014 14:41:53 GMT</pubDate>
      <guid>https://forums.ni.com/t5/LabVIEW/timing-on-first-iteration-wrong/m-p/2983325#M856431</guid>
      <dc:creator>RavensFan</dc:creator>
      <dc:date>2014-09-08T14:41:53Z</dc:date>
    </item>
    <item>
      <title>Re: timing on first iteration wrong</title>
      <link>https://forums.ni.com/t5/LabVIEW/timing-on-first-iteration-wrong/m-p/2983495#M856459</link>
      <description>&lt;P&gt;Thanks RavensFan, Knight of NI, for the fast response!&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I just exchanges the "wait function". It becomes more stable, but unmasked an additional error. The first iteration is one cycle to short but I don't see why...&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;Let' say, the wait function is set to 500msec: For the first iteration it tells me that the time needed is 4.5 sec- but for each iteration later. If the wait function is set to 1000msec I ' ll get 4sec etc.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Best wishes,&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Luke&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Mon, 08 Sep 2014 16:29:59 GMT</pubDate>
      <guid>https://forums.ni.com/t5/LabVIEW/timing-on-first-iteration-wrong/m-p/2983495#M856459</guid>
      <dc:creator>BrainDrain</dc:creator>
      <dc:date>2014-09-08T16:29:59Z</dc:date>
    </item>
    <item>
      <title>Re: timing on first iteration wrong</title>
      <link>https://forums.ni.com/t5/LabVIEW/timing-on-first-iteration-wrong/m-p/2983523#M856465</link>
      <description>&lt;P&gt;As I said,&amp;nbsp;on the very first iteration, the code that executes to check the times is happening in parallel to the code that is doing the time difference calculation.&amp;nbsp; Actually, the error in your time will show up in the Nth iteration when the time differences have happened N times, but you've only executed N-1 waits.&amp;nbsp; The Nth wait is happening in parallel (thus after) the Nth time calculation.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;The next time around you won't see the problem problem because the Nth wait will have occurred before the Nth+1 iteration.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;You need to set up a dataflow dependence (possibly a simple 2 framed flat sequence) in the loop so that the calculations happen after the Wait function.&lt;/P&gt;</description>
      <pubDate>Mon, 08 Sep 2014 16:46:12 GMT</pubDate>
      <guid>https://forums.ni.com/t5/LabVIEW/timing-on-first-iteration-wrong/m-p/2983523#M856465</guid>
      <dc:creator>RavensFan</dc:creator>
      <dc:date>2014-09-08T16:46:12Z</dc:date>
    </item>
    <item>
      <title>Re: timing on first iteration wrong</title>
      <link>https://forums.ni.com/t5/LabVIEW/timing-on-first-iteration-wrong/m-p/2984609#M856595</link>
      <description>&lt;P&gt;Thanks for the help! I finally made it work by adding a flat sequence as you had suggested. I'd tried this before but I had forgotten to move the clock initializing the feedbacl node infront of the timer ...&lt;/P&gt;
&lt;P&gt;I have attached the final screenshot.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Best wishes,&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Luke&lt;/P&gt;</description>
      <pubDate>Tue, 09 Sep 2014 08:21:42 GMT</pubDate>
      <guid>https://forums.ni.com/t5/LabVIEW/timing-on-first-iteration-wrong/m-p/2984609#M856595</guid>
      <dc:creator>BrainDrain</dc:creator>
      <dc:date>2014-09-09T08:21:42Z</dc:date>
    </item>
  </channel>
</rss>

