<?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: Dead loop in formula node in LabVIEW</title>
    <link>https://ni.lithium.com/t5/LabVIEW/Dead-loop-in-formula-node/m-p/612789#M284792</link>
    <description>&lt;DIV&gt;&lt;/DIV&gt;
&lt;P&gt;Look, I am far out on a limb here, because I am not a C programmer. Whatever you're doing would make more sense from a FORTRAN point of view. &lt;span class="lia-unicode-emoji" title=":slightly_smiling_face:"&gt;🙂&lt;/span&gt;&lt;/P&gt;
&lt;P&gt;The LabVIEW formula node uses BNF notation (check the help), which is in many ways C like. So the syntax for a FOR loop is:&lt;/P&gt;
&lt;P&gt;for ( InitExpression ; CondExpression ; LoopExpression ) Statement &lt;/P&gt;
&lt;P&gt;This means the loop iterates until "CondExpression" is true.&lt;/P&gt;
&lt;P&gt;Do a google search on "C For loop" and you might find for example pages like:&lt;/P&gt;
&lt;P&gt;&lt;A href="http://www.hitmill.com/programming/cpp/forLoop.htm" target="_blank"&gt;http://www.hitmill.com/programming/cpp/forLoop.htm&lt;/A&gt;&lt;BR /&gt;&lt;A href="http://www.geocities.com/learnprogramming123/Clesson8Beginner.htm" target="_blank"&gt;http://www.geocities.com/learnprogramming123/Clesson8Beginner.htm&lt;/A&gt;&lt;/P&gt;
&lt;P&gt;Your &lt;STRONG&gt;condExpression&lt;/STRONG&gt; is "n1-1", which, &lt;U&gt;during the execution of the node is a constant&lt;/U&gt;. For example if you array size is 50, n1-1=49, FOREVER! The condition is never true so the loop will never stop.&lt;/P&gt;
&lt;P&gt;I hope somebody more knowledgable will chip in at one point. &lt;span class="lia-unicode-emoji" title=":slightly_smiling_face:"&gt;🙂&lt;/span&gt;&lt;/P&gt;</description>
    <pubDate>Fri, 16 Nov 2007 17:28:51 GMT</pubDate>
    <dc:creator>altenbach</dc:creator>
    <dc:date>2007-11-16T17:28:51Z</dc:date>
    <item>
      <title>Dead loop in formula node</title>
      <link>https://ni.lithium.com/t5/LabVIEW/Dead-loop-in-formula-node/m-p/612399#M284671</link>
      <description>&lt;DIV&gt;Hi, &lt;/DIV&gt;
&lt;DIV&gt;&amp;nbsp;&lt;/DIV&gt;
&lt;DIV&gt;I have encountered the following problem in a formula node. Everything seems simple and right. But there is no output and the loop goes on forever. The sizes of both input arrays are the same. Need your advice. Thanks.&lt;/DIV&gt;
&lt;DIV&gt;&amp;nbsp;&lt;/DIV&gt;
&lt;DIV&gt;Rut&lt;/DIV&gt;
&lt;DIV&gt;&amp;nbsp;&lt;/DIV&gt;
&lt;DIV&gt;&amp;nbsp;&lt;/DIV&gt;</description>
      <pubDate>Fri, 16 Nov 2007 03:12:08 GMT</pubDate>
      <guid>https://ni.lithium.com/t5/LabVIEW/Dead-loop-in-formula-node/m-p/612399#M284671</guid>
      <dc:creator>Rut</dc:creator>
      <dc:date>2007-11-16T03:12:08Z</dc:date>
    </item>
    <item>
      <title>Re: Dead loop in formula node</title>
      <link>https://ni.lithium.com/t5/LabVIEW/Dead-loop-in-formula-node/m-p/612449#M284689</link>
      <description>&lt;DIV&gt;&lt;/DIV&gt;Are you sure you want the &lt;U&gt;test condition&lt;/U&gt; of the FOR loop to be "n1-1"? this in a neverchanging condition and will always be false. try e.g. "n1-i" or whatever is appropriate.</description>
      <pubDate>Fri, 16 Nov 2007 06:46:03 GMT</pubDate>
      <guid>https://ni.lithium.com/t5/LabVIEW/Dead-loop-in-formula-node/m-p/612449#M284689</guid>
      <dc:creator>altenbach</dc:creator>
      <dc:date>2007-11-16T06:46:03Z</dc:date>
    </item>
    <item>
      <title>Re: Dead loop in formula node</title>
      <link>https://ni.lithium.com/t5/LabVIEW/Dead-loop-in-formula-node/m-p/612778#M284790</link>
      <description>&lt;DIV&gt;Hi, &lt;SPAN style="FONT-WEIGHT: bold; COLOR: #666666"&gt;altenbach,&lt;/SPAN&gt;&lt;/DIV&gt;
