Discussion:
DIO function of NI 9401
(too old to reply)
angelmcdoggie
2008-06-05 12:40:11 UTC
Permalink
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
 


NI9401_DIOfunction.ppt:
http://forums.ni.com/attachments/ni/70/8964/1/NI9401_DIOfunction.ppt
MarkGrot
2008-06-05 19:40:16 UTC
Permalink
The NI 9401's direction is nibble configurable but the direction cannot be changed while device is in use.&nbsp; To configure the device for input and output, you must reserve your tasks to set the direction before starting.&nbsp; See <a href="http://forums.ni.com/ni/board/message?board.id=70&amp;message.id=8304" target="_blank">this thread for more details</a>;.

This is an advanced option that is unavailable in MAX test panels.
Message Edited by MarkGrot on 06-05-2008 02:20 PM
angelmcdoggie
2008-06-16 01:40:05 UTC
Permalink
:smileywink:
Thanks Mark for the pointers.&nbsp; I am able to&nbsp;program the NI 9401 as DIO.&nbsp; You mentioned that the output and input cannot occur at the same time.
Please explain why?
&nbsp;
Thanks a bunch,
A
MarkGrot
2008-06-16 16:40:07 UTC
Permalink
This post might be inappropriate. Click to display it.
angelmcdoggie
2008-06-17 03:10:11 UTC
Permalink
Hello Markie,
&nbsp;
My previous understanding is that the read &amp; write cannot be concurrent.&nbsp; So in my program, I used two event handlers &amp; button controls, for the read &amp; write.&nbsp;&nbsp;Maybe later, I'll combine them and then test it.
&nbsp;
&nbsp;
I'll keep you posted once I am done.
&nbsp;
Regards,
A
angelmcdoggie
2008-06-17 09:40:06 UTC
Permalink
By the way, if I setup the NI 9401 as concurrent DIO, can I sync the input and output?
Thanks again,
A
MarkGrot
2008-06-17 16:10:09 UTC
Permalink
Yes, you can synchronize DI and DO on a single NI 9401 (or across multiple modules).&nbsp; To do this on a cDAQ-9172 chassis you need to have the module(s) in slots 1-4.&nbsp; You'll need to create two tasks, one for input and one for output.&nbsp; Make sure you follow the reservation steps I discussed earlier so you can do input and output on the same module.&nbsp; You will also need to configure timing.&nbsp; The goal is to clock in/out data at the specified time.&nbsp; 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.&nbsp; This is called correlated digital.&nbsp; 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).&nbsp; Set your counter to /cDAQx/_ctr0.&nbsp; On your digital tasks, set the sample clock source to /cDAQx/Ctr0InternalOutput.&nbsp; 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.
MarkGrot
2008-06-17 18:10:10 UTC
Permalink
Sorry, I didn't see the <a href="http://forums.ni.com/ni/board/message?board.id=70&amp;thread.id=9037" target="_blank">other thread</a> you started.&nbsp; A quick note:

The cDAQ-9172 chassis has 2 internal counters.&nbsp; There are no counters on the NI 9401 module.&nbsp; 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.&nbsp; This allows you to do timed digital on the module.&nbsp; Under the hood it is using the same counter.



Message Edited by MarkGrot on 06-17-2008 12:50 PM
angelmcdoggie
2008-06-19 11:40:14 UTC
Permalink
Hello Markie,
&nbsp;
Just to verify, using those internal counters will synch my DI &amp; DO, right?
Thanks again,
A
MarkGrot
2008-06-19 15:40:11 UTC
Permalink
Yes, as long as you configure both your input and output timing to use the same sample clock.
angelmcdoggie
2008-06-20 11:40:08 UTC
Permalink
Hello Markie,
&nbsp;
&nbsp;When you mean "sync" in DI &amp; DO, will the rising and falling edges of the clock occur at the same time?&nbsp; Please refer to DI_DO_pulse train.jpg.&nbsp; Second, does is it refer to DO generation and DI capture will occur at the same time?&nbsp; Please refer to generation_capture.jpg.
&nbsp;
Thanks for your patience.
&nbsp;
A


