nidaqmx.task

class nidaqmx.task.ExportSignals(task_handle, interpreter)[source]

Bases: object

Represents the exported signal configurations for a DAQmx task.

__init__(task_handle, interpreter)[source]
__weakref__

list of weak references to the object (if defined)

property adv_cmplt_event_delay

Specifies the output signal delay in periods of the sample clock.

Type:

float

property adv_cmplt_event_output_term

Specifies the terminal to which to route the Advance Complete Event.

Type:

str

property adv_cmplt_event_pulse_polarity

Specifies the polarity of the exported Advance Complete Event.

Type:

nidaqmx.constants.Polarity

property adv_cmplt_event_pulse_width

Specifies the width of the exported Advance Complete Event pulse.

Type:

float

property adv_trig_output_term

Specifies the terminal to which to route the Advance Trigger.

Type:

str

property adv_trig_pulse_polarity

Indicates the polarity of the exported Advance Trigger.

Type:

nidaqmx.constants.Polarity

property adv_trig_pulse_width

Specifies the width of an exported Advance Trigger pulse. Specify this value in the units you specify with adv_trig_pulse_width_units.

Type:

float

property adv_trig_pulse_width_units

Specifies the units of adv_trig_pulse_width.

Type:

nidaqmx.constants.DigitalWidthUnits

property ai_conv_clk_output_term

Specifies the terminal to which to route the AI Convert Clock.

Type:

str

property ai_conv_clk_pulse_polarity

Indicates the polarity of the exported AI Convert Clock. The polarity is fixed and independent of the active edge of the source of the AI Convert Clock.

Type:

nidaqmx.constants.Polarity

property ai_hold_cmplt_event_output_term

Specifies the terminal to which to route the AI Hold Complete Event.

Type:

str

property ai_hold_cmplt_event_pulse_polarity

Specifies the polarity of an exported AI Hold Complete Event pulse.

Type:

nidaqmx.constants.Polarity

property change_detect_event_output_term

Specifies the terminal to which to route the Change Detection Event.

Type:

str

property change_detect_event_pulse_polarity

Specifies the polarity of an exported Change Detection Event pulse.

Type:

nidaqmx.constants.Polarity

property ctr_out_event_output_behavior

Specifies whether the exported Counter Output Event pulses or changes from one state to the other when the counter reaches terminal count.

Type:

nidaqmx.constants.ExportAction

property ctr_out_event_output_term

Specifies the terminal to which to route the Counter Output Event.

Type:

str

property ctr_out_event_pulse_polarity

Specifies the polarity of the pulses at the output terminal of the counter when ctr_out_event_output_behavior is ExportActions2.PULSE. NI-DAQmx ignores this property if ctr_out_event_output_behavior is ExportActions2.TOGGLE.

Type:

nidaqmx.constants.Polarity

property ctr_out_event_toggle_idle_state

Specifies the initial state of the output terminal of the counter when ctr_out_event_output_behavior is ExportActions2.TOGGLE. The terminal enters this state when NI-DAQmx commits the task.

Type:

nidaqmx.constants.Level

property data_active_event_lvl_active_lvl

Specifies the polarity of the exported Data Active Event.

Type:

nidaqmx.constants.Polarity

property data_active_event_output_term

Specifies the terminal to which to export the Data Active Event.

Type:

str

property divided_samp_clk_timebase_output_term

Specifies the terminal to which to route the Divided Sample Clock Timebase.

Type:

str

export_signal(signal_id, output_terminal)[source]

Routes a control signal to the terminal you specify. The output terminal can reside on the device that generates the control signal or on a different device. You can use this function to share clocks and triggers among multiple tasks and devices. The routes this function creates are task-based routes.

Parameters:
  • signal_id (nidaqmx.constants.Signal) – Is the name of the trigger, clock, or event to export.

  • output_terminal (str) – Is the destination of the exported signal. A DAQmx terminal constant lists all terminals on installed devices. You can also specify a string containing a comma-delimited list of terminal names.

property exported_10_mhz_ref_clk_output_term

Specifies the terminal to which to route the 10MHz Clock.

Type:

str

property exported_20_mhz_timebase_output_term

Specifies the terminal to which to route the 20MHz Timebase.

Type:

str

property hshk_event_delay

Specifies the number of seconds to delay after the Handshake Trigger deasserts before asserting the Handshake Event.

Type:

float

property hshk_event_interlocked_assert_on_start

Specifies to assert the Handshake Event when the task starts if hshk_event_output_behavior is ExportActions5.INTERLOCKED.

Type:

bool

property hshk_event_interlocked_asserted_lvl

Specifies the asserted level of the exported Handshake Event if hshk_event_output_behavior is ExportActions5.INTERLOCKED.

Type:

nidaqmx.constants.Level

property hshk_event_interlocked_deassert_delay

Specifies in seconds the amount of time to wait after the Handshake Trigger asserts before deasserting the Handshake Event if hshk_event_output_behavior is ExportActions5.INTERLOCKED.

Type:

float

property hshk_event_output_behavior

Specifies the output behavior of the Handshake Event.

Type:

nidaqmx.constants.ExportAction

property hshk_event_output_term

Specifies the terminal to which to route the Handshake Event.

Type:

str

property hshk_event_pulse_polarity

Specifies the polarity of the exported Handshake Event if hshk_event_output_behavior is ExportActions5.PULSE.

Type:

nidaqmx.constants.Polarity

property hshk_event_pulse_width

Specifies in seconds the pulse width of the exported Handshake Event if hshk_event_output_behavior is ExportActions5.PULSE.

Type:

float

property pause_trig_lvl_active_lvl

Specifies the active level of the exported Pause Trigger.

Type:

nidaqmx.constants.Polarity

property pause_trig_output_term

Specifies the terminal to which to route the Pause Trigger.

Type:

str

property rdy_for_start_event_lvl_active_lvl

Specifies the polarity of the exported Ready for Start Event.

Type:

nidaqmx.constants.Polarity

property rdy_for_start_event_output_term

Specifies the terminal to which to route the Ready for Start Event.

Type:

str

property rdy_for_xfer_event_deassert_cond

Specifies when the ready for transfer event deasserts.

Type:

nidaqmx.constants.DeassertCondition

property rdy_for_xfer_event_deassert_cond_custom_threshold

Specifies in samples the threshold below which the Ready for Transfer Event deasserts. This threshold is an amount of space available in the onboard memory of the device. rdy_for_xfer_event_deassert_cond must be DeassertCondition.ONBOARD_MEMORY_CUSTOM_THRESHOLD to use a custom threshold.

Type:

int

property rdy_for_xfer_event_lvl_active_lvl

Specifies the active level of the exported Ready for Transfer Event.

Type:

nidaqmx.constants.Polarity

property rdy_for_xfer_event_output_term

Specifies the terminal to which to route the Ready for Transfer Event.

Type:

str

property ref_trig_output_term

Specifies the terminal to which to route the Reference Trigger.

Type:

str

property ref_trig_pulse_polarity

Specifies the polarity of the exported Reference Trigger.

Type:

nidaqmx.constants.Polarity

property samp_clk_delay_offset

Specifies in seconds the amount of time to offset the exported Sample clock. Refer to timing diagrams for generation applications in the device documentation for more information about this value.

Type:

float

property samp_clk_output_behavior

Specifies whether the exported Sample Clock issues a pulse at the beginning of a sample or changes to a high state for the duration of the sample.

Type:

nidaqmx.constants.ExportAction

property samp_clk_output_term

Specifies the terminal to which to route the Sample Clock.

Type:

str

property samp_clk_pulse_polarity

Specifies the polarity of the exported Sample Clock if samp_clk_output_behavior is ExportActions3.PULSE.

Type:

nidaqmx.constants.Polarity

property samp_clk_timebase_output_term

Specifies the terminal to which to route the Sample Clock Timebase.

Type:

str

property start_trig_output_term

Specifies the terminal to which to route the Start Trigger.

Type:

str

property start_trig_pulse_polarity

Specifies the polarity of the exported Start Trigger.

Type:

nidaqmx.constants.Polarity

property sync_pulse_event_output_term

Specifies the terminal to which to route the Synchronization Pulse Event.

Type:

str

property watchdog_expired_event_output_term

Specifies the terminal to which to route the Watchdog Timer Expired Event.

Type:

str

class nidaqmx.task.InStream(task, interpreter)[source]

Bases: object

Exposes an input data stream on a DAQmx task.

The input data stream be used to control reading behavior and can be used in conjunction with reader classes to read samples from an NI-DAQmx task.

__eq__(other)[source]

Return self==value.

__hash__()[source]

Return hash(self).

__init__(task, interpreter)[source]
__ne__(other)[source]

Return self!=value.

__repr__()[source]

Return repr(self).

__weakref__

list of weak references to the object (if defined)

property accessory_insertion_or_removal_detected

Indicates if any device(s) in the task detected the insertion or removal of an accessory since the task started. Reading this property clears the accessory change status for all channels in the task. You must read this property before you read devs_with_inserted_or_removed_accessories. Otherwise, you will receive an error.

Type:

bool

property auto_start

Specifies if DAQmx Read automatically starts the task if you did not start the task explicitly by using DAQmx Start. The default value is True. When DAQmx Read starts a finite acquisition task, it also stops the task after reading the last sample.

Type:

bool

property aux_power_error_chans

Indicates a list of names of any virtual channels in the task for which an auxiliary power supply error condition has been detected. You must read the Aux Power Error Channels Exist property before you read this property. Otherwise, you will receive an error.

