0

I am using the python nidaqmx API to instruct a USB-6009 DAQ to output an analog signal when a tone plays. I am trying to use the API guidelines and also the previous stackoverflow question (Triggering an output task with NIDAQmx) but still need help.

The timing of the tone is set using Psychopy, a python-based behavioural task package.

The general format of this would be:

if tone = on:

trigger_digital_output

I just cannot figure out the code from the nidaqmx documentation to trigger the analog output. Additionally, will I need to specify a digital input (USB-6009 will be connected by USb to my computer).

Thankyou

AR141
  • 35
  • 1
  • 4

1 Answers1

0

According to its specifications, the USB-6009 does not have any hardware triggers for analog output, and only a digital edge trigger for analog input.

So for your analog output task, you would use the same approach as the topic you referenced: use stop() and start() to begin the output each time you want to generate it.

The Digital I/O on the USB-6009 is only software-timed: the input or output happens on-demand, each time you call the read_one_sample_one_line() or write_one_sample_one_line() functions.

To get started with the full DAQ commands, there are a few Python examples on GitHub

Joe Friedrichsen
  • 1,976
  • 14
  • 14
  • Thanks Joe! My python is not so great, but would you think this might work: `import nidaqmx with nidaqmx.Task() as task: task.ao_channels.add_ao_voltage_chan('Dev1/ao0') task.write(1.0) if tone = ON: task.start() else: task.stop()` ? Many thanks – AR141 Nov 21 '19 at 10:45
  • I'm _guessing_ that you want the analog output to play a sound that the user can hear, please let me know what I overlooked. The simplest sound to generate is a single tone square wave, and to generate that, the program needs to supply the entire waveform. For example, the list `[0, 1, 0, 1, 0, 1, 0]` would generate a 0V-to-1V squarewave with 3 cycles as fast as the device receives the data from the PC. Depending on the waveform you want to generate (maybe sine? maybe audio?), your program will need to calculate or read the voltage values. – Joe Friedrichsen Nov 22 '19 at 22:14