LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

How can I control random number(s) when case(s) are on?

In the attached Vi, I have 8 buttons. When one or more buttons are pressed to the "On" case, the boolean returns true else it returns false. I want a unique random number to be generated for each button when the boolean is true.

CLD Certified 2014
0 Kudos
Message 1 of 10
(3,702 Views)

Hi ADrexelDragon,

 

can you please explain "unique random numbers"?

And attach a picture for those still not using LV2010?

Best regards,
GerdW


using LV2016/2019/2021 on Win10/11+cRIO, TestStand2016/2019
Message 2 of 10
(3,695 Views)

 


@ADrexelDragon wrote:

In the attached Vi, I have 8 buttons. When one or more buttons are pressed to the "On" case, the boolean returns true else it returns false. I want a unique random number to be generated for each button when the boolean is true.


 

It is not clear what you want:

What boolean? (There are many booleans, but none named "boolean" that I could find)

A random number is unique most of the time, so what does your sentence mean?

What is the program supposed to do?

0 Kudos
Message 3 of 10
(3,692 Views)

I added the converted vis.  I will try to clear things up. I want each button hooked to a separate random number generator. The generation of random numbers should only occur when the button is in the "On" case. The "On" case is signaled by a true boolean.

CLD Certified 2014
Download All
0 Kudos
Message 4 of 10
(3,684 Views)

In the False case and in the Search Button Cases, you have another case structure there.  If the boolean text is "Off" you assign "On" to the button state, and if the text is "On" you assign "Idle".  So in which case do you want to cause a random number to be generated?  When button is on or when button text is "On"?

 

Simply put a random number generator function inside the case where you want it to generate.  Wire it out of the For Loop and you will have an array of random numbers with the first element belonging to the first button, and so on..

 

- tbob

Inventor of the WORM Global
0 Kudos
Message 5 of 10
(3,673 Views)

I added what you have said but still do not understand how this works. I have a bunch of zeros that are not needed. The graphs of these are not suitable. If there was a way to only insert the random numbers into the array not the zeros I could graph it. 

CLD Certified 2014
Download All
0 Kudos
Message 6 of 10
(3,659 Views)

Try inserting NaN in the cases where the random number is not used.  These don't show up on a graph.

- tbob

Inventor of the WORM Global
0 Kudos
Message 7 of 10
(3,654 Views)

Is there a way to reset a single column because when the button is pressed the third time, I want it to reset the number generation. For example, if elapsed time is being recorded during the time random numbers are being generated, I want these values to be written to an excel file.

CLD Certified 2014
0 Kudos
Message 8 of 10
(3,648 Views)

Here is what I have so far.

CLD Certified 2014
0 Kudos
Message 9 of 10
(3,640 Views)

If by "reset a single column" you mean to clear its contents, then no you can't.  All coumns in an array must contain the same number of rows. 

 

From what you are saying, I think your architecture is probably wrong.  Try to explain to me exactly what it is you are wanting to do.  List the steps and the conditions for any actions. 

 

Why do you want a continuous random number generation and timestamp generation when the button is on?  And what defines the button as being on?  Is it the boolean text? 

 

For the timestamp, shoudn't you capture only the time that the button turns to on, rather than a continuous flow of timestamps?

- tbob

Inventor of the WORM Global
0 Kudos
Message 10 of 10
(3,609 Views)