Type:

List[str]

property aux_power_error_chans_exist

Indicates if the device(s) detected an auxiliary power supply error condition for any channel in the task. Reading this property clears the error condition status for all channels in the task. You must read this property before you read the Aux Power Error Channels property. Otherwise, you will receive an error.

Type:

bool

property avail_samp_per_chan

Indicates the number of samples available to read per channel. This value is the same for all channels in the task.

Type:

int

property change_detect_overflowed

Indicates if samples were missed because change detection events occurred faster than the device could handle them. Some devices detect overflows differently than others.

Type:

bool

property channels_to_read

Specifies a subset of channels in the task from which to read.

Type:

nidaqmx.task.channels.Channel

property common_mode_range_error_chans

Indicates a list of names of any virtual channels in the task for which the device(s) detected a common mode range violation. You must read common_mode_range_error_chans_exist before you read this property. Otherwise, you will receive an error.

Type:

List[str]

property common_mode_range_error_chans_exist

Indicates if the device(s) detected a common mode range violation for any virtual channel in the task. Common mode range violation occurs when the voltage of either the positive terminal or negative terminal to ground are out of range. Reading this property clears the common mode range violation status for all channels in the task. You must read this property before you read common_mode_range_error_chans. Otherwise, you will receive an error.

Type:

bool

configure_logging(file_path: str | PurePath, logging_mode=LoggingMode.LOG_AND_READ, group_name='', operation=LoggingOperation.OPEN_OR_CREATE)[source]

Configures TDMS file logging for the task.

Parameters:
  • file_path – Specifies the path to the TDMS file to which you want to log data.

  • logging_mode (Optional[nidaqmx.constants.LoggingMode]) – Specifies whether to enable logging and whether to allow reading data while logging. “log” mode allows for the best performance. However, you cannot read data while logging if you specify this mode. If you want to read data while logging, specify “LOG_AND_READ” mode.

  • group_name (Optional[str]) – Specifies the name of the group to create within the TDMS file for data from this task. If you append data to an existing file and the specified group already exists, NI-DAQmx appends a number symbol and a number to the group name, incrementing that number until finding a group name that does not exist. For example, if you specify a group name of Voltage Task, and that group already exists, NI-DAQmx assigns the group name Voltage Task #1, then Voltage Task #2. If you do not specify a group name, NI-DAQmx uses the name of the task.

  • operation (Optional[nidaqmx.constants.LoggingOperation]) – Specifies how to open the TDMS file.

property curr_read_pos

Indicates in samples per channel the current position in the buffer.

Type:

int

property devs_with_inserted_or_removed_accessories

Indicates the names of any devices that detected the insertion or removal of an accessory since the task started. You must read accessory_insertion_or_removal_detected before you read this property. Otherwise, you will receive an error.

Type:

List[str]

property di_num_booleans_per_chan

Indicates the number of booleans per channel that NI-DAQmx returns in a sample for line-based reads. If a channel has fewer lines than this number, the extra booleans are False.

Type:

int

property excit_fault_chans

Indicates a list of names of any virtual channels in the task for which the device(s) detected an excitation fault condition. You must read excit_fault_chans_exist before you read this property. Otherwise, you will receive an error.

Type:

List[str]

property excit_fault_chans_exist

Indicates if the device(s) detected an excitation fault condition for any virtual channel in the task. Reading this property clears the excitation fault status for all channels in the task. You must read this property before you read excit_fault_chans. Otherwise, you will receive an error.

Type:

bool

property input_buf_size

Specifies the number of samples the input buffer can hold for each channel in the task. Zero indicates to allocate no buffer. Use a buffer size of 0 to perform a hardware-timed operation without using a buffer. Setting this property overrides the automatic input buffer allocation that NI- DAQmx performs.

Type:

int

property input_limits_fault_chans

Indicates the virtual channels that have detected samples outside the upper or lower limits configured for each channel in the task. You must read input_limits_fault_chans_exist before you read this property. Otherwise, you will receive an error.

Type:

List[str]

property input_limits_fault_chans_exist

Indicates if the device or devices detected a sample that was outside the upper or lower limits configured for each channel in the task. Reading this property clears the input limits fault channel status for all channels in the task. You must read this property before you read input_limits_fault_chans. Otherwise, you will receive an error. Note: Fault detection applies to both positive and negative inputs. For instance, if you specify a lower limit of 2 mA and an upper limit of 12 mA, NI-DAQmx detects a fault at 15 mA and -15 mA, but not at -6 mA because it is in the range of -12 mA to -2 mA.

Type:

bool

property input_onbrd_buf_size

Indicates in samples per channel the size of the onboard input buffer of the device.

Type:

int

property logging_file_path: Path | None

Specifies the path to the TDMS file to which you want to log data. If the file path is changed while the task is running, this takes effect on the next sample interval (if Logging.SampsPerFile has been set) or when DAQmx Start New File is called. New file paths can be specified by ending with “" or “/”. Files created after specifying a new file path retain the same name and numbering sequence.

Type:

pathlib.Path

property logging_file_preallocation_size

Specifies a size in samples to be used to pre-allocate space on disk. Pre-allocation can improve file I/O performance, especially in situations where multiple files are being written to disk. For finite tasks, the default behavior is to pre-allocate the file based on the number of samples you configure the task to acquire.

Type:

int

property logging_file_write_size

Specifies the size, in samples, in which data will be written to disk. The size must be evenly divisible by the volume sector size, in bytes.

Type:

int

property logging_mode

Specifies whether to enable logging and whether to allow reading data while logging. Log mode allows for the best performance. However, you cannot read data while logging if you specify this mode. If you want to read data while logging, specify Log and Read mode.

Type:

nidaqmx.constants.LoggingMode

property logging_pause

Specifies whether logging is paused while a task is executing. If logging_mode is set to Log and Read mode, this value is taken into consideration on the next call to DAQmx Read, where data is written to disk. If logging_mode is set to Log Only mode, this value is taken into consideration the next time that data is written to disk. A new TDMS group is written when logging is resumed from a paused state.

Type:

bool

property logging_samps_per_file

Specifies how many samples to write to each file. When the file reaches the number of samples specified, a new file is created with the naming convention of <filename>_####.tdms, where #### starts at 0001 and increments automatically with each new file. For example, if the file specified is C:data.tdms, the next file name used is C:data_0001.tdms. To disable file spanning behavior, set this attribute to 0. If logging_file_path is changed while this attribute is set, the new file path takes effect on the next file created.

Type:

int

property logging_tdms_group_name

Specifies the name of the group to create within the TDMS file for data from this task. If you append data to an existing file and the specified group already exists, NI- DAQmx appends a number symbol and a number to the group name, incrementing that number until finding a group name that does not exist. For example, if you specify a group name of Voltage Task, and that group already exists, NI- DAQmx assigns the group name Voltage Task #1, then Voltage Task #2.

Type:

str

property logging_tdms_operation

Specifies how to open the TDMS file.

Type:

nidaqmx.constants.LoggingOperation

property num_chans

Indicates the number of channels that DAQmx Read reads from the task. This value is the number of channels in the task or the number of channels you specify with channels_to_read.

Type:

int

property offset

Specifies an offset in samples per channel at which to begin a read operation. This offset is relative to the location you specify with relative_to.

Type:

int

property open_chans

Indicates a list of names of any open virtual channels. You must read open_chans_exist before you read this property. Otherwise you will receive an error.

Type:

List[str]

property open_chans_details

Indicates a list of details of any open virtual channels. You must read open_chans_exist before you read this property. Otherwise you will receive an error.

Type:

List[str]

property open_chans_exist

Indicates if the device or devices detected an open channel condition in any virtual channel in the task. Reading this property clears the open channel status for all channels in this task. You must read this property before you read open_chans. Otherwise, you will receive an error.

Type:

bool

property open_current_loop_chans

Indicates a list of names of any virtual channels in the task for which the device(s) detected an open current loop. You must read open_current_loop_chans_exist before you read this property. Otherwise, you will receive an error.

Type:

List[str]

property open_current_loop_chans_exist

Indicates if the device(s) detected an open current loop for any virtual channel in the task. Reading this property clears the open current loop status for all channels in the task. You must read this property before you read open_current_loop_chans. Otherwise, you will receive an error.

Type:

bool

property open_thrmcpl_chans

Indicates a list of names of any virtual channels in the task for which the device(s) detected an open thermcouple. You must read open_thrmcpl_chans_exist before you read this property. Otherwise, you will receive an error.

Type:

List[str]

property open_thrmcpl_chans_exist

Indicates if the device(s) detected an open thermocouple connected to any virtual channel in the task. Reading this property clears the open thermocouple status for all channels in the task. You must read this property before you read open_thrmcpl_chans. Otherwise, you will receive an error.

Type:

bool

property over_write

Deprecated since version 0.7.0: Use overwrite instead.

property overcurrent_chans

Indicates a list of names of any virtual channels in the task for which the device(s) detected an overcurrent condition. You must read overcurrent_chans_exist before you read this property. Otherwise, you will receive an error. On some devices, you must restart the task for all overcurrent channels to recover.

Type:

List[str]

property overcurrent_chans_exist

Indicates if the device(s) detected an overcurrent condition for any virtual channel in the task. Reading this property clears the overcurrent status for all channels in the task. You must read this property before you read overcurrent_chans. Otherwise, you will receive an error.

Type:

bool

property overloaded_chans

