LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Two port in NI 9401 module?

Solved!
Go to solution

Hello everyone,

 

    I am relatively new toLabView but I must say I am enjoying learnicg it. My problem is that I need to generate two independent signals with a NI 9401 module connected to a NI cDAQ-9172.

    I need to generate a bit sequence to control a demultiplexer, the sequence is 0000, 0001, 0010, 0011 ... 1111, 0000, 0001..... So far with the aid of this great forum i managed to generate the sequence, my problem is that I need to use the other bits to control the enable pin (bit) of another cascaded demutiplexers. 

    I have read that the NI-9401 is nibble configurable, so I understand that I could use bits 0:3 to generate the sequence and bits 4:7 to control the enable bits of the demultiplexers. But so far I haven´t been able to accomplish this task, I see all the 8 lines as a single port and I haven't been able to find out how to configure the two ports both as outputs but generating different signals.

    I am using LabView 8.6

    Could anyone please help me with this task, I will truly appreciate any help.

    Regards,

 

    Joseph

0 Kudos
Message 1 of 8
(5,463 Views)

Hi Joseph,


Good afternoon and I hope your well today. Thanks for your post! 

 

Using DAQmx you can use the two ports. This is done by creating two DAQ tasks, one for input and one for output. Obviously, you can only select 0:3 and 4:7 as configurations. 

 

Note: You can set these to be both inputs or both outputs. The advantage he is you could update each port at different rates!

 

If you require the same rate, then you could just combine the two 4# arrays to make an 8# array and output that in one loop.

 

DI2.JPG

 

Please let me know what you think,

Kind Regards
James Hillman
Applications Engineer 2008 to 2009 National Instruments UK & Ireland
Loughborough University UK - 2006 to 2011
Remember Kudos those who help! 😉
Message 2 of 8
(5,444 Views)

Hi Joseph,

 

In addition to what James said, you may also run into a minor complication: the NI 9401's line direction cannot be reconfigured (switched between input and output) while another task is running using lines from the same NI 9401. This would produce error -201133, and the description for this error describes the workaround, which is basically to call DAQmx Control Task(Reserve) on both tasks before calling DAQmx Start on either task.


Brad

---
Brad Keryan
NI R&D
Message 3 of 8
(5,435 Views)

Thank you both for your help. I really appreciate it.

 

    James, I have tested the vi you suggested and it works perfect for the task configured as "Digital 1D Bool 1Chan 1Samp". I also found a work around  using lines 0:5 in a line grouping of "One cahnnel for all lines" and line 6 as "One channel for each line"and it works fine for my application with tasks configured as "Digital U8 1Chan 1Samp" and "Digital Bool 1line 1Point" respectively.

    However, just for the sake of understanding I haven't been able to generate two independent binary sequences of 4 bits, one which each port using "One cahnnel for all lines" and "Digital U8 1Chan 1Samp". As a very simple example I tried to generate the same sequence in both ports, I attach a picture.

    The upper task produces a sequence 0000, 0001, 0010, 0011.... 1111 and repeats as I would expect, but the second task does not produce anything as all the bits are in zero level.

    Thank you very much for your help, I would appreciate any comments or explanation about the reason for this behaviour.

     Best regards,

 

     Joseph,

 

 

0 Kudos
Message 4 of 8
(5,421 Views)

Hi Joseph,


Thanks for your reply and your feedback. I hope your well today.


I think the issue here is the U8. I feel the DAQmx code may look at the lower/upper nibble respectively, and hence you don't get the desired response. 

 

 dgitaldigtal.JPG

Therefore, for the lower nibble DAQ is looking at the lower nibble of the nubmer.

For the upper nibble DAQmx is looknig at the higher nibble of the number. 

 

In this situation, I would suggest combining the signals together.. if you can have the same update rate (all code within one loop). 

 

Something like this.. 

 

digital2.JPG

PS. I couldnt think of a better way to add an ofset to the a u8 number to move it from lower to upper nibble. I am aware you could do a bit shift or rotate the array.. but I couldnt decide which method would be more efficent.


Hope this helps some more, 

 

 

Kind Regards
James Hillman
Applications Engineer 2008 to 2009 National Instruments UK & Ireland
Loughborough University UK - 2006 to 2011
Remember Kudos those who help! 😉
Message 5 of 8
(5,414 Views)
Solution
Accepted by JosephM

Hi Joseph,

 

I have after reflection consider the best way to do this, not with the crazy arry.

 

Use the Scale By Power of 2 - n = 4 and x being the u8. You can then wire the output to the upper nibble DAQ.

 

Note: If you passed a u8 number to a DAQ task configured for line 0 - it will only look at bit 0. This is the extended for what ever and the number of lines selected.

digitaldigital2.JPG

Hope this helps 🙂

Kind Regards
James Hillman
Applications Engineer 2008 to 2009 National Instruments UK & Ireland
Loughborough University UK - 2006 to 2011
Remember Kudos those who help! 😉
Message 6 of 8
(5,412 Views)

Hello James,

 

    The solution you posted is brilliant! Simple, effective and really elegant.

    I have thefeeling that I am using a workaround of an 8 bits port that is being controlled bit by bit, but I can also think that there are two ports just that the upper nibble still requires upper nibble bits i.e. 2^N shift (hope I made myself clear), Smiley Happytricky!

    Thanks very much your help, all the information and notes you posted have greatly improved my understanding.

   

     Best regards. 

Message 7 of 8
(5,405 Views)

Hey Everybody,

 

Here's a great resource for the bidirectional nibble configuration of an NI 9401 with DAQmx.

 

KnowledgeBase: Why Do I Get Error 201133 When Trying To Perform Bidirectional DI/O with My NI 9401 i...

 

Be sure to check out the community examples linked in the KB.  I hope this helps!

 

- Greg J

Message 8 of 8
(4,882 Views)