Is There an API for NI-HSDIO in Python?

Updated Mar 27, 2023

Reported In

Driver

  • NI-HSDIO

Issue Details

I would like to know if there is an API for NI-HSDIO in Python. I see there is an API for other Modular Instruments driver, but I don't see one for NI-HSDIO.

Solution

Unfortunately there is not an API for the NI-HSDIO driver in Python, but there is a workaround. If we use the C DLL installed by the driver NI-HSDIO in Python, we will be able to control the hardware.
 
Here are the steps to follow as a workaround:
 
1. Each driver that you install comes with a C DLL, which has C functions used to control the Hardware. For the HSDIO, they can be located on the following directories:
 
32-bit IDE:
Driver DLL Path: C:\Program Files (x86)\IVI Foundation\IVI\Bin , then look for "niHSDIO.dll"
 
64-bit IDE:
Driver DLL Path: C:\Program Files\IVI Foundation\IVI\Bin, then look for "niHSDIO_64.dll"
 
2. Then in Python, you can use the ctypes function library, which provides C compatible data types on which you can store values to the C variables required by the functions inside the C DLL.
 
For more information about using the ctypes function library, you can look the following link, which also has an example with the DAQmx driver: Advanced Scripting in Perl, Python and Tcl
 
3. Lastly, remember that the NI-HSDIO installs C examples that can be used as a reference for you Python application. They are located in the following directories:
 
C API Reference:
C:\Program Files (x86)\IVI Foundation\IVI\Drivers\niDigital\Documentation\English\nidigitalcref.chm
 
C Examples (that can be translated in Python through the ctypes library function):
<Public Documents>\National Instruments\NI-Digital\Examples\C