Indicates a list of names of any overloaded virtual channels in the task. You must read overloaded_chans_exist before you read this property. Otherwise, you will receive an error.

Type:

List[str]

property overloaded_chans_exist

Indicates if the device(s) detected an overload in any virtual channel in the task. Reading this property clears the overload status for all channels in the task. You must read this property before you read overloaded_chans. Otherwise, you will receive an error.

Type:

bool

property overtemperature_chans

Indicates a list of names of any overtemperature virtual channels. You must read overtemperature_chans_exist before you read this property. Otherwise, you will receive an error.

Type:

List[str]

property overtemperature_chans_exist

Indicates if the device(s) detected an overtemperature condition in any virtual channel in the task. Reading this property clears the overtemperature status for all channels in the task. You must read this property before you read overtemperature_chans. Otherwise, you will receive an error.

Type:

bool

property overwrite

Specifies whether to overwrite samples in the buffer that you have not yet read.

Type:

nidaqmx.constants.OverwriteMode

property pll_unlocked_chans

Indicates the channels that had their PLLs unlock.

Type:

List[str]

property pll_unlocked_chans_exist

Indicates whether the PLL is currently locked, or whether it became unlocked during the previous acquisition. Devices may report PLL Unlock either during acquisition or after acquisition.

Type:

bool

property power_supply_fault_chans

Indicates the virtual channels that have detected a power supply fault. You must read power_supply_fault_chans_exist before you read this property. Otherwise, you will receive an error.

Type:

List[str]

property power_supply_fault_chans_exist

Indicates if the device or devices detected a power supply fault condition in any virtual channel in the task. Reading this property clears the power supply fault status for all channels in this task. You must read this property before you read power_supply_fault_chans. Otherwise, you will receive an error.

Type:

bool

property raw_data_width

Indicates in bytes the size of a raw sample from the task.

Type:

int

read(number_of_samples_per_channel=-1)[source]

Reads raw samples from the task or virtual channels you specify.

Raw samples constitute the internal representation of samples in a device, read directly from the device or buffer without scaling or reordering. The native format of a device can be an 8-, 16-, or 32-bit integer, signed or unsigned.

NI-DAQmx does not separate raw data into channels. It returns data in an interleaved or non-interleaved 1D array, depending on the raw ordering of the device. Refer to your device documentation for more information.

This method determines a NumPy array of appropriate size and data type to create and return based on your device specifications.

Use the “timeout” property on the stream to specify the amount of time in seconds to wait for samples to become available. If the time elapses, the method returns an error and any samples read before the timeout elapsed. The default timeout is 10 seconds. If you set timeout to nidaqmx.WAIT_INFINITELY, the method waits indefinitely. If you set timeout to 0, the method tries once to read the requested samples and returns an error if it is unable to.

Parameters:

number_of_samples_per_channel (int) –

Specifies the number of samples to read.

If you set this input to nidaqmx.READ_ALL_AVAILABLE, NI-DAQmx determines how many samples to read based on if the task acquires samples continuously or acquires a finite number of samples.

If the task acquires samples continuously and you set this input to nidaqmx.READ_ALL_AVAILABLE, this method reads all the samples currently available in the buffer.

If the task acquires a finite number of samples and you set this input to nidaqmx.READ_ALL_AVAILABLE, the method waits for the task to acquire all requested samples, then reads those samples. If you set the “read_all_avail_samp” property to TRUE, the method reads the samples currently available in the buffer and does not wait for the task to acquire all requested samples.

Returns:

The samples requested in the form of a 1D NumPy array. This method determines a NumPy array of appropriate size and data type to create and return based on your device specifications.

Return type:

numpy.ndarray

read_all()[source]

Reads all available raw samples from the task or virtual channels you specify.

NI-DAQmx determines how many samples to read based on if the task acquires samples continuously or acquires a finite number of samples.

If the task acquires samples continuously, this method reads all the samples currently available in the buffer.

If the task acquires a finite number of samples, the method waits for the task to acquire all requested samples, then reads those samples. If you set the “read_all_avail_samp” property to TRUE, the method reads the samples currently available in the buffer and does not wait for the task to acquire all requested samples.

Raw samples constitute the internal representation of samples in a device, read directly from the device or buffer without scaling or reordering. The native format of a device can be an 8-, 16-, or 32-bit integer, signed or unsigned.

NI-DAQmx does not separate raw data into channels. It returns data in an interleaved or non-interleaved 1D array, depending on the raw ordering of the device. Refer to your device documentation for more information.

This method determines a NumPy array of appropriate size and data type to create and return based on your device specifications.

Use the “timeout” property on the stream to specify the amount of time in seconds to wait for samples to become available. If the time elapses, the method returns an error and any samples read before the timeout elapsed. The default timeout is 10 seconds. If you set timeout to nidaqmx.WAIT_INFINITELY, the method waits indefinitely. If you set timeout to 0, the method tries once to read the requested samples and returns an error if it is unable to.

Returns:

The samples requested in the form of a 1D NumPy array. This method determines a NumPy array of appropriate size and data type to create and return based on your device specifications.

Return type:

numpy.ndarray

property read_all_avail_samp

Specifies whether subsequent read operations read all samples currently available in the buffer or wait for the buffer to become full before reading. NI-DAQmx uses this setting for finite acquisitions and only when the number of samples to read is -1. For continuous acquisitions when the number of samples to read is -1, a read operation always reads all samples currently available in the buffer.

Type:

bool

read_into(numpy_array)[source]

Reads raw samples from the task or virtual channels you specify into numpy_array.

The object numpy_array should be a pre-allocated, writable 1D numpy array.

The number of samples per channel to read is determined using the following equation:

number_of_samples_per_channel = math.floor(
numpy_array_size_in_bytes / (

number_of_channels_to_read * raw_sample_size_in_bytes))

Raw samples constitute the internal representation of samples in a device, read directly from the device or buffer without scaling or reordering. The native format of a device can be an 8-, 16-, or 32-bit integer, signed or unsigned.

If you use a different integer size than the native format of the device, one integer can contain multiple samples or one sample can stretch across multiple integers. For example, if you use 32-bit integers, but the device uses 8-bit samples, one integer contains up to four samples. If you use 8-bit integers, but the device uses 16-bit samples, a sample might require two integers. This behavior varies from device to device. Refer to your device documentation for more information.

NI-DAQmx does not separate raw data into channels. It returns data in an interleaved or non-interleaved 1D array, depending on the raw ordering of the device. Refer to your device documentation for more information.

Use the “timeout” property on the stream to specify the amount of time in seconds to wait for samples to become available. If the time elapses, the method returns an error and any samples read before the timeout elapsed. The default timeout is 10 seconds. If you set timeout to -1, the method waits indefinitely. If you set timeout to 0, the method tries once to read the requested samples and returns an error if it is unable to.

Parameters:

numpy_array – Specifies the 1D NumPy array object into which the samples requested are read.

Returns:

Indicates the total number of samples read.

Return type:

int

readall()[source]

Deprecated since version 1.0.0: This will be removed in 1.2.0. Use read_all instead.

readinto(numpy_array)[source]

Deprecated since version 1.0.0: This will be removed in 1.2.0. Use read_into instead.

property relative_to

Specifies the point in the buffer at which to begin a read operation. If you also specify an offset with offset, the read operation begins at that offset relative to the point you select with this property. The default value is ReadRelativeTo.CURRENT_READ_POSITION unless you configure a Reference Trigger for the task. If you configure a Reference Trigger, the default value is ReadRelativeTo.FIRST_PRETRIGGER_SAMPLE.

Type:

nidaqmx.constants.ReadRelativeTo

property remote_sense_error_chans

Indicates a list of names of any virtual channels in the task for which a remote sense connection error condition has been detected. You must read Remote Sense Error Channels Exist before you read this property. Otherwise, you will receive an error.

Type:

List[str]

property remote_sense_error_chans_exist

Indicates if the device(s) detected an error condition of the remote sense connection for any channel in the task. You must disable the output and resolve the hardware connection issue to clear the error condition. You must read this property before you read the Remote Sense Error Channels property. Otherwise, you will receive an error.

Type:

bool

property reverse_voltage_error_chans

Indicates a list of names of all virtual channels in the task for which reverse voltage error condition has been detected. You must read the Reverse Voltage Error Channels Exist property before you read this property. Otherwise, you will receive an error.

Type:

List[str]

property reverse_voltage_error_chans_exist

Indicates if the device(s) detected reverse voltage error for any of the channels in the task. Reverse voltage error occurs if the local voltage is equal to the negative saturated voltage. Reading this property clears the error condition status for all channels in the task. You must read this property before you read the Reverse Voltage Error Channels property. Otherwise, you will receive an error.

Type:

bool

property sleep_time

Specifies in seconds the amount of time to sleep after checking for available samples if wait_mode is WaitMode.SLEEP.

Type:

float

start_new_file(file_path: str | PurePath)[source]

Starts a new TDMS file the next time data is written to disk.

Parameters:

file_path – Specifies the path to the TDMS file to which you want to log data.

property sync_unlocked_chans

Indicates the channels from devices in an unlocked target.

Type:

List[str]

property sync_unlocked_chans_exist

Indicates whether the target is currently locked to the grand master. Devices may report PLL Unlock either during acquisition or after acquisition.

Type:

bool

property timeout

Specifies the amount of time in seconds to wait for samples to become available. If the time elapses, the read method returns an error and any samples read before the timeout elapsed. The default timeout is 10 seconds. If you set timeout to nidaqmx.WAIT_INFINITELY, the read method waits indefinitely. If you set timeout to 0, the read method tries once to read the requested samples and returns an error if it is unable to.

