The Math Forum

Search All of the Math Forum:

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

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

Notice: We are no longer accepting new posts, but the forums will continue to be readable.

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

Advanced Search

Back to Topic List Back to Topic List  

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:
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(.2*L :end -.2*L,1) = -.5; %10 mV @ 20 mV/V gain.
out_data(.2*L: end -.2*L,2) = -.5;

Then I set up a timer to call a function every PER seconds:
t = timer('TimerFcn',@send_and_collect,'Period',PER,...

where function send_and_collect performs:
[data, foo] = s.startForeground;

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]
MeasurementType: 'Voltage'

Help is appreciated!

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

[Privacy Policy] [Terms of Use]

© The Math Forum at NCTM 1994-2018. All Rights Reserved.