Digital I/O

cancel
Showing results for 
Search instead for 
Did you mean: 

DIO function of NI 9401

Greetings Everyone,
 
 
I am confused between these two information that i derived from the DAQmx Help vs the NI9401 Operating Instructions.
When using MAX, the whole port of NI 9401 is reserved as either input or output. Plus there is only one port.
However a part of my attachment says differently.  Which is which??
 
I am using cDAQ 9172 & MSVC++.
 
 
Thanks for the support,
A
 
0 Kudos
Message 1 of 21
(6,377 Views)
The NI 9401's direction is nibble configurable but the direction cannot be changed while device is in use.  To configure the device for input and output, you must reserve your tasks to set the direction before starting.  See this thread for more details;. This is an advanced option that is unavailable in MAX test panels.


Message Edited by MarkGrot on 06-05-2008 02:20 PM
Message 2 of 21
(6,363 Views)
Smiley Wink
Thanks Mark for the pointers.  I am able to program the NI 9401 as DIO.  You mentioned that the output and input cannot occur at the same time.
Please explain why?
 
Thanks a bunch,
A
0 Kudos
Message 3 of 21
(6,299 Views)
The NI 9401 can do input and output at the same time but cannot change direction while in use. The NI 9401 consists of 2 groups of lines (0:3 and 4:7) that must be configured together. This means if you set line 0 to be input, lines 1 through 3 will be input as well. If you want to do input as well as output at the same time, each nibble would need to be configured for a different direction. DAQmx knows the direction you want by how the line is used (digital input, digital output, counter input, counter output, exporting a signal, etc). So to do input and output, create each task you want and use DAQmx Control Task to reserve the task. In the thread I linked in my earlier post, I mentioned that explicitly reserving the task allows you to configure the direction of a NI 9401. This is because you are reserving the direction without starting your task (since the NI 9401 cannot change direction while running). With all of the tasks reserved you are in a state where the direction will be set properly when you start any of your tasks.
0 Kudos
Message 4 of 21
(6,282 Views)
Hello Markie,
 
My previous understanding is that the read & write cannot be concurrent.  So in my program, I used two event handlers & button controls, for the read & write.  Maybe later, I'll combine them and then test it.
 
 
I'll keep you posted once I am done.
 
Regards,
A
0 Kudos
Message 5 of 21
(6,269 Views)
By the way, if I setup the NI 9401 as concurrent DIO, can I sync the input and output?
Thanks again,
A
0 Kudos
Message 6 of 21
(6,263 Views)
Yes, you can synchronize DI and DO on a single NI 9401 (or across multiple modules).  To do this on a cDAQ-9172 chassis you need to have the module(s) in slots 1-4.  You'll need to create two tasks, one for input and one for output.  Make sure you follow the reservation steps I discussed earlier so you can do input and output on the same module.  You will also need to configure timing.  The goal is to clock in/out data at the specified time. 

The digital engines on the cDAQ-9172 cannot generate their own sample clock like analog input and output can so you'll need another source for the clock.  This is called correlated digital.  It is pretty common to use a sample clock from an analog task for digital but if you don't want/need your digital data correlated to an analog task, you can use one of the onboard counters to generate your clock.

To do this, create a pulse train generation task (there are some examples for this).  Set your counter to /cDAQx/_ctr0.  On your digital tasks, set the sample clock source to /cDAQx/Ctr0InternalOutput.  This will allow you to use the internal chassis counters.

There are examples for timed digital (such as Read Dig-Ext Clk and Write Dig-Ext Clk).

I can go into a bit more detail if you necessary.


0 Kudos
Message 7 of 21
(6,251 Views)
Sorry, I didn't see the other thread you started.  A quick note:

The cDAQ-9172 chassis has 2 internal counters.  There are no counters on the NI 9401 module.  The reason to use the cDAQ1/_ctr0 counter instead of cDAQ1/Mod5/ctr0 is that it won't use any lines of your NI 9401 and doesn't require your module to be in slots 5 or 6.  This allows you to do timed digital on the module.  Under the hood it is using the same counter.



Message Edited by MarkGrot on 06-17-2008 12:50 PM
0 Kudos
Message 8 of 21
(6,240 Views)
Hello Markie,
 
Just to verify, using those internal counters will synch my DI & DO, right?
Thanks again,
A
0 Kudos
Message 9 of 21
(6,213 Views)
Yes, as long as you configure both your input and output timing to use the same sample clock.
0 Kudos
Message 10 of 21
(6,206 Views)