Type:

float

property total_samp_per_chan_acquired

Indicates the total number of samples acquired by each channel. NI-DAQmx returns a single value because this value is the same for all channels. For retriggered acquisitions, this value is the cumulative number of samples across all retriggered acquisitions.

Type:

int

property wait_mode

Specifies how DAQmx Read waits for samples to become available.

Type:

nidaqmx.constants.WaitMode

class nidaqmx.task.OutStream(task, interpreter)[source]

Bases: object

Exposes an output data stream on a DAQmx task.

The output data stream be used to control writing behavior and can be used in conjunction with writer classes to write samples to an NI-DAQmx task.

__eq__(other)[source]

Return self==value.

__hash__()[source]

Return hash(self).

__init__(task, interpreter)[source]
__ne__(other)[source]

Return self!=value.

__repr__()[source]

Return repr(self).

__weakref__

list of weak references to the object (if defined)

property accessory_insertion_or_removal_detected

Indicates if any devices in the task detected the insertion or removal of an accessory since the task started. Reading this property clears the accessory change status for all channels in the task. You must read this property before you read devs_with_inserted_or_removed_accessories. Otherwise, you will receive an error.

Type:

bool

property auto_start

Specifies if the “write” method automatically starts the stream’s owning task if you did not explicitly start it with the DAQmx Start Task method.

Type:

bool

property curr_write_pos

Indicates the position in the buffer of the next sample to generate. This value is identical for all channels in the task.

Type:

int

property devs_with_inserted_or_removed_accessories

Indicates the names of any devices that detected the insertion or removal of an accessory since the task started. You must read accessory_insertion_or_removal_detected before you read this property. Otherwise, you will receive an error.

Type:

List[str]

property do_num_booleans_per_chan

Indicates the number of Boolean values expected per channel in a sample for line-based writes. This property is determined by the channel in the task with the most digital lines. If a channel has fewer lines than this number, NI- DAQmx ignores the extra Boolean values.

Type:

int

property external_overvoltage_chans

Indicates a list of names of any virtual channels in the task for which an External Overvoltage condition has been detected. You must read External OvervoltageChansExist before you read this property. Otherwise, you will receive an error.

Type:

List[str]

property external_overvoltage_chans_exist

Indicates if the device(s) detected an External Overvoltage condition for any channel in the task. Reading this property clears the External Overvoltage status for all channels in the task. You must read this property before you read External OvervoltageChans. Otherwise, you will receive an error.

Type:

bool

property num_chans

Indicates the number of channels that DAQmx Write writes to the task. This value is the number of channels in the task.

Type:

int

property offset

Specifies in samples per channel an offset at which a write operation begins. This offset is relative to the location you specify with relative_to.

Type:

int

property open_current_loop_chans

Indicates a list of names of any virtual channels in the task for which the device(s) detected an open current loop. You must read open_current_loop_chans_exist before you read this property. Otherwise, you will receive an error.

Type:

List[str]

property open_current_loop_chans_exist

Indicates if the device(s) detected an open current loop for any channel in the task. Reading this property clears the open current loop status for all channels in the task. You must read this property before you read open_current_loop_chans. Otherwise, you will receive an error.

Type:

bool

property output_buf_size

Specifies the number of samples the output buffer can hold for each channel in the task. Zero indicates to allocate no buffer. Use a buffer size of 0 to perform a hardware-timed operation without using a buffer. Setting this property overrides the automatic output buffer allocation that NI- DAQmx performs.

Type:

int

property output_onbrd_buf_size

Specifies in samples per channel the size of the onboard output buffer of the device.

Type:

int

property overcurrent_chans

Indicates a list of names of any virtual channels in the task for which an overcurrent condition has been detected. You must read overcurrent_chans_exist before you read this property. Otherwise, you will receive an error.

Type:

List[str]

property overcurrent_chans_exist

Indicates if the device(s) detected an overcurrent condition for any channel in the task. Reading this property clears the overcurrent status for all channels in the task. You must read this property before you read overcurrent_chans. Otherwise, you will receive an error.

Type:

bool

property overloaded_chans

Indicates a list of names of any overloaded virtual channels in the task. You must read overloaded_chans_exist before you read this property. Otherwise, you will receive an error.

Type:

List[str]

property overloaded_chans_exist

Indicates if the device(s) detected an overload in any virtual channel in the task. Reading this property clears the overload status for all channels in the task. You must read this property before you read overloaded_chans. Otherwise, you will receive an error.

Type:

bool

property overtemperature_chans

Indicates a list of names of any overtemperature virtual channels. You must read overtemperature_chans_exist before you read this property. Otherwise, you will receive an error. The list of names may be empty if the device cannot determine the source of the overtemperature.

Type:

List[str]

property overtemperature_chans_exist

Indicates if the device(s) detected an overtemperature condition in any virtual channel in the task. Reading this property clears the overtemperature status for all channels in the task. You must read this property before you read overtemperature_chans. Otherwise, you will receive an error.

Type:

bool

property power_supply_fault_chans

Indicates a list of names of any virtual channels in the task that have a power supply fault. You must read power_supply_fault_chans_exist before you read this property. Otherwise, you will receive an error.

Type:

List[str]

property power_supply_fault_chans_exist

Indicates if the device(s) detected a power supply fault for any channel in the task. Reading this property clears the power supply fault status for all channels in the task. You must read this property before you read power_supply_fault_chans. Otherwise, you will receive an error.

Type:

bool

property raw_data_width

Indicates in bytes the required size of a raw sample to write to the task.

Type:

int

property regen_mode

Specifies whether to allow NI-DAQmx to generate the same data multiple times.

Type:

nidaqmx.constants.RegenerationMode

property relative_to

Specifies the point in the buffer at which to write data. If you also specify an offset with offset, the write operation begins at that offset relative to this point you select with this property.

Type:

nidaqmx.constants.WriteRelativeTo

property sleep_time

Specifies in seconds the amount of time to sleep after checking for available buffer space if wait_mode is WaitMode2.SLEEP.

Type:

float

property space_avail

Indicates in samples per channel the amount of available space in the buffer.

Type:

int

property sync_unlocked_chans

Indicates the channels from devices in an unlocked target.

Type:

List[str]

property sync_unlocked_chans_exist

Indicates whether the target is currently locked to the grand master. Devices may report PLL Unlock either during acquisition or after acquisition.

Type:

bool

property timeout

Specifies the amount of time in seconds to wait for the write method to write all samples. NI-DAQmx performs a timeout check only if the write method must wait before it writes data. The write method returns an error if the time elapses. The default timeout is 10 seconds. If you set “timeout” to nidaqmx.WAIT_INFINITELY, the write method waits indefinitely. If you set timeout to 0, the write method tries once to write the submitted samples. If the write method could not write all the submitted samples, it returns an error and the number of samples successfully written in the number of samples written per channel output.

Type:

float

property total_samp_per_chan_generated

Indicates the total number of samples generated by each channel in the task. This value is identical for all channels in the task.

Type:

int

property wait_mode

Specifies how DAQmx Write waits for space to become available in the buffer.

Type:

nidaqmx.constants.WaitMode

write(numpy_array)[source]

Writes raw samples to the task or virtual channels you specify.

The number of samples per channel to write is determined using the following equation:

number_of_samples_per_channel = math.floor(
numpy_array_size_in_bytes / (

number_of_channels_to_write * raw_sample_size_in_bytes))

Raw samples constitute the internal representation of samples in a device, read directly from the device or buffer without scaling or reordering. The native format of a device can be an 8-, 16-, or 32-bit integer, signed or unsigned.

If you use a different integer size than the native format of the device, one integer can contain multiple samples or one sample can stretch across multiple integers. For example, if you use 32-bit integers, but the device uses 8-bit samples, one integer contains up to four samples. If you use 8-bit integers, but the device uses 16-bit samples, a sample might require two integers. This behavior varies from device to device. Refer to your device documentation for more information.

NI-DAQmx does not separate raw data into channels. It accepts data in an interleaved or non-interleaved 1D array, depending on the raw ordering of the device. Refer to your device documentation for more information.

If the task uses on-demand timing, this method returns only after the device generates all samples. On-demand is the default timing type if you do not use the timing property on the task to configure a sample timing type. If the task uses any timing type other than on-demand, this method returns immediately and does not wait for the device to generate all samples. Your application must determine if the task is done to ensure that the device generated all samples.

Use the “auto_start” property on the stream to specify if this method automatically starts the stream’s owning task if you did not explicitly start it with the DAQmx Start Task method.

Use the “timeout” property on the stream to specify the amount of time in seconds to wait for the method to write all samples. NI-DAQmx performs a timeout check only if the method must wait before it writes data. This method returns an error if the time elapses. The default timeout is 10 seconds. If you set timeout to nidaqmx.WAIT_INFINITELY, the method waits indefinitely. If you set timeout to 0, the method tries once to write the submitted samples. If the method could not write all the submitted samples, it returns an error and the number of samples successfully written.

Parameters:

numpy_array (numpy.ndarray) – Specifies a 1D NumPy array that contains the raw samples to write to the task.

Returns:

Specifies the actual number of samples per channel successfully written to the buffer.

Return type:

int

class nidaqmx.task.Task(new_task_name='', *, grpc_options=None)[source]

Bases: object

Represents a DAQmx Task.

__eq__(other)[source]

