Multifunction DAQ

cancel
Showing results for 
Search instead for 
Did you mean: 

help required

hello friends
i am required slight help from ur side.
i am interfacing the USB6210 daq card through the visual c++ by using
the NIDAQmx 8.5 library
but its affecting the timing of program. program just taking the 750us
to just toggle the single digital line from high to low than to high
again. also i think its taking the more time to required samples.
plz help me, i am just attaching the my code

#include <iostream.h>
#include <conio.h>
#include <stdio.h>
#include "NIDAQmx.h"

int main(int argc, char *argv[])
{
int i=0,sample=0,j=0,cut=0,n=0,not=0,k=0;
int32 error=0;
TaskHandle taskHandle=0,taskHandled=0;
uInt8 low[1]={0};
uInt8 high[1]={1};;
int32 read;
float64 data[8000]={'\0'};
double time=0;
// double reading[125][5000]={'\0'};

char errBuff[2048]={'\0'};

Enter:
printf("Enter the averaging number:");
printf(":In between 0 and 10:");
//scanf("%d",n);
cin>>n;
if(n>10)
{
goto Enter;
}
else
{
// while(1)
{
for(i=0;i<10;i++)
{

sample=25+(100*i);
time=(sample*0.000004);
printf("samples %d\n",sample);
printf("time %f\n",time);
for(j=0;j<n-1;j++)
{
DAQmxCreateTask("analog",&taskHandle);
DAQmxCreateTask("digital",&taskHandled);

DAQmxCreateDOChan(taskHandled,"Dev2/port1/
line0","",DAQmx_Val_ChanForAllLines);
DAQmxCreateAIVoltageChan(taskHandle,"Dev2/
ai0","",DAQmx_Val_Cfg_Default,-5.0,5.0,DAQmx_Val_Volts,NULL);

DAQmxCfgSampClkTiming(taskHandle,"",
250000.0,DAQmx_Val_Rising,DAQmx_Val_FiniteSamps,sample);

DAQmxStartTask(taskHandle);
DAQmxStartTask(taskHandled);

DAQmxWriteDigitalLines(taskHandled,
1,1,-1,DAQmx_Val_GroupByScanNumber,high,NULL,NULL);


DAQmxReadAnalogF64(taskHandle,sample,time,DAQmx_Val_GroupByChannel,data,sample,&read,NULL);
printf("\nread %d\n",read);


if(read == 0|| read==sample)
{
cut=cut+1;
}
// printf("cut %d",cut);
// double temp[10][7700];

for(k=0;k<sample;k++)
{
// temp[j][k]=data[k];
}
DAQmxWriteDigitalLines(taskHandled,
1,1,-1,DAQmx_Val_GroupByScanNumber,low,NULL,NULL);

DAQmxReadAnalogF64(taskHandle,sample,time,DAQmx_Val_GroupByChannel,data,sample,&read,NULL);

if(read == 0|| read==sample)
{
not=not+1;
}
// double fake[10][5000];
for(k=0;k<sample;k++)
{
// fake[j][k]=data[k];
}


DAQmxStopTask(taskHandle);
DAQmxClearTask(taskHandle);
DAQmxStopTask(taskHandled);
DAQmxClearTask(taskHandled);

}
}
}
}
getchar();
return 0;

}

0 Kudos
Message 1 of 4
(2,807 Views)

Hi Jagdeep,

According to your code, the 750us that it takes to run is expected behavior. This is because the digital task does not have a clock and is software timed. This 750us may also vary because the software timing is system dependant and windows is non-deterministic.

David L.
Systems Engineering
National Instruments
0 Kudos
Message 2 of 4
(2,786 Views)
hello
David thanks for reply, can u tell how can i make my program faster


regards
jagdeep kataria

0 Kudos
Message 3 of 4
(2,759 Views)

Jagdeep,

The 6210 specifications , P5 , let us know that the digital lines are static, not hardware timed, and therefore cannot be controlled with a clock. Since this is the case, the only way to slightly speed up your digital transition is to place all code pertaining to the digital line close to each other.

David L.
Systems Engineering
National Instruments
0 Kudos
Message 4 of 4
(2,740 Views)