08-10-2011 01:16 PM
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.
08-10-2011 01:58 PM
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.
08-10-2011 03:33 PM - edited 08-10-2011 03:37 PM
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
08-10-2011 05:45 PM
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.
08-10-2011 08:38 PM - edited 08-10-2011 08:42 PM
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
08-10-2011 08:52 PM
example attached write DO (array of bool) in an auto indexed loop
08-11-2011 11:40 AM
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).