Return self==value.

__hash__()[source]

Return hash(self).

__init__(new_task_name='', *, grpc_options=None)[source]

Creates a DAQmx task.

Parameters:
  • new_task_name (Optional[str]) –

    Specifies the name to assign to the task.

    If you use this method in a loop and specify a name for the task, you must use the DAQmx Clear Task method within the loop after you are finished with the task. Otherwise, NI-DAQmx attempts to create multiple tasks with the same name, which results in an error.

  • grpc_options (Optional[GrpcSessionOptions]) – Specifies the gRPC session options.

__ne__(other)[source]

Return self!=value.

__repr__()[source]

Return repr(self).

__weakref__

list of weak references to the object (if defined)

add_global_channels(global_channels)[source]

Adds global virtual channels from MAX to the given task.

Parameters:

global_channels (List[nidaqmx.system.storage.persisted_channel.PersistedChannel]) –

Specifies the channels to add to the task.

These channels must be valid channels available from MAX. If you pass an invalid channel, NI-DAQmx returns an error. This value is ignored if it is empty.

property ai_channels: AIChannelCollection

Gets the collection of analog input channels for this task.

property ao_channels: AOChannelCollection

Gets the collection of analog output channels for this task.

property channel_names

Indicates the names of all virtual channels in the task.

Type:

List[str]

property channels

Specifies a channel object that represents the entire list of virtual channels in this task.

Type:

nidaqmx.task.channels.Channel

property ci_channels: CIChannelCollection

Gets the collection of counter input channels for this task.

close()[source]

Clears the task.

Before clearing, this method aborts the task, if necessary, and releases any resources the task reserved. You cannot use a task after you clear it unless you recreate the task.

If you create a DAQmx Task object within a loop, use this method within the loop after you are finished with the task to avoid allocating unnecessary memory.

property co_channels: COChannelCollection

Gets the collection of counter output channels for this task.

control(action)[source]

Alters the state of a task according to the action you specify.

Parameters:

action (nidaqmx.constants.TaskMode) – Specifies how to alter the task state.

property devices

Indicates a list of Device objects representing all the devices in the task.

Type:

List[nidaqmx.system.device.Device]

property di_channels: DIChannelCollection

Gets the collection of digital input channels for this task.

property do_channels: DOChannelCollection

Gets the collection of digital output channels for this task.

property export_signals: ExportSignals

Gets the exported signal configurations for the task.

property in_stream: InStream

Gets the read configurations for the task.

is_task_done()[source]

Queries the status of the task and indicates if it completed execution. Use this function to ensure that the specified operation is complete before you stop the task.

Returns:

Indicates if the measurement or generation completed.

Return type:

bool

property name

Indicates the name of the task.

Type:

str

property number_of_channels

Indicates the number of virtual channels in the task.

Type:

int

property number_of_devices

Indicates the number of devices in the task.

Type:

int

property out_stream: OutStream

Gets the write configurations for the task.

perform_bridge_offset_nulling_cal(channel='', skip_unsupported_channels=False)[source]

Perform a bridge offset nulling calibration on the channels in the task.

If the task measures both bridge-based sensors and non-bridge-based sensors, use the channels input to specify the names of the channels that measure bridge-based sensors.

Parameters:
  • channel – is a subset of virtual channels in the task that you want to calibrate. Use this input if you do not want to calibrate all the channels in the task or if some channels in the task have open thermocouple detection disabled. If the input is empty, this VI attempts to calibrate all virtual channels in the task.

  • skip_unsupported_channels – specifies whether or not to skip channels that do not support calibration. If skip unsupported channels is TRUE, this VI calibrates only supported channels. If FALSE, this VI calibrates the channels specified by channels. The default is FALSE.

perform_bridge_shunt_cal(channel='', shunt_resistor_value=100000, shunt_resistor_location=ShuntElementLocation.R3, shunt_resistor_select=ShuntCalSelect.A, shunt_resistor_source=ShuntCalSource.DEFAULT, bridge_resistance=120, skip_unsupported_channels=False)[source]

Perform shunt calibration for the specified channels using a bridge sensor.

Refer to the calibration procedure for your module for detailed calibration instructions.

Parameters:
  • channel – Specifies a subset of virtual channels in the task that you want to calibrate. Use this input if you do not want to calibrate all the channels in the task or if some channels in the task measure non-bridge-based sensors. If the input is empty, this method attempts to calibrate all virtual channels in the task.

  • shunt_resistor_value – Specifies the shunt resistance in ohms.

  • shunt_resistor_location – Specifies the location of the shunt resistor.

  • shunt_resistor_select – Specifies which shunt calibration switch to enable.

  • shunt_resistor_source – Specifies which shunt to use.

  • bridge_resistance – Specifies the bridge resistance in ohms. A value of -1 means to use the nominal bridge resistance specified when you created the virtual channel.

  • skip_unsupported_channels – Specifies whether or not to skip channels that do not support calibration. If skip_unsupported_channels is True, this method calibrates only supported channels. If False, this method calibrates the channels specified by channels. The default is False.

perform_strain_shunt_cal(channel='', shunt_resistor_value=100000, shunt_resistor_location=ShuntElementLocation.R3, shunt_resistor_select=ShuntCalSelect.A, shunt_resistor_source=ShuntCalSource.DEFAULT, skip_unsupported_channels=False)[source]

Perform shunt calibration for the specified channels using a strain gage sensor.

Refer to the calibration procedure for your module for detailed calibration instructions.

Parameters:
  • channel – Specifies a subset of virtual channels in the task that you want to calibrate. Use this input if you do not want to calibrate all the channels in the task or if some channels in the task measure non-bridge-based sensors. If the input is empty, this method attempts to calibrate all virtual channels in the task.

  • shunt_resistor_value – Specifies the shunt resistance in ohms.

  • shunt_resistor_location – Specifies the location of the shunt resistor.

  • shunt_resistor_select – Specifies which shunt calibration switch to enable.

  • shunt_resistor_source – Specifies which shunt to use.

  • skip_unsupported_channels – Specifies whether or not to skip channels that do not support calibration. If skip_unsupported_channels is True, this method calibrates only supported channels. If False, this method calibrates the channels specified by channels. The default is False.

perform_thrmcpl_lead_offset_nulling_cal(channel='', skip_unsupported_channels=False)[source]

Perform thermocouple lead offset nulling calibration on the channels in the task.

This is to compensate for offsets introduced by open thermocouple detection. Keep the measured temperature as constant as possible while performing this adjustment.

Parameters:
  • channel – is a subset of virtual channels in the task that you want to calibrate. Use this input if you do not want to calibrate all the channels in the task or if some channels in the task have open thermocouple detection disabled. If the input is empty, this VI attempts to calibrate all virtual channels in the task.

  • skip_unsupported_channels – specifies whether or not to skip channels that do not support calibration. If skip unsupported channels is TRUE, this VI calibrates only supported channels. If FALSE, this VI calibrates the channels specified by channels. The default is FALSE.

read(number_of_samples_per_channel=<nidaqmx.task._task.UnsetNumSamplesSentinel object>, timeout=10.0)[source]

Reads samples from the task or virtual channels you specify.

This read method is dynamic, and is capable of inferring an appropriate return type based on these factors: - The channel type of the task. - The number of channels to read. - The number of samples per channel.

The data type of the samples returned is independently determined by the channel type of the task.

For digital input measurements, the data type of the samples returned is determined by the line grouping format of the digital lines. If the line grouping format is set to “one channel for all lines”, the data type of the samples returned is int. If the line grouping format is set to “one channel per line”, the data type of the samples returned is boolean.

If you do not set the number of samples per channel, this method assumes one sample was requested. This method then returns either a scalar (1 channel to read) or a list (N channels to read).

If you set the number of samples per channel to ANY value (even 1), this method assumes multiple samples were requested. This method then returns either a list (1 channel to read) or a list of lists (N channels to read).

Parameters:
  • number_of_samples_per_channel (Optional[int]) –

    Specifies the number of samples to read. If this input is not set, assumes samples to read is 1. Conversely, if this input is set, assumes there are multiple samples to read.

    If you set this input to nidaqmx.constants. READ_ALL_AVAILABLE, NI-DAQmx determines how many samples to read based on if the task acquires samples continuously or acquires a finite number of samples.

    If the task acquires samples continuously and you set this input to nidaqmx.constants.READ_ALL_AVAILABLE, this method reads all the samples currently available in the buffer.

    If the task acquires a finite number of samples and you set this input to nidaqmx.constants.READ_ALL_AVAILABLE, the method waits for the task to acquire all requested samples, then reads those samples. If you set the “read_all_avail_samp” property to True, the method reads the samples currently available in the buffer and does not wait for the task to acquire all requested samples.

  • timeout (Optional[float]) – Specifies the amount of time in seconds to wait for samples to become available. If the time elapses, the method returns an error and any samples read before the timeout elapsed. The default timeout is 10 seconds. If you set timeout to nidaqmx.constants.WAIT_INFINITELY, the method waits indefinitely. If you set timeout to 0, the method tries once to read the requested samples and returns an error if it is unable to.

Returns:

The samples requested in the form of a scalar, a list, or a list of lists. See method docstring for more info.

NI-DAQmx scales the data to the units of the measurement, including any custom scaling you apply to the channels. Use a DAQmx Create Channel method to specify these units.

Return type:

dynamic

Example

