Acquire Continuous and Background Data Using NI Devices

4 ビュー (過去 30 日間)
Vitali Walter
Vitali Walter 2017 年 8 月 13 日
コメント済み: Shashank 2017 年 8 月 16 日
s = daq.createSession('ni');
addAnalogInputChannel(s,'myDAQ1', 0, 'Voltage'); %%OUT2, X-Achse
addAnalogInputChannel(s,'myDAQ1', 1, 'Voltage'); %%OUT1, Y-Achse
s.Rate = 100000
s.DurationInSeconds = 0.001
while 1
[data, time] = s.startForeground;
plot(data(:,1)-2.5,data(:,2)-2.5,'*')
axis([-2.5 2.5 -2.5 2.5])
end
Hello. I´m working on a project with an melexis hallsensorjoistick and an NI myDAQ device. I wants to a quire the valtage and give it back as a dot on a white screen. The code which you see above worked out. But I´ve tryed it befor with Continuous and Background Data and it didnt worked out. I wrote also a code to get data of the 2 outputs with continuous and Background Data, but can´t figure it out how to combine them.
clear all
close all
clc
s = daq.createSession('ni');
addAnalogInputChannel(s,'myDAQ1', 0, 'Voltage');
addAnalogInputChannel(s,'myDAQ1', 1, 'Voltage');
s.Rate = 10000;
s.IsContinuous = true;
lh = addlistener(s,'DataAvailable', @(src,event) plot(event.TimeStamps, event.Data));
s.startBackground();
[data, time] = startForeground(s);
plot(data(:,1)-2.5,data(:,2)-2.5,'*')
axis([-2.5 2.5 -2.5 2.5])
My goal is now to create an GUI with only 2 buttons, start and stop. If I try to combine the codes in one script, I get error messeges like "Error using qwert (line 19) This command can not be used while the Session is running." How can I make this working? Thx
  1 件のコメント
Shashank
Shashank 2017 年 8 月 16 日
Please post your combined script and the line 19 specifically where it throws this error

サインインしてコメントする。

回答 (0 件)

カテゴリ

Help Center および File ExchangeProgramming についてさらに検索

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by