Multiple channel Data Acquistion - NI USB-6251 & BNC-2090

조회 수: 13 (최근 30일)
Greg
Greg 2011년 8월 22일
편집: Walter Roberson 2020년 8월 5일
Hello, I'm trying to write an m-file using only a couple of channels (triggering off 1 channel) on the NI hardware captioned above to collect voltage. However, after I add channels, specify which channel is the trigger and other parameters, run the program and get data, my plots only reflect data from the trigger channel. I've tried pulling only certain columns out to see the individual channels, but it didn't work. What am I doing wrong or not including in my script?
Also, any advice on the best way to trigger using this hardware configuration would be appreciated.
  댓글 수: 2
Sean de Wolski
Sean de Wolski 2011년 8월 22일
Can you show us the script so we can see what you're not including !
Greg
Greg 2011년 8월 22일
편집: Walter Roberson 2020년 8월 5일
Sure, this is the setup & script I have so far.
Setup:
Voltage Source---Ch0-NI Board/NI DAQ--\______[Computer/Matlab]
Trigger----------Ch1-NI Board/NI DAQ--/
Script:
%Add Channels from DAQ device to program
ai = analoginput ('nidaq','Dev1');
chan = addchannel (ai,0:1);
%Set DAQ Parameters (property values)
set(ai,'SampleRate', 500000); %Value in Hz
set(ai,'SamplesPerTrigger', 2.5e6); %No. of Samples
set(ai,'TriggerChannel',chan(1)); %Choose trigger channel
set(ai,'TriggerType','software'); %Choose trigger type
set(ai,'TriggerCondition','rising'); %Select how trigger initiates
set(ai,'TriggerConditionValue',0.01);%Choose voltage value for trigger to initiate
set(ai,'Timeout',5); %Time in sec for program to wait for trigger start
%Start Data Acq, plot, stop.
start (ai);
wait(ai,6)
[data,time] = getdata(ai);
trigger = data(:,2);
vout = data(:,1);
subplot(2,1,1),plot (time,vout);
subplot(2,1,2),plot (time,trigger);
title('Voltage Data');
xlabel('Time (s)');
ylabel('Voltage (V)');
stop (ai);

댓글을 달려면 로그인하십시오.

답변 (1개)

Chirag Gupta
Chirag Gupta 2011년 8월 22일
Greg from your code, it seems that:
ai = analoginput ('nidaq','Dev1');
chan = addchannel (ai,0:1);
%Set DAQ Parameters (property values)
set(ai,'SampleRate', 500000); %Value in Hz
set(ai,'SamplesPerTrigger', 2.5e6); %No. of Samples
set(ai,'TriggerChannel',chan(1)); %Choose trigger channel
set(ai,'TriggerType','software'); %Choose trigger type
set(ai,'TriggerCondition','rising'); %Select how trigger initiates
set(ai,'TriggerConditionValue',0.01);%Choose voltage value for trigger to initiate
set(ai,'Timeout',5); %Time in sec for program to wait for trigger start
%Start Data Acq, plot, stop.
start (ai);
wait(ai,6)
[data,time] = getdata(ai);
trigger = data(:,2);
vout = data(:,1);
You have assigned ai channel 0 as the trigger channel. Even though the NI channels start from zero, MATLAB index is 1 based. So I think, the code should be:
set(ai,'TriggerChannel',chan(2)); % Corresponds to ai channel 1

카테고리

Help CenterFile Exchange에서 MATLAB에 대해 자세히 알아보기

제품

Community Treasure Hunt

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

Start Hunting!

Translated by