&lt;DIV&gt;&lt;SPAN style="FONT-WEIGHT: bold; COLOR: #666666"&gt;&lt;/SPAN&gt;&amp;nbsp;&lt;/DIV&gt;
&lt;DIV&gt;&lt;SPAN style="FONT-WEIGHT: bold; COLOR: #666666"&gt;I still don't see why the n1-1 is neverchanging condition. I think my question was clear enough. The restated question is: I have this loop in a system and every 100ms when data (about 100points for each array) come in, the formula node is called to do some calculation and output to 2 arrays of the same amount of data points. I tested the formula with 4 points of data in each array and it never ended. I couldn't see anything that could go wrong with inside statements. Need somebody's advice. Also, wondering how to debug formula and script nodes, and how to debug general Labview programs. The inside statements are as follows:&lt;/SPAN&gt;&lt;/DIV&gt;
&lt;DIV&gt;&lt;SPAN style="FONT-WEIGHT: bold; COLOR: #666666"&gt;&lt;/SPAN&gt;&amp;nbsp;&lt;/DIV&gt;
&lt;DIV&gt;&lt;SPAN style="FONT-WEIGHT: bold; COLOR: #666666"&gt;float d=2;&lt;BR /&gt;float B=6.29;&lt;BR /&gt;float V1=300;&lt;BR /&gt;float dv1[100];&lt;BR /&gt;float dv2[100];&lt;BR /&gt;int i;&lt;BR /&gt;float D1[100];&lt;BR /&gt;float D2[100];&lt;BR /&gt;for (i=0;n1-1;i++){&lt;BR /&gt;dv1[i]=-(log(VL1[i]/V1))/(d*B);&lt;BR /&gt;dv2[i]=-(log(VL2[i]/V1))/(d*B);&lt;BR /&gt;D1[i]=1.426*dv1[i]-0.773*dv2[i];&lt;BR /&gt;D2[i]=-0.78*dv1[i]+0.108*dv2[i];&lt;BR /&gt;}&lt;/SPAN&gt;&lt;/DIV&gt;
&lt;DIV&gt;&lt;SPAN style="FONT-WEIGHT: bold; COLOR: #666666"&gt;&lt;/SPAN&gt;&amp;nbsp;&lt;/DIV&gt;
&lt;DIV&gt;&lt;SPAN style="FONT-WEIGHT: bold; COLOR: #666666"&gt;where dv1 and dv2 are input arrays with same dimension, and n1 is the size of them. D1 and D2 are output arrays.&lt;/SPAN&gt;&lt;/DIV&gt;
&lt;DIV&gt;&lt;SPAN style="FONT-WEIGHT: bold; COLOR: #666666"&gt;&lt;/SPAN&gt;&amp;nbsp;&lt;/DIV&gt;
&lt;DIV&gt;&lt;SPAN style="FONT-WEIGHT: bold; COLOR: #666666"&gt;Thank you very much,&lt;/SPAN&gt;&lt;/DIV&gt;
&lt;DIV&gt;&lt;SPAN style="FONT-WEIGHT: bold; COLOR: #666666"&gt;&lt;/SPAN&gt;&amp;nbsp;&lt;/DIV&gt;
&lt;DIV&gt;&lt;SPAN style="FONT-WEIGHT: bold; COLOR: #666666"&gt;Rut&lt;/SPAN&gt;&lt;/DIV&gt;</description>
      <pubDate>Fri, 16 Nov 2007 17:14:21 GMT</pubDate>
      <guid>https://ni.lithium.com/t5/LabVIEW/Dead-loop-in-formula-node/m-p/612778#M284790</guid>
      <dc:creator>Rut</dc:creator>
      <dc:date>2007-11-16T17:14:21Z</dc:date>
    </item>
    <item>
      <title>Re: Dead loop in formula node</title>
      <link>https://ni.lithium.com/t5/LabVIEW/Dead-loop-in-formula-node/m-p/612789#M284792</link>
      <description>&lt;DIV&gt;&lt;/DIV&gt;
