Labfans是一个针对大学生、工程师和科研工作者的技术社区。 论坛首页 | 联系我们(Contact Us)
MATLAB爱好者论坛-LabFans.com
返回   MATLAB爱好者论坛-LabFans.com > 其它 > 资料存档
资料存档 资料存档
 
 
主题工具 显示模式
旧 2019-11-27, 07:35   #1
poster
高级会员
 
注册日期: 2019-11-21
帖子: 3,006
声望力: 66
poster 正向着好的方向发展
默认 Digital Output Using NI BNC-2110 connect to NI USB-6255

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.)



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:



%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%



d = daq.getDevices
s = daq.createSession('ni');



addAnalogInputChannel(s,'dev1', 'ai0', 'Voltage');
s.Rate = 8000;



q = daq.createSession('ni');



addDigitalChannel(q,'dev1','Port2/Line0:0','OutputOnly');



for p = 1:1:100



outputSingleScan(q,1)
pause(0.1)
data = s.inputSingleScan;
data

outputSingleScan(q,0)
pause(0.1)
data = s.inputSingleScan;
data


end



%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%



My current results are an analog input of ~0 Volts, and what I expect is a square wave from my analog input.



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.



Thank you, Avery





More answer...
poster 当前离线   回复时引用此帖
 


发帖规则
不可以发表新主题
不可以发表回复
不可以上传附件
不可以编辑自己的帖子

启用 BB 代码
论坛禁用 表情符号
论坛启用 [IMG] 代码
论坛启用 HTML 代码



所有时间均为北京时间。现在的时间是 05:01


Powered by vBulletin
版权所有 ©2000 - 2025,Jelsoft Enterprises Ltd.