Continue to Site

Welcome to EDAboard.com

Welcome to our site! EDAboard.com is an international Electronics Discussion Forum focused on EDA software, circuits, schematics, books, theory, papers, asic, pld, 8051, DSP, Network, RF, Analog Design, PCB, Service Manuals... and a whole lot more! To participate you need to register. Registration is free. Click here to register now.

Using NI USB-6218 with matlab r2009a for real-time purposes

Status
Not open for further replies.

miskol

Member level 4
Joined
Nov 6, 2008
Messages
75
Helped
6
Reputation
12
Reaction score
6
Trophy points
1,288
Activity points
1,814
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.
 

Status
Not open for further replies.

Part and Inventory Search

Welcome to EDABoard.com

Sponsor

Back
Top