From Friday, April 19th (11:00 PM CDT) through Saturday, April 20th (2:00 PM CDT), 2024, ni.com will undergo system upgrades that may result in temporary service interruption.

We appreciate your patience as we improve our online experience.

LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Creating different output depending on randomly generated number

Currently, I have a for-loop running 10 iterations and with each iteration providing a random number within a set range. My goal is to graph these 10 numbers if they are within my range, but display some sort of arbitrary error message if they are above or below (ie. "Error! Value outside of acceptable range). I've been trying to use a case statement to achieve this, but have had no luck. Any help would be greatly appreciated. Thanks!

0 Kudos
Message 1 of 11
(2,491 Views)

What have you tried?  Please post code and someone can point you in the right direction

aputman
------------------
Heads up! NI has moved LabVIEW to a mandatory SaaS subscription policy, along with a big price increase. Make your voice heard.
0 Kudos
Message 2 of 11
(2,480 Views)

Sorry, meant to add that to the original post. Currently I have the true statement going to one graph while the false goes to another (still haven't figured out the error message so this is my substitute). When running it however, it executes on both graphs on the front end. I thought my greater than and less than relations would restrict it to only run the "true" x were not greater than "32" and also not less than '20."sample1.JPGsample2.JPG

0 Kudos
Message 3 of 11
(2,462 Views)

Are you using the Run Continuous button?

aputman
------------------
Heads up! NI has moved LabVIEW to a mandatory SaaS subscription policy, along with a big price increase. Make your voice heard.
0 Kudos
Message 4 of 11
(2,455 Views)

Nope, just running once, and each time both graphs are executed. I additionally tried changing the boundaries on the random number generator within the for-loop to ensure that it could only be within the range, and even then both graphs still executed when running it.

0 Kudos
Message 5 of 11
(2,450 Views)

Since you don't initialize the graphs at the beginning, the one that is not accessed during any particular run will retain the values from the previous run.  Is this what you are seeing?  

aputman
------------------
Heads up! NI has moved LabVIEW to a mandatory SaaS subscription policy, along with a big price increase. Make your voice heard.
0 Kudos
Message 6 of 11
(2,441 Views)

Please post your VI.  It is really hard to troubleshoot a picture.


GCentral
There are only two ways to tell somebody thanks: Kudos and Marked Solutions
Unofficial Forum Rules and Guidelines
"Not that we are sufficient in ourselves to claim anything as coming from us, but our sufficiency is from God" - 2 Corinthians 3:5
0 Kudos
Message 7 of 11
(2,439 Views)

That doesn't make sense.  Attach the actual VI.

 

Only one or the other can execute.  I have severe doubts that your logic is going to work the way you want since you are working on arrays, than doing an AND Array
Elements on the arrays.  Only if every value in the array is greater than 32 OR less than 20 will the True case run.

 

But the end result is going to be a True or False and only one of the graphs is going to get all the values.

0 Kudos
Message 8 of 11
(2,435 Views)

@kjb123 wrote:

Nope, just running once, and each time both graphs are executed. I additionally tried changing the boundaries on the random number generator within the for-loop to ensure that it could only be within the range, and even then both graphs still executed when running it.


For more clarity in troubleshooting, go to VI options...execution.. and select "clear indicators when called". This guarantees that data in indicators is not retained between runs.

0 Kudos
Message 9 of 11
(2,427 Views)

Thank you everyone for the input. I was able to get it to run how I wanted, sorry for any confusion as I am new to this program. Now that I know it is executing properly, however, I want to achieve my second goal of having the false display an error message rather than go to a different graph. I've been trying to use a 1 button dialogue as this seemed to be the simplest solution, but I cannot seem to find a way to convert so the types match up. Any suggestions? Thanks.sample3.JPG

0 Kudos
Message 10 of 11
(2,258 Views)