LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Random Number not updating

Solved!
Go to solution

Hello,

This is probably a dumb question, but I sincerely don't know how to fix this. I am still learning LabVIEW.

 

I have a simple code where I want the random number to be changing in each run of the while loop, and be an input into another VI were the numbers are displayed on a graph. But it is not working. After the first random value is generated, nothing else is generated. I have tried everything I know. 

Please help me.

 

Thank you very much.

Download All
0 Kudos
Message 1 of 6
(2,487 Views)

I can't open your newer version (I'm only on LV 2015), so please include an older version or a Snippet of your code, so that I can better assist you.

 

My guess is you may be misunderstanding the dataflow in your VI and aren't running the random number function more than once.

LabVIEW programming is based entirely on dataflow and parallelism. This is incredibly powerful and has lead to its success over the years (coupled with the graphical programming), but is usually one of the first things that new developers stumble over. Here's a simple resource to become more familiar with how it works. The Highlight Execution feature is a great way to watch how your application utilizes dataflow.

Cheers


--------,       Unofficial Forum Rules and Guidelines                                           ,--------

          '---   >The shortest distance between two nodes is a straight wire>   ---'


0 Kudos
Message 2 of 6
(2,484 Views)

You have a while loop within a while loop for no obvious reason and no way to stop the inner while loop. By data flow your while loop gets the number outside its loop and never gets updated within the loop. The inner while never stops so your value is never updated.

 

Update the value within the while loop, and no need for the inner while loop, I disabled it below. See below.

 

Snap3.png

 

 

mcduff

0 Kudos
Message 3 of 6
(2,479 Views)
Solution
Accepted by topic author Chimsom

Hi Chimsom,

 

The loop in the subVI is causing the loop in the caller to not iterate. As written, you pass a value into the subVI and then the subVI runs until  you press the stop button on the subVI front panel. This blocks the caller from looping until the VI in the loop returns. In "Untitled 2", right-click your loop and select "remove loop" and then delete your stop button in Untitled 2 since there will be no loop. You might also want to go into the VI properties and set "Untitled 2" to open when called (File >> VI Properties, Window Appearance tab, select the "custom" radio button and then click the "Customize..." button. Here, you can select "Show front panel when called" and "Close afterwards if originally closed". This will then automatically bring up the Utitled2 front panel when you run Untitled 1.

Regards,
0 Kudos
Message 4 of 6
(2,476 Views)

Thanks very much guys.

I really appreciate.

0 Kudos
Message 5 of 6
(2,414 Views)

I feel that dataflow is probably THE MOST IMPORTANT CONCEPT that you can learn in LabVIEW.  Do you actually understand why the solution worked?

 

To give you a little insight, I give you this link:

http://www.ni.com/getting-started/labview-basics/dataflow.  The most important sentence in the link provided is this: "Remember that a node executes only when data is available at all of its input terminals and supplies data to the output terminals only when the node finishes execution."

 

The following is optional, but I think would benefit you greatly in the future if you could answer it:

Given that your subVI is considered a node, and given the sentence in quotation marks above to be strictly true, and also given that your loop structure is considered a node (of sorts) also, can you explain to me why you were having the issue?

Spoiler
Since the subVI is considered a node - and and there is a loop inside that never ends - it never finishes execution and cannot supply data to its output terminals.  Since your outside loop is also considered a node, the subVI inside hasn't completed, so the loop iteration cannot be considered finished; therefore it cannot go to the next one.

If you can answer this question correctly, you'll be well on your way to understanding the most critical LabVIEW concept I can think of.  Every time you have issues like the one you had above, brutally apply that quoted sentence above.  99% of the time, you will be able to figure things out for yourself.  It's tough to identify these issues for what they are, at first, but through experience, you'll be able to identify them quite well.  Let's just say that I speak from experience, myself. 

🙂

Bill
CLD
(Mid-Level minion.)
My support system ensures that I don't look totally incompetent.
Proud to say that I've progressed beyond knowing just enough to be dangerous. I now know enough to know that I have no clue about anything at all.
Humble author of the CLAD Nugget.
0 Kudos
Message 6 of 6
(2,392 Views)