Digital I/O

cancel
Showing results for 
Search instead for 
Did you mean: 

Suggestion to enhance the DAQ speed in USB-6501

I have an application with USB-6501 where 12 DAQmx calls need to be made to do timings for the external hardware. I check with clock() function and it took about 100 ms to finish all these calls along with some calculations. Here is an example typical call that runs for about 8 ms in Interactive Window using CVI 8.0 in a new XP machine:
 
#include <utility.h>
#include <ansi_c.h>
#include <NIDAQmx.h>
static uInt8 w_data[1] = {1};
static unsigned long int x, x1, x2;
static double x3;
static TaskHandle taskHandle=0;
 
x = CLOCK_PER_SEC;
x1 = clock();
w_data[0] = 0;
DAQmxCreateTask("",&taskHandle);
DAQmxCreateDOChan(taskHandle,"Dev1/port2/line7","",DAQmx_Val_ChanForAllLines);
DAQmxStartTask(taskHandle);
DAQmxWriteDigitalLines(taskHandle,1,1,10.0,DAQmx_Val_GroupByChannel, w_data, NULL,NULL);
DAQmxStopTask(taskHandle);
DAQmxClearTask(taskHandle);
x2 = clock();
x3 = ((double)(x2-x1))/x;
printf ("x1 = %d\nx2 = %d\nElapsed time in sec = %f\n", x1, x2, x3); 
------------------------------
Result:
x1 = 912272
x2 = 912280
Elapsed time in ms = 0.008000
 
----------------------------------------
 
My external circuit is supposed to take data at 20 ms interval for each data point. With 12 DAQ calls in the loop for each data  point taking 100 ms, I am missing many data points. Is ther a way to get around this so 12 DAQ calls could be made shorter than 20 ms? Thanks for any suggestions!
0 Kudos
Message 1 of 2
(3,087 Views)
I don't use CVI anymore but I can tell you that if you call the Create Channel, Start Task, Stop Task, and Clear Task, each and every time, you are adding a lot of unnecessary overhead. You should create the channels, start the task, and then do all of your I/O. When that is complete, then do the stop and clear. Also, with the 6501, the digital I/O is software timed so the actual interval between you logic updates is going to be highly dependent on the type of pc, the OS, and whatever other background tasks might be running.
0 Kudos
Message 2 of 2
(3,079 Views)