Multifunction DAQ

cancel
Showing results for 
Search instead for 
Did you mean: 

4 tasks in sync: Analog/Digital I/O

I've been building a program in LabVIEW 2009, with the design of doing four tasks in lockstep: analog input and output, and digital input and output. It has two vital statistics: the sampling rate, typically 100 kHz, and the read/write cycle rate, typically 10 Hz. So in this typical scenario, once every read/write cycle,a waveform of 10,000 samples is output on one or more analog channels,a waveform of 10,000 samples is read in on one or more analog channels, a digital waveform of 10,000 samples is written, affecting multiple lines, and the digital waveform of 10,000 samples is read in, from one or more digital lines. (For those who care for such details, I'm doing cyclic voltammetry.)

 

My design is based upon a provided example, Multi-Function-Synch AI-AO.vi. But it isn't robust. It is prone to error -200279 (lost samples) sporadically on some configurations and systematically on others. Such errors are very likely to occur if one drags windows from other applications (or even the Context Help window from LabVIEW) over the application window.

 

The list of troubles goes on. Sometimes my users want to take the cycle rate up from the usual 10 Hz to 60 Hz. Things absolutely break down. Furthermore, we tested on a new USB-6363, which we would really like to be able to use. But it cannot handle a cycle rate faster than 3 Hz without starting to lose data. And that's even when reading and writing on only one analog line each.

 

Surely, someone will say, you could just fix the problem by reading and writing longer chunks less frequently. But not quite. There are interactions. Sometimes the value of a digital line in one cycle will control the nature of the waveform output on an analog line in the next. A slower read/write cycle rate would mean slower response time, which would be less encouraging to our experimental animal.

 

Has someone out there done this before? Surely someone has needed to keep digital and analog data tightly in sync. How do you make it work, and work well?

 

Thanks,

Ken Brooks

University of North Carolina

0 Kudos
Message 1 of 2
(3,046 Views)

Hi Ken,

 

The error you are getting (-200279) occurs when data is overwritten in your input buffer.  This happens when your loop cannot keep up with the data coming in.  It sounds like you were probably aware of this, but I just wanted to point it out.

 

 

I'm not sure what code you are using exactly, but try running the following for now:

 

https://decibel.ni.com/content/docs/DOC-6460

 

This code simply outputs the acquired analog input signal onto an analog output.  You can configure the amount of delay between the input and the output.  It has to be enough time to account for the possible latency of the data transfers.  I would start with this and see what kind of delay is sustainable on your system in the simple loopback scenario.  60 Hz would correspond to a ~16.67 ms loop rate.  As you add more and more functionality you would expect to have to increase the delay.

 

 

Having said this, USB is not the best bus choice for your application--from what I can tell you need to stream data to the PC, make some computations, then write new data to the output.  These transfers over USB have relatively high latency (compared to an internal bus like PCI or PCIe) and require resources from the OS.  The timing of the transfers is non-deterministic and can can be affected by the OS if it decides to allocate resources elsewhere (e.g. to resize a window).  You have to allow time in your loop for the data transfers as well as time for the software calls and processing that you are implementing.

 

 

Best Regards,

John Passiak
0 Kudos
Message 2 of 2
(3,036 Views)