Skip to content

Connecting to NI DAQ by National Instruments in Python

Instrument Card

Data acquisition (DAQ) is the process of measuring an electrical or physical phenomenon, such as voltage, current, temperature, pressure, or sound. A DAQ system consists of sensors, DAQ measurement hardware, and a computer with programmable software such as LabVIEW.

NI DAQ

Device Specification: here

Manufacturer card: NATIONAL INSTRUMENTS

NATIONAL INSTRUMENTS

A producer of automated test equipment and virtual instrumentation software. Common applications include data acquisition, instrument control and machine vision.

  • Headquarters: Austin, Texas, USA
  • Yearly Revenue (millions, USD): 1657
  • Vendor Website: here

Demo: Record temperature over time with a LabJack DAQ board

Connect to the NI DAQ in Python

PROTOCOLS > SCPI

To connect to a NI DAQ board using Qcodes Community, you can use the following Python script:

import qcodes as qc
from qcodes_contrib_drivers.drivers.NI_DAQ import DAQAnalogInputs, DAQAnalogOutputs, DAQDigitalOutputs
# Create a connection to the NI DAQ board
daq = qc.Instrument('daq', 'DAQAnalogInputs', dev_name='Dev1', rate=1000, channels={'ch1': 0})
# Read analog input voltage
voltage = daq.voltage.get()
# Write analog output voltage
daq_ao = qc.Instrument('daq_ao', 'DAQAnalogOutputs', dev_name='Dev1', channels={'ch1': 0})
daq_ao.voltage_ch1.set(1.23)
# Write digital output state
daq_do = qc.Instrument('daq_do', 'DAQDigitalOutputs', dev_name='Dev1', lines=['port0/line0'])
daq_do.state.set(True)

Note: Replace 'Dev1' with the appropriate device name for your NI DAQ board, and adjust the channel and line configurations as needed.