Instrument Control (GPIB, Serial, VISA, IVI)

cancel
Showing results for 
Search instead for 
Did you mean: 

Automating Agilent6700 Power Supply

Hi, I'm trying to automate the this Agilent6700 PS,

I have the following code, which I can't access the instrument specific options.

 

#import "IviDriverTypeLib.dll" no_namespace
#import "IviDCPwrTypeLib.dll" no_namespace
#import "IviSessionFactory.dll" no_namespace
#import "GlobMgr.dll" no_namespace

 

void main()
{
        HRESULT hr;
        hr = CoInitialize(NULL);
        if (FAILED(hr)) exit(1);

    IIviDCPwrPtr DCptr("Agilent6700");
    DCptr->Initialize("GPIB::23",false,true,"Simulate=true");

....

}

 

 

After initiazing it, I can't access any specific option of the instrument.

When I type DCptr->  intellisense only offers only basic options the are common to all instruments.

 

Regards,

Hagai.

 

 

 

0 Kudos
Message 1 of 6
(3,585 Views)

Hello Hagai,

 

Have you looked into the manual for your device for the proper commands to send to your device? That should tell you how to bring up the advanced options for the device.

 

Best Regards,

 

Adam G 

National Instruments
Applications Engineer
0 Kudos
Message 2 of 6
(3,549 Views)

Hi,

I finally managed to find those commands, but I keep getting runtime error while trying to initialize it.

Note I do not have the deivce connected yet, and only use the Simulation mode.

 

Here's what Im trying to do:

 

 

#import "IviDriverTypeLib.dll" no_namespace
#import "IviDCPwrTypeLib.dll" no_namespace
#import "GlobMgr.dll" no_namespace
#import "AgN67xx.dll" no_namespace


int main(int argc, char* argv[])
{
    HRESULT hr;
    IAgilentN67xx4Ptr driverPtr=NULL;
    hr = CoInitialize(NULL);
    if (FAILED(hr))
    exit(1);

    // create a safe pointer for interface access
        
        hr = driverPtr.CreateInstance(__uuidof(AgilentN67xx));
        if (FAILED(hr))
        exit(1);

        // open the instrument for communication
        hr = driverPtr->Initialize(
            L"GPIB0::20::INSTR",  //Visa address,(not applicable if simulation=true)
            VARIANT_TRUE,    // ID query
            VARIANT_TRUE,     // Reset
            LPCTSTR("Cache=true, InterchangeCheck=false, QueryInstrStatus=true, Simulate=true, DriverSetup= Trace=true, TraceName=MyTrace"));
        if (FAILED(hr))
            exit(1);

...

}

 

After calling to driverPtr->Initialize I get runtime error in 'ividrivertypelib.tli'  :

 

inline HRESULT IIviDriver::Initialize ( _bstr_t ResourceName, VARIANT_BOOL IdQuery, VARIANT_BOOL Reset, _bstr_t OptionString ) {
    HRESULT _hr = raw_Initialize(ResourceName, IdQuery, Reset, OptionString);
    if (FAILED(_hr)) _com_issue_errorex(_hr, this, __uuidof(this)); 
    return _hr;
}

 

The value in _hr is 0x80047060.

 

Please help,

Hagai.

0 Kudos
Message 3 of 6
(3,521 Views)

Have you tried using our IVI-C driver instead of IVI-COM driver from Agilent?

 

http://sine.ni.com/apps/utf8/niid_web_display.download_page?p_id_guid=E3B19B3E9723659CE034080020E748...

0 Kudos
Message 4 of 6
(3,507 Views)

No, I need this for a Visual C++ code, so sticking with IVI-COM.

 

0 Kudos
Message 5 of 6
(3,503 Views)

You aren't using any NI software. Why are you asking about COM drivers here instead of Agilent? I would expect they are going to be much more familiar with how their code should be used.

Message 6 of 6
(3,493 Views)