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

4 次查看(过去 30 天)
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 中查找有关 Simultaneous and Synchronized Operations 的更多信息

产品

Community Treasure Hunt

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

Start Hunting!

Translated by