VeriStand

cancel
Showing results for 
Search instead for 
Did you mean: 

Random Error

It appears the Rand(1) calculation requires a variable in the formula to work properly.  For example:

x = Rand(1) failes to deploy

x = 0 + Rand(1) failes to deploy

x = Rand(1)*[Var0] deploys correctly

 

Has anyone verified this or I am I just nuts?

0 Kudos
Message 1 of 4
(5,615 Views)

Hi Intertia,

 

This is expected behavior since the purpose of a Calculated Channels produce new values based on calculations performed on other channels in the system.  So, it does need to involve a channel, whether it's I/O or a User Channel.  

 

Can you provide some context for wanting to generate a random value without any other channel input?  A possible reason that I've thought of is to control your AO with this.  But, maybe if you could provide some context we can examine ways to accomplish what you want.  

 

As a workaround, you can create a user channel and set the value to "1" and multiply it with this random number.

 

 

Regards,

Che T

Che T.
Applications Engineer
National Instruments
0 Kudos
Message 2 of 4
(5,606 Views)

My use case is a random number from 0 to 1 that I want to apply to multiple calculations (using the same random number).  I know there is a workaround - the confusion is that this calculation is allowed and seen as valid until deployment.  It would be better to flag it as invalid prior prior to that point.  I would also challenge the assumption that all calculations must involve a variable.  Frequently we have customers use "fixed" calculations that only employ constants in an effort to self document the calculation and break it into smaller chunks.  It is not as efficient but more readable.  Also, you're implying that the VeriStand calculation engine can't/shouldn't be able to handle x = 1 + 1?  Just my 2 cents worth...

0 Kudos
Message 3 of 4
(5,593 Views)
Hello Inertia,
 
Providing a random number input to multiple calculations is common need, a calculated channel is not the best way to accomplish this end goal. As documented in the VeriStand Help on Calculated Channels , "calculated channels produce a new value based on calculations performed on other channels in the system." That means they expect an input from either a physical channel or a user channel (a Varible, as you had originally noticed). Instead of using a calculated channel, you would be better served to use a VI to generate the random number and read that from VeriStand.
 
That being said,  I agree that it is strange that you get no error messages until deploying. If you would like to see that changed, please post to the NI VeriStand Idea Exchange where it may be voted up by other users. We try to incorporate the most popular ideas into future releases of our products.
 
Thank you for your feedback on this. Best of luck with the rest of your application and have a wonderful holiday season! 
 
~kgarrett
District Sales Engineer
0 Kudos
Message 4 of 4
(5,572 Views)