Reading and writing digital using a NI DAQ Device PCIe6321 with Python has low performance. I got up to 1 kHz. Here is the code. Python steadily works out an input signal of 300 Hz and the output is also synchronously 300 Hz. When the frequency is raised to 5 kHz, chaotic signals are obtained at the output, which are not synchronous with the input. And you need to raise the input frequency to 50 kHz. Is it possible to increase the exchange rate to 50 kHz. Or is it not possible in Python? Thanks for your attention and advice.
import mathimport numpy as npimport timeimport nidaqmximport nidaqmx.system
system = nidaqmx.system.System.local()
system.driver_versionfor device in system.devices:print(device)with nidaqmx.Task() as input_task, nidaqmx.Task() as output_task:
input_task.di_channels.add_di_chan("Dev1/port0/line2")
output_task.do_channels.add_do_chan("Dev1/port1/line3")
input_task.start()
output_task.start()whileTrue:
input_data = input_task.read(number_of_samples_per_channel=1)
output_task.write(np.array(input_data, dtype=bool).tolist())