08-05-2023 09:36 PM
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.
12-08-2023 03:36 AM
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.