LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Generating events at random hours

Hello All,
I am testing a pressure system and would like to turn on a valve for x number of minutes at y hours, where both x and y are random number. How does one generate a event that lasts for a random number of minutes at random hours?

Thanks in advance,
KB
0 Kudos
Message 1 of 5
(2,887 Views)
There are plenty of ways to do this. If you like to use an event structure, you can use the timeout event initialized with a suitable random variable for each iteration to switch the valve. The attached example turns the valve on for a random amount of time in the range 2-4s and then off for a random time of 6-12s.
0 Kudos
Message 2 of 5
(2,887 Views)
(One little dataflow flaw in the code. The "get time/date string" must be forced to execute after the event strucure, else the log times are off.)
0 Kudos
Message 3 of 5
(2,887 Views)
Works well. I am modifying the vi to send a digital pulse to the valve and so on. But how do I change it so that the valve remains open for X MINUTES and waits for Y HOURS (x and y are random). The way you have it the X and the Y are derived from the same random value, right?

Thanks for your help. I noticed that you have answered my previous questions as well!
0 Kudos
Message 4 of 5
(2,887 Views)
The event structure acts as a toggle. The timeout value is randomly generated by the case structure in front of it and the case depends on the current state of the valve. The 0-1 random value is scaled and offset differently for the two cases. Simply scale the ON case to get e.g. a random number of 60000 to 660000 (1-11 minutes) (RND#*600000+60000) until it turns from on to off and a much longer timeout (hours) to turn from off to on.
0 Kudos
Message 5 of 5
(2,887 Views)