NI Measurement Hardware Driver Development Kit (MHDDK) Readme


Copyright 2011 National Instruments. All rights reserved. For patents covering National Instruments products, refer to ni.com/patents.

CVI™, LabVIEW™, Measurement Studio™, National Instruments™, NI™, ni.com™, and NI-DAQmx™ are trademarks of National Instruments Corporation.

Product and company names mentioned herein are trademarks or trade names of their respective companies.




Thank you for using the NI Measurement Hardware Driver Development Kit.

This readme contains the following sections:




General Information



MHDDK KBs

Measurement Hardware Driver Development Kit (MHDDK) Frequently Asked Questions
Measurement Hardware Driver Development Kit (MHDDK) Register Level Programming Architecture
Measurement Hardware Driver Development Kit (MHDDK) Technical Support
How to Make an iBus
How to Use a Chip Object
Register Level Programming (RLP) Examples for Legacy Devices
Register Level Programming for the NI 6013 and 6014 Devices


Reference Build System

All device examples provide a reference makefile to build the examples. The makefiles list the files that need to be compiled to create an example, which can be used as a reference to build examples in a different build environment.

To build the examples, complete the following steps:

  1. Set up the build environment by running any shell or batch file to add the compiler to the system path. Also, include 'make' in your environment.
  2. Download the appropriate OS interface.
  3. Set OSINTERFACE_DIR and OSINTERFACE_MAKEFILE in the makefile to point to the OS interface .mak file.
  4. If using DMA, set DMA_LIBRARY_DIR in the makefile to the root directory of the DMA library files.
  5. Edit the examples to use the appropriate PXI resource string. Some OS interfaces build a helper utility (lsdaq) to list all available devices and resource strings.
  6. Run make.

Free versions of make.exe for Windows are available on the Web.


DMA Libraries

The MHDDK provides support for data transfer via DMA on devices that support this functionality. The DMA libraries implement interfaces for controlling the DMA channels on the device and the memory buffers on the host. In hardware, DMA bus mastering is performed by the bus interface chip on the device: either the MITE or the CHInCh.

MITE-based Devices

E and M Series devices feature the MITE bus interface chip for their DMA controller. The following files are included in the MITE DMA library:

CHInCh-based Devices

X Series devices feature the CHInCh bus interface chip for their DMA controller. The following files are included in the CHInCh DMA library:





OS Interface

osiBus.h and osiTypes.h expose the OS interface used by the device examples. Each specific OS interface implementation provides the definitions for the following functions:

Additionally, the OS interface implementation provides a .mak file for inclusion in the example makefiles. This file provides the appropriate rules for building executables for the target OS.

All OS interface implementations use the VISA PXI resource string: PXI<bus>::<device>::INSTR to identify the hardware.


NI-VISA (Win32/Win64 and Linux32/Linux64)

NI-VISA provides a convenient API to communicate with PCI/PXI device at the register level. Install NI-VISA (available at www.ni.com) before building the examples.

NI-VISA includes win-visa.mak and linux-visa.mak for building examples on Windows and Linux. To build the device examples, set OSINTERFACE_MAKEFILE to win-visa.mak or linux-visa.mak. Change the Makefile variables VISA_INCLUDE_DIR and VISA_LIB_DIR to point to the correct header and library directories for your installation of NI-VISA. Refer to nimhddk_visa.inf for further installation instructions.


Windows WDM (Windows Driver Model) (Win32/Win64)

The Windows WDM OS Interface includes a native WDM driver (nirlpk.sys) to provide access to the hardware. The nirlpk.sys binaries are available for the Win32 x86 and Win64 x64 platforms.

Use the NI-VISA PXI resource string format to specify a device in acquireBoard (main.cpp). Part of the build process for this OS interface builds the lsdaq.exe utility. lsdaq.exe lists the devices detected by nirlpk.sys and their VISA PXI resource strings. Source code for lsdaq is included in ./WindowsWDM/lsdaq.cpp.

Installing nirlpk.sys

To install nirlpk.sys, complete the following steps:

  1. Copy .\WindowsWDM\nirlpk\nirlp.inf to C:\Windows\inf
  2. Copy .\WindowsWDM\nirplk\<build_dir>\nirlp.sys to C:\Windows\system32\drivers, where <build_dir> can be:

Power Management

nirlpk.sys cannot detect if an application is using the hardware and stop the system from powering down (standby, hibernate or shutdown). The application ensures that the system does not power-down while the hardware is in use. However, nirlpk.sys can be built to detect open references to the driver and stop the system from powering down. See power.h for more details.

