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

4 ビュー (過去 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 Center および File ExchangeMATLAB についてさらに検索

製品

Community Treasure Hunt

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

Start Hunting!

Translated by