LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

How do I output up to 8 high and low signals?

Solved!
Go to solution

Hello,

  I'm still new to Labview, and I can't seem to figure out how to do something pretty simple.

 

  I have a device that has 8 inputs, and each input is "turned on" by providing a high (5V) signal.  I would like to use Labview to provide these high and low output signals to these 8 pins.  One extra intracacy is that each channel will need to be turned on and off by a press of a Labview button.  Which labview commands/functions do I need to use in order to provide this functionality?  Are there any related examples in Labview or online?  Thank you very much. 

 

  I'm using an NI 9401 to provide these 8 output channels.  https://www.ni.com/en-us/shop/model/ni-9401.html

 

John

0 Kudos
Message 1 of 10
(5,110 Views)
Solution
Accepted by topic author jwbrooks

You can search for examples on how to output digital signals.  Just go to Help - Find Examples and type in digital and look for examples labled "Write Dig Chan".  There is an example that will run on the 9401.  Then you can adapt it to your use.

 

- tbob

Inventor of the WORM Global
0 Kudos
Message 2 of 10
(5,101 Views)

Bob,

  That seems to be working at least for the 1 channel I have currently hooked up.  I'll need to wire the remaining 7. 

 

  I really appreciate you, Bob, and the entire community. 

 

John

0 Kudos
Message 3 of 10
(5,087 Views)

There are numerous ways to do this depending on what approach you took.  Post your vi and I can tell you how to expand to 8 channels.  It usually involves defining a complete port (8 lines) and sending a byte of data.  The first bit (LSB) of the byte will go to line 0 of the port, the second bit will go to line 1, and so on until the MSB goes to line 7.  To change the bits, just write several bytes in succession.

- tbob

Inventor of the WORM Global
0 Kudos
Message 4 of 10
(5,037 Views)

Tbob,

  So I pretty much just expanded on the example you showed me, but now I keep having errors thrown at me.  Every time I start the code, 4 of the 8 IO ports throw an error and refuse to work.  The interesting thing is that it's not always the same ports.  Normally, IO ports 3,4,5,7 or 4,5,6,7 are the ones that don't work, but periodically others swap in.  Every now and then, all 8 refuse to work. 

  I've attached my code and the error log.  I appreciate any help I can get. 

 

John

Download All
0 Kudos
Message 5 of 10
(5,016 Views)

Try changing the "one channel for all lines" to "one channel for each line" for all the Create Channel functions.  One channel for all lines means that you specify a port and the task contains all 8 lines in that one task.  Since you are wanting individual lines, choose one channel for each line.

 

 

- tbob

Inventor of the WORM Global
0 Kudos
Message 6 of 10
(5,008 Views)

Tbob,

    Unfortunately, changing all Create Channel line signals to "one channel for each line" didn't change anything.  I'm still getting the same error messages as before.  Any other thoughts? 

    Again, thanks for your time. 

 

John

0 Kudos
Message 7 of 10
(5,002 Views)

Your particular instrument must not allow more than one task at a time. You will have to combine all lines into one task.  See attached VI.  You must combine all booleans into an array, use one channel for all lines, and set up one task to handle the entire port of 8 lines.  Also, you should put your delay so that it runs in each loop iteration (not in a case structure) to avoid using 100% CPU time.  Also you should use shift registers for error wires at the loop borders so that any error gets propogated to the next loop iteration.

 

Review the vi.  If you have questions, just ask.

 

Almost forgot to mention.  Your device name must be something like Dev1/port0.  Do not put line0 in the name.

- tbob

Inventor of the WORM Global
0 Kudos
Message 8 of 10
(4,994 Views)

Tbob,

   The code works great!  I really appreciate you. 

   I went through it in order to learn how it works, but I still don't understand why it works in contrast to mine.  You think the hardware couldn't handle having 8 open tasks?  Thanks.

 

John

0 Kudos
Message 9 of 10
(4,939 Views)

@jwbrooks wrote:

Tbob,

....  You think the hardware couldn't handle having 8 open tasks?  Thanks.

 

John


It depends on the hardware.  They are not all the same with respect to tasks.  Some DAQ boards can handle multiple tasks, some can only handle one.  Evidently, your board is designed to handle one task only.

- tbob

Inventor of the WORM Global
Message 10 of 10
(4,922 Views)