LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

How do I randomize the line to which a digital output is sent on a NI USB-6501?

Hi,

I am using the NI USB-6501.  I would like to have a LabVIEW program which does the following;

 

          1) Randomly select a port/line of the USB-6501

          2) Send a digital output (3V) for about 3 seconds to that line

          3) Stop the digital output for approximately 3 seconds

          4) Randomly select a different port/line for the same digital output

          5) Repeat steps 2-4 until all 24 lines have been selected once.

 

Could you offer any advice on how to randomly select the port/line that digitally outputs a voltage?

Thank you for your assistance.

 

0 Kudos
Message 1 of 7
(2,649 Views)

One way would be to use physical channel syntax (look it up in LV help).  You can wire a string to specify port/line and then append a random number using the String VIs, etc.

0 Kudos
Message 2 of 7
(2,644 Views)

Probability of getting the "outside" ports/lines is half of the inside ones, keep that in mind...

 

Doesn't do anything for logging to ensure duplicates aren't selected.

 

Why does it have to be random?  Just start with one port, toggle it on/off for 3 secs, then move to the next one?

 

Also, the digital outputs on there are 5V TTL, not going to get 3V out of it without some signal conditioning afterwards.

Also also, the 2nd write should be [F]. :doh

Download All
Message 3 of 7
(2,631 Views)

A variation on that approach that does ensure that you don't get duplicates.  It's not the most efficient approach because it creates and destroys the DAQmax task each time, but it's simple.

 

select random line.png

Message 4 of 7
(2,610 Views)

I would create a sinlge task that uses every 24 bits=F, as array of bool [24]  Create an array of I32(0:23), use Riffle.vi to "shuffle" Array of I32 to get 24 values of 0-23 in random order.  Replace the value of bool[24} index riffled Array of I32= T.

 

BAM! random 24 bit = T without dupes  Smiley Wink


"Should be" isn't "Is" -Jay
0 Kudos
Message 5 of 7
(2,604 Views)

!bam.png

 

 

example attached  write DO (array of bool) in an auto indexed loop


"Should be" isn't "Is" -Jay
Message 6 of 7
(2,599 Views)

You could randomize an array of values and then assign these values to each port (note that this random number VI will not include 0).

 

Capture.JPG

Applications Engineering Specialist - Semiconductor Test
National Instruments
0 Kudos
Message 7 of 7
(2,575 Views)