11-19-2010
05:28 PM
- last edited on
06-03-2024
11:05 PM
by
Content Cleaner
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
Solved! Go to Solution.
11-19-2010 06:09 PM - edited 11-19-2010 06:09 PM
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.
11-19-2010 07:29 PM - edited 11-19-2010 07:32 PM
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
11-22-2010 12:11 PM
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.
11-24-2010 01:35 PM
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
11-24-2010 02:39 PM
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.
11-24-2010 03:50 PM
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
11-24-2010 04:19 PM - edited 11-24-2010 04:20 PM
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.
11-29-2010 08:08 PM
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
11-30-2010 11:02 AM
@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.