Drexel dragonThe Math ForumDonate to the Math Forum



Search All of the Math Forum:

Views expressed in these public forums are not endorsed by Drexel University or The Math Forum.


Math Forum » Discussions » Software » comp.soft-sys.matlab

Topic: session-based timing a USB DAQ device
Replies: 0  

Advanced Search

Back to Topic List Back to Topic List  
J H

Posts: 2
Registered: 2/13/08
session-based timing a USB DAQ device
Posted: Jan 31, 2013 12:15 PM
  Click to see the message monospaced in plain text Plain Text   Click to reply to this topic Reply

I'm using session-based code to talk to a NIDAQ USB-6212 on Matlab 2012a.

I need to send out a signal and collect responses, on two channels. I set things up with the following, to send a 30-ms wave every 0.1 seconds:
RATE=5000;
PER= 0.1; %the desired period for the timer, in s.
s = daq.createSession('ni');
s.DurationInSeconds = 0.3 * PER; %only use 1/3 of the desired period
s.Rate = RATE;
s.addAnalogInputChannel('Dev1', 'ai0', 'Voltage');
s.addAnalogInputChannel('Dev1', 'ai2', 'Voltage');
s.addAnalogOutputChannel('Dev1','ao0', 'Voltage');
s.addAnalogOutputChannel('Dev1', 'ao1', 'Voltage');
L= round( 0.3 *PER*RATE);
out_data=zeros(L,2);
out_data(.2*L :end -.2*L,1) = -.5; %10 mV @ 20 mV/V gain.
out_data(.2*L: end -.2*L,2) = -.5;
s.queueOutputData(out_data);

Then I set up a timer to call a function every PER seconds:
t = timer('TimerFcn',@send_and_collect,'Period',PER,...
'ExecutionMode','fixedRate','BusyMode','queue');

where function send_and_collect performs:
s.queueOutputData(out_data);
[data, foo] = s.startForeground;
set(gca,'Ydata',data);
-----------------------------------------------------------------

My problem is that the s.startForeground takes 0.3 seconds, on average, to do this; even without the timer, just executing { tic, s.queueOutput, s.startForeground, toc} gives an elapsed time of 0.3 seconds. I need it to be faster, so that I can see the plot refresh quicker.

I searched and found the property s.Channel.ADCTimingMode that I should be able to set to 'HighSpeed' instead of the default 'HighResolution' for this purpose, but I don't seem to be able to set it. I get an error "No appropriate method, property, or field ADCTimingMode for class daq.AnalogChannel", and s.Channels says:
Data acquisition analog input voltage channel 'ai0' on device 'Dev1':
Coupling: DC
TerminalConfig: Differential
Range: -10 to +10 Volts
Name: ''
ID: 'ai0'
Device: [1x1 daq.ni.DeviceInfo]
MeasurementType: 'Voltage'

Help is appreciated!
Thanks,
JSH



Point your RSS reader here for a feed of the latest messages in this topic.

[Privacy Policy] [Terms of Use]

© Drexel University 1994-2014. All Rights Reserved.
The Math Forum is a research and educational enterprise of the Drexel University School of Education.