LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

VXIpeek occasionally takes long time (few ms)

I am using LabWindow/CVI 6.0 with Window XP for a DAQ.
In average, it takes 2.5us to excute VXIpeek. Also
occasionly it is observed that it takes few ms to execute VXIpeek. The maximum observed time is 19ms
where timing is measured by Timer from VXI library.
And it occurs at 2x10-5 level. I have set the system timeout to 8us which does not help.

regards,

Tiesheng
0 Kudos
Message 1 of 4
(2,529 Views)
Hello Tiesheng,

The delay with your VXIpeek function is most likely associated with a hardware or hardware configuration issue, as you've hinted at in your post.

In order to troubleshoot this further, it would be helpful to have a better understanding of your system:

1. What is your hardware setup, both in your PC and in your VXI chassis?
2. How are they connected together?
3. What driver versions do you have for:
NI-VISA, NI-VXI, and NI-DAQ.
4. Are there any errors that are returned when you execute a VXIpeek?
5. Is there a pattern to how often the delay occurs?
6. Can you provide an NI-Spy file with the peek and poke communication?
7. Can you reproduce the problem with a small section of code? Or using Visa Interactive Control or VXI Interactive Cont
rol (depending on your driver versions provided in question 3).
8. Does the problem occur when all other cards are removed from the VXI chassis, except the Slot 0 controller and the one VXI device with the problem?

As you can see, the problem could be caused by any number of variables, and we would need to narrow the problem more before we can diagnose effectively.

Thank you,
Josh Hernstrom
Application Engineer
National Instruments
0 Kudos
Message 2 of 4
(2,529 Views)
Hello Josh,
Nice to hear from you. Here are answers for your questions:
Question 1:
My PC 1.8GHz Intel Pentium 4 512MB of RAM
operating system WINDOW XP
VMEcrate 5 slots VME crate from
Solflower Computer Inc.
VMEController VME-MXI-2
Question 2:
PC and VME controller connected via MXI-2 cable
with "MXI-2" card (sorry I do not know the name
of the card which installed at PC).
Question 3:
NI-VISA 2.5.2
NI-VXI 3.2
I did not use NI-DAQ
Question 4:
No error is returned when VXIpeek is excuted
Question 5:
It depends on the VME address (card?). For my card
it occurs at 2x10-5 level. It seems it occurs more
often when VME controller is accessed.
Question 6:
I have not used NI-Spy. I am afraid that NI-Spy may
cause additional delay for VXIpeek due to competation
of CPU. If you think that it will help, I could try
to provide NI-Spy file for you. But you have to tell
me how to do it. Thanks.
Question 7:
Yes, the problem can be repoduced by using a small
code. See attachment. I did not try with VXI
interactive Control where I may unable to get time
information.
Question 8:
Yes, I have removed all cards and only left VME
controller, the problem is still there. See the
results of attachment where only VME controller is
installed in the VME crate.

Sorry, I was unable to add attachment. The code and
output are listed belew:
int main(int argc, char *argv[])
{
int initial;
///////////////////////////////
uint32 timeout, trlWindow, count, i, resp;
int16 status;
double time0, time1, timeDiff;
void *trlAddr;
///////////////////////////////

// Needed if linking in external compiler; harmless otherwise out of memory
if (InitCVIRTE(0, argv, 0) == 0) return -1;
// Initializes VXIlibrary, allows handling of VXI reads and writes
initial = InitVXIlibrary();
if (initial < 0) {
MessagePopup("MiniDAQ Error", "VXI library initialization failed.");
return (1);
}
SetSleepPolicy(VAL_SLEEP_NONE);

////////////////////////////////
count = 0;
timeout = 1000L; // Timeout of 1 second
//trlAddr = (void *)MapVXIAddress(0x3, 0x40, timeout, &trlWindow, &status);
trlAddr = (void *)MapVXIAddress(0x3, 0x800000, timeout, &trlWindow, &status);
printf("trlWindow = %u status = %d\n", trlWindow, status);
//Timing Check
time0 = Timer();
for(i = 0; i < 10000000; i++) {
VXIpeek(trlAddr, 2, &resp);
time1 = Timer();
timeDiff = time1 - time0;
if(timeDiff >= 0.002) {
printf("i = %u timeDiff = %f\n", i, timeDiff);
count++;
time0 = Timer();
if (count > 100) break;
}
else time0 = time1;
}
printf("count = %u # VXIpeek calls = %u\n", count, i);
UnMapVXIAddress(trlWindow);
return 0;
}

Output of above program is following, where the unit of timeDiff is in second
as one can see, sometimes it takes few ms to excute VXIpeek
trlWindow = 0 status = 0
i = 4311 timeDiff = 0.003000
i = 9292 timeDiff = 0.005000
i = 18710 timeDiff = 0.004000
i = 41546 timeDiff = 0.004000
i = 64712 timeDiff = 0.003000
i = 87550 timeDiff = 0.004000
i = 94511 timeDiff = 0.004000
...
i = 507335 timeDiff = 0.002000
i = 511628 timeDiff = 0.002000
i = 520272 timeDiff = 0.005000
i = 522846 timeDiff = 0.003000
i = 524782 timeDiff = 0.013000
i = 528826 timeDiff = 0.009000
i = 530637 timeDiff = 0.003000
i = 547681 timeDiff = 0.004000
i = 556325 timeDiff = 0.004000
i = 560569 timeDiff = 0.012000
count = 101 # VXIpeek calls = 560569

Tiesheng
0 Kudos
Message 3 of 4
(2,529 Views)
Hello Tiesheng,

After much experimentation, it appears that the delays you are experiencing are actually due to non-deterministic behavior in the Windows OS. As you may know, since Windows is not a real-time operating system, there cannot be guaranteed iteration times, or even guarantees that a function will return within a certain time. Windows delays your code execution to handle other application threads, service interrupts from other hardware, and perform other unrelated tasks.

For example, I was able to reproduce your behavior on a Windows 2000 machine and get about 100 "failures" in 900,000 VXIpeek calls. If I diable every memory resident program and attempt to run Windows in a "lean" state, I can reduce the number of failures on my test
machine to 30 out of 10,000,000.

If you need guaranteed loop times and more deterministic function behavior on the VXI platform, you might like to investigate VXWorks, a real-time operating system for embedded VXI controllers (like our VXIpc series) that is manufactured by WindRiver.

National Instruments Products: VXI Embedded Pentium Controllers
WindRiver

Regards,
Josh Hernstrom
Applications Engineer
National Instruments
0 Kudos
Message 4 of 4
(2,529 Views)