01-19-2018 11:14 AM
Hey everyone. I'm Andrea, a technician who just started working with a Fluke 8845a which needs to be controlled by an Excel file to measure resistance every "x" seconds.
Now, I'm really just beginning. And I'm already in trouble. When inserting the code below in VBA I get the error attached. The error pops up at the ReadString line.
It says "runtime timeout, automation error". What can it be?
P. S. Sorry if there is a presentation section, I'm from mobile and I couldn't find it.
[code]
Sub idn()
Dim ioMgr As VisaComLib.ResourceManager
Dim idn
Dim instrument As VisaComLib.FormattedIO488
Set ioMgr = New VisaComLib.ResourceManager
Set instrument = New VisaComLib.FormattedIO488
' use instrument specific address for Open() parameter – i.e. GPIB0::22
Set instrument.IO = ioMgr.Open("TCPIP0::192.168.1.6::5025::SOCKET")
instrument.WriteString ("*IDN?")
instrument.WriteString "SYSTem:REMote"
instrument.WriteString ("READ?")
idn = instrument.ReadString
End Sub
[/code]
01-22-2018 09:31 AM
For a socket connection, you need to send every command with a linefeed at the end ('\n') and then for the Reads you need to enable TermChar:
instrument.IO.TerminationCharacterEnabled = true
Make sure the termination character in the Fluke is linefeed as this is the default for Visa. If different then you need to set this also.
01-22-2018 10:59 AM
Hi and thank you.
My Fluke seems to receive the commands I'm sending because it gets in remote. It's reading that causes the issue. Also, all I need to had is "\n" at the end of every command I send and "\n" when reading?
01-22-2018 11:35 AM - edited 01-22-2018 11:36 AM
@miclausig90 wrote:
instrument.WriteString ("*IDN?")
instrument.WriteString "SYSTem:REMote"
instrument.WriteString ("READ?")
idn = instrument.ReadString
Typically, a newline "\n" should be appended to each WriteString function. Be aware that you have requested two separate pieces of data from the instrument. The first is for the instrument identification string (*IDN?) while the other is for some unknown data (READ?) that may or may not reside within the instrument buffer. If an error occurs, then maybe it is because nothing currently exists within the buffer to read or this program has been repetitively called and forced an overflow in the response buffer.
01-22-2018 11:58 AM
Ok, I got what you mean about the READ error. Only thing I don't understand is "a newline "\n" should be appended to each WriteString function". You literally mean another line by pressing enter? Or can you make an example, please?
01-23-2018 12:10 PM
When you start sending data (commands) to the instrument it will go into remote mode but most instruments (SCPI) won't parse (execute that command) until it knows it has received a "complete command" Now on GPIB, USBTMC, LAN (VXI-11 and HiSLIP) there is a handshake that lets an instrument know the command has been completely sent. For RS232 and LAN - Raw Socket there is no handshake so the instrument is waiting to see a Linefeed and vice versa for the PC receiving data back from the instrument.
So for C# you should send this
instrument.WriteString("*idn?\n")
I am not sure if VB.NET understands the "\n" or you need to do string concatenation like "*idn?" + Environment.NewLine
02-28-2018 08:21 AM
Hey everyone. Sorry, I know it's been a long time. Unfortunetly, that's how my job is done.
So, the code is now as follows:
Sub idn() Dim ioMgr As VisaComLib.ResourceManager Dim idn As String Dim instrument As VisaComLib.FormattedIO488 Set ioMgr = New VisaComLib.ResourceManager Set instrument = New VisaComLib.FormattedIO488 ' use instrument specific address for Open() parameter – i.e. GPIB0::22 Set instrument.IO = ioMgr.Open("TCPIP0::192.168.1.6::5025::SOCKET") instrument.WriteString ("*RST") instrument.WriteString ("CONFigure:RESistance") instrument.WriteString ("SYSTem:REMote") instrument.WriteString ("*IDN?") idn = instrument.ReadString() ActiveSheet.Cells(1, 1) = idn End Sub
And everything works fine untill idn=instrument.ReadString()
After that, I get the attached error. The second line is "Automation error".
The program is written in VBA in Excel 2007.
Can someone help me (again)?