>>> task = Task()
>>> task.ai_channels.add_ai_voltage_chan('Dev1/ai0:3')
>>> data = task.read()
>>> type(data)
<type 'list'>
>>> type(data[0])
<type 'float'>
register_done_event(callback_method)[source]

Registers a callback function to receive an event when a task stops due to an error or when a finite acquisition task or finite generation task completes execution. A Done event does not occur when a task is stopped explicitly, such as by calling DAQmx Stop Task.

Parameters:

callback_method (function) –

Specifies the function that you want DAQmx to call when the event occurs. The function you pass in this parameter must have the following prototype:

>>> def callback(task_handle, status, callback_data):
>>>     return 0

Upon entry to the callback, the task_handle parameter contains the handle to the task on which the event occurred. The status parameter contains the status of the task when the event occurred. If the status value is negative, it indicates an error. If the status value is zero, it indicates no error. If the status value is positive, it indicates a warning. The callbackData parameter contains the value you passed in the callbackData parameter of this function.

Passing None for this parameter unregisters the event callback function.

register_every_n_samples_acquired_into_buffer_event(sample_interval, callback_method)[source]

Registers a callback function to receive an event when the specified number of samples is written from the device to the buffer. This function only works with devices that support buffered tasks.

When you stop a task explicitly any pending events are discarded. For example, if you call DAQmx Stop Task then you do not receive any pending events.

Parameters:
  • sample_interval (int) – Specifies the number of samples after which each event should occur.

  • callback_method (function) –

    Specifies the function that you want DAQmx to call when the event occurs. The function you pass in this parameter must have the following prototype:

    >>> def callback(task_handle, every_n_samples_event_type,
    >>>         number_of_samples, callback_data):
    >>>     return 0
    

    Upon entry to the callback, the task_handle parameter contains the handle to the task on which the event occurred. The every_n_samples_event_type parameter contains the EveryNSamplesEventType.ACQUIRED_INTO_BUFFER value. The number_of_samples parameter contains the value you passed in the sample_interval parameter of this function. The callback_data parameter contains the value you passed in the callback_data parameter of this function.

    Passing None for this parameter unregisters the event callback function.

register_every_n_samples_transferred_from_buffer_event(sample_interval, callback_method)[source]

Registers a callback function to receive an event when the specified number of samples is written from the buffer to the device. This function only works with devices that support buffered tasks.

When you stop a task explicitly any pending events are discarded. For example, if you call DAQmx Stop Task then you do not receive any pending events.

Parameters:
  • sample_interval (int) – Specifies the number of samples after which each event should occur.

  • callback_method (function) –

    Specifies the function that you want DAQmx to call when the event occurs. The function you pass in this parameter must have the following prototype:

    >>> def callback(task_handle, every_n_samples_event_type,
    >>>         number_of_samples, callback_data):
    >>>     return 0
    

    Upon entry to the callback, the task_handle parameter contains the handle to the task on which the event occurred. The every_n_samples_event_type parameter contains the EveryNSamplesEventType.TRANSFERRED_FROM_BUFFER value. The number_of_samples parameter contains the value you passed in the sample_interval parameter of this function. The callback_data parameter contains the value you passed in the callback_data parameter of this function.

    Passing None for this parameter unregisters the event callback function.

register_signal_event(signal_type, callback_method)[source]

Registers a callback function to receive an event when the specified hardware event occurs.

When you stop a task explicitly any pending events are discarded. For example, if you call DAQmx Stop Task then you do not receive any pending events.

Parameters:
  • signal_type (nidaqmx.constants.Signal) – Specifies the type of signal for which you want to receive results.

  • callback_method (function) –

    Specifies the function that you want DAQmx to call when the event occurs. The function you pass in this parameter must have the following prototype:

    >>> def callback(task_handle, signal_type, callback_data):
    >>>     return 0
    

    Upon entry to the callback, the task_handle parameter contains the handle to the task on which the event occurred. The signal_type parameter contains the integer value you passed in the signal_type parameter of this function. The callback_data parameter contains the value you passed in the callback_data parameter of this function.

    Passing None for this parameter unregisters the event callback function.

save(save_as='', author='', overwrite_existing_task=False, allow_interactive_editing=True, allow_interactive_deletion=True)[source]

Saves this task and any local channels it contains to MAX.

This function does not save global channels. Use the DAQmx Save Global Channel function to save global channels.

Parameters:
  • save_as (Optional[str]) – Is the name to save the task, global channel, or custom scale as. If you do not specify a value for this input, NI-DAQmx uses the name currently assigned to the task, global channel, or custom scale.

  • author (Optional[str]) – Is a name to store with the task, global channel, or custom scale.

  • overwrite_existing_task (Optional[bool]) – Specifies whether to overwrite a task of the same name if one is already saved in MAX. If this input is False and a task of the same name is already saved in MAX, this function returns an error.

  • allow_interactive_editing (Optional[bool]) – Specifies whether to allow the task, global channel, or custom scale to be edited in the DAQ Assistant. If allow_interactive_editing is True, the DAQ Assistant must support all task or global channel settings.

  • allow_interactive_deletion (Optional[bool]) – Specifies whether to allow the task, global channel, or custom scale to be deleted through MAX.

start()[source]

Transitions the task to the running state to begin the measurement or generation. Using this method is required for some applications and is optional for others.

If you do not use this method, a measurement task starts automatically when the DAQmx Read method runs. The autostart input of the DAQmx Write method determines if a generation task starts automatically when the DAQmx Write method runs.

If you do not use the DAQmx Start Task method and the DAQmx Stop Task method when you use the DAQmx Read method or the DAQmx Write method multiple times, such as in a loop, the task starts and stops repeatedly. Starting and stopping a task repeatedly reduces the performance of the application.

stop()[source]

Stops the task and returns it to the state the task was in before the DAQmx Start Task method ran or the DAQmx Write method ran with the autostart input set to TRUE.

If you do not use the DAQmx Start Task method and the DAQmx Stop Task method when you use the DAQmx Read method or the DAQmx Write method multiple times, such as in a loop, the task starts and stops repeatedly. Starting and stopping a task repeatedly reduces the performance of the application.

property timing: Timing

Gets the timing configurations for the task.

property triggers: Triggers

Gets the trigger configurations for the task.

wait_for_valid_timestamp(timestamp_event, timeout=10.0)[source]

Wait until the specified timestamp has a value.

Use this method to ensure the timestamp has a valid value to prevent an error when querying a timestamp value.

Parameters:
  • timestamp_event (nidaqmx.constants.TimestampEvent) – Specifies the timestamp type to wait on.

  • timeout (float) – Specifies the maximum amount of time in seconds to wait for a valid timestamp. This method returns an error if the time elapses. The default is 10. If you set timeout (sec) to nidaqmx.WAIT_INFINITELY, the method waits indefinitely.

wait_until_done(timeout=10.0)[source]

Waits for the measurement or generation to complete.

Use this method to ensure that the specified operation is complete before you stop the task.

Parameters:

timeout (Optional[float]) – Specifies the maximum amount of time in seconds to wait for the measurement or generation to complete. This method returns an error if the time elapses. The default is 10. If you set timeout (sec) to nidaqmx.WAIT_INFINITELY, the method waits indefinitely. If you set timeout (sec) to 0, the method checks once and returns an error if the measurement or generation is not done.

write(data, auto_start=<nidaqmx.task._task.UnsetAutoStartSentinel object>, timeout=10.0)[source]

Writes samples to the task or virtual channels you specify.

This write method is dynamic, and is capable of accepting the samples to write in the various forms for most operations:

  • Scalar: Single sample for 1 channel.

  • List/1D numpy.ndarray: Multiple samples for 1 channel or 1 sample for multiple channels.

  • List of lists/2D numpy.ndarray: Multiple samples for multiple channels.

The data type of the samples passed in must be appropriate for the channel type of the task.

For counter output pulse operations, this write method only accepts samples in these forms:

  • Scalar CtrFreq, CtrTime, CtrTick (from nidaqmx.types): Single sample for 1 channel.

  • List of CtrFreq, CtrTime, CtrTick (from nidaqmx.types): Multiple samples for 1 channel or 1 sample for multiple channels.

If the task uses on-demand timing, this method returns only after the device generates all samples. On-demand is the default timing type if you do not use the timing property on the task to configure a sample timing type. If the task uses any timing type other than on-demand, this method returns immediately and does not wait for the device to generate all samples. Your application must determine if the task is done to ensure that the device generated all samples.

Parameters:
  • data (dynamic) –

    Contains the samples to write to the task.

    The data you write must be in the units of the generation, including any custom scales. Use the DAQmx Create Channel methods to specify these units.

  • auto_start (Optional[bool]) –

    Specifies if this method automatically starts the task if you did not explicitly start it with the DAQmx Start Task method.

    The default value of this parameter depends on whether you specify one sample or many samples to write to each channel. If one sample per channel was specified, the default value is True. If multiple samples per channel were specified, the default value is False.

  • timeout (Optional[float]) – Specifies the amount of time in seconds to wait for the method to write all samples. NI-DAQmx performs a timeout check only if the method must wait before it writes data. This method returns an error if the time elapses. The default timeout is 10 seconds. If you set timeout to nidaqmx.constants.WAIT_INFINITELY, the method waits indefinitely. If you set timeout to 0, the method tries once to write the submitted samples. If the method could not write all the submitted samples, it returns an error and the number of samples successfully written.

Returns:

Specifies the actual number of samples this method successfully wrote.

Return type:

int

class nidaqmx.task.Timing(task_handle, interpreter)[source]

