Hi,
I'm trying to connect with 34410 through usb using latest IVICom driver_ivicom_ivic_Agilent34410_1_0_22_0.msi, but it return wrong value "9,9E37" on all functions, though it changes function voltage, resistance e.t.c, however it return right value when IO Monitor is runned. With driver_ivicom_ivic_Agilent34410_1_0_19_0.msi all work fine.
Thanks in advance.
I'm trying to connect with 34410 through usb using latest IVICom driver_ivicom_ivic_Agilent34410_1_0_22_0.msi, but it return wrong value "9,9E37" on all functions, though it changes function voltage, resistance e.t.c, however it return right value when IO Monitor is runned. With driver_ivicom_ivic_Agilent34410_1_0_19_0.msi all work fine.
Thanks in advance.
void __fastcall CreateDRV()
{
HRESULT hr;
IIviDriver *pInknown = NULL;
// IAgilent34405 pAg34405 = NULL;
const int tmp_size = 1024;
char ch_temp1[ tmp_size ] = {0};
char ch_temp2[ tmp_size ] = {0};
wchar_t wchProgID[ tmp_size ] = {0};
wchar_t wchResource[ tmp_size ] = {0};
wchar_t wchLN[ tmp_size ] = {0};
wchar_t *pwcDrvSetup = L"QueryInstrStatus=false, Simulate=false, Cache=false";
wchar_t *pwcRDes = NULL;
short shInit;
CLSID clsid;
bool bUseLogicalName;
bUseLogicalName = CheckBoxUseConfigStore->Checked;
EditLogicalName->Text.WideChar( wchLN , tmp_size );
try
{
if( pIviDmm )
{
pIviDmm->Close();
pIviDmm->Release();
}
if( bUseLogicalName )
{
hr = spFactory->CreateDriver( wchLN , (IUnknown**)&pInknown );
hr = pInknown->QueryInterface( IID_IIviDmm , (void**)&pIviDmm );
if( !SUCCEEDED( hr ) )
{
TraceError( Handle );
}
}
else
{
//Create through ProgID
EditProgID->Text.WideChar( wchProgID, tmp_size );
hr = CLSIDFromProgID( wchProgID , &clsid );
hr = ::CoCreateInstance(
clsid,
NULL,
CLSCTX_ALL,
IID_IIviDmm,
(void**)&pIviDmm);
if( !SUCCEEDED( hr ) )
{
TraceError( Handle );
}
}
if( pIviDmm )
{
IIviDriverIdentity *pDI = NULL;
wchar_t *pCroupCpb = NULL;
EditResource->Text.WideChar( wchResource , tmp_size );
if( bUseLogicalName )
{
hr = pIviDmm->Initialize( wchLN , VARIANT_TRUE , VARIANT_TRUE , pwcDrvSetup );
if( !SUCCEEDED( hr ) )
{
TraceError( Handle );
}
hr = pIviDmm->get_Initialized( &shInit );
}
else
{
//wchResource
EditResource->Text.WideChar( wchResource , tmp_size );
hr = pIviDmm->get_Initialized( &shInit );
hr = pIviDmm->Initialize( wchResource , VARIANT_TRUE , VARIANT_TRUE , pwcDrvSetup );
hr = pIviDmm->get_Initialized( &shInit );
}
hr = pIviDmm->QueryInterface( &pDI );
TraceError2( hr , Handle );
hr = pDI->get_GroupCapabilities( &pCroupCpb );
TraceError2( hr , Handle );
if( SUCCEEDED(hr) )
{
ListBoxGroupCap->Items->Clear();
ListBoxGroupCap->Items->CommaText = pCroupCpb;
}
if( pDI )
pDI->Release();
if( pInknown )
{
pInknown->Release();
pInknown = NULL;
}
hr = pIviDmm->get_DriverOperation( &pDriverOp );
if( SUCCEEDED(hr) )
{
hr = pDriverOp->get_IoResourceDescriptor( &pwcRDes );
hr = pRM->Open( pwcRDes , NO_LOCK, 200 , NULL , &pVSession );
if( SUCCEEDED(hr) )
{
hr = pVSession->QueryInterface( IID_IMessage , (void**)&pMess );
long lTimeOut;
pMess->get_Timeout( &lTimeOut );
pMess->set_Timeout( 5000 );
hr = fmioPtr->_set_IO(pMess);
ThrowError( hr );
}
if( pDriverOp )
{
pDriverOp->Release();
pDriverOp = NULL;
}
}
ButtonRead->Enabled = true;
}
}
catch( _com_error e )
{
sprintf( ch_temp1 , "Add HardwareAsset failed.\n");
sprintf( ch_temp2 , "Error description is: %s\n",(char*)e.Description());
MessageBox( Handle , ch_temp1, ch_temp2, MB_ICONERROR|MB_OK );
}
}
//----------------------------------
//Getting the result
//----------------------------------
void __fastcall TForm1::ButtonReadClick(TObject *Sender)
{
HRESULT hr;
double dResult;
BSTR pwchError = NULL;
long lErrCode;
IIviDmmMeasurement *pIviDmmMeas = NULL;
IIviDriverUtility *pIviDU = NULL;
// if( RadioGroupFunction->ItemIndex == )
try
{
try
{
// Set the measure function
// IviDmmFunctionDCVolts,
// IviDmmFunctionACVolts,
// IviDmmFunctionDCCurrent, etc
hr = pIviDmm->set_Function( DmmFuncArr[ RadioGroupFunction->ItemIndex ] );
ThrowError( hr );
hr = pIviDmm->get_Measurement( &pIviDmmMeas );
ThrowError( hr );
hr = pIviDmmMeas->Read( EditTimeOut->Text.ToInt() , &dResult );
ThrowError( hr );
hr = pIviDmmMeas->Abort();
ThrowError( hr );
EditResult->Text = dResult;
}
catch(HRESULT &hr2)
{
TraceError( Handle );
}
}
__finally
{
if(pIviDmmMeas)
pIviDmmMeas->Release();
}
}
Try it out with your driver and see if it works correctly. If IO Monitor is changing the behavior, I'd say it might be a timing issue. You might want to set your Timeout to a higher value.
I couldn't compile your code, so I couldn't see where your problem was. It would be helpful if you shared a simple console example, send me all of the project files to build it and tell me what version of Visual Studio I need to build it it in.
Attachments
I agree, it seems that problem in timeout, but which? It dont react on timeout in IIviDmmMeasurement::Read( long MaxTimeMilliseconds,
double* retval);
I tryed up to 10000 ms timeout for IIviDmmMeasurement::Read and the instrument even dont try to measure, return value is "9,91E37, but it changes functions.
If i execute programm step by step the instrument make the measuring but the returning result in programm is "9,91E37" though on display of 34410 appear righr result. It seems that IIviDmmMeasurement::Read dont wait DMM.
I've attached my latest example. I use the Configure method to set the measurement parameters.
Attachments
HRESULT Configure(
IviDmmFunctionEnum Function,
double Range,
double Resolution
);
Range
The measurement range. Positive values represent the absolute value of the maximum measurement expected. The driver coerces this value to the appropriate range for the instrument. Negative values represent the Auto Range mode.
If the value of the Range parameter is Auto Range On, then the Resolution parameter is ignored.
I try to set the range to negative value,
pIviDmm->Configure( IviDmmFunctionDCVolts, -1, 1);
but occure error 311, "Not able to specify resolution with Auto range". Where's my wrong?
Edited by: gumanist on Apr 5, 2012 11:08 PM
WORKAROUND:
So, rather than use Configure, use the following:
pIviDmm->Function = IviDmmFunctionEnum::IviDmmFunctionDCVolts;
pIviDmm->Range = -1;
//don't set the resolution when using Auto Ranging
double dResult;
IIviDmmMeasurement *pIviDmmMeas = NULL;
IIviDriverUtility *pIviDU = NULL;
HRESULT hr;
hr = pIviDmm->set_Function(IviDmmFunction2WireRes );
hr = pIviDmm->set_Range(-1);
hr = pIviDmm->get_Measurement( &pIviDmmMeas );
hr = pIviDmmMeas->Read( 1000 , &dResult );
in this case on DMM display appears: "000.205 OHM"
pIviDmmMeas->Read( 1000 , &dResult ); return dResult = 9.91e+37
measuring VDC with shorted leads and autorange:
dmm: 000.009 mVDC
driver: 9.91e+37
measuring ACV line voltage, autorange:
dmm: 0,217.850 VAC
driver: 9.91e+3
if I set range 100V for VDC:
hr = pIviDmm->set_Function( IviDmmFunctionDCVolts );
hr = pIviDmm->Configure( IviDmmFunctionDCVolts, 100, 1);
hr = pIviDmm->get_Measurement( &pIviDmmMeas );
hr = pIviDmmMeas->Read( 1000 , &dResult );
dmm: 0,000.01 VDC
driver: 0.0120981252 it works!
slow functions dont work with range too (VAC, Frec for example), only fast function like VDC or 2WRES have time to return value to the driver. And all this work with old driver.
It appears to be a bug in the driver. I can see correct behavior in the old driver and I see broken behavior in the new driver.
The workaround at this point is to use the Agilent-specific interface.
I'll submit this as a defect on the driver, AND update this post when the updated driver has been released.
Edited by: hognala on Apr 23, 2012 4:56 PM