Change Voltage Limits of DAQ Device Using Python DAQmx API

Updated May 20, 2019

Reported In

Driver

  • NI-DAQmx

Programming Language

  • Python

Issue Details

I would like to change the analogue output voltage limits of my DAQ device using Python DAQmx API. What functions do I need to use in my script to achieve this?

Solution

In order to change the analogue output voltage limits of your DAQ device, you need to make use of the following functions from the nidaqmx.task.ao_channel Python DAQmx API :

  • task.ao_channels.all.ao_max
  • task.ao_channels.all.ao_min

These float-type functions specify the maximum and minimum values you expect to generate with your DAQ device.

Critically, you must ensure you incorporate "all" before ao_max and ao_min. This is to ensure you specify a channel object that represents the entire list of virtual channels on this channel collection .

Additional Information

The following is a basic example of using an nidaqmx.task script which is used to change the voltage limits of an SC Express device to a maximum and minimum voltage limit of +/- 16V:
 

import nidaqmx

from nidaqmx.constants import AcquisitionType, Edge

with nidaqmx.Task() as task:

task.ao_channels.add_ao_voltage_chan("<Your Device Name>/<Channel Name>")

task.ao_channels.all.ao_max = 16

task.ao_channels.all.ao_min = -16