Multifunction DAQ

cancel
Showing results for 
Search instead for 
Did you mean: 

Analog output error for nidaqmx

Hi! I would like to input the analog output triggers to EEG through NI USB-6003 using nidaqmx by Python.

In programming, there are two types of triggers, and the output trigger changes depending on the data being read ("image_type").

The following is the program.

 

task = nidaqmx.Task()
task01 = nidaqmx.Task()

task.ao_channels.add_ao_voltage_chan('Dev2/ao0', min_val=-4, max_val=8)
task01.ao_channels.add_ao_voltage_chan('Dev2/ao1', min_val=-4, max_val=8)

task.start()
task01.start()

task.write(0)
task01.write(0)

 

if image_type == 1:
task.write(5)
else:
task01.write(5)

 

Although I can send the trigger from "task01", the trigger from "task" doesn't work. I have no idea how to fix the problem.

 I am glad if someone helped me.

 

Thank you.

0 Kudos
Message 1 of 2
(1,197 Views)

Although I never worked with the analog outputs I would suggest you to use pythons context manager (with statement). And then either use one or two tasks.

 

with nidaqmx.Task() as task, nidaqmx.Task() as task01:
task.ao_channels.add_ao_voltage_chan('Dev2/ao0', min_val=-4, max_val=8)
task01.ao_channels.add_ao_voltage_chan('Dev2/ao1', min_val=-4, max_val=8)
task.start()
task01.start()
...

 

check also the example code ni provides this might help as well.

 

 

0 Kudos
Message 2 of 2
(975 Views)