LabWindows/CVI

cancel
Showing results for 
Search instead for 
Did you mean: 

Measure the time of an operation (LabWindows)

Hello,

i used LabWindows/CVI to transfert a waveform (in my oscilloscope) into my computer. I would like to know the time with precision for this operation. Can you give me the fonctions for that.

Thank you and bye.
0 Kudos
Message 1 of 7
(5,047 Views)
The most precise timer available from the system is just a millisecond timer. You can use the Timer() function to determine elapsed time using the system clock. For example,

double timeStart = 0, timeElapsed = 0;

timeStart = Timer();

timeElapsed = Timer() - timeStart;

If you need more precision than milliseconds, you will have to find some way to use the CPU for timing or use a timing plug-in device (PCI card).

Best Regards,

Chris Matthews
National Instruments
0 Kudos
Message 2 of 7
(5,047 Views)
Thanks Chris for your answer,

i use this code and the answer is timeElapsed=0.2060000000. But this time is in seconds or milliseconds?? Because if this time is in milliseconds the transfert rate is not respected!!
0 Kudos
Message 3 of 7
(5,047 Views)
That is in seconds. So, 206 milliseconds is the elapsed time.
0 Kudos
Message 4 of 7
(5,047 Views)
Ok, I prefer.

Thanks
0 Kudos
Message 5 of 7
(5,047 Views)
If you need really precise timer AND if your processor is a Pentium AND if you plan to recompile your code with MSVC you could do as follow :

At the top of your source code type in
#ifndef _CVI_
#define MyRDTSC(var)\
__asm _emit 0x0F \
__asm _emit 0x31 \
__asm mov DWORD PTR var, eax \
__asm mov DWORD PTR var+4, edx
#endif

Somewhere in a callback where you need to measure a timing

int CVICALLBACK OnBlablabla (int panel, int control, int event, void *callbackData, int eventData1, int eventData2){

#ifndef _CVI_
__int64 i64_start, i64_end, i64_diff;
#else
time_t t1, t2;
#endif

#ifndef _CVI_
MyRDTSC(i64_start);
#else
t1=clock();
#endif

MyTestFunction(void);

#ifndef _CVI_
MyRDTSC(i64
_end);
i64_diff = (i64_end - i64_start);
sprintf(cMsg, "Processing request : %d µP cycles", (int)(i64_diff & 0xffffffff));

#else
t2=clock();
sprintf(cMsg, "Processing time : %d ms", t2-t1);
#endif

return(0);
}


Doing so you should be able to compile the code either under CVI or MSVC and take advantage of a very precise timer whenever it make sens.

Regards, Philippe
Feel free to visit http://www.baucour.com
0 Kudos
Message 6 of 7
(5,047 Views)
Thanks for your answer
0 Kudos
Message 7 of 7
(5,047 Views)