Clear Filters
Clear Filters

National Instruments digital out rate very slow

1 view (last 30 days)
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);

Answers (0)

Categories

Find more on Simultaneous and Synchronized Operations in Help Center and File Exchange

Community Treasure Hunt

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

Start Hunting!