I'm using the python (v3.6) API nidaqmx (https://nidaqmx-python.readthedocs.io/) to interface with an NI PCI-6132 Multifunction DAQ card on a Windows 10 PC.
I'd like to be able to use a digital trigger to start the acquisition of two analog signals, but have a number of issues.
First, in adding a channel to a task, the names of the inputs on the PCI-card (http://www.ni.com/documentation/en/multifunction-io-device/latest/pci-6132/pinout/) seemingly do not correspond to the names in nidaqmx. For example, AI0 is actually "ai0" but P0.0 is actually "port0/line0". Where is there documentation that lists the nidaqmx names of the various inputs for the PCI-6132. I have not been able to figure out how to add one of the PFI inputs as a channel specifically.
Second, in order to use an input (analog or digital) is it necessary to first add that input as a channel to the task which it is triggering? For an analog trigger, this seems to be true. I have been completely unsuccessful in setting up a digital trigger. Below is my attempt at code which uses P0.0 as a digital trigger to a digital stream reader task. If you remove the trigger setup statements, the code runs fine.
###
import nidaqmx
from nidaqmx.constants import TriggerType, Edge, AcquisitionType, TaskMode, LineGrouping
with nidaqmx.Task() as trig_task:
trig_task.di_channels.add_di_chan('Dev1/port0/line0', line_grouping=LineGrouping.CHAN_PER_LINE)
trig_reader = DigitalSingleChannelReader(trig_task.in_stream)
#set up digital trigger
trig_task.triggers.start_trigger.trig_type = TriggerType.DIGITAL_EDGE
trig_task.triggers.start_trigger.cfg_dig_edge_start_trig(trigger_source = "Dev1/port0/line0", trigger_edge = Edge.RISING)
trig_task.start()
dig_data = np.zeros(n_dig_samples, dtype=np.uint8)
trig_reader.read_many_sample_port_byte(dig_data, n_dig_samples, timeout=10)
###
This code fails for me with error:
Traceback (most recent call last):
File "test_NI_DAQmx_digital_trigger.py", line 42, in <module>
trig_task.triggers.start_trigger.trig_type = TriggerType.DIGITAL_EDGE
File "C:\ProgramData\Anaconda3\lib\site-packages\nidaqmx\_task_modules\triggering\start_trigger.py", line 1838, in trig_type
check_for_error(error_code)
File "C:\ProgramData\Anaconda3\lib\site-packages\nidaqmx\errors.py", line 127, in check_for_error
raise DaqError(error_buffer.value.decode("utf-8"), error_code)
nidaqmx.errors.DaqError: Specified property is not supported by the device or is not applicable to the task.
Property: DAQmx_StartTrig_Type
Task Name: _unnamedTask<0>
Status Code: -200452
Lastly, I would like to actually use a digital trigger to start a task which does analog acquisition. How does one approach this? The nidaqmx examples (https://github.com/ni/nidaqmx-python/tree/master/nidaqmx_examples) and the usage documentation fall far short of explaining how to use the majority of this API's even basic functionality.
Thank you!
Jake Connors