Bases: object

Represents the timing configurations for a DAQmx task.

__init__(task_handle, interpreter)[source]
__weakref__

list of weak references to the object (if defined)

property ai_conv_active_edge

Specifies on which edge of the clock pulse an analog-to-digital conversion takes place.

Type:

nidaqmx.constants.Edge

property ai_conv_dig_fltr_enable

Specifies whether to apply a digital filter to the AI Convert Clock.

Type:

bool

property ai_conv_dig_fltr_min_pulse_width

Specifies in seconds the minimum pulse width the filter recognizes.

Type:

float

property ai_conv_dig_fltr_timebase_rate

Specifies in hertz the rate of the digital filter timebase. NI-DAQmx uses this value to compute settings for the filter.

Type:

float

property ai_conv_dig_fltr_timebase_src

Specifies the terminal of the signal to use as the timebase of the digital filter.

Type:

str

property ai_conv_dig_sync_enable

Specifies whether to synchronize recognition of transitions in the signal to the internal timebase of the device.

Type:

bool

property ai_conv_max_rate

Indicates the maximum convert rate supported by the task, given the current devices and channel count.

Type:

float

property ai_conv_rate

Specifies in Hertz the rate at which to clock the analog- to-digital converter. This clock is specific to the analog input section of multiplexed devices.

Type:

float

property ai_conv_src

Specifies the terminal of the signal to use as the AI Convert Clock.

Type:

str

property ai_conv_timebase_div

Specifies the number of AI Convert Clock Timebase pulses needed to produce a single AI Convert Clock pulse.

Type:

int

property ai_conv_timebase_src

Specifies the terminal of the signal to use as the AI Convert Clock Timebase.

Type:

nidaqmx.constants.MIOAIConvertTimebaseSource

cfg_burst_handshaking_timing_export_clock(sample_clk_rate, sample_clk_outp_term, sample_mode=AcquisitionType.FINITE, samps_per_chan=1000, sample_clk_pulse_polarity=Polarity.ACTIVE_HIGH, pause_when=Level.HIGH, ready_event_active_level=Polarity.ACTIVE_HIGH)[source]

Configures when the DAQ device transfers data to a peripheral device, using the onboard Sample Clock of the DAQ device to control burst handshake timing and exporting that clock for use by the peripheral device.

Parameters:
  • sample_clk_rate (float) – Specifies in hertz the rate of the Sample Clock.

  • sample_clk_outp_term (str) – Specifies the terminal to which to export the Sample Clock.

  • sample_mode (Optional[nidaqmx.constants.AcquisitionType]) – Specifies if the task acquires or generates samples continuously or if it acquires or generates a finite number of samples.

  • samps_per_chan (Optional[int]) – Specifies the number of samples to acquire or generate for each channel in the task if sample_mode is FINITE_SAMPLES. If sample_mode is CONTINUOUS_SAMPLES, NI-DAQmx uses this value to determine the buffer size. This function returns an error if the specified value is negative.

  • sample_clk_pulse_polarity (Optional[nidaqmx.constants.Polarity]) – Specifies the polarity of the exported Sample Clock.

  • pause_when (Optional[nidaqmx.constants.Level]) – Specifies whether the task pauses while the trigger signal is high or low.

  • ready_event_active_level (Optional[nidaqmx.constants.Polarity]) – Specifies the polarity of the Ready for Transfer Event.

cfg_burst_handshaking_timing_import_clock(sample_clk_rate, sample_clk_src, sample_mode=AcquisitionType.FINITE, samps_per_chan=1000, sample_clk_active_edge=Edge.RISING, pause_when=Level.HIGH, ready_event_active_level=Polarity.ACTIVE_HIGH)[source]

Configures when the DAQ device transfers data to a peripheral device, using an imported sample clock to control burst handshake timing.

Parameters:
  • sample_clk_rate (float) – Specifies in hertz the rate of the Sample Clock.

  • sample_clk_src (str) – Specifies the source terminal of the Sample Clock. Leave this input unspecified to use the default onboard clock of the device.

  • sample_mode (Optional[nidaqmx.constants.AcquisitionType]) – Specifies if the task acquires or generates samples continuously or if it acquires or generates a finite number of samples.

  • samps_per_chan (Optional[int]) – Specifies the number of samples to acquire or generate for each channel in the task if sample_mode is FINITE_SAMPLES. If sample_mode is CONTINUOUS_SAMPLES, NI-DAQmx uses this value to determine the buffer size. This function returns an error if the specified value is negative.

  • sample_clk_active_edge (Optional[nidaqmx.constants.Edge]) – Specifies on which edges of Sample Clock pulses to acquire or generate samples.

  • pause_when (Optional[nidaqmx.constants.Level]) – Specifies whether the task pauses while the trigger signal is high or low.

  • ready_event_active_level (Optional[nidaqmx.constants.Polarity]) – Specifies the polarity of the Ready for Transfer Event.

cfg_change_detection_timing(rising_edge_chan='', falling_edge_chan='', sample_mode=AcquisitionType.FINITE, samps_per_chan=1000)[source]

Configures the task to acquire samples on the rising and/or falling edges of the lines or ports you specify. To detect both rising and falling edges on a line or port, specify the name of that line or port to both rising_edge_chan and falling_edge_chan.

Parameters:
  • rising_edge_chan (Optional[str]) – Specifies the names of the digital lines or ports on which to detect rising edges. The DAQmx physical channel constant lists all lines and ports for devices installed in your system.

  • falling_edge_chan (Optional[str]) – Specifies the names of the digital lines or ports on which to detect falling edges. The DAQmx physical channel constant lists all lines and ports for devices installed in your system.

  • sample_mode (Optional[nidaqmx.constants.AcquisitionType]) – Specifies if the task acquires samples continuously or if it acquires a finite number of samples.

  • samps_per_chan (Optional[int]) – Specifies the number of samples to acquire from each channel in the task if sample_mode is FINITE_SAMPLES. This function returns an error if the specified value is negative.

cfg_handshaking_timing(sample_mode=AcquisitionType.FINITE, samps_per_chan=1000)[source]

Determines the number of digital samples to acquire or generate using digital handshaking between the device and a peripheral device.

Parameters:
  • sample_mode (Optional[nidaqmx.constants.AcquisitionType]) – Specifies if the task acquires or generates samples continuously or if it acquires or generates a finite number of samples.

  • samps_per_chan (Optional[int]) – Specifies the number of samples to acquire or generate for each channel in the task if sample_mode is FINITE_SAMPLES. If sample_mode is CONTINUOUS_SAMPLES, NI-DAQmx uses this value to determine the buffer size. This function returns an error if the specified value is negative.

cfg_implicit_timing(sample_mode=AcquisitionType.FINITE, samps_per_chan=1000)[source]

Sets only the number of samples to acquire or generate without specifying timing. Typically, you should use this instance when the task does not require sample timing, such as tasks that use counters for buffered frequency measurement, buffered period measurement, or pulse train generation. For finite counter output tasks, samps_per_chan is the number of pulses to generate.

Parameters:
  • sample_mode (Optional[nidaqmx.constants.AcquisitionType]) – Specifies if the task acquires or generates samples continuously or if it acquires or generates a finite number of samples.

  • samps_per_chan (Optional[int]) – Specifies the number of samples to acquire or generate for each channel in the task if sample_mode is FINITE_SAMPLES. If sample_mode is CONTINUOUS_SAMPLES, NI-DAQmx uses this value to determine the buffer size. This function returns an error if the specified value is negative.

cfg_pipelined_samp_clk_timing(rate, source='', active_edge=Edge.RISING, sample_mode=AcquisitionType.FINITE, samps_per_chan=1000)[source]

Sets the source of the Sample Clock, the rate of the Sample Clock, and the number of samples to acquire or generate. The device acquires or generates samples on each Sample Clock edge, but it does not respond to certain triggers until a few Sample Clock edges later. Pipelining allows higher data transfer rates at the cost of increased trigger response latency. Refer to the device documentation for information about which triggers pipelining affects. This timing type allows handshaking using the Pause trigger and either the Ready for Transfer event or the Data Active event. Refer to the device documentation for more information. This timing type is supported only by the NI 6536 and NI 6537.

Parameters:
  • rate (float) – Specifies the sampling rate in samples per channel per second. If you use an external source for the Sample Clock, set this input to the maximum expected rate of that clock.

  • source (Optional[str]) – Specifies the source terminal of the Sample Clock. Leave this input unspecified to use the default onboard clock of the device.

  • active_edge (Optional[nidaqmx.constants.Edge]) – Specifies on which edges of Sample Clock pulses to acquire or generate samples.

  • sample_mode (Optional[nidaqmx.constants.AcquisitionType]) – Specifies if the task acquires or generates samples continuously or if it acquires or generates a finite number of samples.

  • samps_per_chan (Optional[int]) – Specifies the number of samples to acquire or generate for each channel in the task if sample_mode is FINITE_SAMPLES. If sample_mode is CONTINUOUS_SAMPLES, NI-DAQmx uses this value to determine the buffer size. This function returns an error if the specified value is negative.

cfg_samp_clk_timing(rate, source='', active_edge=Edge.RISING, sample_mode=AcquisitionType.FINITE, samps_per_chan=1000)[source]

Sets the source of the Sample Clock, the rate of the Sample Clock, and the number of samples to acquire or generate.

