Measurement Studio for VC++

cancel
Showing results for 
Search instead for 
Did you mean: 

Measurement Studio, NI488.2, 40 sec timeout works interactively, but only 10 sec when compiled.

Summary: In Measurement Studio, NI488.2, a 40 second timeout works interactively, but transaction times out after only 10 seconds when running compiled program.

Detail: I'm zeroing and calibrating an Agilent RF Power Meter. When I run the Assistant in Measurement Studio, the 40 second timeout I programmed (40,000 msec.) works fine and the Query/Reply transactions with the RF Power Meter complete with good status returned. However, when the code is compiled with my program, the transaction times out after less than 10 seconds. The complete Microsoft Visual Studion C++ project is posted on my web site, complete with source code, NI's mxb files, and executable program.
See:
http://www.michaeltnelson.com/NI/Agilent_E4417A/
0 Kudos
Message 1 of 3
(3,302 Views)
In the code you posted, I believe you have the timeout set even longer - to 100 seconds. The problem apepars to be originating from a bug in the template source file from which the Instrument I/O Assistant generates C++ code. This file can be found on your system at c:\program files\National Instruments\MAX\Assistants\InstrumentIOAssistantGPIB.cs.
Open the file in Visual Studio, look at or near line 322 and you should see something like the following:

for (int timeoutEnumIndex=5;((timeoutEnumIndex<13) && (timeout < timeoutIn));timeoutEnumIndex++) {
if (timeoutEnumIndex%2)
{
timeout = timeout*3;
}
else
{
timeout = timeout*10/3;
}

}

This code is pretty much inserted verbatim into your source code. The ending index of the for loop is the enum value that gets used to set the timeout for the GPIB session. Note that the loop is executing from 5 to at most 13. 13 corresponds to the enum value for 10 seconds - which is why your timeout cuts out at 10 seconds.

If you make any changes to your source code, and then do anything that causes the Assistant to re-generate code, those changes are going to be overwritten. So I believe what you will want to do is fix the template file on your system. You should be able to fix this problem by modifying that for loop in the template file to terminate at 17 (which is the maximum timeout enum value, corresponding to 1000 seconds). After changing and saving the template file, re-run the assistant so that it re-generates code. Confirm that the change in the template propagated into your project's source files.
Please let me know if making that change in the template file works
for you.

- Glenn
Message 2 of 3
(3,302 Views)
Glenn:

You fixed it!!!

All I had to do was change the 13 to 17 and it worked.

Thanks:

Mike Nelson
0 Kudos
Message 3 of 3
(3,302 Views)