miskol
Member level 4
Hi,
I've already programmed a GUI to communicate between USB-6218 and matlab r2009a. However the performance are relatively slow.
In theory the USB-6218 can support up to 250kS/s, and since i am using 16 channels the sample rate are divided with 16 = 15,625S/s thus for a single sample for each channels it will take 64microseconds. In between channel samplings a delay is introduced by the hardware which is called channel skew rate which is 4microseconds. Thus for a single channel it will take around 68microseconds to sample.
Let's say roughly a single channel will take approximately 100microseconds to acquire a single sample. Thus if 2 samples are acquired from each channels the total time taken will be = 3.2miliseconds(for 16 channels). Below in the example program the SamplesPerTrigger is set to 2 as that is the minimum setting allowed.
clc; clear;
ai = analoginput('nidaq','Dev1');
set(ai,'InputType','SingleEnded');
addchannel(ai, 0:15); %16 channels
ai.SampleRate = 15625; %supported max. sampling rate divided by 16 channels
ai.SamplesPerTrigger = 2; %minumum supported
out = zeros(2,16);
tic;
start(ai);
out = getdata(ai);
toc;
stop(ai);
clear ai
delete ai
The recorded time for this is around 50 miliseconds which is far from the calculated 3.2 miliseconds. Unfortunately Real-Time Windows Target does not support for this particular hardware (NI USB-6218).
is there any other way to program MatLAB to communicate with the hardware faster? did i miss or do anything wrong?
Please help and correct me if i'm wrong, Thank you.
p/s: getsample(ai) can be used to immediately acquire a single sample for each channels, however the speed performance are around the same still.
I've already programmed a GUI to communicate between USB-6218 and matlab r2009a. However the performance are relatively slow.
In theory the USB-6218 can support up to 250kS/s, and since i am using 16 channels the sample rate are divided with 16 = 15,625S/s thus for a single sample for each channels it will take 64microseconds. In between channel samplings a delay is introduced by the hardware which is called channel skew rate which is 4microseconds. Thus for a single channel it will take around 68microseconds to sample.
Let's say roughly a single channel will take approximately 100microseconds to acquire a single sample. Thus if 2 samples are acquired from each channels the total time taken will be = 3.2miliseconds(for 16 channels). Below in the example program the SamplesPerTrigger is set to 2 as that is the minimum setting allowed.
clc; clear;
ai = analoginput('nidaq','Dev1');
set(ai,'InputType','SingleEnded');
addchannel(ai, 0:15); %16 channels
ai.SampleRate = 15625; %supported max. sampling rate divided by 16 channels
ai.SamplesPerTrigger = 2; %minumum supported
out = zeros(2,16);
tic;
start(ai);
out = getdata(ai);
toc;
stop(ai);
clear ai
delete ai
The recorded time for this is around 50 miliseconds which is far from the calculated 3.2 miliseconds. Unfortunately Real-Time Windows Target does not support for this particular hardware (NI USB-6218).
is there any other way to program MatLAB to communicate with the hardware faster? did i miss or do anything wrong?
Please help and correct me if i'm wrong, Thank you.
p/s: getsample(ai) can be used to immediately acquire a single sample for each channels, however the speed performance are around the same still.