poster
2019-11-27, 07:35
<p>I currently have NI BNC-2110 connect to the NI USB-6255 which is then connected to my computer.
My goal is to generate a digital output through the NI BNC-2110 and then read the output on an analog input on the same NI BNC-2110. (The perpose of this is to make sure that I know how to properly output a digital signal and can input an analog signal, and I figured this would just check both things simultaneously.) </p>
<p>The setup works when generating a digital signal and reading an analog when I use the software NI MAX, my problem is when I try and do the same thing in matlab.
Here is my current code in matlab:</p>
<p>%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%</p>
<p>d = daq.getDevices
s = daq.createSession('ni');</p>
<p>addAnalogInputChannel(s,'dev1', 'ai0', 'Voltage');
s.Rate = 8000;</p>
<p>q = daq.createSession('ni');</p>
<p>addDigitalChannel(q,'dev1','Port2/Line0:0','OutputOnly');</p>
<p>for p = 1:1:100</p>
<pre><code>outputSingleScan(q,1)
pause(0.1)
data = s.inputSingleScan;
data
outputSingleScan(q,0)
pause(0.1)
data = s.inputSingleScan;
data
</code></pre>
<p>end</p>
<p>%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%</p>
<p>My current results are an analog input of ~0 Volts, and what I expect is a square wave from my analog input.</p>
<p>Any help on this would be much appreciated.
I am expecting somthing with a syntax in matlab with port to be the problem, but not to sure.</p>
<p>Thank you, Avery</p>
More answer... (https://stackoverflow.com/questions/59060630/digital-output-using-ni-bnc-2110-connect-to-ni-usb-6255)
My goal is to generate a digital output through the NI BNC-2110 and then read the output on an analog input on the same NI BNC-2110. (The perpose of this is to make sure that I know how to properly output a digital signal and can input an analog signal, and I figured this would just check both things simultaneously.) </p>
<p>The setup works when generating a digital signal and reading an analog when I use the software NI MAX, my problem is when I try and do the same thing in matlab.
Here is my current code in matlab:</p>
<p>%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%</p>
<p>d = daq.getDevices
s = daq.createSession('ni');</p>
<p>addAnalogInputChannel(s,'dev1', 'ai0', 'Voltage');
s.Rate = 8000;</p>
<p>q = daq.createSession('ni');</p>
<p>addDigitalChannel(q,'dev1','Port2/Line0:0','OutputOnly');</p>
<p>for p = 1:1:100</p>
<pre><code>outputSingleScan(q,1)
pause(0.1)
data = s.inputSingleScan;
data
outputSingleScan(q,0)
pause(0.1)
data = s.inputSingleScan;
data
</code></pre>
<p>end</p>
<p>%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%</p>
<p>My current results are an analog input of ~0 Volts, and what I expect is a square wave from my analog input.</p>
<p>Any help on this would be much appreciated.
I am expecting somthing with a syntax in matlab with port to be the problem, but not to sure.</p>
<p>Thank you, Avery</p>
More answer... (https://stackoverflow.com/questions/59060630/digital-output-using-ni-bnc-2110-connect-to-ni-usb-6255)