Building nirlpk.sys

To build nirlpk.sys, complete the following steps:

  1. The source code for nirlpk.sys is located in the following directory: ./osinterface/windows/nirlpk.
  2. Install the Windows Driver Development Kit.
  3. Binaries included in this package were built using the Windows Server 2003 Service Pack 1 (SP1) Driver Development Kit (DDK).
  4. Open the command prompt and change the working directory to ./osinterface/windows/nirlpk.
  5. Setup the DDK build environment for the desired platform. The setupEnvDDK.bat batch file shows how to configure for the Windows Server 2003 SP1 DDK.
  6. Run build. The build.exe is the DDK build utility.

To build the device examples, set OSINTERFACE_MAKEFILE to win-wdm.mak.


Linux Native (Linux32/Linux64)

The LinuxKernel OS Interface includes a native kernel driver (nirlpk.ko) that provides access to the hardware. The nirplk.ko driver is distributed as source (under the BSD license) and must be built for the running kernel.

Use the NI-VISA PXI resource string format to specify a device in acquireBoard (main.cpp). This OS interface includes a lsdaq script that lists the devices, and their VISA PXI resource strings, as detected by nirlpk.ko. This script reads a /proc file entry, which is created when nirlpk.ko is loaded.

Building and Installing nirlpk.ko

To build and install nirlpk.ko, complete the following steps:

  1. Setup your kernel sources for kernel module development. To do so, refer to your distribution's documentation.
  2. 'cd' to ./LinuxKernel/nirlpk.
  3. Run make. The makefile invokes configure to create Makefile.in.
  4. Run make install. This operation requires root access.
  5. To remove, run make uninstall.

To build the device examples, set OSINTERFACE_MAKEFILE to LinuxKernel.mak.

The install/uninstall procedure runs the nirlp startup script. You can set up this script as part of your boot startup scripts. The nirlp startup script loads nirlpk and creates the appropriate /dev nodes.


Linux /dev/mem

This OS interface uses the linux /dev/mem file to access the PCI device address spaces. PCI devices are located by searching the /proc/bus/pci/devices directory. The device memory is mapped to user-mode using mmap, which is located in the /dev/mem directory. This operation usually requires root access, because unrestricted access to /dev/mem can compromise system security.

DMA is not supported. DMA memory allocation requires kernel level support.

To build the device examples, set OSINTERFACE_MAKEFILE to LinuxDevMem.mak. No kernel support is required.


QNX Neutrino

The QNX microkernel architecture allows writing (and debugging) device drivers in user-mode. The OS interface uses the QNX PCI API to access PCI devices and the mmap call to allocate DMA memory. Refer to Talking to hardware under QNX Neutrino and mmap for more information.

To build the device examples, set OSINTERFACE_MAKEFILE to QNX.mak.

The examples were tested using QNX Neutrino 6.2.


Ardence RTX

The RTX OS Interface provides a native implementation to locate and access hardware. The MHDDK examples access the hardware directly without an intermediate kernel driver.

To build the device examples, set OSINTERFACE_MAKEFILE to RTX.mak.

The bus and device number for a PCI device are obtainable from the Windows Device Manager. The Ardence SDK provides an example (ScanBus.c) about how to dynamically read the bus and device numbers of any PCI device.

The examples were tested using Ardence RTX 6.1 (Windows XP host).

Windows CE

The Windows CE OS Interface is included in the CF-6004 examples. Embedded Visual C++ 4.0 is included in the examples for building the driver and examples.

Windows CE is the only OS Interface that works with PCMCIA devices. nirlpdriver is a Windows CE driver designed to detect the PCMCIA devices and provide access to the hardware. On some architectures, such as the x86, PCMCIA address spaces are not memory mapped and register IO is possible only in the kernel. The nirlpdriver provides functions to proxy register IO requests from user-mode.

On platforms where all IO is memory mapped (ARM), the PCMCIA address space is mapped to user-mode. Memory-mapped IO is significantly faster than register IO through the nirlpdriver.




Device Examples

NI X Series

Known Issues

  1. Software timing too slow for Linux
  2. DMA allocation fails for small, finite scatter-gather buffers
  3. aiex2 misses short fast scans
  4. gpctex2 cannot detect a missing source signal
  5. Counter output examples do not check for minimum pulse length
  6. gpctex9 does not generate a pulse train after a DMA error

NI M Series


NI E Series


NI 6143


NI 6110/6111


NI 671x/673x - Waveform AO


NI 670x - Static AO


NI Static DIO


NI PCI-DIO-96


NI CF-6004


NI 660x

NI 7831R