Got Questions? Get Answers.
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:
session-based timing a USB DAQ device

Subject: session-based timing a USB DAQ device

From: J H

Date: 31 Jan, 2013 17:15:12

Message: 1 of 1

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!

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