05-02-2017 04:57 AM
Hi all,
I'm using USB-6003 with Python and I have an issue when trying to use PFI to trigger an analog output generation. Please note that Analog I/O, Digital I/O and PFI to Trigger an Analog Input Acquisition works just fine. But for some reason this analog output generation is not working. The problem is that an analog output task won't wait for an edge on PFI 0 or PFI 1 before starting the acquisition. There were no errors printed out when I executed the python macro.
Please find the functions related to it. First I call "trigger analog output" and then "write analog io trigger" function.
daq = NiDAQlib.trigger_analog_output('{}/{}'.format(self.dev, port), edge_selection)
data = NiDAQlib.write_analog_io_trigger(daq, value)
def trigger_analog_output(devport, edge_selection):
max_num_samples = 2
task = Task()
task.CreateAOVoltageChan(devport, '', -10.0, 10.0, DAQmx_Val_Volts, None)
task.CfgSampClkTiming('', float64(100), DAQmx_Val_Rising,
task.CfgOutputBuffer(2)
task.CfgDigEdgeStartTrig("/Dev2/PFI0", DAQmx_Val_Rising)
return task
def write_analog_io_trigger(taskhandle, value, intimeout=10000):
samples = 2
datatype = float64*samples
data = datatype()
for i in range(samples):
data[i] = float(value)
timeout = float64(intimeout)
taskhandle.WriteAnalogF64(2, False, timeout, DAQmx_Val_GroupByChannel, data, int32(), None)
taskhandle.StartTask()
return data
Any hints are welcome!
Thanks and regards,
Antti
05-04-2017 08:34 AM
Hi Antti,
I'm afraid I am not familiar with Python syntax, but I am noticing an inconsistency in the DAQ Driver software referencing. You mention "NiDAQlib..." and also "DAQmx" - is this intentional? I ask because NI-DAQ and NI-DAQmx are two separate driver sets, with NI-DAQ being legacy and not very well supported anymore. Please note: if you are working with NI-DAQ currently, I would absolutely suggest migrating to NI-DAQmx, the drivers are available on our website.
I have found, however, some documentation that may help you.
NI-DAQmx Python Documentation
http://nidaqmx-python.readthedocs.io/en/latest/
Within this link there are further links relating to DAQ devices/systems and DAQ tasks. For example:
nidaqmx.task.start_trigger
http://nidaqmx-python.readthedocs.io/en/latest/start_trigger.html
I hope this helps!
Sarah Flanagan
Applications Engineering
National Instruments
05-09-2017 11:49 PM
Hi Sarah,
Thank you for your reply. I finally figured it out what was the problem. It started to work after I added WaitUntilTaskDone. It seems that is required when timing is configured and write task is used.
taskhandle.WriteAnalogF64(2, False, timeout, DAQmx_Val_GroupByChannel, data, int32(), None)
taskhandle.StartTask()
taskhandle.WaitUntilTaskDone(-1)
Thanks and regards,
Antti
08-19-2022 08:19 AM
Hi Antti,
I am also trying to trigger an X-series DAQ card. I am using USB-6366. However, I have some confusion. For triggering do I need to use any other pins or the analog channel pin can do it by itself? And what can be the python programming for trigeering? Can you help me? I am very new at NI DAQ devices