Hello everyone !
I've just bought a NI-9401 for some stuff I'm working on. I'm using Python with this device and I'm having trouble. I spent the last 3 days searching everywhere online and I couldn't seem to find any answers (I'm fairly new to both Python and NI btw).
So here is the thing : I want to test the device by transfering some floats from a digital output to a digital input.
Here is my code so far :
import nidaqmx as ni import numpy as np import matplotlib.pyplot as plt from nidaqmx.constants import (LineGrouping) ## Emission ## fe = 44100 f = 440 T = 0.05 t = np.linspace(0, 0.05, fe*0.05) sig_E = np.sin(f*2*np.pi*t) plt.figure() plt.subplot(211) plt.plot(t, sig_E) plt.title("Signal Emis") plt.tight_layout() with ni.Task() as task: task.do_channels.add_do_chan("cDAQ1Mod1/port0/line0", line_grouping=LineGrouping.CHAN_FOR_ALL_LINES) task.write(sig_E) ## Reception ## with ni.Task() as task: task.di_channels.add_di_chan("cDAQ1Mod1/port0/line4", line_grouping=LineGrouping.CHAN_FOR_ALL_LINES) sig_R = task.read(number_of_samples_per_channel=len(t)) plt.subplot(212) plt.plot(t,sig_R) plt.title("Signal Recu") plt.tight_layout() plt.show()
So it's 5 seconds of a sine at 440 Hz and I want to send it from the DO to the DI (linked with a cable). But the error message I get is that the "write" function can only send boolean samples and obviously I want to send floats.
So how can I send my sine through the digital output (and read it from the digital input)? What are the appropriate functions ?
Thank you in advance for your help.
Best regards.