Discover MakerZone

MATLAB and Simulink resources for Arduino, LEGO, and Raspberry Pi

Learn more

Discover what MATLAB® can do for your career.

Opportunities for recent engineering grads.

Apply Today

Thread Subject:
Data acquisition toolbox with NI card digital output very slow

Subject: Data acquisition toolbox with NI card digital output very slow

From: Ryan Miller

Date: 26 Oct, 2012 21:43:09

Message: 1 of 4

Below is the code I'm using to switch 96 digital channels of a National Instruments 6509 card. I'm using the session-based interface in R2012b 64-bit on a reasonably fast PC (Core i7, 16GB RAM) running Windows 7 64-bit. All I'm doing here is setting the 96 digital outs high and low many times in a loop to see how long it takes. According to National Instruments website, this card should be able to loop at least 48 kHz on this PC. Instead, I'm around 50 Hz with the code below. If I only set one digital line instead of all 96, it takes around 2 ms/write instead of 20 ms/write. Am I missing something? I don't need 50 kHz but 50 Hz is abysmal -- something around 1 kHz is acceptable.


%Define addresses
port_addresses = {'port0/line0:7','port1/line0:7','port2/line0:7','port3/line0:7',...
    'port4/line0:7','port5/line0:7','port6/line0:7','port7/line0:7','port8/line0:7',...
    'port9/line0:7','port10/line0:7','port11/line0:7'};

%Initialize connection
session = daq.createSession('ni');
session.addDigitalChannel('dev1', port_addresses, 'OutputOnly');

%Define two vectors which we will alternate between
all_on= true(1,96);
all_off= false(1,96);

%Alternate between those two vectors loops number of times
loops=100;
tic
for this_write = 1:loops
    session.outputSingleScan(all_on);
    session.outputSingleScan(all_off);
end
disp(['loop time: ' num2str(round(toc/loops/2*10000)/10) ' ms each'])

session.release;
delete(session);

Subject: Data acquisition toolbox with NI card digital output very slow

From: Manikandan

Date: 27 Oct, 2012 17:25:07

Message: 2 of 4

check the sampling time of DAQ card setting, try to change it.

Subject: Data acquisition toolbox with NI card digital output very slow

From: Ryan Miller

Date: 29 Oct, 2012 13:24:08

Message: 3 of 4

"Manikandan " <electricmani@yahoo.co.in> wrote in message
> check the sampling time of DAQ card setting, try to change it.

As I understand it, this card doesn't have a sampling rate per se.

From NI website:
The data transfer rates of the NI 6509 are software timed, also called unstrobed or nonlatched, and do not require status and control signals so the transfer speed are completely software/computer dependant. These rates may vary due to programming language and code efficiency, CPU utilization, transfer methods, and so on.

Subject: Data acquisition toolbox with NI card digital output very slow

From: Joost

Date: 17 Jun, 2013 12:04:10

Message: 4 of 4

"Ryan Miller" wrote in message <k6m01o$3pl$1@newscl01ah.mathworks.com>...
> "Manikandan " <electricmani@yahoo.co.in> wrote in message
> > check the sampling time of DAQ card setting, try to change it.
>
> As I understand it, this card doesn't have a sampling rate per se.
>
> From NI website:
> The data transfer rates of the NI 6509 are software timed, also called unstrobed or nonlatched, and do not require status and control signals so the transfer speed are completely software/computer dependant. These rates may vary due to programming language and code efficiency, CPU utilization, transfer methods, and so on.

Hi Ryan,
did you ever solve this issue?
I have the same problem; the Rate cannot be set for this card as far as I can tell.

I am looking into using io64.mexw64 to control the individual ports.(http://sunburst.usd.edu/~schieber/psyc770/IO64.html)
using the initialization and addresses specified in
http://www.ni.com/pdf/manuals/371580a.pdf

I am interested to find out if there is a simpler work around, as there was for the legacy interface:

(copied from http://psychtoolbox.org/wikka.php?wakka=FaqTTLTrigger)

dio = digitalio('parallel')
addline(dio,7,0,'out') %pin 9
putvalue(dio,1) %~700us
putvalue(dio.Line,1) %~150us
uddobj = daqgetfield(dio,'uddobject')
putvalue(uddobj,1,1); %~20us (undocumented use demo in @dioline\putvalue.m and @digitalio\putvalue.m - args are: uddobj, vals [, lineInds])
getvalue(uddobj,1);

I could always go back to 32 bit...

Joost

Tags for this Thread

What are tags?

A tag is like a keyword or category label associated with each thread. Tags make it easier for you to find threads of interest.

Anyone can tag a thread. Tags are public and visible to everyone.

Contact us