&lt;P&gt;Look, I am far out on a limb here, because I am not a C programmer. Whatever you're doing would make more sense from a FORTRAN point of view. &lt;span class="lia-unicode-emoji" title=":slightly_smiling_face:"&gt;🙂&lt;/span&gt;&lt;/P&gt;
&lt;P&gt;The LabVIEW formula node uses BNF notation (check the help), which is in many ways C like. So the syntax for a FOR loop is:&lt;/P&gt;
&lt;P&gt;for ( InitExpression ; CondExpression ; LoopExpression ) Statement &lt;/P&gt;
&lt;P&gt;This means the loop iterates until "CondExpression" is true.&lt;/P&gt;
&lt;P&gt;Do a google search on "C For loop" and you might find for example pages like:&lt;/P&gt;
&lt;P&gt;&lt;A href="http://www.hitmill.com/programming/cpp/forLoop.htm" target="_blank"&gt;http://www.hitmill.com/programming/cpp/forLoop.htm&lt;/A&gt;&lt;BR /&gt;&lt;A href="http://www.geocities.com/learnprogramming123/Clesson8Beginner.htm" target="_blank"&gt;http://www.geocities.com/learnprogramming123/Clesson8Beginner.htm&lt;/A&gt;&lt;/P&gt;
&lt;P&gt;Your &lt;STRONG&gt;condExpression&lt;/STRONG&gt; is "n1-1", which, &lt;U&gt;during the execution of the node is a constant&lt;/U&gt;. For example if you array size is 50, n1-1=49, FOREVER! The condition is never true so the loop will never stop.&lt;/P&gt;
&lt;P&gt;I hope somebody more knowledgable will chip in at one point. &lt;span class="lia-unicode-emoji" title=":slightly_smiling_face:"&gt;🙂&lt;/span&gt;&lt;/P&gt;</description>
      <pubDate>Fri, 16 Nov 2007 17:28:51 GMT</pubDate>
      <guid>https://ni.lithium.com/t5/LabVIEW/Dead-loop-in-formula-node/m-p/612789#M284792</guid>
      <dc:creator>altenbach</dc:creator>
      <dc:date>2007-11-16T17:28:51Z</dc:date>
    </item>
    <item>
      <title>Re: Dead loop in formula node</title>
      <link>https://ni.lithium.com/t5/LabVIEW/Dead-loop-in-formula-node/m-p/612790#M284793</link>
      <description>&lt;DIV&gt;&lt;/DIV&gt;
&lt;DIV&gt;&lt;/DIV&gt;
&lt;P&gt;Your condition for stopping is incorrect. You are not comparing it to anything. For example, you should have something like i&amp;lt;n1-1.&lt;/P&gt;
&lt;P&gt;You can also quite easily implement this with native LabVIEW functions.&lt;/P&gt;&lt;BR /&gt;&lt;BR /&gt;Message Edited by Dennis Knutson on &lt;SPAN class="date_text"&gt;11-16-2007&lt;/SPAN&gt; &lt;SPAN class="time_text"&gt;10:30 AM&lt;/SPAN&gt;</description>
      <pubDate>Fri, 16 Nov 2007 17:30:52 GMT</pubDate>
      <guid>https://ni.lithium.com/t5/LabVIEW/Dead-loop-in-formula-node/m-p/612790#M284793</guid>
      <dc:creator>Dennis_Knutson</dc:creator>
      <dc:date>2007-11-16T17:30:52Z</dc:date>
    </item>
    <item>
      <title>Re: Dead loop in formula node</title>
      <link>https://ni.lithium.com/t5/LabVIEW/Dead-loop-in-formula-node/m-p/612792#M284794</link>
      <description>&lt;DIV&gt;&lt;/DIV&gt;sorry. should read "was not clear enough".</description>
      <pubDate>Fri, 16 Nov 2007 17:29:44 GMT</pubDate>
      <guid>https://ni.lithium.com/t5/LabVIEW/Dead-loop-in-formula-node/m-p/612792#M284794</guid>
      <dc:creator>Rut</dc:creator>
      <dc:date>2007-11-16T17:29:44Z</dc:date>
    </item>
    <item>
      <title>Re: Dead loop in formula node</title>
      <link>https://ni.lithium.com/t5/LabVIEW/Dead-loop-in-formula-node/m-p/612807#M284800</link>
      <description>&lt;DIV&gt;&lt;/DIV&gt;
&lt;P&gt;altenbach and Denis,&lt;/P&gt;
&lt;P&gt;Thanks for both of you and you guys are right. My incorrect test condition had something to do with Matlab (not pure though). I thought Labview supports Matlab scripts this way. It should be in the script node that I haven't tried yet. It's working now. I appreciate your time and kindness.&lt;/P&gt;
&lt;P&gt;Rut&lt;/P&gt;</description>
      <pubDate>Fri, 16 Nov 2007 17:45:05 GMT</pubDate>
      <guid>https://ni.lithium.com/t5/LabVIEW/Dead-loop-in-formula-node/m-p/612807#M284800</guid>
      <dc:creator>Rut</dc:creator>
      <dc:date>2007-11-16T17:45:05Z</dc:date>
    </item>
  </channel>
</rss>