Parameters:
  • rate (float) – Specifies the sampling rate in samples per channel per second. If you use an external source for the Sample Clock, set this input to the maximum expected rate of that clock.

  • source (Optional[str]) – Specifies the source terminal of the Sample Clock. Leave this input unspecified to use the default onboard clock of the device.

  • active_edge (Optional[nidaqmx.constants.Edge]) – Specifies on which edges of Sample Clock pulses to acquire or generate samples.

  • sample_mode (Optional[nidaqmx.constants.AcquisitionType]) – Specifies if the task acquires or generates samples continuously or if it acquires or generates a finite number of samples.

  • samps_per_chan (Optional[int]) – Specifies the number of samples to acquire or generate for each channel in the task if sample_mode is FINITE_SAMPLES. If sample_mode is CONTINUOUS_SAMPLES, NI-DAQmx uses this value to determine the buffer size. This function returns an error if the specified value is negative.

property change_detect_di_falling_edge_physical_chans

nidaqmx.system.physical_channel.PhysicalChannel: Specifies the names of the digital lines or ports on which to detect falling edges. The lines or ports must be used by virtual channels in the task. You also can specify a string that contains a list or range of digital lines or ports.

property change_detect_di_rising_edge_physical_chans

nidaqmx.system.physical_channel.PhysicalChannel: Specifies the names of the digital lines or ports on which to detect rising edges. The lines or ports must be used by virtual channels in the task. You also can specify a string that contains a list or range of digital lines or ports.

property change_detect_di_tristate

Specifies whether to tristate lines specified with change_detect_di_rising_edge_physical_chans and change_detect_di_falling_edge_physical_chans that are not in a virtual channel in the task. If you set this property to True, NI-DAQmx tristates rising/falling edge lines that are not in a virtual channel in the task. If you set this property to False, NI-DAQmx does not modify the configuration of rising/falling edge lines that are not in a virtual channel in the task, even if the lines were previously tristated. Set this property to False to detect changes on lines in other tasks or to detect changes on output-only lines.

Type:

bool

property delay_from_samp_clk_delay

Specifies the amount of time to wait after receiving a Sample Clock edge before beginning to acquire the sample. This value is in the units you specify with delay_from_samp_clk_delay_units.

Type:

float

property delay_from_samp_clk_delay_units

Specifies the units of delay_from_samp_clk_delay.

Type:

nidaqmx.constants.DigitalWidthUnits

property first_samp_timestamp_enable

Specifies whether to enable the first sample timestamp.

Type:

bool

property first_samp_timestamp_timescale

Specifies the timescale to be used for the first sample timestamp.

Type:

nidaqmx.constants.Timescale

property hshk_delay_after_xfer

Specifies the number of seconds to wait after a handshake cycle before starting a new handshake cycle.

Type:

float

property hshk_sample_input_data_when

Specifies on which edge of the Handshake Trigger an input task latches the data from the peripheral device.

Type:

nidaqmx.constants.SampleInputDataWhen

property hshk_start_cond

Specifies the point in the handshake cycle that the device is in when the task starts.

Type:

nidaqmx.constants.HandshakeStartCondition

property implicit_underflow_behavior

Specifies the action to take when the onboard memory of the device becomes empty.

Type:

nidaqmx.constants.UnderflowBehavior

property master_timebase_rate

Specifies the rate of the Master Timebase.

Type:

float

property master_timebase_src

Specifies the terminal of the signal to use as the Master Timebase. On an E Series device, you can choose only between the onboard 20MHz Timebase or the RTSI7 terminal.

Type:

str

property ref_clk_rate

Specifies the frequency of the Reference Clock.

Type:

float

property ref_clk_src

Specifies the terminal of the signal to use as the Reference Clock.

Type:

str

property samp_clk_active_edge

Specifies on which edge of a clock pulse sampling takes place. This property is useful primarily when the signal you use as the Sample Clock is not a periodic clock.

Type:

nidaqmx.constants.Edge

property samp_clk_dig_fltr_enable

Specifies whether to apply the pulse width filter to the signal.

Type:

bool

property samp_clk_dig_fltr_min_pulse_width

Specifies in seconds the minimum pulse width the filter recognizes.

Type:

float

property samp_clk_dig_fltr_timebase_rate

Specifies in hertz the rate of the pulse width filter timebase. NI-DAQmx uses this value to compute settings for the filter.

Type:

float

property samp_clk_dig_fltr_timebase_src

Specifies the input terminal of the signal to use as the timebase of the pulse width filter.

Type:

str

property samp_clk_dig_sync_enable

Specifies whether to synchronize recognition of transitions in the signal to the internal timebase of the device.

Type:

bool

property samp_clk_max_rate

Indicates the maximum Sample Clock rate supported by the task, based on other timing settings. For output tasks, the maximum Sample Clock rate is the maximum rate of the DAC. For input tasks, NI-DAQmx calculates the maximum sampling rate differently for multiplexed devices than simultaneous sampling devices.

Type:

float

property samp_clk_overrun_behavior

Specifies the action to take if Sample Clock edges occur faster than the device can handle them.

Type:

nidaqmx.constants.OverflowBehavior

property samp_clk_rate

Specifies the sampling rate in samples per channel per second. If you use an external source for the Sample Clock, set this input to the maximum expected rate of that clock.

Type:

float

property samp_clk_src

Specifies the terminal of the signal to use as the Sample Clock.

Type:

str

property samp_clk_term

Indicates the name of the internal Sample Clock terminal for the task. This property does not return the name of the Sample Clock source terminal specified with samp_clk_src.

Type:

str

property samp_clk_timebase_active_edge

Specifies on which edge to recognize a Sample Clock Timebase pulse. This property is useful primarily when the signal you use as the Sample Clock Timebase is not a periodic clock.

Type:

nidaqmx.constants.Edge

property samp_clk_timebase_div

Specifies the number of Sample Clock Timebase pulses needed to produce a single Sample Clock pulse.

Type:

int

property samp_clk_timebase_master_timebase_div

Specifies the number of pulses of the Master Timebase needed to produce a single pulse of the Sample Clock Timebase.

Type:

int

property samp_clk_timebase_rate

Specifies the rate of the Sample Clock Timebase. Some applications require that you specify a rate when you use any signal other than the onboard Sample Clock Timebase. NI- DAQmx requires this rate to calculate other timing parameters.

Type:

float

property samp_clk_timebase_src

Specifies the terminal of the signal to use as the Sample Clock Timebase.

Type:

str

property samp_clk_timebase_term

Indicates the name of the internal Sample Clock Timebase terminal for the task. This property does not return the name of the Sample Clock Timebase source terminal specified with samp_clk_timebase_src.

Type:

str

property samp_clk_underflow_behavior

Specifies the action to take when the onboard memory of the device becomes empty. In either case, the sample clock does not stop.

Type:

nidaqmx.constants.UnderflowBehavior

property samp_clk_write_wfm_use_initial_wfm_dt

Specifies that the value of samp_clk_rate will be determined by the dt component of the initial DAQmx Write waveform input for Output tasks.

Type:

bool

property samp_quant_samp_mode

Specifies if a task acquires or generates a finite number of samples or if it continuously acquires or generates samples.

Type:

nidaqmx.constants.AcquisitionType

property samp_quant_samp_per_chan

Specifies the number of samples to acquire or generate for each channel if samp_quant_samp_mode is AcquisitionType.FINITE. If samp_quant_samp_mode is AcquisitionType.CONTINUOUS, NI-DAQmx uses this value to determine the buffer size.

Type:

int

property samp_timing_engine

Specifies which timing engine to use for the task.

Type:

int

property samp_timing_type

Specifies the type of sample timing to use for the task.

Type:

nidaqmx.constants.SampleTimingType

property simultaneous_ao_enable

Specifies whether to update all channels in the task simultaneously, rather than updating channels independently when you write a sample to that channel.

Type:

bool

property sync_clk_interval

Specifies the interval, in Sample Clock periods, between each internal Synchronization Clock pulse. NI-DAQmx uses this pulse for synchronization of triggers between multiple devices at different rates. Refer to device documentation for information about how to calculate this value.

Type:

int

property sync_pulse_min_delay_to_start

Specifies in seconds the amount of time that elapses after the master device issues the synchronization pulse before the task starts.

Type:

float

property sync_pulse_reset_delay

Specifies in seconds the amount of time to wait after the Synchronization Pulse before resetting the ADCs or DACs on the device. When synchronizing devices, query sync_pulse_reset_time on all devices and note the largest reset time. Then, for each device, subtract the reset time from the largest reset time and set this property to the resulting value.

Type:

float

property sync_pulse_reset_time

Indicates in seconds the amount of time required for the ADCs or DACs on the device to reset. When synchronizing devices, query this property on all devices and note the largest reset time. Then, for each device, subtract the value of this property from the largest reset time and set sync_pulse_reset_delay to the resulting value.

Type:

float

property sync_pulse_src

Specifies the terminal of the signal to use as the synchronization pulse. The synchronization pulse resets the clock dividers and the ADCs/DACs on the device.

Type:

str

property sync_pulse_sync_time

Indicates in seconds the delay required to reset the ADCs/DACs after the device receives the synchronization pulse.

Type:

float

property sync_pulse_term

Indicates the name of the internal Synchronization Pulse terminal for the task. This property does not return the name of the source terminal.

Type:

str

property sync_pulse_time_timescale

Specifies the timescale to be used for timestamps for a sync pulse.

Type:

nidaqmx.constants.Timescale

property sync_pulse_type

Specifies the type of sync pulse used in the task.

Type:

nidaqmx.constants.SyncPulseType