DI_DO_pulse train1.jpg:
http://forums.ni.com/attachments/ni/70/9067/1/DI_DO_pulse train1.jpg


generation_capture1.jpg:
Loading Image...
tnek
2008-06-23 23:10:07 UTC
Permalink
Hi A, Since the same exact sample clock will be used for the digital input and output, they will share the same rising and falling edges. This will also mean that the each acquisition and generation will occur at the same time. Regards,KentApplications Engineer
angelmcdoggie
2008-06-24 04:40:05 UTC
Permalink
Hello :smileyhappy:
&nbsp;
My understanding of what you have mentioned is illustrated in the page 1 of the attachment.&nbsp; At every active edge ( rising edge ) of the clock, the generation and acquisition occurs.
Specifically for my application as shown in page&nbsp;2 of the attachment, the moment I generated the 1st desired setpoint, &nbsp;the 1st sample readback will occur at the same time.&nbsp; Is there an API or a code setup to achieve this?
&nbsp;
Thanks again,


MyApplication.ppt:
http://forums.ni.com/attachments/ni/70/9079/1/MyApplication.ppt
tnek
2008-06-24 20:10:11 UTC
Permalink
Hi A, I am not quite sure what the difference between the two pictures that you have posted. It seems that it is the same signal but shifted in time. But regardless, both digital tasks will act at the same clock edge. As for the code, I believe that you are working on this on <a href="http://forums.ni.com/ni/board/message?board.id=70&amp;thread.id=9037" target="_blank">another post</a>. As was discussed before on this thread, the only thing needed is to create a counter output task for the sample clock, and use this clock as the sample clock for both digital tasks. Regards,KentApplications Engineer
angelmcdoggie
2008-06-25 01:10:06 UTC
Permalink
Hello :smileyhappy:
&nbsp;
I have completed the code for that without using a counter module.
&nbsp;
Sorry for the confusion again.
Well anyway, both pictures are quite similar except that the 2nd picture, wherein I put emphasis on the 1st generation &amp; 1st capture.
The moment I write&nbsp;the 1st&nbsp;sample, I want to acquire the 1st sample immedietely.&nbsp; I am going to use this on a speed application that is &lt; 10 ms, with a tolerance of +/- 1%.
&nbsp;
Is there an API or something to achieve the immediete 1st sample&nbsp;acquisition?
Thanks for your patience.
&nbsp;
Best regards,
A
&nbsp;
&nbsp;
tnek
2008-06-25 18:40:12 UTC
Permalink
Hi A, If the sample clock begins after the digital tasks are started then both the first generation and first acquisition will occur at the first rising edge of the sample clock. If the sample clock is already running when the tasks are started, you can use a trigger to align the two. See <a href="http://zone.ni.com/devzone/cda/tut/p/id/4329" target="_blank">this</a> article for more information on triggering in DAQmx. There is also very good information about sample clocks and triggers in the DAQmx Help file. Regards,KentApplications Engineer
angelmcdoggie
2008-06-26 01:40:06 UTC
Permalink
Dear tnek,
&nbsp;
you mean like this:
&nbsp;
DOTask-&gt;Start();
DITask-&gt;Start();
...
...
...
&nbsp;
DOTask-&gt;Timing...
DITask-&gt;Timing...
&nbsp;
Best regards,
A
tnek
2008-06-26 16:40:11 UTC
Permalink
Hi A,Here is an LabVIEW example which accomplishes this task. I have attached it as a screenshot so you can use it to structure your program. Note that the timing is set before the tasks are started.Regards,KentApplications EngineerMessage Edited by tnek on 06-26-2008 11:16 AM


examp.png:
Loading Image...
angelmcdoggie
2008-06-27 01:40:06 UTC
Permalink
Dear K,
errrr..ooopss sorry I cannot open the attachment because I am using Visual C++.
Thanks,
:smileywink:
&nbsp;
tnek
2008-06-27 21:10:09 UTC
Permalink
Hi A, The attachment is just a picture and should be viewable in your web browser. I just posted it so you can see how your task should be structured.Regards,KentApplications Engineer
Continue reading on narkive:
Loading...