03-28-2012 04:31 AM
Hi all,
I have sporadically a timeout issue with Delta Power Supply SM3545 when performing "measure:current?" or "measure:voltage?" command via GPIB. It sometimes happens that I get Timeout Error bfff0015. After this I have to reset complete device (switch power off) before I can talking to this device again.
Does anybody have same error ever seen?
03-29-2012 06:53 AM
Hello Webserver 81,
could you post your VI, please?
Maybe you can reset the comunication and try to connect again.
If you post your vi, i will check this.
Best regards
Lorenz Casper
03-29-2012 07:09 AM
I'm using the NI Visa driver in Visual Studio 2010 and there I use function viPrintf and viScanf...
m_viState = Send ( rcszSendString );
if ( m_viState != VI_SUCCESS )
{
return m_viState;
}
m_viState = Receive ( rcszReceiveString, bRemoveCRNL );
if ( m_viState != VI_SUCCESS )
{
return m_viState;
}
int CVisa::Send ( CString rcszSendString, BOOL bSendLF /* == TRUE */ )
{
CString TempStr=rcszSendString;
if ( m_DeviceDescriptor.uiTypeOfDevice == VISA_NONE )
{
m_cszLastErrorString = "No init!";
return VISA_NOT_INSTALLED;
}
if ( bSendLF ) TempStr += CString ( "\n");
m_viState = viPrintf ( m_Instr, TempStr.GetBuffer ( TempStr.GetLength() ) );
if ( m_viState != VI_SUCCESS )
{
CString strTemp("");
strTemp.Format("Write(viPrintf) error:\n%x",m_viState);
MakeErrorString ( strTemp );
return m_viState;
}
m_cszLastSendString = rcszSendString;
return m_viState;
}
int CVisa::Receive ( CString &rcszReceiveString, BOOL bRemoveCRNL /* == TRUE */ )
{
if ( m_DeviceDescriptor.uiTypeOfDevice == VISA_NONE )
{
m_cszLastErrorString = "No init!";
return VISA_NOT_INSTALLED;
}
// m_viState = viScanf ( m_Instr, "%t", rcszReceiveString.GetBuffer ( MAXBUFFERSIZE ) );
m_viState = viScanf ( m_Instr, "%t", rcszReceiveString.GetBuffer ( 100000 ) );
rcszReceiveString.ReleaseBuffer ();
if ( m_viState != VI_SUCCESS )
{
CString strTemp("");
strTemp.Format("Read error:\n%x",m_viState);
MakeErrorString ( strTemp );
return m_viState;
}
m_cszLastReceiveString = rcszReceiveString;
// remove the carriage return and line feed characters
if ( bRemoveCRNL == TRUE )
{
rcszReceiveString.Remove ( 10 );
rcszReceiveString.Remove ( 13 );
}
return VI_SUCCESS;
}
How long should I wait between send and receive?
03-29-2012 01:19 PM
Hey Webserver81,
The amount of time you need to wait between writing and reading is completely dependent on what instrument you are trying to control. For examples, some simple devices may take milliseconds to reset after the RST command is received and reply while other more advanced instruments can take multiple minutes to complete a reset or auto-initialize. As a programmer you can either increase your VISA read timeout to account for possible delays on the instrument side or you can see if your device has a "Status?" or "Busy?" command that you could poll to see if the instrument is ready to respond.
If you can communicate with the instrument over GPIB, another more advanced option is to take advantage of Service Requests where the device essentially notifies you when it is ready to execute another command set. Here is a Developer Zone on the topic:
Using Service Requests in your GPIB application
http://zone.ni.com/devzone/cda/tut/p/id/4629
Lars
NI R&D