Digital I/O

cancel
Showing results for 
Search instead for 
Did you mean: 

Increment Digital I/O lines with USB-6008

Hello,
 
I am trying to increment the digial I/O lines on a USB-6008.  I will be using all 12 outputs (port 0 and1) and will have the lines on for a set amount of time (probably 2 sec).  I know that you can turn each line on by setting up a bunch of case structures and a boolean toggle switch, but coding this way will make for a very large, complicated VI real fast, so i figured that there had to be an easier way to code this, plus I wanted to be able to hit start and have it increment through automatically.  I was thinking that I could turn each line on and off by writing a number to the ports and changing it every 2 seconds or so.  For example, for line 1 I would use 00000001, line 2 = 00000010, line 3 = 00000100, etc.  I was trying to use an array of numbers and then converting them to a boolean, but that did not go well (at least for me).
 
My application for this is to have the lines connected to MOSFET's and the line will turn on the mosfet in the order specified. 
 
Any ideas would be greatly appreciated.
Kenny

0 Kudos
Message 1 of 4
(3,589 Views)
Hello Kenny,
You could possibly use a "Boolean Array to Number" from the boolean palette.  You could then use an array of booleans, one for each digital line, turn that array into a number that you could use as the input to the DAQmx Base Write.vi.  If you just wanted to automatically increment the port, you could simply use the iteration number from the loop (the little i), and do some simple math.  Perhaps try this:  Use the "Scale By Power of 2" function.  Put the iteration number into the 'n' input, and use 1 as the 'x' input.  Wire the result to your DAQmx Base Write.  That will give you 1, 2, 4, 8.....and so on, which will turn on line 0, 1, 2, 3...and so on. 
-Alan A.
Message 2 of 4
(3,582 Views)

Alan,

Thanks for your response.  I had not thought of the scale by 2 method, which is much simplier then indexing an array (which I got to work awhile after I posted the question). 

I am still having problems getting the last lines to output correctly (port 1 lines).  I have the Virtual Channel set to "One channel for all lines" and I am setting my I/O name as "Dev1/port0:1".  I also have my Write to channel.vi set to "digital 1 U32 1 chan 1 samp".

Thanks for your help.

Kenny

 

Kenny

0 Kudos
Message 3 of 4
(3,581 Views)
Hello Kenny,
I've addressed the issue of using both ports in this thread.
-Alan A.
Message 4 of 4
(3,563 Views)