Multifunction DAQ

cancel
Showing results for 
Search instead for 
Did you mean: 

to much time for loop

Hello,
I have a program  with a DAQ-Operation. I read with DAQ_Op command analog-input in an array. That works fine. But there is a problem with reading the result array. I read the array with a loop, but it needs nearly 20sec to count the while - loop up to 50000 (number of points). I have tested the loop without any other code, only counting from 0 to 50000 . The CPU - usage is 100% and needs 17sec.

This is the code:

            //DAQ_Op (1, 0, 1, temp_data, nbr_points, sample_rate);
            PlotDigitalLines (DSC, DSC_DIGGRAPH, temp_data, 100, VAL_SHORT_INTEGER, 1);
             GetSystemTime (&h, &min, &sek1);
           
             while (i<=nbr_points)
                 {
                 
                 i++;
                 }
             
             GetSystemTime (&h, &min, &sek2);
             
             SetCtrlVal (DSC, DSC_NUMERIC_TEMP, sek2-sek1);
             SetCtrlVal (DSC, DSC_NUMERIC_LOW, 100.0);

With another system it needs only under 1s.

(Win2k, CVI 7.1, NIDaq 6.9.3, PCI-1200)

Thanks for help,

Christian



0 Kudos
Message 1 of 7
(3,971 Views)
Christian,

you tell us "With another system it needs only under 1s".
two questions:
a) what differences are there between the systems (RAM, OS and so on)?
b) have you copied the sources to the other system and compiled it there or have you copied the executable?
regarding b): if you copied the sources, what happens if you copy the exe?
i hope this will give you a hint to know where you can find some more clues regarding this odd behaviour.


Norbert B.
NI Germany
Norbert
----------------------------------------------------------------------------------------------------
CEO: What exactly is stopping us from doing this?
Expert: Geometry
Marketing Manager: Just ignore it.
0 Kudos
Message 2 of 7
(3,920 Views)
Hello,

there are no hardware-differences between the two systems (the same cpu, RAM OS) but on the other system is NIDaqmx 7.5 installed but not used in the sample code.

I had tranfered the source-code and compiled it on the other system. But if I copied the exe-file there is the same result.

Christian
0 Kudos
Message 3 of 7
(3,886 Views)
Christian,

thats really weird. but i have another test for you to run/check:
Is there a timer on your userinterface?
If yes, what happens if you make it significantly slower?
Another point is: is there a difference in the version of the CVI-Runtime Engine on the two systems?

Norbert B.
- NI Germany
Norbert
----------------------------------------------------------------------------------------------------
CEO: What exactly is stopping us from doing this?
Expert: Geometry
Marketing Manager: Just ignore it.
0 Kudos
Message 4 of 7
(3,861 Views)
Hello,
there is no timer on the UIR. Its a very minimalistic UIR, only a graph and two numeric displays and two buttons. I have installed no seperate run-time-engine, only CVI  from the CD-Pack (Fall 2005) on both computers.

I changed my system until now, a complete new installation of OS (Now with Win XP Prof.) and CVI - the same result - 20s for the loop.
There is also no other software on the computer, only OS and CVI.
I have also removed the DAQ-Board.

But I have tested the program a second time on  the other computer and it needs suddenly also 14s. Thats very mysterious.
I attached the whole program with UIR, so you can see it all.

thanks for your help,

Christian

PS.
I can also send you the exe-file (ca. 600k) if it will be useful.
Download All
0 Kudos
Message 5 of 7
(3,859 Views)
Christian,

to be honest, i do not have any clue why this issue occurs with your PCs. at least the sources you attached run fine with mine....
here is a small sample code you can insert into an empty c-file. add this c-file to an empty project and compile it.
when running the application, you should see (for a very, very, very short time) the default output window (console). If you can see the outputwindow for several seconds, there is definetly running something wrong with your PCs or the installation of CVI.
to check what is going on, you can try to compile the source with another ANSI C-compiler like GNU (http://gcc.gnu.org/). if there occurs the same issue, then there is definetly something very wrong with your PC. if not, we have to check back on the CVI installation.
if the example runs fine, please feel free to add functions untill you reach the same extend of functionality like your example.
Another workaround might be to use the for-loop instead of the while-loop. the two loops have quite (not exactly) the same behaviour, but i dont think this does matter to this application.

Well, here we go with the sourcecode:
#include <ansi_c.h>

void main(void)
{
    int i=0;
    int maxcount=50000;
    printf("Start");
    while(i<=maxcount)
        i++;
    printf("Fertig");
}

Norbert B.
NI Germany
Norbert
----------------------------------------------------------------------------------------------------
CEO: What exactly is stopping us from doing this?
Expert: Geometry
Marketing Manager: Just ignore it.
Message 6 of 7
(3,854 Views)
Hello Norbert,

I have found it! There was a watch-expression set. After copying your code in the file comes an error - watch expression not found. I have delete it, now the program works fine.

Thank you very much.

Christian
0 Kudos
Message 7 of 7
(3,849 Views)