10-27-2021 10:05 PM
I'm writing code to write digital pulse signals to t6 channels on the NI 9403 via the DAQmx Python API. The code looks something like this:
waveform = [some_data]
my_task = Task()
for channel in some_channels:
my_Task.add_do_chan(lines = f"device/port/line{channel}")
my_task.cfg_samp_clk_timing(rate = 100000, sample_mode = AcquisitionType.CONTINUOUS, samples_per_chan = len(waveform[0]))
my_task.control(TaskMode.TASK_RESERVE)
my_task.write(waveform)
my_task.start()
The length of the waveform is about 2000 samples. The waveform will be generated continuously. I then have a button with a call-back to another function
def button_pressed():
my_task.write(some_other_waveform)
When I press a button, this new waveform will be generated, but only after 30 seconds or so.
Why is this latency so high? Should I change the buffer size? What can I do to improve performance?
11-03-2021 11:50 AM
By default DAQmx task is configured to regenerate data from the buffer continuously. So depending on your buffer size and sample clock rate, it could take a while for new data to show up on the output. I am very surprised that it took 30 seconds though. You can query the output buffer size; it is a DAQmx attribute.
Is this a Ethernet cDAQ device? Ethernet cDAQ buffers up lots of data on the device side to mitigate network latency issue, so there will be a bunch of regenerated data in the buffer on the device side to exhaust before it gets to the new data.