From 04:00 PM CDT – 08:00 PM CDT (09:00 PM UTC – 01:00 AM UTC) Tuesday, April 16, ni.com will undergo system upgrades that may result in temporary service interruption.

We appreciate your patience as we improve our online experience.

Example Code

Configuring an NI 9401 for Bidirectional DIO By Nibble with DAQmx

Products and Environment

This section reflects the products and operating system used to create the example.

To download NI software, including the products shown below, visit ni.com/downloads.

    Hardware

  • Data Acquisition (DAQ)

    Software

  • LabVIEW

    Driver

  • NI DAQmx

Code and Documents

Attachment

Description

Overview

 

This example demonstrates how to properly configure an NI 9401 in DAQmx for independently controlled bidirectional DI/O with nibble 0 (lines 0-3) set for digital input and nibble 1 (lines 4-7) set for digital output.

 

Description

This VI creates a digital input (DI) and digital output (DO) task which will perform continuous bidirectional data acquistion.

 

Requirements

Software

  • NI LabVIEW 2009 or compatible
  • NI DAQmx 8.9.5 or compatible

Hardware

  • NI 9401 DIO Module
  • NI CompactDAQ Chassis

 

Steps to Implement or Execute Code

 

To run this example, select the proper I/O channels for each nibble corresponding to DI and DO, set the execution timing for each nibble independently, and run the VI.

 

This VI:

1. Creates DI and DO tasks
2. Reserves one of the tasks first
3. Starts the other task that has not yet been reserved
4. Starts the task that was previously reserved
5. Performs continuous bidirectional DIO
6. * Note that each nibble can execute at different rates
7. Clears tasks and handles errors

 

NibbleFP2.png

 

NibbleBD.png

Additional Information or References

 

One way to easily observe the bidirectional capability is to perform a loopback test across the nibbles (i.e. connect line 0 to line 4, line 1 to line 5, and so on).  Then when you run this VI, you should see your output reflected on the input indicators.

 

See Nibble DI/O Configuration for Triggering with NI 9401 for an example of this configuration used to trigger an analog task.

 

**This document has been updated to meet the current required format for the NI Code Exchange.**

Example code from the Example Code Exchange in the NI Community is licensed with the MIT license.

Comments
pollon
Member
Member
on

Can you please convert to labview 8.6? thank you

pollon
MarkMoss
Member
Member
on

I just ran into this "must reserve the task first" issue in one of my programs.  Does anybody know why this is required when using the 9401, and not for most other boards/modules?

In my program, I don't have much control over which task is configured or started first (user configurable).  It looks like if you reserve each task as you create it, you can create or start the tasks in any order.  Some understanding of why this is needed for the 9401 and not other modules would give me more confidence that this isn't going to cause an issue for me somewhere else...

ryanpkc
Member
Member
on

Can you please explain how to build this VI?

philip.timson
Member
Member
on

Great example.  You just saved me a bunch of time!

JasonWebb
Member
Member
on

After setting up 4 inputs and 4 outputs, I only want to read 2 of the 4 outputs and do a comparison, using bit 4 for the reference waveform, eg bit 4 and bit 5, or bit 4 and bit 6. Can I access a subset of the input channels?

JasonWebb
Member
Member
on

For clarity, I have one NI-9401, and I want to configure it for bi-directional DIO, which I have done using the example above D0 on 0:3 and DI on 4:7. What I need to do from there is output a waveform on port 0 and read ports 4 , 5 , 6  or 7 individually. I've tried using the active channel property on the channel node, but when I come to generate the waveform it is expecting 4 channels and errors.  Any ideas how I can work with a subset of the channels ?

 

 

Contributors