NI DAQ AI and AO realtime data acquaring

조회 수: 2 (최근 30일)
Sergey Makovkin
Sergey Makovkin 2016년 9월 6일
Hi, All!
I use NI PCI-6229 card. And I need to set 2 AO voltage outputs and get 1 AI voltage inputs. And I need to plot synchronously all these data on plots.
I do this with the following code:
clear all
close all
clc
Session = daq.createSession('ni');
Session.addAnalogInputChannel('Dev2', 'ai0', 'Voltage');
lh1 = addlistener(Session, 'DataAvailable', @plotData);
%lh1 = addlistener(Session, 'DataAvailable', @(src, event) plot(event.TimeStamps, event.Data));
addAnalogOutputChannel(Session, 'Dev2', 0:1, 'Voltage');
Session.IsContinuous = true;
Session.Rate = 10000;
data(:, 1) = [linspace(-1, 5, 5000) linspace(5, -1, 5000)]';
data(:, 2) = [linspace(-1, 10, 5000) linspace(10, -1, 5000)]';
%lh2 = addlistener(Session, 'DataRequired', @(src, event) src.queueOutputData(data));
lh2 = addlistener(Session, 'DataRequired', @(src, event) src.queueOutputData(data));
queueOutputData(Session, data);
subplot(2, 2, 1);
plot(data(:, 1))
subplot(2, 2, 2);
plot(data(:, 2))
% subplot(2, 2, 4);
% plot(event.TimeStamps, event.Data)
startBackground(Session);
function plotData(src, event)
subplot(2, 2, 3)
plot(event.TimeStamps, event.Data, 'ro-', 'MarkerEdgeColor', 'k', 'MarkerSize', 1);
%event.Data
end
But I see only AI data. How can I get from the listener the AO data in the same time?

답변 (0개)

카테고리

Help CenterFile Exchange에서 Data Acquisition Toolbox Supported Hardware에 대해 자세히 알아보기

태그

Community Treasure Hunt

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

Start Hunting!

Translated by