Measurement Studio for VC++

cancel
Showing results for 
Search instead for 
Did you mean: 

problem with NIDAQdelay function

Hi all,

I'm currenly using a new PCI-MIO-16E-1 board , with the most recent driver. I am programming using VC++ in Window NT environment.

However, when I implement the "DOonePORT.c" example program using "NIDAQdelay" in a for loop, the program functions for a while but stops functioning in the middle of the process. The coding works well if I used a software implement delay "Sleep" but that's not imprecise when it gets into milliseconds.

Any ideas why NIDAQdelay not work?

The C code in included as follows:


i16 iStatus = 0;
i16 iRetVal = 0;
i16 iDevice = 1;
i16 iPort = 0;
i16 iMode = 0;
i16 iDir = 1;
i32 iPattern = 0;
i32 iNumLoops = 16;
i16 iIgnoreWarning
= 0;
i16 iYieldON = 1;

/* Configure port as output, no handshaking. */

iStatus = DIG_Prt_Config(iDevice, iPort, iMode, iDir);

iRetVal = NIDAQErrorHandler(iStatus, "DIG_Prt_Config",
iIgnoreWarning);

while ((iPattern < iNumLoops) && (iStatus == 0)) {


iStatus = DIG_Out_Prt(iDevice, iPort, iPattern);

iRetVal = NIDAQErrorHandler(iStatus, "DIG_Out_Prt",
iIgnoreWarning);

printf(" The digital pattern on port %d is set to (DECIMAL) %ld\n", iPort, iPattern);

iRetVal = NIDAQDelay(2);
//Sleep(1000);

++iPattern;

iRetVal = NIDAQYield(iYieldON);

}



}

Thanks in advance

Ric
0 Kudos
Message 1 of 2
(3,222 Views)
This is a known issue with the NIDaqDelay function used in some of the examples that ship with the NI-DAQ driver (note: the NIDAQDelay function is not a function directly implemented in the NI-DAQ driver but is rather a function written only for the examples and you do not have to use it). The common suggestion is to just use the Windows SDK Sleep function instead, because in truth it does nearly the exact same thing. The examples will work fine if you replace NIDaqDelay with Sleep.

Jason F.
Applications Engineer
National Instruments
www.ni.com/ask
0 Kudos
Message 2 of 2
(3,222 Views)