05-18-2010 09:26 AM
I have noticed some strange behavior with connecting to an Agilent power supply over GPIB, but hopefully I am just missing something.
If I have the power supply turned on and connected over GPIB to a National Instruments PCI card and launch my application, viOpen gives me VI_SUCCESS and I can manipulate the power supply as desired (changing output voltage, turning output on and off, etc). However, if I start the application with the power supply turned off (not just output disabled, but completely off) then viOpen gives me the no resources found error, as it should since the instrument cannot be detected. My application is programmed to retry the connection every 10 seconds, and as long as the supply is turned, off this is the case as expected. The strangeness comes in when I turn the power supply on when the application is trying to reconnect. Even though the power supply is connected, viOpen still gives a fail condition. Moreover, using the Agilent IO Connection Expert software, it lists the instrument in an error state. It gets stranger when I open up MAX, and click "Communicate with Instrument." Simply clicking on this option restores the instrument to being error free and my application's viOpen call works perfectly. Is there something that MAX does to initialize the instrument when you want to communicate with it? If so, is there a way to recreate this this using VISA software controls? For reference, here is the code I am using to connect to the instrument (and subsequently attempt to reconnect if the connection fails). Thanks for any help in advance.
In a header file:
ViSession session, defrm;
ViStatus VISAstatus;
In a .c file:Code is executed every 10 seconds
strcpy(IOaddress, "GPIB0::5");
VISAstatus = viOpenDefaultRM(&defrm);
VISAstatus = viOpen(defrm, IOaddress, VI_NULL, VI_NULL, &session);
if (VISAstatus != VI_SUCCESS)
{
viStatusDesc(session, VISAstatus, statdsc);
// Print an error message
return;
}
else if (VISAstatus == VI_SUCCESS)
{
viStatusDesc(session, VISAstatus, statdsc);
// Print success message
initializeStuff();
}
Solved! Go to Solution.
05-18-2010 10:15 AM
It seems I spoke too soon, just got the problem resolved.
The Agilent VISA Library was being used as the primary VISA library. I entirely uninstalled the Agilent IOSuite software (including its VISA) and uninstalled the National Instruments VISA as well. I then reinstalled the IOSuite and allowed the most recent NI VISA to overwrite it. The first time I ran my application after doing this, it worked perfectly.