How to import a continuous signal from USB-6009 to an Oscilloscope (DAQ toolbox)

6 visualizzazioni (ultimi 30 giorni)
Hi everyone,
I am using the USB-6009 card from NI. How can I output a smooth sine wave out using the DAQ toolbox?
I have written some codes like this, is there anything wrong?
N=10;
t=(0:pi/12:2*pi);
data=(sin(t));
for i=1:length(data)
t = timer('TimerFcn', ' putsample(AO,data(i)));
start(t);
end
thanks, Kay

Risposte (2)

Walter Roberson
Walter Roberson il 27 Giu 2011
N=10;
t=(0:pi/12:2*pi);
data=(sin(t));
putdata(A0, data(:));
You definitely do not want to be starting a new timer for every sample! At most you might want to have a single timer that you use to putsample() the next sample.
  3 Commenti
Walter Roberson
Walter Roberson il 28 Giu 2011
Question: are you trying to input into MATLAB (as your title implies) or are you trying to output from MATLAB (as your use of putsample() implies) ?
Walter Roberson
Walter Roberson il 28 Giu 2011
The only applicable limitation that I have been able to find in the USB-6009 documentation is that the USB-6009 does not support retriggerable inputs. It does, however, support continuous input at predefined rates, and does support continuous output at predefined rates.
The maximum output rate for the USB-6009 is 150 Hz.
The maximum single-channel input rate for the USB-6009 is 48 KHz. The maximum achievable rate goes down by just under 1 KHz per additional channel of input.
The USB-6009 is USB based. USB is packet based. The USB protocol defines a list of tasks, and during each cycle the tasks will be done in a fixed order. With USB it is mandatory that there be a USB controller that arbitrates the bus access and manages the cycles in order. It is not possible to "interrupt" a USB bus, and it is not possible to output samples and have them transported with just serialization delays: instead, the device that wants to do the output has to wait until the USB controller asks it whether it has any work to do, with the device replying that it does, and the USB controller then giving it the go-ahead to send the packet. USB does *not* "sit idle" waiting for an output request: the USB controller keeps running its cycle of arbitration and polling devices asking if they have work.
Because of this USB cycle, if you want to send samples independently one by one, then unless you want to get deep in to controlling exactly which USB packets are to be sent, the maximum output rate is effectively 25 samples per second (that is, USB defines the buffer hold time waiting for more data as 40 milliseconds.)
I do not recall how long the USB work cycle time is, and thus the granularity with which you could choose the 40 millisecond latency. It would depend in part on what else was going on on the bus; in particular, the cycle time would be longer if you had both input and output.
If you are expecting to be able to generate anything other than a very crude clock by sending individual samples through the USB-6009, then you are going to be completely disappointed. USB is not suitable for that kind of work.
USB is, though, fine for the transportation of batches of samples to a device that will buffer them and send them out at a fixed output rate. (I would, though, need to do research as to the maximum sustainable transfer rate and the buffer sizes needed for it.)

Accedi per commentare.


Rob Purser
Rob Purser il 6 Lug 2011
The USB-6009 doesn't support hardware clocked outputs. There's no way to have it generate a smooth curve. You're on the right track with the timer, but you need to set it to fixed rate mode, and call putsample inside the timer callback function. See the documentation for the timer for more info.
  1 Commento
Walter Roberson
Walter Roberson il 8 Lug 2011
I do not understand what hardware clocked outputs have to do with this matter, since the device does support buffering data samples and outputting them at a fixed rate? Is the issue that the fixed rate output has too much jitter? If so how much jitter does it have and how much jitter is acceptable to Kay?
In your suggestion of using putsample() and a timer, I do not see any recognition that the device is USB based and the USB controller for it is going to sit accumulating samples until there is a 40ms silence in the buffer or until the controller receives a "push" command (there is no obvious way to generate such a command with the digitialio framework.)

Accedi per commentare.

Categorie

Scopri di più su Simultaneous and Synchronized Operations in Help Center e File Exchange

Community Treasure Hunt

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

Start Hunting!

Translated by